Kitt Parker vor 5 Monaten
Ursprung
Commit
f73264f102
3 geänderte Dateien mit 46 neuen und 31 gelöschten Zeilen
  1. 17 4
      LaborRuleBase.cs
  2. 21 20
      LaborRules.cs
  3. 8 7
      ProjectEntryExt.cs

+ 17 - 4
LaborRuleBase.cs

@@ -1,8 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace ProjectEntryLaborAdjust
 {
@@ -15,6 +12,14 @@ namespace ProjectEntryLaborAdjust
         public HashSet<string> ExcludedTemplateCDs { get; }
         public HashSet<string> ExcludedBillRules { get; }
 
+        /// <summary>
+        /// Optional project creation cutoff date. If set, any project whose CreatedDateTime
+        /// is strictly before this date will be excluded (rule will be skipped).
+        /// Date part is compared (time-of-day ignored).
+        /// </summary>
+        public DateTime? ProjectDate { get; set; }
+
+
         /// <summary>
         /// Optional fixed unit rate. If null, the AR pricing engine (defaults) should apply.
         /// </summary>
@@ -42,11 +47,19 @@ namespace ProjectEntryLaborAdjust
         public abstract decimal GetHours(decimal jobSize);
 
         /// <summary>Check if this rule should be skipped under the provided context.</summary>
-        public virtual bool IsExcludedFor(string branchCD, string templateCD, string billRule)
+        public virtual bool IsExcludedFor(string branchCD, string templateCD, string billRule, DateTime? projectCreatedDate)
         {
             if (!string.IsNullOrWhiteSpace(branchCD) && ExcludedBranchCDs.Contains(branchCD.Trim())) return true;
             if (!string.IsNullOrWhiteSpace(templateCD) && ExcludedTemplateCDs.Contains(templateCD.Trim())) return true;
             if (!string.IsNullOrWhiteSpace(billRule) && ExcludedBillRules.Contains(billRule.Trim())) return true;
+
+            if (ProjectDate.HasValue && projectCreatedDate.HasValue)
+            {
+                // Compare by date part only
+                if (projectCreatedDate.Value.Date < ProjectDate.Value.Date)
+                    return true;
+            }
+
             return false;
         }
     }

+ 21 - 20
LaborRules.cs

@@ -15,6 +15,7 @@ namespace ProjectEntryLaborAdjust
             ExcludedBranchCDs.Add("112");
             ExcludedTemplateCDs.Add("ENVIRONMENTAL");
             ExcludedBillRules.Add("PROGRESS");
+            ProjectDate = new DateTime(2025, 9, 02);
         }
 
         // Leave null => use AR Sales Prices (no fixed rate)
@@ -37,9 +38,13 @@ namespace ProjectEntryLaborAdjust
             if (jobSize <= 50000m) return 7.0m;
             return 10.5m;
         }
+
+
+
+
     }
 
-    // second rule that DOES supply a fixed rate
+    // second rule that DOES supply a fixed rate ->DROP this code, implement updated table in L001 Bullet point one.  Currently Inactive and removed for processesing per Mario.
     public sealed class L014LaborRule : LaborRuleBase
     {
         public L014LaborRule() : base("L014", "Auto-added Coordinator Labor")
@@ -66,16 +71,18 @@ namespace ProjectEntryLaborAdjust
         }
     }
 
-    public sealed class L001LaborRule : LaborRuleBase
+    public sealed class L001LaborRule : LaborRuleBase    //Date exclusion only this code. drop this code, only one code in production
     {
         public L001LaborRule() : base("L001", "Auto-added Admin Labor")
         {
-            ExcludedBranchCDs.Add("303");
-            ExcludedBranchCDs.Add("112");
+            ExcludedBranchCDs.Add("301");
+            //ExcludedBranchCDs.Add("112");
             ExcludedBillRules.Add("PROGRESS");
-            ExcludedTemplateCDs.Add("ENVIRONMENTAL");
+            ExcludedTemplateCDs.Add("RENTAL");
+            // Exclude projects created before 8/24 of the current year
+            
+            ProjectDate = new DateTime(2025, 8, 24);
         }
-
         public override decimal? FixedUnitRate
         {
             get { return 40m; } // supply a fixed unit rate
@@ -83,23 +90,17 @@ namespace ProjectEntryLaborAdjust
 
         public override decimal GetHours(decimal jobSize)
         {
-            if (jobSize <= 1000m) return 0m;
-            if (jobSize <= 10000m) return 1m;
-
-            return 3m;
+            if (jobSize <= 616m) return 0m;   // $0–$616
+            if (jobSize <= 1000m) return 1m;   // $617–$1,000
+            if (jobSize <= 2500m) return 2m;   // $1,001–$2,500
+            if (jobSize <= 7500m) return 2.5m; // $2,501–$7,500
+            if (jobSize <= 10000m) return 3m;   // $7,501–$10,000
+            if (jobSize <= 25000m) return 4.5m; // $10,001–$25,000
+            if (jobSize <= 50000m) return 4m;   // $25,001–$50,000
+            return 4m;                           // $50,001+
         }
     }
 
 
 
-
-
-
-
-
-
-
-
-
-
 }

+ 8 - 7
ProjectEntryExt.cs

@@ -9,10 +9,6 @@ using PX.Objects.PM;
 
 namespace ProjectEntryLaborAdjust
 {
-  
-
-  
-
     // ===================== GRAPH EXTENSION (RULE-DRIVEN) =====================
     public class ProjectEntryExt : PXGraphExtension<ProjectEntry>
     {
@@ -33,8 +29,8 @@ namespace ProjectEntryLaborAdjust
 
             _rules.Clear();
             _rules.Add(new L023PmLaborRule());  // uses AR pricing (no fixed rate)
-            _rules.Add(new L014LaborRule()); // fixed rate example
-            _rules.Add(new L001LaborRule());
+           //_rules.Add(new L014LaborRule()); // fixed rate example
+           // _rules.Add(new L001LaborRule());
         }
 
         // -------------------- Event Handlers --------------------
@@ -65,6 +61,8 @@ namespace ProjectEntryLaborAdjust
             string branchCD = ResolveBranchCD(proj?.DefaultBranchID);
             string templateCD = ResolveTemplateCD(proj?.TemplateID);
             string billRule = ResolveBillRule(proj);
+            DateTime? projectCreatedDate = proj?.CreatedDateTime;
+
 
             PXContext.SetSlot<bool?>(SlotLaborUpdate, true);
             try
@@ -72,8 +70,11 @@ namespace ProjectEntryLaborAdjust
                 foreach (var rule in _rules)
                 {
                     // Per-rule exclusion check
-                    if (rule.IsExcludedFor(branchCD, templateCD, billRule))
+                    if(rule.IsExcludedFor(branchCD, templateCD, billRule, projectCreatedDate))
+                    {
                         continue;
+                    }
+                        
 
                     decimal hours = rule.GetHours(totalRevised);
                     UpsertLaborLine(rule, hours, row);