• DevPilot's avatar
    feat(accounting): posting chains + accrual reconciler · 1bc26cc1
    DevPilot authored
    Two gaps closed, both of which let real money go unrecorded.
    
    CHAINS — money moving between accounts across several entries
    
    The allocation wizard splits one amount inside one entry. It had no
    answer for the same money moving through a sequence of entries as
    separate actions happen: cash into a safe, settled to main, banked.
    Each hop must clear the account the previous one filled, and nothing
    enforced that.
    
    Concretely broken: every cash collection debited one global account
    regardless of which safe took it, then the settlement credited an
    unmapped `treasury:sub_cash` pointer that fell back to الصندوق بالدولار
    — an account no collection had ever touched. The sub-safes were also
    pointed at the USD/EUR cash boxes, so 972,791 EGP of pound takings sat
    in foreign-currency accounts.
    
    A chain step now declares where it leaves money and which earlier step
    it clears; the counter side is derived by re-resolving that step's rule
    against the same document, so a chain cannot be authored that fails to
    net to zero. Each safe owns a GL account, resolved through one service
    both the engine and the chain call. Guards refuse a hop whose two sides
    resolve to the same account, or whose type puts both on the same side.
    
    The historic misposting is corrected by a reviewable journal entry —
    not by rewriting posted history — and cannot be posted twice.
    
    ACCRUALS — obligations the ledger was never told about
    
    24 revenue streams were marked `needs_code`. 18 are now booked, finding
    1,316 claims worth 835,167 EGP that were nowhere in the accounts.
    
    Built as a scanner over the source tables rather than event dispatches
    in twelve modules: an event can be missed or misnamed — the coach
    payroll listener was bound to a name nothing dispatched — while a
    scanner is self-healing, retroactive and idempotent.
    
    Critically, collection here posts revenue directly, so accruing without
    releasing would double-count on every future payment. Each accrual is
    released when its document is paid, by mirroring the same rule.
    
    Outflows that had no entry at all are wired too: staff loans (an asset,
    not an expense), end of service, coach fees, goods receipt (against a
    new clearing account, so the invoice does not book inventory twice),
    depreciation per asset category, stock variances, asset disposal, and
    fine waivers.
    
    6 streams are deliberately left unbooked — no amount or no counterparty
    recorded, so any figure would be a guess. They are listed on screen
    with what each one needs.
    
    Verified against a scratch copy of production: trial balance nets to
    0.00, no unbalanced entries, no postings to header accounts, every pass
    idempotent.
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    1bc26cc1
Name
Last commit
Last update
..
data Loading commit data...
Phase_02_001_seed_default_roles.php Loading commit data...
Phase_02_002_seed_super_admin.php Loading commit data...
Phase_03_001_seed_branches.php Loading commit data...
Phase_03_002_seed_governorates.php Loading commit data...
Phase_03_003_seed_countries.php Loading commit data...
Phase_03_004_seed_qualifications.php Loading commit data...
Phase_05_001_import_departments_and_titles.php Loading commit data...
Phase_05_001_seed_all_business_rules.php Loading commit data...
Phase_05_002_import_employees_from_registry.php Loading commit data...
Phase_05_002_seed_pricing_configs.php Loading commit data...
Phase_05_003_seed_performance_criteria.php Loading commit data...
Phase_05_003_seed_service_catalog.php Loading commit data...
Phase_05_004_import_work_schedules.php Loading commit data...
Phase_05_005_seed_shift_definitions.php Loading commit data...
Phase_06_001_seed_field_types.php Loading commit data...
Phase_06_002_seed_form_schemas.php Loading commit data...
Phase_07_001_seed_workflow_definitions.php Loading commit data...
Phase_100_001_seed_board_offer_tiers.php Loading commit data...
Phase_100_001_seed_revenue_posting_engine.php Loading commit data...
Phase_100_002_grant_revenue_mapping_permissions.php Loading commit data...
Phase_100_002_seed_sheraton_offers_2026.php Loading commit data...
Phase_101_001_provision_employee_accounts.php Loading commit data...
Phase_101_001_seed_full_cycle_accounts.php Loading commit data...
Phase_101_002_seed_full_cycle_streams.php Loading commit data...
Phase_102_001_rebuild_balance_caches.php Loading commit data...
Phase_102_002_seed_payroll_deduction_pointers.php Loading commit data...
Phase_102_003_seed_cron_disabled_flag.php Loading commit data...
Phase_103_001_seed_unconnected_streams.php Loading commit data...
Phase_103_002_seed_club_funds.php Loading commit data...
Phase_104_001_seed_billing_sources.php Loading commit data...
Phase_104_002_grant_billing_permissions.php Loading commit data...
Phase_104_003_seed_instrument_accounts.php Loading commit data...
Phase_104_004_install_billing_sources.php Loading commit data...
Phase_105_001_fix_role_access_gaps.php Loading commit data...
Phase_105_001_seed_voucher_types.php Loading commit data...
Phase_105_002_grant_voucher_permissions.php Loading commit data...
Phase_108_001_seed_posting_chains.php Loading commit data...
Phase_108_002_seed_chain_permissions.php Loading commit data...
Phase_109_001_seed_accrual_rules.php Loading commit data...
Phase_109_002_seed_operational_rules.php Loading commit data...
Phase_11_001_seed_payment_methods.php Loading commit data...
Phase_15_001_seed_sms_templates.php Loading commit data...
Phase_15_002_seed_report_definitions.php Loading commit data...
Phase_16_001_seed_branding_config.php Loading commit data...
Phase_17_001_seed_sport_disciplines.php Loading commit data...
Phase_17_002_seed_facilities.php Loading commit data...
Phase_17_003_seed_sports_business_rules.php Loading commit data...
Phase_17_004_seed_sports_service_catalog.php Loading commit data...
Phase_18_001_seed_academies_and_levels.php Loading commit data...
Phase_19_001_seed_player_form_schemas.php Loading commit data...
Phase_19_002_seed_sports_report_definitions.php Loading commit data...
Phase_19_003_seed_sports_sms_templates.php Loading commit data...
Phase_22_001_seed_activity_pricing.php Loading commit data...
Phase_25_001_seed_inventory_categories.php Loading commit data...
Phase_25_002_seed_inventory_business_rules.php Loading commit data...
Phase_25_003_seed_default_warehouses.php Loading commit data...
Phase_28_001_seed_hr_workflow_definitions.php Loading commit data...
Phase_28_002_seed_hr_leave_types.php Loading commit data...
Phase_28_003_seed_hr_system_config.php Loading commit data...
Phase_28_004_seed_hr_salary_structure.php Loading commit data...
Phase_28_005_seed_hr_holidays.php Loading commit data...
Phase_28_006_seed_hr_work_schedules.php Loading commit data...
Phase_28_007_seed_hr_sms_templates.php Loading commit data...
Phase_33_001_seed_chart_of_accounts.php Loading commit data...
Phase_33_020_seed_journal_types.php Loading commit data...
Phase_34_001_seed_procurement_workflow_definitions.php Loading commit data...
Phase_34_002_seed_procurement_config.php Loading commit data...
Phase_36_001_seed_expanded_chart_of_accounts.php Loading commit data...
Phase_36_002_seed_fiscal_year.php Loading commit data...
Phase_36_003_seed_sync_gl_from_existing_data.php Loading commit data...
Phase_38_001_seed_cashier_permissions.php Loading commit data...
Phase_39_001_seed_form_session_rules.php Loading commit data...
Phase_39_001_seed_support_permissions.php Loading commit data...
Phase_40_001_seed_master_document_compliance.php Loading commit data...
Phase_41_001_seed_unification_rules.php Loading commit data...
Phase_41_002_seed_complete_service_catalog.php Loading commit data...
Phase_42_001_seed_egyptian_chart_of_accounts.php Loading commit data...
Phase_43_001_seed_full_chart_of_accounts.php Loading commit data...
Phase_44_001_seed_trial_balance_2024_2025.php Loading commit data...
Phase_45_001_seed_complete_accounting_data.php Loading commit data...
Phase_46_001_seed_subscription_rates_and_prices.php Loading commit data...
Phase_50_001_seed_alert_rules.php Loading commit data...
Phase_52_001_seed_facility_pricing_rules.php Loading commit data...
Phase_56_001_seed_movement_types.php Loading commit data...
Phase_63_012_seed_notification_triggers.php Loading commit data...
Phase_64_001_seed_seasonal_pricing_rules.php Loading commit data...
Phase_70_001_seed_swimming_pool.php Loading commit data...
Phase_70_002_seed_pool_grid_zones.php Loading commit data...
Phase_70_003_seed_full_sports_activity.php Loading commit data...
Phase_71_001_seed_expanded_roles.php Loading commit data...
Phase_71_002_seed_permission_dependencies.php Loading commit data...
Phase_72_001_seed_treasuries.php Loading commit data...
Phase_72_002_seed_treasury_permissions.php Loading commit data...
Phase_73_001_seed_locker_and_referral_permissions.php Loading commit data...
Phase_75_001_seed_updated_roles.php Loading commit data...
Phase_80_001_seed_all_academy_pricing.php Loading commit data...
Phase_80_002_seed_additional_disciplines.php Loading commit data...
Phase_86_001_populate_program_pricing_from_groups.php Loading commit data...
Phase_88_001_seed_tournament_bot_players.php Loading commit data...
Phase_95_001_seed_rental_vat_rule.php Loading commit data...
Phase_96_001_seed_rental_bank_rate_rule.php Loading commit data...
Phase_96_002_seed_pool_lane_pricing.php Loading commit data...
Phase_96_003_seed_swimming_academy_programs.php Loading commit data...
Phase_96_004_seed_swimming_teams_programs.php Loading commit data...
Phase_99_003_seed_regulatory_discounts.php Loading commit data...