Commit Graph

66 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 57a9a1022e Remove cover sheet from financial reports; nest Budget vs Actuals accounts
- Drop the branded cover page from all financial/accounting report exports
  (P&L, Balance Sheet, Cash Flow, Movement of Equity, AR/AP flats, Trial
  Balance, General Ledger, Budget vs Actuals, and the Zoho/Board financial
  reports). The general Report Generator's own cover is unchanged.
- Budget vs Actuals now orders accounts as a parent→child tree with
  indentation (on screen and in CSV/PDF) instead of flat by account number.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 22:26:05 -04:00
admin 39829b7e1b Accounting statement matches main account-statement; fix payments cut off
- Homeowner "Export/Email Statement" now uses the same generateLedgerStatement
  layout as the main-app account statement (account holder, amounts-due
  breakdown, categorized columns incl. Pay (AR), no cover page) instead of the
  branded-cover table.
- Ledger view: default the "To" date to the latest entry when it's beyond
  today, so a payment dated when an invoice was marked paid (updated_at) is no
  longer filtered out of the rows / Total Paid.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 22:17:04 -04:00
admin 0e34d18adf Accounting homeowner ledger/statement defaults to full history
The customer Ledger tab + statement defaulted to the current calendar year,
so older payments looked missing and didn't line up with the main-app owner
ledger (all-time). Default the "From" date to the earliest transaction
(user can still narrow), so the accounting ledger/statement matches the
main owner ledger.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 22:06:06 -04:00
admin b77860772e Fix report exports: Budget vs Actuals + branded cover everywhere
- Budget vs Actuals now exports (CSV + branded PDF); previously the page's
  export buttons were disabled for it. Wired into hasOwnExport with its own
  buttons in the report.
- Apply the shared branded cover page to the remaining PDF exports so they
  match the main scheme: homeowner account Statement (AccountingCustomer
  DetailPage), Trial Balance, and General Ledger.

Note: payments already render on the accounting customer ledger/statement
via payments_received (phase 3+4).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 22:00:57 -04:00
admin 8360363a15 Unify financial report styling with branded cover page
Extract the general Report Generator's branded cover (cover image/band,
logo, title, prepared-for/by) into shared src/lib/reportCover.ts. Financial
reports now open with the same cover: platform AccountingReportsPage via new
renderReportPdfWithCover(), and the Zoho/Board financial reports
(zohoFinancialReportPdf generators). ReportGeneratorPage refactored to use
the shared module (removes duplicated cover code).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 21:49:34 -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 8ac0edfbd9 Admin-only Accounting tab + platform COA consolidation
Phase 1: gate the Accounting sidebar item and /dashboard/accounting route
behind isAdmin via a RequireAdmin guard; Financial Reports stay visible.

Phase 2: platform associations now read the Chart of Accounts from
accounting.accounts (single source) instead of public.chart_of_accounts.
Shared fetchChartOfAccounts() normalizes both sources; central COA hooks
and ChartOfAccountsDropdown route through it (reads only, no migration).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 21:21:48 -04:00
admin 64aad1d283 Reassign payments_received when merging homeowners
mergeHomeownersByAddress reassigned invoices/transactions/work_orders/
estimates but missed payments_received, orphaning payment references on
the deleted duplicate. Add it to the FK reassignment list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 21:00:25 -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 b67587a2b7 Update environment variables for Supabase and Plaid 2026-06-01 20:29:13 -04:00
admin 73561fb796 Add .env file from example 2026-06-01 20:28:31 -04:00
admin 07ab8b9713 Add .env.example template
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 20:27:50 -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
admin 313b51b412 first commit 2026-06-01 20:10:57 -04:00