|
@@ -225,27 +225,38 @@ namespace Comal.Classes
|
|
|
Category = new PurchaseOrderCategoryLink();
|
|
|
}
|
|
|
|
|
|
- public static void UpdateCosts(IEnumerable<PurchaseOrderItem> items, Guid supplierid, Action<String,object>? update)
|
|
|
+ public static void UpdateCosts(IEnumerable<PurchaseOrderItem> items, Guid supplierid, Dictionary<String,object?> changes)
|
|
|
{
|
|
|
|
|
|
void UpdateValue<TType>(PurchaseOrderItem item,Expression<Func<PurchaseOrderItem, TType>> property, TType value)
|
|
|
{
|
|
|
- String propertyname = CoreUtils.GetFullPropertyName(property, ".");
|
|
|
- if (update == null)
|
|
|
- CoreUtils.SetPropertyValue(item, propertyname , value);
|
|
|
- else
|
|
|
- update?.Invoke(propertyname, value);
|
|
|
+ CoreUtils.MonitorChanges(
|
|
|
+ item,
|
|
|
+ () => CoreUtils.SetPropertyValue(item, CoreUtils.GetFullPropertyName(property, "."), value),
|
|
|
+ changes
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
var productids = items.Where(x => x.Product.ID != Guid.Empty).Select(x => x.Product.ID).ToArray();
|
|
|
MultiQuery query = new MultiQuery();
|
|
|
query.Add(
|
|
|
- new Filter<SupplierProduct>(x=>x.SupplierLink.ID).IsEqualTo(supplierid).And(x=>x.ProductLink.ID).InList(productids),
|
|
|
- new Columns<SupplierProduct>(x=>x.ProductLink.ID).Add(x=>x.Job.ID).Add(x=>x.CostPrice).Add(x=>x.SupplierCode).Add(x=>x.SupplierDescription)
|
|
|
+ new Filter<SupplierProduct>(x=>x.SupplierLink.ID).IsEqualTo(supplierid)
|
|
|
+ .And(x=>x.ProductLink.ID).InList(productids)
|
|
|
+ .And(x=>x.Dimensions.UnitSize).IsEqualTo(items.First().Dimensions.UnitSize),
|
|
|
+ new Columns<SupplierProduct>(x=>x.ProductLink.ID)
|
|
|
+ .Add(x=>x.Job.ID)
|
|
|
+ .Add(x=>x.CostPrice)
|
|
|
+ .Add(x=>x.SupplierCode)
|
|
|
+ .Add(x=>x.SupplierDescription)
|
|
|
+ .Add(x=>x.Dimensions.Value)
|
|
|
);
|
|
|
query.Add(
|
|
|
new Filter<Product>(x=>x.ID).InList(productids),
|
|
|
- new Columns<Product>(x=>x.ID).Add(x=>x.NettCost).Add(x=>x.Code).Add(x=>x.Name)
|
|
|
+ new Columns<Product>(x=>x.ID)
|
|
|
+ .Add(x=>x.NettCost)
|
|
|
+ .Add(x=>x.Code)
|
|
|
+ .Add(x=>x.Name)
|
|
|
+ .Add(x=>x.Dimensions.Value)
|
|
|
);
|
|
|
query.Query();
|
|
|
|
|
@@ -275,7 +286,16 @@ namespace Comal.Classes
|
|
|
{
|
|
|
UpdateValue<String>(item, x => x.SupplierCode, row.Get<Product, String>(c => c.Code));
|
|
|
UpdateValue<String>(item, x => x.Description, row.Get<Product, String>(c => c.Name));
|
|
|
- UpdateValue<double>(item, x => x.Cost, row.Get<Product, double>(c => c.NettCost));
|
|
|
+ if (String.Equals(row.Get<Product,String>(c=>c.Dimensions.UnitSize),items.First().Dimensions.UnitSize))
|
|
|
+ UpdateValue<double>(item, x => x.Cost, row.Get<Product, double>(c => c.NettCost));
|
|
|
+ else
|
|
|
+ UpdateValue<double>(item, x => x.Cost, 0.0F);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ UpdateValue<String>(item, x => x.SupplierCode, "");
|
|
|
+ UpdateValue<String>(item, x => x.Description, "");
|
|
|
+ UpdateValue<double>(item, x => x.Cost, 0.0F);
|
|
|
}
|
|
|
}
|
|
|
|