This commit is contained in:
2021-05-11 23:39:21 +00:00
parent 785b26a3c1
commit db8fa8aed8
2 changed files with 46 additions and 4 deletions

View File

@@ -915,6 +915,7 @@ namespace AyaNova.Biz
await ItemSearchIndexAsync(newObject, true);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
await ItemHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await ItemPopulateVizFields(newObject);
return newObject;
}
}
@@ -994,6 +995,7 @@ namespace AyaNova.Biz
await ItemSearchIndexAsync(putObject, false);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
await ItemHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await ItemPopulateVizFields(putObject);
return putObject;
}
@@ -1303,6 +1305,7 @@ namespace AyaNova.Biz
await ExpenseSearchIndexAsync(newObject, true);
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await ExpensePopulateVizFields(newObject);
return newObject;
}
}
@@ -1355,6 +1358,7 @@ namespace AyaNova.Biz
await ExpenseSearchIndexAsync(putObject, false);
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
await ExpenseHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await ExpensePopulateVizFields(putObject);
return putObject;
}
@@ -1562,6 +1566,7 @@ namespace AyaNova.Biz
await LaborSearchIndexAsync(newObject, true);
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
await LaborHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await LaborPopulateVizFields(newObject);
return newObject;
}
}
@@ -1617,6 +1622,7 @@ namespace AyaNova.Biz
await LaborSearchIndexAsync(putObject, false);
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
await LaborHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await LaborPopulateVizFields(putObject);
return putObject;
}
@@ -1688,6 +1694,27 @@ namespace AyaNova.Biz
o.ServiceRateViz = await ct.ServiceRate.AsNoTracking().Where(x => x.Id == o.ServiceRateId).Select(x => x.Name).FirstOrDefaultAsync();
if (o.TaxCodeSaleId != null)
o.TaxCodeSaleViz = await ct.TaxCode.AsNoTracking().Where(x => x.Id == o.TaxCodeSaleId).Select(x => x.Name).FirstOrDefaultAsync();
//Calculate totals and taxes
o.TaxAViz = 0;
o.TaxBViz = 0;
var netPrice = (o.Price * o.ServiceRateQuantity);
if (o.TaxAPct != 0)
{
o.TaxAViz = netPrice * o.TaxAPct;
}
if (o.TaxBPct != 0)
{
if (o.TaxOnTax)
{
o.TaxBViz = (netPrice + o.TaxAViz) * o.TaxBPct;
}
else
{
o.TaxBViz = netPrice * o.TaxBPct;
}
}
o.LineTotalViz = netPrice + o.TaxAViz + o.TaxBViz;
}
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1695,13 +1722,14 @@ 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
//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
switch (ayaEvent)
{
@@ -1857,6 +1885,7 @@ namespace AyaNova.Biz
await LoanSearchIndexAsync(newObject, true);
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
await LoanHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await LoanPopulateVizFields(newObject);
return newObject;
}
}
@@ -1911,6 +1940,7 @@ namespace AyaNova.Biz
await LoanSearchIndexAsync(putObject, false);
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
await LoanHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await LoanPopulateVizFields(putObject);
return putObject;
}
@@ -2127,6 +2157,7 @@ namespace AyaNova.Biz
await OutsideServiceSearchIndexAsync(newObject, true);
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
await OutsideServicePopulateVizFields(newObject);
return newObject;
}
}
@@ -2181,7 +2212,9 @@ namespace AyaNova.Biz
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct);
await OutsideServiceSearchIndexAsync(putObject, false);
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await OutsideServicePopulateVizFields(putObject);
return putObject;
}
@@ -2389,6 +2422,7 @@ namespace AyaNova.Biz
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct);
await PartSearchIndexAsync(newObject, true);
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
await PartPopulateVizFields(newObject);
return newObject;
}
}
@@ -2443,6 +2477,7 @@ namespace AyaNova.Biz
await PartSearchIndexAsync(putObject, false);
//await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
await PartHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
await PartPopulateVizFields(putObject);
return putObject;
}

View File

@@ -25,6 +25,8 @@ namespace AyaNova.Models
public decimal NoChargeQuantity { get; set; }
public long? ServiceBankId { get; set; }
public long? TaxCodeSaleId { get; set; }
[NotMapped]
public string TaxCodeSaleViz { get; set; }
/*
@@ -42,14 +44,19 @@ namespace AyaNova.Models
*/
//PRICE FIELDS
[Required]
public decimal Cost { get; set; }
[Required]
public decimal ListPrice { get; set; }
[Required]
public decimal Price { get; set; }
[Required]
public string TaxName { get; set; }
[Required]
public decimal TaxAPct { get; set; }
[Required]
public decimal TaxBPct { get; set; }
[Required]
public bool TaxOnTax { get; set; }
[NotMapped]
public decimal TaxAViz { get; set; }