Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt

Use this file to discover all available pages before exploring further.

Version: 1.0.0 Status: πŸ“ Planned Created: 2026-03-21 Last Updated: 2026-03-21 Constitution Reference: Section 1.3 (Integration Patterns β€” Pattern 1: Platform Integration Layer, Pattern 2: Event-Based, Pattern 3: API Contracts)

Overview

This document defines the comprehensive integration contract between the FA (Fund Accounting) core and the FW (Forms & Workflow) core. FA uses FW extensively for financial approval workflows, expense forms, purchase order routing, budget approvals, and amount-based decision table routing. Related Specifications:
  • FA-02: Vendor Bills & Journal Entries
  • FA-03: Payments
  • FA-04: Purchase Orders & Procurement
  • FA-08: Budgeting
  • FA-12: Expense Management
  • FA-19: Period Close
  • FA-22: Accounts Payable Automation
  • FA-UX-05: Purchase Order Creation Wizard
  • FA-UX-07: Expense Report Wizard
FW Features Consumed:
  • FW-01/FW-05: Forms (expense reports, purchase requisitions)
  • FW-03: Automation Engine (AP automation, payment processing triggers)
  • FW-15: Form Field Lookups (vendors, GL accounts, funds, cost centers)
  • FW-16: Event-Based Workflow Triggers
  • FW-34: Approval Workflows (multi-level financial approvals)
  • FW-45: Decision Tables (amount-based approval routing)
Existing Integration: FA-UX-05 / FW-03 Integration β€” PO-specific approval contract (this document supersedes it as the comprehensive guide). Cross-cutting guide: See FW Cross-Core Integration Guide for shared patterns, platform layer imports, and testing requirements.

Integration Pattern

Primary Pattern: Pattern 1 β€” Platform Integration Layer Secondary Pattern: Pattern 2 β€” Event-Based Integration Tertiary Pattern: Pattern 3 β€” API Contracts (for PO approval submission) FA accesses FW capabilities through:
  • @/platform/forms β€” expense report and purchase requisition forms
  • @/platform/approvals β€” financial approval chain submission
  • @/platform/events β€” publishing FA events for FW automation triggers
  • @/platform/data-lookup β€” vendor, GL account, fund lookups in forms
  • @/platform/calendar β€” business day calculations for payment deadlines

Event Contracts (FA β†’ FW)

Events published by FA that trigger FW automations and workflows.

FA-12: Expense Management Events

Event: fa_expense_report_submitted

Event: fa_expense_report_submitted Channel: fa_events Publisher: FA (FA-12 Expense Management) Subscribers: FW-34 (approval workflow), PF-10 (notification) Status: βœ… Implemented (registered in KnownEventName)
Purpose
Triggers expense report approval workflow when an employee submits an expense report.
Payload Schema
interface FaExpenseReportSubmittedPayload {
  organization_id: string;
  expense_report_id: string;    // UUID - fa_expense_reports.id
  employee_id: string;          // UUID - submitter
  department_id: string;        // UUID - pf_departments.id
  total_amount: number;         // Total expense amount
  currency: string;             // ISO currency code
  line_count: number;           // Number of expense lines
  fund_id?: string;             // UUID - fa_funds.id
  project_id?: string;          // UUID - fa_projects.id
  timestamp: string;
}
Consumer Actions
ConsumerActionStatus
FW-45 Decision TableDetermine approval chain based on amountπŸ“
FW-34 ApprovalRoute to amount-tiered approval chainπŸ“
PF-10 NotificationNotify next approverπŸ“

Event: fa_expense_report_approved

Event: fa_expense_report_approved Channel: fa_events Publisher: FA (FA-12 Expense Management) Subscribers: FW-03 (reimbursement automation), PF-10 (notification) Status: βœ… Implemented (registered in KnownEventName)
Purpose
Triggers reimbursement processing when an expense report is fully approved.
Payload Schema
interface FaExpenseReportApprovedPayload {
  organization_id: string;
  expense_report_id: string;
  employee_id: string;
  total_amount: number;
  approved_by: string;          // UUID - final approver
  timestamp: string;
}

FA-04: Purchase Order Events

Event: fa_purchase_order_created

