This commit is contained in:
2021-05-25 20:31:55 +00:00
parent 8c0262cf86
commit 5d62db13f7
4 changed files with 51 additions and 95 deletions

2
.vscode/launch.json vendored
View File

@@ -53,7 +53,7 @@
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", "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_SEEDLEVEL": "small",
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"

View File

@@ -2928,7 +2928,7 @@ namespace AyaNova.Biz
return null; return null;
else else
{ {
//await PartBizActionsAsync(AyaEvent.Created, newObject, null, null); await PartBizActionsAsync(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.WorkOrderItemPart.AddAsync(newObject); await ct.WorkOrderItemPart.AddAsync(newObject);
@@ -2974,7 +2974,7 @@ namespace AyaNova.Biz
await PartValidateAsync(putObject, dbObject); await PartValidateAsync(putObject, dbObject);
if (HasErrors) return null; if (HasErrors) return null;
// await PartBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null); await PartBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null);
ct.Replace(dbObject, putObject); ct.Replace(dbObject, putObject);
try try
{ {
@@ -3070,10 +3070,10 @@ namespace AyaNova.Biz
o.PriceViz = 0; o.PriceViz = 0;
if (part != null) if (part != null)
{ {
o.CostViz = part.Cost; // o.CostViz = part.Cost;
o.ListPriceViz = part.Retail; // o.ListPriceViz = part.Retail;
o.UnitOfMeasureViz = part.UnitOfMeasure; 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 //manual price overrides anything
@@ -3118,9 +3118,9 @@ namespace AyaNova.Biz
if (pct != 0) if (pct != 0)
{ {
if (cot == ContractOverrideType.CostMarkup) if (cot == ContractOverrideType.CostMarkup)
o.PriceViz = o.CostViz + (o.CostViz * pct); o.PriceViz = o.Cost + (o.Cost * pct);
else if (cot == ContractOverrideType.PriceDiscount) 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; o.LineTotalViz = o.NetViz + o.TaxAViz + o.TaxBViz;
} }
// //////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
// //BIZ ACTIONS //BIZ ACTIONS
// // //
// // //
// private async Task PartBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemPart newObj, WorkOrderItemPart oldObj, IDbContextTransaction transaction) private async Task PartBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemPart newObj, WorkOrderItemPart 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 //SNAPSHOT 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;
// bool ApplyPricingUpdate = true; bool ApplyPricingUpdate = 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 it wasn't a complete part change there is no need to set pricing //If it wasn't a complete part change there is no need to set pricing
// if (newObj.PartId == oldObj.PartId) if (newObj.PartId == oldObj.PartId)
// { {
// ApplyPricingUpdate = false; ApplyPricingUpdate = false;
// } }
// //If taxes haven't change then no need to update taxes }
// if (newObj.TaxPartSaleId == oldObj.TaxPartSaleId)
// ApplyTax = false;
// }
// //Tax code
// if (ApplyTax)
// {
// //Default in case nothing to apply
// newObj.TaxAPct = 0;
// newObj.TaxBPct = 0;
// newObj.TaxOnTax = false;
// if (newObj.TaxPartSaleId != null) //Pricing
// { if (ApplyPricingUpdate)
// var t = await ct.TaxCode.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.TaxPartSaleId); {
// if (t != null) //default in case nothing to apply
// { newObj.Cost = 0;
// newObj.TaxAPct = t.TaxAPct; newObj.ListPrice = 0;
// newObj.TaxBPct = t.TaxBPct;
// newObj.TaxOnTax = t.TaxOnTax;
// }
// }
// }
// //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); var s = await ct.Part.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.PartId);
// if (s != null) if (s != null)
// { {
// newObj.Cost = s.Cost; newObj.Cost = s.Cost;
// newObj.ListPrice = s.Retail; newObj.ListPrice = s.Retail;
// var Contract = await GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId); }
// PartSetListPrice(newObj, Contract); }
// } }
// }
// }
// //////////////////////////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////////////////////////
// // SET PER UNIT LIST PRICE // // SET PER UNIT LIST PRICE

View File

@@ -27,35 +27,15 @@ namespace AyaNova.Models
[NotMapped] [NotMapped]
public string TaxPartSaleViz { get; set; } public string TaxPartSaleViz { get; set; }
// //PRICE FIELDS //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
// [Required] public decimal Cost { get; set; }//cost from source record (e.g. serviceRate) or zero if no cost entered
// public decimal Cost { get; set; } public decimal ListPrice { get; set; }//List price from source record (e.g. serviceRate) or zero if no cost entered
// [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; }
//Standard pricing fields (mostly to support printed reports though some show in UI) //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) //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 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] [NotMapped]
public string UnitOfMeasureViz { get; set; }//"each", "hour" etc public string UnitOfMeasureViz { get; set; }//"each", "hour" etc
[NotMapped] [NotMapped]

View File

@@ -799,7 +799,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//WORKORDERITEM PART //WORKORDERITEM PART
await ExecQueryAsync("CREATE TABLE aworkorderitempart (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid BIGINT NOT NULL REFERENCES aworkorderitem (id), " 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, " + "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 //WORKORDERITEM PART REQUEST