|
@@ -175,12 +175,9 @@ namespace Comal.Classes
|
|
|
|
|
|
static PurchaseOrderItem()
|
|
|
{
|
|
|
-
|
|
|
LinkedProperties.Register<PurchaseOrderItem, ProductLink, String>(x => x.Product, x => x.Code, x => x.SupplierCode);
|
|
|
LinkedProperties.Register<PurchaseOrderItem, ProductLink, String>(x => x.Product, x => x.Name, x => x.Description);
|
|
|
- LinkedProperties.Register<PurchaseOrderItem, ProductLink, double>(x => x.Product, x => x.NettCost,
|
|
|
- x => x.Cost);
|
|
|
-
|
|
|
+
|
|
|
LinkedProperties.Register<PurchaseOrderItem, TaxCodeLink, Guid>(x => x.Product.TaxCode, x => x.ID, x => x.TaxCode.ID);
|
|
|
LinkedProperties.Register<PurchaseOrderItem, TaxCodeLink, String>(x => x.Product.TaxCode, x => x.Code,
|
|
|
x => x.TaxCode.Code);
|
|
@@ -188,28 +185,22 @@ namespace Comal.Classes
|
|
|
x => x.TaxCode.Description);
|
|
|
LinkedProperties.Register<PurchaseOrderItem, TaxCodeLink, double>(x => x.Product.TaxCode, x => x.Rate,
|
|
|
x => x.TaxCode.Rate);
|
|
|
- LinkedProperties.Register<PurchaseOrderItem, TaxCodeLink, double>(x => x.Product.TaxCode, x => x.Rate, x => x.TaxCode.Rate);
|
|
|
-
|
|
|
- LinkedProperties.Register<PurchaseOrderItem, PurchaseGLCodeLink, Guid>(x => x.Product.PurchaseGL, x => x.ID, x => x.PurchaseGL.ID);
|
|
|
+ LinkedProperties.Register<PurchaseOrderItem, TaxCodeLink, double>(x => x.TaxCode, x => x.Rate, x => x.TaxRate);
|
|
|
|
|
|
+ LinkedProperties.Register<PurchaseOrderItem, PurchaseGLCodeLink, Guid>(x => x.Product.PurchaseGL, x => x.ID, x => x.PurchaseGL.ID);
|
|
|
LinkedProperties.Register<PurchaseOrderItem, CostCentreLink, Guid>(x => x.Product.CostCentre, x => x.ID, x => x.CostCentre.ID);
|
|
|
|
|
|
LinkedProperties.Register<PurchaseOrderItem, ProductStyleLink, Guid>(x => x.Product.DefaultInstance.Style, x => x.ID, x => x.Style.ID);
|
|
|
LinkedProperties.Register<PurchaseOrderItem, ProductStyleLink, String>(x => x.Product.DefaultInstance.Style, x => x.Code, x => x.Style.Code);
|
|
|
LinkedProperties.Register<PurchaseOrderItem, ProductStyleLink, String>(x => x.Product.DefaultInstance.Style, x => x.Description, x => x.Style.Description);
|
|
|
|
|
|
- StockEntity.LinkStockDimensions<PurchaseOrderItem>();
|
|
|
+ LinkedProperties.Register<PurchaseOrderItem, ProductInstanceLink, double>(x => x.Product.DefaultInstance, x => x.NettCost,
|
|
|
+ x => x.Cost);
|
|
|
|
|
|
- LinkedProperties.Register<PurchaseOrderItem, TaxCodeLink, double>(x => x.TaxCode, x => x.Rate, x => x.TaxRate);
|
|
|
+ StockEntity.LinkStockDimensions<PurchaseOrderItem>();
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- private static Column<PurchaseOrderItem> qty = new Column<PurchaseOrderItem>(x => x.Qty);
|
|
|
- private static Column<PurchaseOrderItem> cost = new Column<PurchaseOrderItem>(x => x.Cost);
|
|
|
- private static Column<PurchaseOrderItem> extax = new Column<PurchaseOrderItem>(x => x.ExTax);
|
|
|
- private static Column<PurchaseOrderItem> inctax = new Column<PurchaseOrderItem>(x => x.IncTax);
|
|
|
- private static Column<PurchaseOrderItem> balance = new Column<PurchaseOrderItem>(x => x.Balance);
|
|
|
- private static Column<PurchaseOrderItem> received = new Column<PurchaseOrderItem>(x => x.ReceivedDate);
|
|
|
-
|
|
|
+
|
|
|
private bool bChanging;
|
|
|
|
|
|
protected override void DoPropertyChanged(string name, object? before, object? after)
|
|
@@ -221,17 +212,24 @@ namespace Comal.Classes
|
|
|
{
|
|
|
bChanging = true;
|
|
|
|
|
|
- if (qty.IsEqualTo(name))
|
|
|
- ExTax = (double)after /* * Dimensions.Value */ * Cost;
|
|
|
+ if (name.Equals(nameof(Qty)) && after is double qty)
|
|
|
+ ExTax = qty * Cost;
|
|
|
|
|
|
- else if (cost.IsEqualTo(name))
|
|
|
- ExTax = Qty /* * Dimensions.Value */ * (double)after;
|
|
|
+ else if (name.Equals(nameof(Cost)) && after is double cost)
|
|
|
+ ExTax = Qty * cost;
|
|
|
+
|
|
|
+ else if (name.Equals(nameof(ExTax)) && after is double extax)
|
|
|
+ {
|
|
|
+ if (Qty == 0)
|
|
|
+ Qty = 1;
|
|
|
+ Cost = extax / Qty;
|
|
|
+ }
|
|
|
|
|
|
- else if (inctax.IsEqualTo(name))
|
|
|
- Balance = ReceivedDate.IsEmpty() ? (double)after : 0.00F;
|
|
|
+ else if (name.Equals(nameof(IncTax)) && after is double inctax)
|
|
|
+ Balance = ReceivedDate.IsEmpty() ? inctax : 0.00F;
|
|
|
|
|
|
- else if (received.IsEqualTo(name))
|
|
|
- Balance = ((DateTime)after).IsEmpty() ? IncTax : 0.00F;
|
|
|
+ else if (name.Equals(nameof(ReceivedDate)) && after is DateTime received)
|
|
|
+ Balance = received.IsEmpty() ? IncTax : 0.00F;
|
|
|
}
|
|
|
finally
|
|
|
{
|