This commit is contained in:
@@ -466,6 +466,8 @@ MULTIPLE discount / markup ITEMS
|
|||||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("HeadOffice"));
|
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("HeadOffice"));
|
||||||
if (await ct.Unit.AnyAsync(m => m.ContractId == inObj.Id))
|
if (await ct.Unit.AnyAsync(m => m.ContractId == inObj.Id))
|
||||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("Unit"));
|
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("Unit"));
|
||||||
|
if (await ct.WorkOrder.AnyAsync(m => m.ContractId == inObj.Id))
|
||||||
|
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("WorkOrder"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -681,9 +681,6 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// NOTIFICATION PROCESSING
|
// NOTIFICATION PROCESSING
|
||||||
//
|
//
|
||||||
@@ -706,10 +703,12 @@ namespace AyaNova.Biz
|
|||||||
}//end of process notifications
|
}//end of process notifications
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion workorder level
|
#endregion workorder level
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
███████╗████████╗ █████╗ ████████╗███████╗███████╗
|
███████╗████████╗ █████╗ ████████╗███████╗███████╗
|
||||||
@@ -1724,7 +1723,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
|
|
||||||
//automatic actions on record change, called AFTER validation
|
//automatic actions on record change, called AFTER validation
|
||||||
|
var Contract = GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId);
|
||||||
|
|
||||||
switch (ayaEvent)
|
switch (ayaEvent)
|
||||||
{
|
{
|
||||||
@@ -1765,8 +1764,8 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Contract
|
//Contract
|
||||||
todo: need to have a bombproof way to get the effective contract and statically hold it here in wobiz until processing finished because other objects in tree may also need it
|
// todo: need to have a bombproof way to get the effective contract and statically hold it here in wobiz until processing finished because other objects in tree may also need it
|
||||||
figure out if there will only ever be ONE effective contract or multiple and then can determine how to handle here
|
// figure out if there will only ever be ONE effective contract or multiple and then can determine how to handle here
|
||||||
//Yes precedence is Unit->Customer->headoffice.
|
//Yes precedence is Unit->Customer->headoffice.
|
||||||
//it's not permitted to have more than one contracted unit on a workorder
|
//it's not permitted to have more than one contracted unit on a workorder
|
||||||
//if a unit has a contract on workorder it applies to *entire* workorder so they must use one unit under contract and it's the entirety of the work performed
|
//if a unit has a contract on workorder it applies to *entire* workorder so they must use one unit under contract and it's the entirety of the work performed
|
||||||
@@ -4083,6 +4082,27 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//GET CONTRACT FOR WORKORDER FROM RELATIVE
|
||||||
|
//
|
||||||
|
internal async Task<Contract> GetCurrentWorkOrderContractFromRelatedAsync(AyaType ayaType, long id)
|
||||||
|
{
|
||||||
|
//instantiated method to save adding the context
|
||||||
|
return await GetCurrentWorkOrderContractFromRelatedAsync(ayaType, id, ct);
|
||||||
|
}
|
||||||
|
internal static async Task<Contract> GetCurrentWorkOrderContractFromRelatedAsync(AyaType ayaType, long id, AyContext ct)
|
||||||
|
{
|
||||||
|
//static method
|
||||||
|
long WoId = await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct);
|
||||||
|
var WoContractId = await ct.WorkOrder.AsNoTracking().Where(z => z.Id == WoId).Select(z => z.ContractId).FirstOrDefaultAsync();
|
||||||
|
if (WoContractId == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return await ct.Contract.AsNoTracking().FirstOrDefaultAsync(z => z.Id == WoContractId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//GET CURRENT STATUS FOR WORKORDER FROM RELATIVE
|
//GET CURRENT STATUS FOR WORKORDER FROM RELATIVE
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace AyaNova.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public long CustomerId { get; set; }
|
public long CustomerId { get; set; }
|
||||||
public long? ProjectId { get; set; }
|
public long? ProjectId { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string ProjectViz { get; set; }
|
public string ProjectViz { get; set; }
|
||||||
public string InternalReferenceNumber { get; set; }
|
public string InternalReferenceNumber { get; set; }
|
||||||
public string CustomerReferenceNumber { get; set; }
|
public string CustomerReferenceNumber { get; set; }
|
||||||
@@ -49,8 +49,11 @@ namespace AyaNova.Models
|
|||||||
public string TechSignature { get; set; }
|
public string TechSignature { get; set; }
|
||||||
public string TechSignatureName { get; set; }
|
public string TechSignatureName { get; set; }
|
||||||
public DateTime? TechSignatureCaptured { get; set; }
|
public DateTime? TechSignatureCaptured { get; set; }
|
||||||
public bool Onsite {get;set;}
|
public bool Onsite { get; set; }
|
||||||
public string Contract { get; set; }
|
public long? ContractId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string ContractViz { get; set; }
|
||||||
|
|
||||||
|
|
||||||
//POSTAL ADDRESS / "BILLING ADDRESS"
|
//POSTAL ADDRESS / "BILLING ADDRESS"
|
||||||
public string PostAddress { get; set; }
|
public string PostAddress { get; set; }
|
||||||
|
|||||||
@@ -758,7 +758,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
|||||||
//WORKORDER
|
//WORKORDER
|
||||||
await ExecQueryAsync("CREATE TABLE aworkorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, "
|
await ExecQueryAsync("CREATE TABLE aworkorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, "
|
||||||
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, customerid BIGINT NOT NULL REFERENCES acustomer (id), "
|
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, customerid BIGINT NOT NULL REFERENCES acustomer (id), "
|
||||||
+ "projectid BIGINT REFERENCES aproject, internalreferencenumber text, customerreferencenumber text, customercontactname text, "
|
+ "projectid BIGINT REFERENCES aproject, contractid BIGINT NULL REFERENCES acontract, internalreferencenumber text, customerreferencenumber text, customercontactname text, "
|
||||||
+ "servicedate TIMESTAMP, completebydate TIMESTAMP, invoicenumber TEXT, customersignature TEXT, customersignaturename TEXT, customersignaturecaptured TIMESTAMP, "
|
+ "servicedate TIMESTAMP, completebydate TIMESTAMP, invoicenumber TEXT, customersignature TEXT, customersignaturename TEXT, customersignaturecaptured TIMESTAMP, "
|
||||||
+ "techsignature TEXT, techsignaturename TEXT, techsignaturecaptured TIMESTAMP, durationtocompleted INTERVAL NOT NULL, onsite BOOL NOT NULL, contract TEXT, "
|
+ "techsignature TEXT, techsignaturename TEXT, techsignaturecaptured TIMESTAMP, durationtocompleted INTERVAL NOT NULL, onsite BOOL NOT NULL, contract TEXT, "
|
||||||
+ "postaddress TEXT, postcity TEXT, postregion TEXT, postcountry TEXT, postcode TEXT, address TEXT, city TEXT, region TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6) "
|
+ "postaddress TEXT, postcity TEXT, postregion TEXT, postcountry TEXT, postcode TEXT, address TEXT, city TEXT, region TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6) "
|
||||||
|
|||||||
Reference in New Issue
Block a user