Quellcode durchsuchen

Added Allocated and Unallocated Formulas to PurchaseOrderItem

frankvandenbos vor 11 Monaten
Ursprung
Commit
7eaf4b7c8b

+ 33 - 1
prs.classes/Entities/Job/Requisitions/JobRequisitionItem.cs

@@ -180,7 +180,39 @@ namespace Comal.Classes
         [DoubleEditor(Editable = Editable.Disabled)]
         [EditorSequence(12)]
         public double OnOrder { get; set; }
-
+        
+        
+        private class GeneralOrderFormula : ComplexFormulaGenerator<JobRequisitionItem, double>
+        {
+            public override IComplexFormulaNode<JobRequisitionItem, double> GetFormula() =>
+                Formula(
+                    FormulaOperator.Divide,
+                    Formula(
+                        FormulaOperator.Add,
+
+                        Aggregate<PurchaseOrderItem>(
+                                AggregateCalculation.Sum,
+                                x => x.Property(x => x.Unallocated),
+                                new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(null)
+                                    .And(x => x.Job.ID).IsEqualTo(Guid.Empty)
+                            )
+                            .WithLink(x => x.Product.ID, x => x.Product.ID),
+                        
+                            
+                        Aggregate<PurchaseOrderItemAllocation>(
+                            AggregateCalculation.Sum,
+                            x => x.Property(x => x.Quantity),
+                            new Filter<PurchaseOrderItemAllocation>(x => x.Item.ReceivedDate).IsEqualTo(null)
+                                .And(x => x.Job.ID).IsEqualTo(Guid.Empty)
+                            ).WithLink(x => x.Item.Product.ID, x => x.Product.ID)
+                    ),
+                    Property(x => x.Dimensions.Value)
+                );
+        }
+        [ComplexFormula(typeof(GeneralOrderFormula))]
+        [DoubleEditor(Editable = Editable.Hidden)]
+        public double GeneralOrder { get; set; }
+        
         private class TreatmentRequiredFormula : ComplexFormulaGenerator<JobRequisitionItem, double>
         {
             public override IComplexFormulaNode<JobRequisitionItem, double> GetFormula() =>

+ 32 - 0
prs.classes/Entities/PurchaseOrder/PurchaseOrderItem.cs

@@ -56,6 +56,38 @@ namespace Comal.Classes
         [EditorSequence(7)]
         public double Qty { get; set; } = 1;
         
+        private class AllocatedFormula : ComplexFormulaGenerator<PurchaseOrderItem, double>
+        {
+            public override IComplexFormulaNode<PurchaseOrderItem, double> GetFormula() =>
+                Aggregate<PurchaseOrderItemAllocation>(
+                        AggregateCalculation.Sum,
+                        x => x.Property(x => x.Quantity))
+                    .WithLink(x => x.Item.ID, x => x.ID);
+        }
+        
+        [ComplexFormula(typeof(AllocatedFormula))]
+        [DoubleEditor(Editable = Editable.Hidden)]
+        public double Allocated { get; set; }
+        
+        private class UnallocatedFormula : ComplexFormulaGenerator<PurchaseOrderItem, double>
+        {
+            public override IComplexFormulaNode<PurchaseOrderItem, double> GetFormula() =>
+                Formula(
+                    FormulaOperator.Subtract,
+                    Formula(
+                        FormulaOperator.Multiply,
+                        Property(x=>x.Qty),
+                        Property(x=>x.Dimensions.Value)
+                    ),
+                    Property(x=>x.Allocated)
+                );
+        }
+        
+        [ComplexFormula(typeof(UnallocatedFormula))]
+        [DoubleEditor(Editable = Editable.Hidden)]
+        public double Unallocated { get; set; }
+        
+        
         [CurrencyEditor(Visible = Visible.Optional)]
         [EditorSequence(8)]
         public double ForeignCurrencyCost { get; set; }