This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -53,7 +53,7 @@
|
||||
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
|
||||
"AYANOVA_SERVER_TEST_MODE": "false",
|
||||
"AYANOVA_SERVER_TEST_MODE": "true",
|
||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
|
||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
|
||||
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"
|
||||
|
||||
@@ -2928,7 +2928,7 @@ namespace AyaNova.Biz
|
||||
return null;
|
||||
else
|
||||
{
|
||||
//await PartBizActionsAsync(AyaEvent.Created, newObject, null, null);
|
||||
await PartBizActionsAsync(AyaEvent.Created, newObject, null, null);
|
||||
//newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
|
||||
//newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
|
||||
await ct.WorkOrderItemPart.AddAsync(newObject);
|
||||
@@ -2974,7 +2974,7 @@ namespace AyaNova.Biz
|
||||
|
||||
await PartValidateAsync(putObject, dbObject);
|
||||
if (HasErrors) return null;
|
||||
// await PartBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null);
|
||||
await PartBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null);
|
||||
ct.Replace(dbObject, putObject);
|
||||
try
|
||||
{
|
||||
@@ -3070,10 +3070,10 @@ namespace AyaNova.Biz
|
||||
o.PriceViz = 0;
|
||||
if (part != null)
|
||||
{
|
||||
o.CostViz = part.Cost;
|
||||
o.ListPriceViz = part.Retail;
|
||||
// o.CostViz = part.Cost;
|
||||
// o.ListPriceViz = part.Retail;
|
||||
o.UnitOfMeasureViz = part.UnitOfMeasure;
|
||||
o.PriceViz = part.Retail;//default price used if not manual or contract override
|
||||
o.PriceViz = o.ListPrice;//default price used if not manual or contract override
|
||||
}
|
||||
|
||||
//manual price overrides anything
|
||||
@@ -3118,9 +3118,9 @@ namespace AyaNova.Biz
|
||||
if (pct != 0)
|
||||
{
|
||||
if (cot == ContractOverrideType.CostMarkup)
|
||||
o.PriceViz = o.CostViz + (o.CostViz * pct);
|
||||
o.PriceViz = o.Cost + (o.Cost * pct);
|
||||
else if (cot == ContractOverrideType.PriceDiscount)
|
||||
o.PriceViz = o.ListPriceViz - (o.ListPriceViz * pct);
|
||||
o.PriceViz = o.ListPrice - (o.ListPrice * pct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3153,75 +3153,51 @@ namespace AyaNova.Biz
|
||||
o.LineTotalViz = o.NetViz + o.TaxAViz + o.TaxBViz;
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //BIZ ACTIONS
|
||||
// //
|
||||
// //
|
||||
// private async Task PartBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemPart newObj, WorkOrderItemPart oldObj, IDbContextTransaction transaction)
|
||||
// {
|
||||
// //automatic actions on record change, called AFTER validation
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//BIZ ACTIONS
|
||||
//
|
||||
//
|
||||
private async Task PartBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemPart newObj, WorkOrderItemPart oldObj, IDbContextTransaction transaction)
|
||||
{
|
||||
//automatic actions on record change, called AFTER validation
|
||||
|
||||
// //currently no processing required except for created or modified at this time
|
||||
// if (ayaEvent != AyaEvent.Created && ayaEvent != AyaEvent.Modified)
|
||||
// return;
|
||||
//currently no processing required except for created or modified at this time
|
||||
if (ayaEvent != AyaEvent.Created && ayaEvent != AyaEvent.Modified)
|
||||
return;
|
||||
|
||||
// //SET TAXES AND PRICING
|
||||
//SNAPSHOT PRICING
|
||||
|
||||
// //by default apply all automatic actions with further restrictions possible below
|
||||
// bool ApplyTax = true;
|
||||
// bool ApplyPricingUpdate = true;
|
||||
//by default apply all automatic actions with further restrictions possible below
|
||||
bool ApplyTax = true;
|
||||
bool ApplyPricingUpdate = true;
|
||||
|
||||
// //if modifed, see what has changed and should be re-applied
|
||||
// if (ayaEvent == AyaEvent.Modified)
|
||||
// {
|
||||
// //If it wasn't a complete part change there is no need to set pricing
|
||||
// if (newObj.PartId == oldObj.PartId)
|
||||
// {
|
||||
// ApplyPricingUpdate = false;
|
||||
// }
|
||||
// //If taxes haven't change then no need to update taxes
|
||||
// if (newObj.TaxPartSaleId == oldObj.TaxPartSaleId)
|
||||
// ApplyTax = false;
|
||||
// }
|
||||
//if modifed, see what has changed and should be re-applied
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
//If it wasn't a complete part change there is no need to set pricing
|
||||
if (newObj.PartId == oldObj.PartId)
|
||||
{
|
||||
ApplyPricingUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
// //Tax code
|
||||
// if (ApplyTax)
|
||||
// {
|
||||
// //Default in case nothing to apply
|
||||
// newObj.TaxAPct = 0;
|
||||
// newObj.TaxBPct = 0;
|
||||
// newObj.TaxOnTax = false;
|
||||
|
||||
// if (newObj.TaxPartSaleId != null)
|
||||
// {
|
||||
// var t = await ct.TaxCode.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.TaxPartSaleId);
|
||||
// if (t != null)
|
||||
// {
|
||||
// newObj.TaxAPct = t.TaxAPct;
|
||||
// newObj.TaxBPct = t.TaxBPct;
|
||||
// newObj.TaxOnTax = t.TaxOnTax;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//Pricing
|
||||
if (ApplyPricingUpdate)
|
||||
{
|
||||
//default in case nothing to apply
|
||||
newObj.Cost = 0;
|
||||
newObj.ListPrice = 0;
|
||||
|
||||
// //Pricing
|
||||
// if (ApplyPricingUpdate)
|
||||
// {
|
||||
// //default in case nothing to apply
|
||||
// newObj.Cost = 0;
|
||||
// newObj.ListPrice = 0;
|
||||
// newObj.Price = 0;
|
||||
|
||||
// var s = await ct.Part.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.PartId);
|
||||
// if (s != null)
|
||||
// {
|
||||
// newObj.Cost = s.Cost;
|
||||
// newObj.ListPrice = s.Retail;
|
||||
// var Contract = await GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId);
|
||||
// PartSetListPrice(newObj, Contract);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
var s = await ct.Part.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.PartId);
|
||||
if (s != null)
|
||||
{
|
||||
newObj.Cost = s.Cost;
|
||||
newObj.ListPrice = s.Retail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// // SET PER UNIT LIST PRICE
|
||||
|
||||
@@ -27,35 +27,15 @@ namespace AyaNova.Models
|
||||
[NotMapped]
|
||||
public string TaxPartSaleViz { get; set; }
|
||||
|
||||
// //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; }
|
||||
// [NotMapped]
|
||||
// public decimal TaxBViz { get; set; }
|
||||
// [NotMapped]
|
||||
// public decimal LineTotalViz { get; set; }
|
||||
//NOTE: part prices are volatile and expected to be frequently edited so snapshotted when newly added unlike other things like rates etc that are protected from change
|
||||
public decimal Cost { get; set; }//cost from source record (e.g. serviceRate) or zero if no cost entered
|
||||
public decimal ListPrice { get; set; }//List price from source record (e.g. serviceRate) or zero if no cost entered
|
||||
|
||||
//Standard pricing fields (mostly to support printed reports though some show in UI)
|
||||
//some not to be sent with record depending on role (i.e. cost and charge in some cases)
|
||||
public decimal? PriceOverride { get; set; }//user entered manually overridden price, if null then ignored in calcs otherwise this *is* the price even if zero
|
||||
[NotMapped]
|
||||
public decimal CostViz { get; set; }//cost from source record (e.g. serviceRate) or zero if no cost entered
|
||||
[NotMapped]
|
||||
public decimal ListPriceViz { get; set; }//List price from source record (e.g. serviceRate) or zero if no cost entered
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public string UnitOfMeasureViz { get; set; }//"each", "hour" etc
|
||||
[NotMapped]
|
||||
|
||||
@@ -799,7 +799,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
//WORKORDERITEM PART
|
||||
await ExecQueryAsync("CREATE TABLE aworkorderitempart (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid BIGINT NOT NULL REFERENCES aworkorderitem (id), "
|
||||
+ "description TEXT, serials TEXT, partid BIGINT NOT NULL REFERENCES apart, partwarehouseid BIGINT NOT NULL REFERENCES apartwarehouse, quantity DECIMAL(19,5) NOT NULL default 0, "
|
||||
+ "taxpartsaleid BIGINT REFERENCES ataxcode, priceoverride DECIMAL(38,18) "
|
||||
+ "cost DECIMAL(38,18) NOT NULL default 0, listprice DECIMAL(38,18) NOT NULL default 0, taxpartsaleid BIGINT REFERENCES ataxcode, priceoverride DECIMAL(38,18) "
|
||||
+ ")");
|
||||
|
||||
//WORKORDERITEM PART REQUEST
|
||||
|
||||
Reference in New Issue
Block a user