This commit is contained in:
@@ -1722,22 +1722,51 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
private async Task LaborBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemLabor newObj, WorkOrderItemLabor oldObj, IDbContextTransaction transaction)
|
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
|
//automatic actions on record change, called AFTER validation
|
||||||
//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
|
|
||||||
|
|
||||||
switch (ayaEvent)
|
switch (ayaEvent)
|
||||||
{
|
{
|
||||||
case AyaEvent.Created:
|
case AyaEvent.Created:
|
||||||
//get contract
|
//Tax code
|
||||||
//get rate
|
if (newObj.TaxCodeSaleId != null)
|
||||||
//calculate base price
|
{
|
||||||
//(rate price - contract discount and / or manual discount)
|
|
||||||
|
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;
|
break;
|
||||||
case AyaEvent.Modified:
|
case AyaEvent.Modified:
|
||||||
|
|
||||||
@@ -2685,6 +2714,7 @@ namespace AyaNova.Biz
|
|||||||
//await PartRequestSearchIndexAsync(newObject, true);
|
//await PartRequestSearchIndexAsync(newObject, true);
|
||||||
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||||
await PartRequestHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
await PartRequestHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||||
|
await PartRequestPopulateVizFields(newObject);
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2737,6 +2767,7 @@ namespace AyaNova.Biz
|
|||||||
// await PartRequestSearchIndexAsync(putObject, false);
|
// await PartRequestSearchIndexAsync(putObject, false);
|
||||||
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
||||||
await PartRequestHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
await PartRequestHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
||||||
|
await PartRequestPopulateVizFields(putObject);
|
||||||
return putObject;
|
return putObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2922,6 +2953,7 @@ namespace AyaNova.Biz
|
|||||||
//await ScheduledUserSearchIndexAsync(newObject, true);
|
//await ScheduledUserSearchIndexAsync(newObject, true);
|
||||||
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||||
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||||
|
await ScheduledUserPopulateVizFields(newObject);
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2975,6 +3007,7 @@ namespace AyaNova.Biz
|
|||||||
// await ScheduledUserSearchIndexAsync(dbObject, false);
|
// await ScheduledUserSearchIndexAsync(dbObject, false);
|
||||||
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||||
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
||||||
|
await ScheduledUserPopulateVizFields(putObject);
|
||||||
return putObject;
|
return putObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3175,6 +3208,7 @@ namespace AyaNova.Biz
|
|||||||
await TaskSearchIndexAsync(newObject, true);
|
await TaskSearchIndexAsync(newObject, true);
|
||||||
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||||
await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||||
|
await TaskPopulateVizFields(newObject);
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3227,6 +3261,7 @@ namespace AyaNova.Biz
|
|||||||
await TaskSearchIndexAsync(dbObject, false);
|
await TaskSearchIndexAsync(dbObject, false);
|
||||||
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||||
await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
||||||
|
await TaskPopulateVizFields(putObject);
|
||||||
return putObject;
|
return putObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3434,6 +3469,7 @@ namespace AyaNova.Biz
|
|||||||
await TravelSearchIndexAsync(newObject, true);
|
await TravelSearchIndexAsync(newObject, true);
|
||||||
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||||
await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||||
|
await TravelPopulateVizFields(newObject);
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3487,6 +3523,7 @@ namespace AyaNova.Biz
|
|||||||
await TravelSearchIndexAsync(putObject, false);
|
await TravelSearchIndexAsync(putObject, false);
|
||||||
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||||
await TravelHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
await TravelHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
||||||
|
await TravelPopulateVizFields(putObject);
|
||||||
return putObject;
|
return putObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3697,6 +3734,7 @@ namespace AyaNova.Biz
|
|||||||
await UnitSearchIndexAsync(newObject, true);
|
await UnitSearchIndexAsync(newObject, true);
|
||||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||||
await UnitHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
await UnitHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||||
|
await UnitPopulateVizFields(newObject);
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3749,6 +3787,7 @@ namespace AyaNova.Biz
|
|||||||
await UnitSearchIndexAsync(putObject, false);
|
await UnitSearchIndexAsync(putObject, false);
|
||||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
||||||
await UnitHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
await UnitHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
||||||
|
await UnitPopulateVizFields(putObject);
|
||||||
return putObject;
|
return putObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user