Skip to main content

05 — Core Financial Operations: AP, AR, Cash, Reimbursement & Accounting

Domain: Transactional finance modules, payment processing, bank reconciliation Dependencies: 01-Data (schema), 03-ELT (connectors), 04-Security (RBAC, audit) Outputs: Feature specifications, API contracts, workflow diagrams, business rules


ROLE

You are a Senior Financial Systems Architect with deep expertise in Brazilian and US accounting systems, payment processing (Pix/Boleto/ACH/Wire), bank reconciliation, NF-e integration, and multi-currency transaction management. You design systems that accountants and controllers trust for month-end close.


OBJECTIVE

Design the complete specification for the five core financial operations modules, migrating and enhancing the existing Avivatec modules (F-006 through F-011) from Angular/.NET/SQL Server to the AI-first stack while preserving all existing user story functionality and adding AI-powered automation.


DELIVERABLES

D1. Accounts Payable (F-007 Enhanced)

Transaction Lifecycle:

Document Capture → AI Categorization → Approval Workflow → Scheduling → Payment → Reconciliation

Requirements:

  • Multi-currency expense entry with live FX rates (PTAX for BRL, ECB for EUR)
  • AI-powered document ingestion: PDF, email forward, mobile photo, NF-e XML
  • SEFAZ NF-e automatic import via e-CNPJ certificate (Brazil)
  • Invoice matching: 2-way (PO + invoice) and 3-way (PO + receipt + invoice)
  • Payment method routing: Boleto, Pix, TED/DOC (BR) / ACH, Wire, Check (US)
  • Installment scheduling with CDI/SELIC interest and early-payment discount
  • Approval workflows: amount-based thresholds, separation of duties
  • AP aging reports (30/60/90/120 days) with payment priority scoring
  • Vendor master with spend analytics and duplicate detection
  • Tax withholding calculation: ISS, IRRF, PIS/COFINS (BR) / 1099 tracking (US)

API Endpoints:

  • POST /ap/invoices — Create with optional OCR attachment
  • PATCH /ap/invoices/{id}/approve — Approval with OpenFGA check
  • POST /ap/invoices/{id}/schedule-payment — Schedule with method selection
  • GET /ap/aging — Aging report with filters (entity, vendor, currency, status)
  • POST /ap/bulk-import — NF-e XML batch import

D2. Accounts Receivable (F-008 Enhanced)

Transaction Lifecycle:

Invoice Creation → Delivery → Collection Tracking → Payment Receipt → Reconciliation → Revenue Recognition

Requirements:

  • Customer master data with CRM integration (Salesforce, HubSpot, Pipedrive)
  • Recurring revenue contract management with auto-invoicing
  • Payment processor integration: Stone, Cielo, Rede, PagSeguro (BR) + Stripe, Square (US)
  • MDR rate comparison engine: expected vs. actual fees, savings identification
  • Card receivables forecasting: receivable schedule projection by processor
  • AI-powered collection priority scoring (payment history, aging, amount)
  • Aging reports with collection probability and DSO metrics
  • Revenue recognition engine: ASC 606 (US) / CPC 47 (Brazil)
  • Dunning workflow: automated payment reminders (email, WhatsApp, SMS)
  • Credit analysis: customer risk scoring based on payment behavior

API Endpoints:

  • POST /ar/invoices — Create invoice with line items
  • GET /ar/receivables/schedule — Card receivables projection
  • GET /ar/mdr-comparison — MDR analysis by processor
  • GET /ar/aging — Aging with collection probability scores
  • POST /ar/dunning/{customer_id} — Trigger dunning sequence

D3. Cash & Bank Management (F-009 Enhanced)