Event: fa_purchase_order_created Channel: fa_events Publisher: FA (FA-04 / FA-UX-05) Subscribers: FW-34 (PO approval workflow) Status: πŸ“ Planned (see FA-UX-05-FW-03-INTEGRATION.md for detailed API contract)
Purpose
Triggers PO approval workflow when a purchase order is created via the PO wizard.
Payload Schema
interface FaPurchaseOrderCreatedPayload {
  organization_id: string;
  purchase_order_id: string;    // UUID - fa_purchase_orders.id
  po_number: string;
  vendor_id: string;            // UUID - fa_vendors.id
  total_amount: number;
  department_id: string;
  fund_id?: string;
  project_id?: string;
  submitted_by: string;         // UUID
  timestamp: string;
}
Consumer Actions
ConsumerActionStatus
FW-45 Decision TableDetermine PO approval levels based on amountπŸ“
FW-34 ApprovalRoute through amount-tiered approval chainπŸ“
PF-10 NotificationNotify purchasing manager, next approverπŸ“

FA-02: Vendor Bill & Journal Entry Events

Event: fa_vendor_bill_received

Event: fa_vendor_bill_received Channel: fa_events Publisher: FA (FA-02 / FA-22) Subscribers: FW-34 (bill approval workflow), FW-03 (AP automation) Status: πŸ“ Planned
Purpose
Triggers bill approval workflow when a vendor bill is received (manually entered or auto-scanned via FA-22).
Payload Schema
interface FaVendorBillReceivedPayload {
  organization_id: string;
  bill_id: string;              // UUID - fa_vendor_bills.id
  vendor_id: string;
  total_amount: number;
  due_date: string;             // ISO date
  fund_id?: string;
  is_auto_scanned: boolean;     // True if captured via FA-22 AP automation
  timestamp: string;
}

Event: fa_journal_entry_pending

Event: fa_journal_entry_pending Channel: fa_events Publisher: FA (FA-02 Journal Entries) Subscribers: FW-34 (JE approval workflow) Status: πŸ“ Planned
Purpose
Triggers journal entry approval when a JE is submitted for review.
Payload Schema
interface FaJournalEntryPendingPayload {
  organization_id: string;
  journal_entry_id: string;     // UUID - fa_journal_entries.id
  entry_type: string;           // 'standard' | 'adjusting' | 'closing' | 'reversing'
  total_debits: number;
  total_credits: number;
  fund_id?: string;
  prepared_by: string;          // UUID
  timestamp: string;
}

FA-08: Budget Events

Event: fa_budget_approved

Event: fa_budget_approved Channel: fa_events Publisher: FA (FA-08 Budgeting) Subscribers: FW-03 (budget activation automation), PF-10 (notification) Status: βœ… Implemented (registered in KnownEventName)
Purpose
Triggers budget activation when a budget is approved through the approval chain.
Payload Schema
interface FaBudgetApprovedPayload {
  organization_id: string;
  budget_id: string;
  fiscal_year: number;
  budget_type: string;          // 'operating' | 'capital' | 'project'
  total_amount: number;
  department_id?: string;
  fund_id?: string;
  approved_by: string;
  timestamp: string;
}

FA-22: AP Automation Events

Event: fa_bill_scan_completed

Event: fa_bill_scan_completed Channel: fa_events Publisher: FA (FA-22 AP Automation) Subscribers: FW-03 (auto-matching workflow) Status: πŸ“ Planned (referenced in EVENT_CONTRACTS.md)
Payload Schema
interface FaBillScanCompletedPayload {
  organization_id: string;
  scan_id: string;
  bill_id: string;
  vendor_id?: string;           // Auto-detected vendor
  total_amount?: number;        // OCR-extracted amount
  confidence_score: number;     // 0-1 extraction confidence
  timestamp: string;
}

Event: fa_bill_duplicate_flagged

Event: fa_bill_duplicate_flagged Channel: fa_events Publisher: FA (FA-22 AP Automation) Subscribers: FW-03 (duplicate review workflow) Status: πŸ“ Planned (referenced in EVENT_CONTRACTS.md)
Payload Schema
interface FaBillDuplicateFlaggedPayload {
  organization_id: string;
  bill_id: string;
  duplicate_bill_id: string;    // UUID - potential duplicate
  similarity_score: number;     // 0-1 similarity confidence
  timestamp: string;
}

FA-19: Period Close Events

Event: fa_close_period_started

