This commit is contained in:
2021-01-18 20:12:41 +00:00
parent 4b2e972580
commit 13f04cffbf
5 changed files with 17 additions and 4 deletions

2
.vscode/launch.json vendored
View File

@@ -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\\"

View File

@@ -109,7 +109,7 @@ namespace AyaNova.Biz
if (logTheGetEvent && ret != null)
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
if (populatePartNames && ret.Items!=null && ret.Items.Count > 0)
if (populatePartNames && ret.Items != null && ret.Items.Count > 0)
{
var partIdList = ret.Items.Select(z => z.PartId).ToArray();
var PickList = PickListFactory.GetAyaPickList(AyaType.Part);
@@ -265,6 +265,15 @@ namespace AyaNova.Biz
if (proposedObj.Items.GroupBy(z => z.PartId).Any(g => g.Count() > 1))
{
AddError(ApiErrorCode.VALIDATION_FAILED, "Items", "Duplicate parts are not allowed in the items collection");
return;
}
//Make sure there are no < 1 quantities and if there are make them 1 rather than reporting a broken rule
//(decided this based on UI and likelyhood etc it woudl be hard to show this as a biz rule with the simple UI for it)
foreach (var pai in proposedObj.Items)
{
if (pai.Quantity < 1)
pai.Quantity = 1;
}
//Any form customizations to validate?

View File

@@ -12,12 +12,16 @@ namespace AyaNova.Models
[Required]
public long PartAssemblyId { get; set; }
[Required]
public long PartId { get; set; }
[Required]
public decimal Quantity { get; set; }
[JsonIgnore]
public PartAssembly PartAssembly { get; set; }
[NotMapped]
public string PartDisplay {get;set;}
public string PartDisplay { get; set; }
}//eoc

View File

@@ -671,7 +671,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//PARTASSEMBLYITEM
await ExecQueryAsync("CREATE TABLE apartassemblyitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, partassemblyid bigint not null REFERENCES apartassembly on delete cascade, " +
"partid bigint not null REFERENCES apart, " +
"partid bigint not null REFERENCES apart, quantity decimal(19,4) not null default 1, " +
"CONSTRAINT UNQ_PartAssemblyPart UNIQUE (partid, partassemblyid) " +//ensure no duplicate parts in the same assembly
")");
// await ExecQueryAsync("CREATE INDEX idx_apartassemblyitem_partid ON apartassemblyitem(partid)");