diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 15a1efbc..092f82a3 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -1722,22 +1722,51 @@ namespace AyaNova.Biz // private async Task LaborBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemLabor newObj, WorkOrderItemLabor oldObj, IDbContextTransaction transaction) { - await Task.CompletedTask; - //automatic actions on record change, called AFTER validation - //For now calculate totals only which could be done more simply but doing it this way in case of future needs and for consistency - //HOW PRICING WORKS - //Base price is the regular rate price for that rate regardless if it's a contract only or normal rate, it's the actual price - //manual discount is the user applying a discount above and beyond the contract discount if there is any (?? HOW IS MANUAL CALCULATED?? AFTER CONTRACT OR B4??) - //contract discount is the actual discount the contract provides for + //automatic actions on record change, called AFTER validation + switch (ayaEvent) { case AyaEvent.Created: - //get contract - //get rate - //calculate base price - //(rate price - contract discount and / or manual discount) + //Tax code + if (newObj.TaxCodeSaleId != null) + { + + var t = await ct.TaxCode.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.TaxCodeSaleId); + if (t != null) + { + newObj.TaxAPct = t.TaxAPct; + newObj.TaxBPct = t.TaxBPct; + newObj.TaxOnTax = t.TaxOnTax; + } + else + { + newObj.TaxAPct = 0; + newObj.TaxBPct = 0; + newObj.TaxOnTax = false; + } + } + + //Pricing + if (newObj.ServiceRateId != null) + { + var s = await ct.ServiceRate.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.ServiceRateId); + if (s != null) + { + newObj.Cost = s.Cost; + newObj.ListPrice = s.Charge; + } + else + { + newObj.Cost = 0; + newObj.ListPrice = 0; + } + } + + + + //Contract break; case AyaEvent.Modified: @@ -2685,6 +2714,7 @@ namespace AyaNova.Biz //await PartRequestSearchIndexAsync(newObject, true); //await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); await PartRequestHandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await PartRequestPopulateVizFields(newObject); return newObject; } } @@ -2737,6 +2767,7 @@ namespace AyaNova.Biz // await PartRequestSearchIndexAsync(putObject, false); //await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags); await PartRequestHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); + await PartRequestPopulateVizFields(putObject); return putObject; } @@ -2922,6 +2953,7 @@ namespace AyaNova.Biz //await ScheduledUserSearchIndexAsync(newObject, true); //await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await ScheduledUserPopulateVizFields(newObject); return newObject; } } @@ -2975,6 +3007,7 @@ namespace AyaNova.Biz // await ScheduledUserSearchIndexAsync(dbObject, false); //await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); + await ScheduledUserPopulateVizFields(putObject); return putObject; } @@ -3175,6 +3208,7 @@ namespace AyaNova.Biz await TaskSearchIndexAsync(newObject, true); //await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await TaskPopulateVizFields(newObject); return newObject; } } @@ -3227,6 +3261,7 @@ namespace AyaNova.Biz await TaskSearchIndexAsync(dbObject, false); // await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); + await TaskPopulateVizFields(putObject); return putObject; } @@ -3434,6 +3469,7 @@ namespace AyaNova.Biz await TravelSearchIndexAsync(newObject, true); //await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await TravelPopulateVizFields(newObject); return newObject; } } @@ -3487,6 +3523,7 @@ namespace AyaNova.Biz await TravelSearchIndexAsync(putObject, false); //await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags); await TravelHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); + await TravelPopulateVizFields(putObject); return putObject; } @@ -3697,6 +3734,7 @@ namespace AyaNova.Biz await UnitSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); await UnitHandlePotentialNotificationEvent(AyaEvent.Created, newObject); + await UnitPopulateVizFields(newObject); return newObject; } } @@ -3749,6 +3787,7 @@ namespace AyaNova.Biz await UnitSearchIndexAsync(putObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags); await UnitHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); + await UnitPopulateVizFields(putObject); return putObject; }