Event: fa_close_period_started Channel: fa_events Publisher: FA (FA-19 Period Close) Subscribers: FW-03 (close checklist automation) Status: βœ… Implemented (registered in KnownEventName)
Payload Schema
interface FaClosePeriodStartedPayload {
  organization_id: string;
  close_period_id: string;
  fiscal_period: string;        // e.g., '2026-03'
  fiscal_year: number;
  timestamp: string;
}

Approval Chain Configurations

Expense Report Approval

Chain ID: fa-expense-report-approval Entity Type: fa_expense_reports Based On: FA-12, FA-UX-07
StepApprover TypeConditionTimeoutEscalation
1submitter_managerAlways48hdepartment_head
2role: finance_managerAmount > $50048hrole: finance_director
3role: finance_directorAmount > $5,00072hrole: cfo
4role: cfoAmount > $25,00072hβ€”

Purchase Order Approval

Chain ID: fa-purchase-order-approval Entity Type: fa_purchase_orders Based On: FA-04, FA-UX-05
StepApprover TypeConditionTimeoutEscalation
1submitter_managerAlways48hdepartment_head
2role: purchasing_managerAmount > $1,00048hrole: finance_director
3role: finance_directorAmount > $10,00072hrole: cfo
4role: cfoAmount > $50,00072hβ€”
See FA-UX-05-FW-03-INTEGRATION.md for the detailed PO approval API contract.

Journal Entry Approval

Chain ID: fa-journal-entry-approval Entity Type: fa_journal_entries Based On: FA-02
StepApprover TypeConditionTimeoutEscalation
1role: gl_reviewerAlways48hrole: controller
2role: controllerAmount > $10,000 OR adjusting/closing entry72hrole: cfo

Budget Approval

Chain ID: fa-budget-approval Entity Type: fa_budgets Based On: FA-08
StepApprover TypeConditionTimeoutEscalation
1department_headAlways5 business daysrole: finance_director
2role: finance_directorAlways5 business daysrole: cfo
3role: cfoBudget > $100K5 business daysβ€”
4role: board_treasurerCapital budget OR > $500K10 business daysβ€”

Vendor Bill Approval

Chain ID: fa-vendor-bill-approval Entity Type: fa_vendor_bills Based On: FA-02
StepApprover TypeConditionTimeoutEscalation
1role: ap_clerkAlways (3-way match verification)48hrole: ap_manager
2role: ap_managerAmount > $5,00048hrole: controller
3role: controllerAmount > $25,00072hrole: cfo

Decision Tables

Expense Approval Routing

Table ID: fa-expense-approval-routing Hit Policy: FIRST (first matching rule wins)
AmountCategoryDepartment→ Approval Chain
< $500AnyAnymanager_only
500–500 – 5,000AnyAnymanager_finance
5,000–5,000 – 25,000AnyAnymanager_finance_director
> $25,000AnyAnymanager_finance_cfo
AnytravelAnymanager_finance (always requires finance)
AnyequipmentAnymanager_finance_it (includes IT review)

PO Approval Levels

Table ID: fa-po-approval-levels Hit Policy: FIRST
AmountVendor Type→ Required Approvals
< $1,000AnyManager only
1,000–1,000 – 10,000AnyManager β†’ Purchasing
10,000–10,000 – 50,000AnyManager β†’ Purchasing β†’ Finance Director
> $50,000AnyManager β†’ Purchasing β†’ Finance Director β†’ CFO
Anysole_source+1 additional approval level
Anynew_vendor+Vendor verification step

Budget Exception Routing

Table ID: fa-budget-exception-routing Hit Policy: FIRST
Variance %Budget Category→ Action
< 5%AnyAuto-approve, log only
5-10%OperatingManager β†’ Finance notification
5-10%CapitalManager β†’ Finance β†’ Director
> 10%AnyManager β†’ Finance Director β†’ CFO β†’ Board notification

Form Templates

FA uses these FW form templates:
Template IDTypeSpec LocationDescription
fa-expense-report-formFormspecs/fw/templates/forms/fa-expense-report-form.mdExpense report with line items
fa-purchase-requisition-formFormspecs/fw/templates/forms/fa-purchase-requisition-form.mdPurchase request data capture
fa-expense-report-bundleBundlespecs/fw/templates/bundles/fa-expense-report-bundle.mdForm + approval workflow
fa-purchase-requisition-bundleBundlespecs/fw/templates/bundles/fa-purchase-requisition-bundle.mdForm + PO approval workflow

