This commit is contained in:
2021-02-25 16:03:16 +00:00
parent 6358a94fd3
commit d70b1f3066
4 changed files with 38 additions and 3 deletions

View File

@@ -512,6 +512,23 @@ namespace AyaNova.Biz
{
AddError(ApiErrorCode.API_SERVER_ERROR, "generalerror", $"Error updating inventory ({i.Description}):{pib.GetErrorsAsString()}");
return;
}
if (!string.IsNullOrWhiteSpace(newItem.Serials))
{
//javascript version at UI for partserials entry
//let splitted = this.newSerial.split(/[\s,]+/).filter(Boolean); //filter Boolean is equivalent to array.filter(item => Boolean(item)) and it's to filter out nulls concisely from badly formatted strings
// splitted = [...splitted, ...this.obj];
// let uniqueItems = [...new Set(splitted)];
// uniqueItems.sort();
//c# version to replicate above
var serials = System.Text.RegularExpressions.Regex.Split(newItem.Serials, "[\\s,]+", System.Text.RegularExpressions.RegexOptions.IgnoreCase,
TimeSpan.FromMilliseconds(2000)).Select(x => x.Trim()).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().OrderBy(x => x).ToArray();
}
}

View File

@@ -29,6 +29,7 @@ namespace AyaNova.Models
public long? WorkorderItemPartRequestId { get; set; }
public long? PurchaseTaxCodeId { get; set; }
public string VendorPartNumber { get; set; }
public string Serials { get; set; }
[JsonIgnore]
public PurchaseOrder PurchaseOrder { get; set; }

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 = 15;
internal const long EXPECTED_COLUMN_COUNT = 735;
internal const long EXPECTED_COLUMN_COUNT = 736;
internal const long EXPECTED_INDEX_COUNT = 125;
internal const long EXPECTED_CHECK_CONSTRAINTS = 328;
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 70;
@@ -744,7 +744,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
await ExecQueryAsync("CREATE TABLE apurchaseorderitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, purchaseorderid BIGINT NOT NULL REFERENCES apurchaseorder ON DELETE CASCADE, " +
"partid BIGINT NOT NULL REFERENCES apart, partwarehouseid BIGINT NOT NULL REFERENCES apartwarehouse, quantityordered DECIMAL(19,4) NOT NULL default 0, " +
"quantityreceived DECIMAL(19,4) NOT NULL default 0, purchaseordercost DECIMAL(19,4) NOT NULL default 0, receivedcost DECIMAL(19,4) NOT NULL default 0, " +
"receiveddate TIMESTAMP, partrequestedbyid BIGINT REFERENCES auser, purchasetaxcodeid BIGINT REFERENCES ataxcode, vendorpartnumber TEXT " +
"receiveddate TIMESTAMP, partrequestedbyid BIGINT REFERENCES auser, purchasetaxcodeid BIGINT REFERENCES ataxcode, vendorpartnumber TEXT, serials TEXT " +
")");

View File

@@ -1742,6 +1742,9 @@ namespace AyaNova.Util
List<long> partsAdded = new List<long>();
int partCount = Fake.Random.Int(1, 5);
//simulate some items without tax codes
bool addTaxCode = (Fake.Random.Number(1, 4) != 3);
@@ -1761,6 +1764,19 @@ namespace AyaNova.Util
var qty = Fake.Random.Int(1, 100);
var cost = Fake.Random.Decimal(1, 25);
// 50% chance it has received serial numbers
string serials = string.Empty;
if (isReceived && Fake.Random.Number() == 1)
{
var serialStart = Fake.Finance.Account().ToString();
for (int si = 0; si < qty; si++)
{
serials += serialStart + si.ToString() + ", ";
}
serials = serials.TrimEnd().TrimEnd(',');
}
o.Items.Add(new PurchaseOrderItem()
{
PartId = partId,
@@ -1770,7 +1786,8 @@ namespace AyaNova.Util
PurchaseOrderCost = cost,
ReceivedCost = isReceived ? cost : 0,
ReceivedDate = isReceived ? o.ExpectedReceiveDate : null,
PurchaseTaxCodeId = addTaxCode ? 3 : null//sales and goods
PurchaseTaxCodeId = addTaxCode ? 3 : null,//sales and goods
Serials = serials
});
}