|
@@ -270,6 +270,8 @@ namespace Comal.Classes
|
|
|
LinkedProperties.Register<PurchaseOrder, SupplierLink, String>(x => x.SupplierLink, x => x.Code, x => x.SupplierCode);
|
|
|
LinkedProperties.Register<PurchaseOrder, SupplierLink, String>(x => x.SupplierLink, x => x.Name, x => x.SupplierName);
|
|
|
}
|
|
|
+
|
|
|
+ private static Column<PurchaseOrderItem> POProductIDColumn = new Column<PurchaseOrderItem>(x => x.Product.ID);
|
|
|
|
|
|
/// <summary>
|
|
|
/// Recalculate the cost of each PurchaseOrderItem in <paramref name="items"/>, by finding a <see cref="SupplierProduct"/> that matches.
|
|
@@ -277,7 +279,7 @@ namespace Comal.Classes
|
|
|
/// <param name="items"></param>
|
|
|
/// <param name="supplierid"></param>
|
|
|
/// <param name="changes"></param>
|
|
|
- public static void UpdateCosts(IEnumerable<PurchaseOrderItem> items, Guid supplierid, Dictionary<String,object?> changes)
|
|
|
+ public static void UpdateCosts(IEnumerable<PurchaseOrderItem> items, Guid supplierid, Dictionary<String,object?> changes, string columnName)
|
|
|
{
|
|
|
var itemsList = items.AsIList();
|
|
|
|
|
@@ -329,8 +331,17 @@ namespace Comal.Classes
|
|
|
&& x.Job.ID == item.Job.ID);
|
|
|
if (supplierProduct != null)
|
|
|
{
|
|
|
- UpdateValue<string>(item, x => x.SupplierCode, supplierProduct.SupplierCode);
|
|
|
- UpdateValue<string>(item, x => x.Description, supplierProduct.SupplierDescription);
|
|
|
+ if(POProductIDColumn.IsEqualTo(columnName))
|
|
|
+ {
|
|
|
+ if (!supplierProduct.SupplierCode.IsNullOrWhiteSpace())
|
|
|
+ {
|
|
|
+ UpdateValue<string>(item, x => x.SupplierCode, supplierProduct.SupplierCode);
|
|
|
+ }
|
|
|
+ if (!supplierProduct.SupplierDescription.IsNullOrWhiteSpace())
|
|
|
+ {
|
|
|
+ UpdateValue<string>(item, x => x.Description, supplierProduct.SupplierDescription);
|
|
|
+ }
|
|
|
+ }
|
|
|
UpdateValue<double>(item, x => x.ForeignCurrencyCost, supplierProduct.ForeignCurrencyPrice);
|
|
|
UpdateValue<double>(item, x => x.Cost, supplierProduct.CostPrice);
|
|
|
continue;
|
|
@@ -345,8 +356,17 @@ namespace Comal.Classes
|
|
|
&& x.Job.ID == Guid.Empty);
|
|
|
if (supplierProduct != null)
|
|
|
{
|
|
|
- UpdateValue<string>(item, x => x.SupplierCode, supplierProduct.SupplierCode);
|
|
|
- UpdateValue<string>(item, x => x.Description, supplierProduct.SupplierDescription);
|
|
|
+ if(POProductIDColumn.IsEqualTo(columnName))
|
|
|
+ {
|
|
|
+ if (!supplierProduct.SupplierCode.IsNullOrWhiteSpace())
|
|
|
+ {
|
|
|
+ UpdateValue<string>(item, x => x.SupplierCode, supplierProduct.SupplierCode);
|
|
|
+ }
|
|
|
+ if (!supplierProduct.SupplierDescription.IsNullOrWhiteSpace())
|
|
|
+ {
|
|
|
+ UpdateValue<string>(item, x => x.Description, supplierProduct.SupplierDescription);
|
|
|
+ }
|
|
|
+ }
|
|
|
UpdateValue<double>(item, x => x.ForeignCurrencyCost, supplierProduct.ForeignCurrencyPrice);
|
|
|
UpdateValue<double>(item, x => x.Cost, supplierProduct.CostPrice);
|
|
|
continue;
|