Commit Graph

55 Commits

Author SHA1 Message Date
admin 04d1bdfb49 Post AR/AP sub-ledgers to the general ledger (fix empty P&L/Balance Sheet)
The P&L and Balance Sheet are GL-driven, but invoices/payments/bills never
posted to journal_entries (the referenced syncBillsInvoicesToLedger was never
built), so accounts with no GL activity showed $0 and were hidden.

Adds an idempotent GL posting engine (migration applied to prod), scoped to
companies whose GL is "managed" (no imported/foreign journal entries) to avoid
double-counting Bridgewater/Bent Oak:
- invoice  -> Dr Accounts Receivable / Cr income (keyword-mapped, default Assessment Fees)
- payment  -> Dr Undeposited Funds   / Cr Accounts Receivable
- bill     -> Dr expense (bill_items) / Cr Accounts Payable (+ paid leg to bank)
Auto-creates AR (1100) / AP (2000) where missing. AFTER triggers on
invoices/payments_received/bills keep the GL in sync; existing docs backfilled.
Verified debits=credits and the balance-sheet invariant holds.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 22:39:07 -04:00
admin 3c32f8ac47 Bidirectional bill sync between app and Accounting
Migration applied to prod: approved/paid public.bills mirror into
accounting.bills (Payables) with find-or-create vendor + line item
(external_source='acmacc_bill'/'acmacc_vendor'). When an accounting bill is
marked paid (paid_amount>=total), the linked public.bills is set status=paid
(+paid_date, amount_paid) and its bill_approvals marked paid. Loop-guarded
with is-distinct-from. Backfilled 370 bills/45 vendors; totals reconcile.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 21:41:51 -04:00
admin 2d216e24c9 Sync owner ledger + payments into Accounting
DB triggers on public.owner_ledger_entries (migration applied to prod):
charges (debit) -> accounting.invoices; payments (credit) ->
accounting.payments_received (deposited=false, Undeposited Funds). Customer
balance recomputed authoritatively from the source ledger; ledger payments
FIFO-applied to ledger invoices. Keyed external_source='acmacc_ledger'.
Backfilled 6,756 invoices + 4,253 payments; balances reconcile exactly.

Frontend: customer Ledger tab now renders real payments_received credits
(true dates/amounts); Make Deposit page surfaces undeposited payments_received
alongside Undeposited Funds transactions and deposits both.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 21:36:55 -04:00
admin c124397a97 Sync accounting Homeowners from Units & Owners per association
Adds DB triggers + backfill so accounting.customers is driven by the
public units/owners roster: one customer per unit, all owners combined,
Units/Owners as source of truth for contact fields. Balances and ledger
links (invoices, payments_received, transactions, work_orders, estimates)
are always preserved. Scoped to associations with an accounting company.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 20:57:01 -04:00
admin 183fe0a93c Add ACMCC app source, Supabase backend, and project config
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 20:19:26 -04:00