This commit is contained in:
2021-05-27 17:50:20 +00:00
parent 8b1d1f22a2
commit 881bf57116
3 changed files with 70 additions and 5 deletions

View File

@@ -2918,9 +2918,51 @@ namespace AyaNova.Biz
//
private async Task OutsideServicePopulateVizFields(WorkOrderItemOutsideService o)
{
await Task.CompletedTask;
// if (o.WorkOrderOverseerId != null)
// o.WorkOrderOverseerViz = await ct.User.AsNoTracking().Where(x => x.Id == o.WorkOrderOverseerId).Select(x => x.Name).FirstOrDefaultAsync();
if (o.UnitId != 0)
o.UnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.UnitId).Select(x => x.Serial).FirstOrDefaultAsync();
if (o.VendorSentToId != null)
o.VendorSentToViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.VendorSentToId).Select(x => x.Name).FirstOrDefaultAsync();
if (o.VendorSentViaId != null)
o.VendorSentViaViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.VendorSentViaId).Select(x => x.Name).FirstOrDefaultAsync();
TaxCode Tax = null;
if (o.TaxCodeId != null)
Tax = await ct.TaxCode.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.TaxCodeId);
if (Tax != null)
o.TaxCodeViz = Tax.Name;
o.CostViz = o.ShippingCost + o.RepairCost;
o.PriceViz = o.ShippingPrice + o.RepairPrice;
//Currently not contract discounted so no further calcs need apply to priceViz
//Calculate totals and taxes
//NET
o.NetViz = o.PriceViz;//just for standardization, no quantity so is redundant but reporting easier if all the same
//TAX
o.TaxAViz = 0;
o.TaxBViz = 0;
if (Tax != null)
{
if (Tax.TaxAPct != 0)
{
o.TaxAViz = o.NetViz * (Tax.TaxAPct / 100);
}
if (Tax.TaxBPct != 0)
{
if (Tax.TaxOnTax)
{
o.TaxBViz = (o.NetViz + o.TaxAViz) * (Tax.TaxBPct / 100);
}
else
{
o.TaxBViz = o.NetViz * (Tax.TaxBPct / 100);
}
}
}
o.LineTotalViz = o.NetViz + o.TaxAViz + o.TaxBViz;
}
////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -14,16 +14,39 @@ namespace AyaNova.Models
public string Notes { get; set; }
public long UnitId { get; set; }
[NotMapped]
public string UnitViz { get; set; }
public long? VendorSentToId { get; set; }
[NotMapped]
public string VendorSentToViz { get; set; }
public long? VendorSentViaId { get; set; }
[NotMapped]
public string VendorSentViaViz { get; set; }
public string RMANumber { get; set; }
public string TrackingNumber { get; set; }
public decimal RepairCost { get; set; }
public decimal RepairPrice { get; set; }
public decimal ShippingCost { get; set; }
public decimal ShippingPrice { get; set; }
public DateTime? SentDate { get; set; }
public DateTime? ETADate { get; set; }
public DateTime? ReturnDate { get; set; }
public long? TaxCodeId { get; set; }
[NotMapped]
public string TaxCodeViz { get; set; }
[NotMapped]
public decimal CostViz { get; set; }//Total cost shipping + repairs
[NotMapped]
public decimal PriceViz { get; set; }//Total price shipping + repairs
[NotMapped]
public decimal NetViz { get; set; }//=priceViz for standardization not because it's necessary (before taxes line total essentially)
[NotMapped]
public decimal TaxAViz { get; set; }//total amount of taxA
[NotMapped]
public decimal TaxBViz { get; set; }//total amount of taxB
[NotMapped]
public decimal LineTotalViz { get; set; }//line total netViz + taxes
//UTILITY FIELDS

View File

@@ -22,7 +22,7 @@ namespace AyaNova.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
private const int DESIRED_SCHEMA_LEVEL = 1;
internal const long EXPECTED_COLUMN_COUNT = 943;
internal const long EXPECTED_COLUMN_COUNT = 945;
internal const long EXPECTED_INDEX_COUNT = 141;
internal const long EXPECTED_CHECK_CONSTRAINTS = 430;
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 118;
@@ -835,7 +835,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//WORKORDERITEM OUTSIDE SERVICE
await ExecQueryAsync("CREATE TABLE aworkorderitemoutsideservice (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid BIGINT NOT NULL REFERENCES aworkorderitem (id), "
+ "notes TEXT, unitid BIGINT NOT NULL REFERENCES aunit, vendorsenttoid BIGINT REFERENCES avendor, vendorsentviaid BIGINT REFERENCES avendor, rmanumber text, trackingnumber text, "
+ "repaircost DECIMAL(38,18) NOT NULL default 0, shippingcost DECIMAL(38,18) NOT NULL default 0, shippingprice DECIMAL(38,18) NOT NULL default 0, "
+ "taxcodeid BIGINT REFERENCES ataxcode, repaircost DECIMAL(38,18) NOT NULL default 0, repairprice DECIMAL(38,18) NOT NULL default 0, shippingcost DECIMAL(38,18) NOT NULL default 0, shippingprice DECIMAL(38,18) NOT NULL default 0, "
+ "SentDate TIMESTAMP, etadate TIMESTAMP, returndate TIMESTAMP"
+ ")");