Requirements:

  • Multi-bank statement import: OFX, CSV, API (Open Finance Brasil, Plaid)
  • Automated bank reconciliation with AI matching (target: 90%+ auto-match rate)
  • Matching rules: exact amount, date proximity, description similarity, reference number
  • Unmatched item queue with AI-suggested matches and confidence scores
  • Duplicate detection with explainability ("Duplicate: same amount, date, vendor")
  • Open Finance Brasil integration: real-time balance, transaction sync (BACEN-regulated)
  • Plaid integration for US bank accounts
  • Investment portfolio tracking: CDB, LCA/LCI, Tesouro Direto (BR) / Money market, T-bills (US)
  • Loan and financing management with amortization schedules (SAC, Price, American)
  • Cash position dashboard: real-time balances across all accounts
  • Intercompany cash management with netting and settlement
  • Cash flow forecasting integration (feeds into Sub-Prompt 06)

API Endpoints:

  • POST /bank/statements/import — Upload OFX/CSV or trigger API sync
  • POST /bank/reconciliation/auto — Run AI reconciliation
  • GET /bank/cash-position — Real-time multi-account balance
  • GET /bank/investments — Portfolio summary with yields
  • POST /bank/intercompany/transfer — Intercompany with dual-entry

D4. Expense Reimbursement (F-010 Enhanced)

Requirements:

  • Mobile-first receipt capture: camera → OCR → AI extraction (vendor, amount, date, category)
  • Corporate card integration: automatic transaction import and matching
  • Per-policy expense validation: daily limits, category restrictions, per diem rates
  • Multi-level approval routing based on amount and category
  • Mileage calculator with Google Maps integration
  • Per diem rates by city (Brazil ANTT rates, US GSA rates)
  • Tax deductibility flagging per category
  • Integration with AP for reimbursement payment
  • Employee expense analytics: spending patterns, policy compliance rate
  • Receipt archival with OCR searchability (7-year retention)

D5. Accounting Integration (F-011 Enhanced)

Connector Specifications:

SystemSync DirectionData ScopeFrequency
TactusBi-directionalGL, trial balance, DRENightly
Conta AzulBi-directionalTransactions, contacts, categoriesReal-time (webhook)
OmieBi-directionalNF-e, AP, AR, bank, productsHourly
DomínioImport onlyAccounting export, fiscal booksOn-demand
QuickBooksBi-directionalCOA, journals, invoices, paymentsReal-time (CDC)
XeroBi-directionalSame as QBOReal-time (webhook)
NetSuiteBi-directionalFull ERP scopeHourly

COA Normalization:

  • Each ERP has different COA structure (flat vs. hierarchical, numbered vs. named)
  • Platform maintains a unified COA with mapping tables per source
  • dbt macros handle normalization (from Sub-Prompt 03)
  • Manual override UI for unmapped accounts

D6. Period Close Workflow

Month-End Close Checklist (AI-assisted):

  1. Bank reconciliation completion (all accounts matched within tolerance)
  2. AP accrual verification (outstanding invoices accrued)
  3. AR revenue recognition (ASC 606 / CPC 47 calculations)
  4. Intercompany elimination entries
  5. FX revaluation (unrealized gains/losses)
  6. Depreciation posting
  7. Payroll accrual
  8. Trial balance review (AI anomaly check)
  9. Journal entry approval (separation of duties)
  10. Period lock (prevent backdated entries)

CONSTRAINTS

  • All amounts as NUMERIC(19,4) — never floating point
  • Every transaction creates audit trail entry (forwarded to immudb)
  • Brazilian tax calculations must follow current SEFAZ/RFB rules
  • Bank reconciliation must handle timezone differences (BR vs US banks)
  • Payment scheduling must respect banking calendars (holidays, cutoff times)
  • Multi-entity transactions must create balanced intercompany entries

RESEARCH QUESTIONS

  1. What is the optimal AI matching algorithm for bank reconciliation (rule-based + ML hybrid)?
  2. How should the MDR comparison engine handle different processor fee structures (flat, tiered, interchange-plus)?
  3. What is the best approach for NF-e XML ingestion at scale (1000+ NF-e/day for large tenants)?
  4. How to model Brazilian tax withholding (ISS, IRRF, PIS/COFINS) across municipal, state, and federal jurisdictions?
  5. What is the recommended revenue recognition engine architecture for ASC 606 compliance?