This commit is contained in:
@@ -466,6 +466,8 @@ MULTIPLE discount / markup ITEMS
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("HeadOffice"));
|
||||
if (await ct.Unit.AnyAsync(m => m.ContractId == inObj.Id))
|
||||
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
|
||||
//
|
||||
@@ -706,10 +703,12 @@ namespace AyaNova.Biz
|
||||
}//end of process notifications
|
||||
|
||||
|
||||
|
||||
#endregion workorder level
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
███████╗████████╗ █████╗ ████████╗███████╗███████╗
|
||||
@@ -1724,7 +1723,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
|
||||
//automatic actions on record change, called AFTER validation
|
||||
|
||||
var Contract = GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId);
|
||||
|
||||
switch (ayaEvent)
|
||||
{
|
||||
@@ -1765,8 +1764,8 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//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
|
||||
figure out if there will only ever be ONE effective contract or multiple and then can determine how to handle here
|
||||
// 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
|
||||
//Yes precedence is Unit->Customer->headoffice.
|
||||
//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
|
||||
@@ -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
|
||||
//
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace AyaNova.Models
|
||||
[Required]
|
||||
public long CustomerId { get; set; }
|
||||
public long? ProjectId { get; set; }
|
||||
[NotMapped]
|
||||
[NotMapped]
|
||||
public string ProjectViz { get; set; }
|
||||
public string InternalReferenceNumber { get; set; }
|
||||
public string CustomerReferenceNumber { get; set; }
|
||||
@@ -49,9 +49,12 @@ namespace AyaNova.Models
|
||||
public string TechSignature { get; set; }
|
||||
public string TechSignatureName { get; set; }
|
||||
public DateTime? TechSignatureCaptured { get; set; }
|
||||
public bool Onsite {get;set;}
|
||||
public string Contract { get; set; }
|
||||
|
||||
public bool Onsite { get; set; }
|
||||
public long? ContractId { get; set; }
|
||||
[NotMapped]
|
||||
public string ContractViz { get; set; }
|
||||
|
||||
|
||||
//POSTAL ADDRESS / "BILLING ADDRESS"
|
||||
public string PostAddress { get; set; }
|
||||
public string PostCity { get; set; }
|
||||
|
||||
@@ -758,7 +758,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
//WORKORDER
|
||||
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), "
|
||||
+ "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, "
|
||||
+ "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) "
|
||||
|
||||
Reference in New Issue
Block a user