Files
acmcc/src/pages/accounting/lib/useCompanyId.ts
T
admin e302fb91f0 Accounting platform: remove Zoho, unify reports, board access, vendor sharing
- Remove the Zoho Books integration (edge functions, sync libs, settings,
  reports/overview, banking links, fees tab, import dialog); preserve fee
  rules as a standalone FeesTab and the COA accounting_system classification.
- Financial Overview/Reports (staff + board) render the Accounting dashboard
  and reports; board reports mirror the rich Accounting Reports.
- New Reserve Fund Schedule report + an is_reserve flag on accounts.
- Unify all report exports to a branded format (logo + centered header +
  footer): shared ReportSheet (on-screen) and reportHeader (PDF). Budget vs
  Actuals and Bank Reconciliation PDFs now match the reference layout.
- Render financial reports inline (no preview pop-up).
- Budget Management mirrors Accounting Budgeting (staff-accessible) with SPA
  navigation; editable bills in the Accounting Bills page.
- Negative opening balances flow through to the GL and reports (allow negative
  input; keep non-zero on save; signed CSV import).
- Upload a per-account trial balance via CSV on Opening Balances.
- Board members: read-only RLS access to their association's accounting ledger;
  editable board-members panel on the association page; share vendor contacts
  with the board (toggle + directory section).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 18:29:31 -04:00

32 lines
1.2 KiB
TypeScript

import { useAssociation } from "@/contexts/AssociationContext";
import { useAccountingCompany } from "@/hooks/useAccountingCompany";
/**
* The accounting module's single source for the current company scope.
*
* In the original standalone app this came from `useCompany().current.id`
* (a per-user company picker). In avria, accounting is multi-tenant by HOA
* association: the selected association resolves (and auto-provisions) an
* `accounting.companies` row, whose id scopes every accounting query.
*
* Every ported accounting page uses this instead of the old `useCompany`.
*/
export function useCompanyId(override?: { id: string; name?: string } | null) {
const { selectedAssociation } = useAssociation() as {
selectedAssociation: { id: string; name?: string } | null;
};
// When an explicit association is supplied (e.g. the Financial Overview /
// Reports wrappers, or a board scope), it takes precedence over the global
// association picker.
const active = override ?? selectedAssociation;
const associationId = active?.id ?? null;
const { companyId, loading, error } = useAccountingCompany(associationId);
return {
associationId,
associationName: active?.name ?? null,
companyId,
loading,
error,
};
}