using PowderCoating.Core.Enums; namespace PowderCoating.Infrastructure.Services; /// /// Single source of truth for double-entry sign conventions shared by /// and . /// Centralised here so that adding a new AccountSubType only requires /// one edit rather than two independently maintained switch expressions. /// internal static class AccountingRules { /// /// Returns true for sub-types whose normal balance is a debit /// (Assets, COGS, Expenses). Sub-type is used rather than AccountType /// because it is constrained to a known enum set and cannot be /// misconfigured by a user. Expense enum values are ≥ 50 by convention, /// allowing a catch-all range match for any future expense sub-types. /// internal static bool IsNormalDebitBalance(AccountSubType subType) => subType switch { // Asset subtypes → normal debit balance AccountSubType.Cash or AccountSubType.Checking or AccountSubType.Savings or AccountSubType.AccountsReceivable or AccountSubType.Inventory or AccountSubType.FixedAsset or AccountSubType.OtherCurrentAsset or AccountSubType.OtherAsset => true, // COGS → normal debit balance AccountSubType.CostOfGoodsSold => true, // Expense subtypes (enum values ≥ 50) → normal debit balance var st when (int)st >= 50 => true, // Liability subtypes (AP, CreditCard, etc.), Equity, Revenue → normal credit balance _ => false }; }