This commit is contained in:
@@ -1543,7 +1543,7 @@ namespace AyaNova.Biz
|
|||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await ExpenseBizActionsAsync(AyaEvent.Created, newObject, null, null);
|
//await ExpenseBizActionsAsync(AyaEvent.Created, newObject, null, null);
|
||||||
// newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
|
// newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
|
||||||
// newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
|
// newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
|
||||||
await ct.WorkOrderItemExpense.AddAsync(newObject);
|
await ct.WorkOrderItemExpense.AddAsync(newObject);
|
||||||
@@ -1588,7 +1588,7 @@ namespace AyaNova.Biz
|
|||||||
// dbObject.CustomFields = JsonUtil.CompactJson(dbObject.CustomFields);
|
// dbObject.CustomFields = JsonUtil.CompactJson(dbObject.CustomFields);
|
||||||
await ExpenseValidateAsync(putObject, dbObject);
|
await ExpenseValidateAsync(putObject, dbObject);
|
||||||
if (HasErrors) return null;
|
if (HasErrors) return null;
|
||||||
await ExpenseBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null);
|
//await ExpenseBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null);
|
||||||
ct.Replace(dbObject, putObject);
|
ct.Replace(dbObject, putObject);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1674,81 +1674,88 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
if (o.UserId != null)
|
if (o.UserId != null)
|
||||||
o.UserViz = await ct.User.AsNoTracking().Where(x => x.Id == o.UserId).Select(x => x.Name).FirstOrDefaultAsync();
|
o.UserViz = await ct.User.AsNoTracking().Where(x => x.Id == o.UserId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||||
// if (o.ChargeTaxCodeId != null)
|
|
||||||
// o.ChargeTaxCodeViz = await ct.TaxCode.AsNoTracking().Where(x => x.Id == o.ChargeTaxCodeId).Select(x => x.Name).FirstOrDefaultAsync();
|
TaxCode Tax = null;
|
||||||
|
if (o.ChargeTaxCodeId != null)
|
||||||
|
Tax = await ct.TaxCode.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.ChargeTaxCodeId);
|
||||||
|
if (Tax != null)
|
||||||
|
o.ChargeTaxCodeViz = Tax.Name;
|
||||||
|
|
||||||
//Calculate totals and taxes
|
//Calculate totals and taxes
|
||||||
o.TaxAViz = 0;
|
o.TaxAViz = 0;
|
||||||
o.TaxBViz = 0;
|
o.TaxBViz = 0;
|
||||||
|
|
||||||
if (o.TaxAPct != 0)
|
if (Tax != null)
|
||||||
{
|
{
|
||||||
o.TaxAViz = o.ChargeAmount * (o.TaxAPct / 100);
|
if (Tax.TaxAPct != 0)
|
||||||
}
|
|
||||||
if (o.TaxBPct != 0)
|
|
||||||
{
|
|
||||||
if (o.TaxOnTax)
|
|
||||||
{
|
{
|
||||||
o.TaxBViz = (o.ChargeAmount + o.TaxAViz) * (o.TaxBPct / 100);
|
o.TaxAViz = o.ChargeAmount * (Tax.TaxAPct / 100);
|
||||||
}
|
}
|
||||||
else
|
if (Tax.TaxBPct != 0)
|
||||||
{
|
{
|
||||||
o.TaxBViz = o.ChargeAmount * (o.TaxBPct / 100);
|
if (Tax.TaxOnTax)
|
||||||
|
{
|
||||||
|
o.TaxBViz = (o.ChargeAmount + o.TaxAViz) * (Tax.TaxBPct / 100);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
o.TaxBViz = o.ChargeAmount * (Tax.TaxBPct / 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o.LineTotalViz = o.ChargeAmount + o.TaxAViz + o.TaxBViz;
|
o.LineTotalViz = o.ChargeAmount + o.TaxAViz + o.TaxBViz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//BIZ ACTIONS
|
// //BIZ ACTIONS
|
||||||
//
|
// //
|
||||||
//
|
// //
|
||||||
private async Task ExpenseBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemExpense newObj, WorkOrderItemExpense oldObj, IDbContextTransaction transaction)
|
// private async Task ExpenseBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemExpense newObj, WorkOrderItemExpense oldObj, IDbContextTransaction transaction)
|
||||||
{
|
// {
|
||||||
//automatic actions on record change, called AFTER validation
|
// //automatic actions on record change, called AFTER validation
|
||||||
|
|
||||||
//currently no processing required except for created or modified at this time
|
// //currently no processing required except for created or modified at this time
|
||||||
if (ayaEvent != AyaEvent.Created && ayaEvent != AyaEvent.Modified)
|
// if (ayaEvent != AyaEvent.Created && ayaEvent != AyaEvent.Modified)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
//SET TAXES AND PRICING
|
// //SET TAXES AND PRICING
|
||||||
|
|
||||||
//by default apply all automatic actions with further restrictions possible below
|
// //by default apply all automatic actions with further restrictions possible below
|
||||||
bool ApplyTax = true;
|
// bool ApplyTax = true;
|
||||||
|
|
||||||
|
|
||||||
//if modifed, see what has changed and should be re-applied
|
// //if modifed, see what has changed and should be re-applied
|
||||||
if (ayaEvent == AyaEvent.Modified)
|
// if (ayaEvent == AyaEvent.Modified)
|
||||||
{
|
// {
|
||||||
|
|
||||||
//If taxes haven't change then no need to update taxes
|
// //If taxes haven't change then no need to update taxes
|
||||||
if (newObj.ChargeTaxCodeId == oldObj.ChargeTaxCodeId)
|
// if (newObj.ChargeTaxCodeId == oldObj.ChargeTaxCodeId)
|
||||||
ApplyTax = false;
|
// ApplyTax = false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Tax code
|
// //Tax code
|
||||||
if (ApplyTax)
|
// if (ApplyTax)
|
||||||
{
|
// {
|
||||||
//Default in case nothing to apply
|
// //Default in case nothing to apply
|
||||||
newObj.TaxAPct = 0;
|
// newObj.TaxAPct = 0;
|
||||||
newObj.TaxBPct = 0;
|
// newObj.TaxBPct = 0;
|
||||||
newObj.TaxOnTax = false;
|
// newObj.TaxOnTax = false;
|
||||||
newObj.TaxName = "";
|
// newObj.TaxName = "";
|
||||||
|
|
||||||
if (newObj.ChargeTaxCodeId != null)
|
// if (newObj.ChargeTaxCodeId != null)
|
||||||
{
|
// {
|
||||||
var t = await ct.TaxCode.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.ChargeTaxCodeId);
|
// var t = await ct.TaxCode.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.ChargeTaxCodeId);
|
||||||
if (t != null)
|
// if (t != null)
|
||||||
{
|
// {
|
||||||
newObj.TaxAPct = t.TaxAPct;
|
// newObj.TaxAPct = t.TaxAPct;
|
||||||
newObj.TaxBPct = t.TaxBPct;
|
// newObj.TaxBPct = t.TaxBPct;
|
||||||
newObj.TaxOnTax = t.TaxOnTax;
|
// newObj.TaxOnTax = t.TaxOnTax;
|
||||||
newObj.TaxName = t.Name;
|
// newObj.TaxName = t.Name;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1879,7 +1886,7 @@ namespace AyaNova.Biz
|
|||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// await LaborBizActionsAsync(AyaEvent.Created, newObject, null, null);
|
// await LaborBizActionsAsync(AyaEvent.Created, newObject, null, null);
|
||||||
//newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
|
//newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
|
||||||
//newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
|
//newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
|
||||||
await ct.WorkOrderItemLabor.AddAsync(newObject);
|
await ct.WorkOrderItemLabor.AddAsync(newObject);
|
||||||
@@ -1927,7 +1934,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
await LaborValidateAsync(putObject, dbObject);
|
await LaborValidateAsync(putObject, dbObject);
|
||||||
if (HasErrors) return null;
|
if (HasErrors) return null;
|
||||||
// await LaborBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null);
|
// await LaborBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null);
|
||||||
ct.Replace(dbObject, putObject);
|
ct.Replace(dbObject, putObject);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user