| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using System.Collections.Generic;
- namespace ProjectEntryLaborAdjust
- {
- public abstract class LaborRuleBase
- {
- public string InventoryCD { get; }
- public string Description { get; protected set; }
- public HashSet<string> ExcludedBranchCDs { get; }
- 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>
- public virtual decimal? FixedUnitRate
- {
- get { return null; }
- }
- protected LaborRuleBase(string inventoryCD, string description = null)
- {
- if (string.IsNullOrWhiteSpace(inventoryCD))
- throw new ArgumentException("inventoryCD");
- InventoryCD = inventoryCD.Trim();
- Description = string.IsNullOrWhiteSpace(description)
- ? "Auto-added Labor (" + InventoryCD + ")"
- : description.Trim();
- ExcludedBranchCDs = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
- ExcludedTemplateCDs = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
- ExcludedBillRules = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
- }
- /// <summary>Compute the quantity (hours) for this labor item from the job size.</summary>
- public abstract decimal GetHours(decimal jobSize, DateTime? projectCreatedDate);
- /// <summary>Check if this rule should be skipped under the provided context.</summary>
- 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;
- return false;
- }
- }
- }
|