Quellcode durchsuchen

Added bill line product field for non stock items

Kenric Nugteren vor 1 Jahr
Ursprung
Commit
fb4c1e590d

+ 28 - 1
prs.classes/Entities/Bill/BillLine.cs

@@ -20,6 +20,9 @@ namespace Comal.Classes
         [EditorSequence(1)]
         public PurchaseOrderItemLink OrderItem { get; set; }
 
+        [EditorSequence(2)]
+        public ProductLink Product { get; set; }
+
         [MemoEditor]
         [EditorSequence(2)]
         public string Description { get; set; }
@@ -83,6 +86,30 @@ namespace Comal.Classes
 
             LinkedProperties.Register<BillLine, TaxCodeLink, double>(x => x.TaxCode, x => x.Rate, x => x.TaxRate);
 
-        }       
+            LinkedProperties.Register<BillLine, PurchaseGLCodeLink, Guid>(x => x.Product.PurchaseGL, x => x.ID, x => x.PurchaseGL.ID);
+            LinkedProperties.Register<BillLine, CostCentreLink, Guid>(x => x.Product.CostCentre, x => x.ID, x => x.CostCentre.ID);
+            LinkedProperties.Register<BillLine, TaxCodeLink, Guid>(x => x.Product.TaxCode, x => x.ID, x => x.TaxCode.ID);
+            LinkedProperties.Register<BillLine, TaxCodeLink, string>(x => x.Product.TaxCode, x => x.Code, x => x.TaxCode.Code);
+            LinkedProperties.Register<BillLine, TaxCodeLink, string>(x => x.Product.TaxCode, x => x.Description, x => x.TaxCode.Description);
+            LinkedProperties.Register<BillLine, TaxCodeLink, double>(x => x.Product.TaxCode, x => x.Rate, x => x.TaxCode.Rate);
+        }
+
+        private static readonly Column<BillLine> OrderItemColumn = new Column<BillLine>(x => x.OrderItem.ID);
+        private static readonly Column<BillLine> ProductColumn = new Column<BillLine>(x => x.Product.ID);
+
+        protected override void DoPropertyChanged(string name, object? before, object? after)
+        {
+            base.DoPropertyChanged(name, before, after);
+            if (OrderItemColumn.IsEqualTo(name) && after is Guid orderItemID && orderItemID != Guid.Empty)
+            {
+                Product.ID = Guid.Empty;
+                Product.Clear();
+            }
+            else if(ProductColumn.IsEqualTo(name) && after is Guid productID && productID != Guid.Empty)
+            {
+                OrderItem.ID = Guid.Empty;
+                OrderItem.Clear();
+            }
+        }
     }
 }

+ 12 - 1
prs.classes/Entities/Product/ProductLookups.cs

@@ -8,7 +8,8 @@ namespace Comal.Classes
         ILookupDefinition<Product, StockMovement>, 
         ILookupDefinition<Product, EmployeeProduct>,
         ILookupDefinition<Product, StagingManufacturingPacketTreatment>,
-        ILookupDefinition<Product, ManufacturingTreatment>
+        ILookupDefinition<Product, ManufacturingTreatment>,
+        ILookupDefinition<Product, BillLine>
 
     {
         // EmployeeProduct records also require a Default Location to pull from
@@ -90,5 +91,15 @@ namespace Comal.Classes
         {
             return new SortOrder<Product>(x => x.Code);
         }
+
+        public Filter<Product> DefineFilter(BillLine[] items)
+        {
+            return new Filter<Product>(x => x.NonStock);
+        }
+
+        public Columns<BillLine> DefineFilterColumns()
+        {
+            return new Columns<BillLine>();
+        }
     }
 }