Planned Form Templates

Template IDPriorityDescription
fa-vendor-setup-formP2New vendor onboarding form
fa-budget-request-formP2Budget amendment/exception request
fa-payment-request-formP2Manual payment request form

Workflow Templates

Template IDSpec LocationDescription
fa-expense-approvalspecs/fw/templates/workflows/fa-expense-approval.mdAmount-tiered expense approval
fa-purchase-order-approvalspecs/fw/templates/workflows/fa-purchase-order-approval.mdPO approval through procurement chain
Template IDPriorityDescription
fa-budget-approvalP1Multi-level budget approval with board escalation
fa-journal-entry-approvalP1Preparer β†’ Reviewer β†’ Controller JE approval
fa-month-end-closeP1Period close checklist with task assignment and deadline tracking
fa-vendor-bill-approvalP23-way match verification + amount-based approval
fa-payment-authorizationP2Payment batch approval with dual authorization

Form Field Lookups

FA exposes these data sources for FW form field lookups (FW-15):
Lookup SourceTableValue ColumnLabel ColumnFilterUsed By
Vendorsfa_vendorsidnamestatus = 'active'PO forms, bill forms
GL Accountsfa_accountsidaccount_number || ' - ' || nameis_active = trueExpense, JE forms
Fundsfa_fundsidfund_number || ' - ' || namestatus = 'active'All FA forms
Projectsfa_projectsidproject_number || ' - ' || namestatus = 'active'Expense, PO forms
Cost Centerspf_departmentsidnameorganization_idExpense, budget forms
Expense Categoriesfa_expense_categoriesidnameis_active = trueExpense report form

Platform Layer Usage

Hooks FA Components Import

// Forms
import { useFormTemplate, FormRenderer } from '@/platform/forms';

// Approvals
import { useSubmitApprovalRequest, useApprovalInbox } from '@/platform/approvals';

// Events
import { publishEvent } from '@/platform/events';
import type { KnownEventName } from '@/platform/events';

// Data lookups for form fields
import { useLookupOptions } from '@/platform/data-lookup';

// Business calendar for payment deadlines
import { useBusinessCalendar, calculateDeadline } from '@/platform/calendar';

Testing Requirements

Unit Tests

  • FA event payloads match documented schemas
  • Expense routing decision table returns correct chain for each amount tier
  • PO approval decision table handles sole-source and new-vendor escalation
  • Budget exception routing returns correct actions per variance
  • No PII/PHI in event payloads

Integration Tests

  • fa_expense_report_submitted event triggers approval chain in FW
  • fa_purchase_order_created event routes through PO approval (FA-UX-05 contract)
  • Amount-based conditional steps activate/skip correctly
  • Approval completion updates FA entity status (e.g., PO β†’ approved)
  • Rejection updates FA entity status and notifies submitter
  • Form field lookups return correct vendors, GL accounts, funds

E2E Tests

  • Complete expense report flow: form β†’ decision table β†’ approval β†’ reimbursement
  • Complete PO flow: wizard β†’ approval β†’ goods receipt β†’ payment
  • Budget approval flow: submission β†’ multi-level approval β†’ activation
  • Month-end close: period start β†’ checklist tasks β†’ completion

RLS Tests

  • FA events filtered by organization_id
  • Approval requests scoped to submitter’s organization
  • Form submissions isolated per tenant
  • Vendor and GL account lookups filtered by organization

Implementation Status

IntegrationStatusNotes
FA events in KnownEventNameβœ… PartialExpense, budget, close events registered; bill, JE events pending
PO approval (FA-UX-05)πŸ“ PlannedDetailed contract in FA-UX-05-FW-03-INTEGRATION.md
Expense approval chainπŸ“ PlannedForm + workflow templates ready
Budget approval chainπŸ“ PlannedEvents registered; chain config needed
JE approval chainπŸ“ PlannedEvents and chain not yet registered
Vendor bill approvalπŸ“ PlannedEvents and chain not yet registered
Decision tablesπŸ“ PlannedNo FA-specific decision tables created yet
Form field lookupsπŸ“ PlannedFA table lookup configs not yet registered
AP automation (FA-22)πŸ“ PlannedScan + duplicate events in EVENT_CONTRACTS.md
Period close workflowπŸ“ PlannedEvents registered; workflow template needed