Last Updated: 2025-11-26
Related Documentation: FA-01 through FA-09 specifications
Overview
This document provides a comprehensive reference for all frontend hooks, components, and utilities in the Finance & Accounting (FA) module. All FA APIs follow Constitutional guidelines for import paths, RLS enforcement, and integration patterns.Table of Contents
Hooks
Chart of Accounts & Funds (FA-01)
useAccounts
Fetch chart of accounts with filtering and search.
accounts: FAAccount[]- Array of account recordsisLoading: boolean- Loading stateerror: Error | null- Error object if query failed
has_org_access(auth.uid(), organization_id)
useAccountDetail
Fetch single account with balances (when FA-02 implemented).
account: FAAccount- Account recordbalances: { debit: number; credit: number; balance: number }- Account balancesisLoading: boolean
useFunds
Fetch list of funds.
funds: FAFund[]- Array of fund recordsisLoading: boolean
useDepartments
Fetch department hierarchy.
departments: FADepartment[]- Array of department records with parent-child relationshipsisLoading: boolean
usePrograms
Fetch program list.
programs: FAProgram[]- Array of program recordsisLoading: boolean
useFiscalPeriods
Fetch fiscal periods for a year.
periods: FAFiscalPeriod[]- Array of fiscal periodscurrentPeriod: FAFiscalPeriod | null- Current open periodisLoading: boolean
useAccountMutation
Create, update, delete accounts.
fa_is_finance_admin(auth.uid(), organization_id)
General Ledger (FA-02)
useJournalEntries
Fetch journal entries with filtering.
useTrialBalance
Fetch trial balance for a period.
trialBalance: TrialBalanceRow[]- Array of account balancestotals: { totalDebits: number; totalCredits: number }- Trial balance totalsisLoading: boolean
useJournalEntryMutation
Create, post, void journal entries.
Accounts Payable (FA-04)
useVendors
Fetch vendor list.
useVendorBills
Fetch vendor bills.
usePayments
Fetch payments.
useVendorBillMutation
Create, approve, pay vendor bills.
Accounts Receivable (FA-06)
useCustomers
Fetch customer list.
useInvoices
Fetch invoices.
useCustomerPayments
Fetch customer payments.
Financial Reporting (FA-07)
useReportDefinitions
Fetch saved report definitions.
useReportExecution
Execute financial report.
useReportSchedules
Fetch scheduled reports.
Budgeting (FA-08)
useBudgets
Fetch budgets.
useBudgetVsActual
Fetch budget vs actual comparison.
data: BudgetVsActualRow[]- Array of budget vs actual comparisonsisLoading: boolean
useBudgetAlerts
Fetch budget alerts for exceeded thresholds.
Multi-Entity Consolidation (FA-09)
useEntities
Fetch legal entities.
useEntityHierarchy
Fetch entity hierarchy with ownership percentages.
hierarchy: EntityNode[]- Tree structure of entities with childrenisLoading: boolean
useIntercompanyBalances
Fetch inter-company balances for reconciliation.
balances: IntercompanyBalance[]- Array of inter-company transactionsisBalanced: boolean- True if all inter-company accounts net to zeroisLoading: boolean
useRunConsolidation
Execute consolidation process.
Module Settings (FA-10)
useFAModuleSettings
Fetch and update FA module settings.
Components
Account Selector
Select from chart of accounts with filtering.Fund Selector
Select from available funds.Department Selector
Select from department hierarchy.Journal Entry Form
Create and edit journal entries.Trial Balance Report
Display trial balance with drill-down.Utilities
Account Number Formatting
Balance Calculation
Fiscal Period Helpers
Types
Core Types
Edge Functions
execute-report
Execute financial report and return data.
Endpoint: supabase/functions/execute-report/index.ts
Request:
consolidate-entities
Run multi-entity consolidation.
Endpoint: supabase/functions/consolidate-entities/index.ts
Request:
check-budget-alerts
Scheduled function to check budget thresholds.
Endpoint: supabase/functions/check-budget-alerts/index.ts
Trigger: Cron (daily at 8 AM)
Behavior:
- Queries
fa_budget_vs_actual_view - Compares variance to module settings thresholds
- Creates
fa_budget_alertsrecords - Publishes
budget_exceededevents - Sends notifications via PF-10
Error Handling
All FA hooks use consistent error handling:RLS Reference
All FA tables enforce RLS with these common patterns: View Access:has_org_access(user_id, org_id)- User belongs to organizationfa_is_finance_admin(user_id, org_id)- User has org_admin or platform_admin role
Import Paths
CORRECT:Version History
- v1.0.0 (2025-11-26): Initial API reference for FA-01 through FA-10