• Mahmoud Aglan's avatar
    feat(accounting): configurable revenue posting engine (account determination) · bb3e8ccd
    Mahmoud Aglan authored
    Replaces the hardcoded AccountCodes::creditAccountForPaymentType() match
    statement with a versioned, effective-dated mapping that finance controls
    from /accounting/revenue-mapping.
    
    Every collected amount can now be split across multiple GL accounts by flat
    amount, percentage, or remainder, with VAT handled as its own layer and
    deferred revenue amortised over the service period.
    
    What the live DB showed, and this addresses:
    - 4,256,399.96 EGP across 129 transactions posted to a single catch-all
      account (410515 إيرادات متنوعه) — waiver, separation, death, foreign
      membership, early settlement and four payment types that had no rule in
      the code at all and silently fell through to `default`.
    - 240,582 EGP of divorce fees posted to 410302 «محل 1», a shop rental account.
    - 120301 العملاء and 230804 جاري مصلحة الضرائب are header accounts, and
      JournalService rejects posting to headers — so every AR and VAT entry has
      been failing silently. accounts_receivable holds 0 rows against 970,592.67
      EGP of unpaid instalments.
    
    Model follows SAP account determination / Dynamics posting profiles, adapted
    to Egyptian VAT law 67/2016 and EAS 48 revenue recognition:
    
    - revenue_streams              catalogue of every chargeable thing
    - revenue_tax_profiles         rate + inclusive/exclusive + treatment
    - revenue_posting_rules        versioned, effective-dated, scopeable
    - revenue_posting_rule_lines   the split components
    - revenue_posting_log          which rule version produced which entry
    - revenue_recognition_schedules deferred revenue amortisation
    
    Allocation order is fixed and deterministic: tax extraction, then fixed
    amounts, then percentages, then a mandatory remainder line that absorbs
    rounding residue so the entry always balances.
    
    Tax is a separate layer rather than a split because inclusive and exclusive
    pricing are not the same number: 14% of a tax-inclusive 1140 is 140 on
    revenue of 1000, not 159.60. Deferral is separate for the same reason — it
    is a split across periods, not accounts.
    
    Adds two postable accounts the chart was missing: 120301004 أعضاء النادي
    (مدينون) and 12041106 ضريبة القيمة المضافة — مدخلات.
    
    Seeded rules reproduce current posting behaviour exactly, so this deploy
    moves no reported number. Streams landing in a catch-all are flagged for
    review rather than silently re-pointed — repointing them moves real revenue
    between accounts and is finance's decision.
    
    Unconfigured streams fall through to the legacy path unchanged.
    Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    bb3e8ccd
Name
Last commit
Last update
..
Academies Loading commit data...
AcademyContracts Loading commit data...
AccessMatrix Loading commit data...
Accounting Loading commit data...
Achievements Loading commit data...
ActivitySubscriptions Loading commit data...
Alerts Loading commit data...
Archive Loading commit data...
Audit Loading commit data...
Auth Loading commit data...
Branches Loading commit data...
Carnets Loading commit data...
Cashier Loading commit data...
Children Loading commit data...
Coaches Loading commit data...
Dashboard Loading commit data...
Death Loading commit data...
Disciplines Loading commit data...
Divorce Loading commit data...
Documents Loading commit data...
Facilities Loading commit data...
FacilityDashboards Loading commit data...
FacilityGrids Loading commit data...
Fines Loading commit data...
Foreign Loading commit data...
Forms Loading commit data...
HR Loading commit data...
Honorary Loading commit data...
Installments Loading commit data...
Interviews Loading commit data...
Inventory Loading commit data...
MatchCenter Loading commit data...
MedicalBoard Loading commit data...
Members Loading commit data...
News Loading commit data...
Notifications Loading commit data...
ParentPortal Loading commit data...
Payments Loading commit data...
PlayerAffairs Loading commit data...
PlayerApi Loading commit data...
PlayerAuth Loading commit data...
PlaygroundAdmin Loading commit data...
PoolManagement Loading commit data...
Pricing Loading commit data...
Procurement Loading commit data...
Receipts Loading commit data...
Rentals Loading commit data...
Reports Loading commit data...
Reservations Loading commit data...
Roles Loading commit data...
Rules Loading commit data...
Sales Loading commit data...
Scheduling Loading commit data...
Seasonal Loading commit data...
ServiceCatalog Loading commit data...
Sessions Loading commit data...
Settings Loading commit data...
Sports Loading commit data...
SportsActivity Loading commit data...
SportsDashboard Loading commit data...
Spouses Loading commit data...
Subscriptions Loading commit data...
Support Loading commit data...
Temporary Loading commit data...
Tournaments Loading commit data...
TrainerPortal Loading commit data...
Training Loading commit data...
TrainingGroups Loading commit data...
Transfers Loading commit data...
Treasury Loading commit data...
Tutorials Loading commit data...
Users Loading commit data...
Waiver Loading commit data...
Workflow Loading commit data...