Commerce Accounts Payable
Track supplier bills, process payments, run payment batches, and monitor AP aging.
How It Works
- Create bills from supplier invoices with line items.
- Approve bills for payment.
- Record individual payments or create payment runs for batch processing.
- Allocate payments to specific bills.
- Generate AP aging reports by supplier.
Usage
- CLI:
stateset ap ... or stateset "AP aging report"
- Writes require
--apply.
- MCP tools:
list_bills, create_bill, approve_bill, record_bill_payment, create_payment_run, approve_payment_run, get_ap_aging, get_ap_summary.
Permissions
- Read:
list_bills, get_ap_aging, get_ap_summary — no --apply needed.
- Write:
create_bill, approve_bill, record_bill_payment, create_payment_run, approve_payment_run — requires --apply.
Examples
stateset --db ./store.db "list bills where supplier = 'Acme Corp'"
stateset --db ./store.db "create bill supplier='Acme Corp' amount=2500 due_date=2026-04-15" --apply
stateset --db ./store.db "approve bill BILL-2025-0050" --apply
stateset --db ./store.db "get ap aging"
Status Flows
Bill: Draft -> Pending -> Approved -> PartiallyPaid -> Paid (or Cancelled/Disputed/Overdue)
Payment Run: Draft -> Pending -> Approved -> Processing -> Completed (or Cancelled)
Payment Methods
- Check, ACH, Wire, CreditCard, Cash, Other
Aging Buckets
- Current, 1-30 days, 31-60 days, 61-90 days, 90+ days
Output
{"status":"payment_recorded","bill_id":"BILL-2025-0050","amount_paid":2500.00,"balance_remaining":0.00,"payment_method":"ACH"}
Present Results to User
- Bill number, supplier, and payment status.
- Amount paid and remaining balance.
- Aging summary with overdue amounts by bucket.
- Payment run totals and included bills.
Troubleshooting
- Bill not approved: bills must be approved before payment.
- Payment exceeds balance: verify bill amount and prior payments.
- Duplicate bill: check existing bills for the same supplier invoice number.
- Payment run stuck processing: verify bank integration status and retry or cancel the run.
Error Codes
AP_BILL_NOT_APPROVED: Bill must be approved before payment can be recorded.
AP_PAYMENT_EXCEEDS_BALANCE: Payment amount exceeds the outstanding bill balance.
AP_DUPLICATE_INVOICE: A bill with the same supplier invoice number already exists.
Related Skills
- commerce-general-ledger: Bill payments auto-post journal entries to GL.
- commerce-receiving: Match supplier bills against received PO quantities.
- commerce-accounts-receivable: Offset vendor debit memos against payables.
References
- references/ap-aging.md
- /home/dom/stateset-icommerce/crates/stateset-core/src/models/accounts_payable.rs
- /home/dom/stateset-icommerce/crates/stateset-embedded/src/accounts_payable.rs
1---2name: commerce-accounts-payable3description: Manage supplier bills, payments, and AP aging. Use when recording supplier invoices, processing payments, running payment batches, or reviewing AP aging reports.4---56# Commerce Accounts Payable78Track supplier bills, process payments, run payment batches, and monitor AP aging.910## How It Works11121. Create bills from supplier invoices with line items.132. Approve bills for payment.143. Record individual payments or create payment runs for batch processing.154. Allocate payments to specific bills.165. Generate AP aging reports by supplier.1718## Usage1920- CLI: `stateset ap ...` or `stateset "AP aging report"`21- Writes require `--apply`.22- MCP tools: `list_bills`, `create_bill`, `approve_bill`, `record_bill_payment`, `create_payment_run`, `approve_payment_run`, `get_ap_aging`, `get_ap_summary`.2324## Permissions2526- Read: `list_bills`, `get_ap_aging`, `get_ap_summary` — no `--apply` needed.27- Write: `create_bill`, `approve_bill`, `record_bill_payment`, `create_payment_run`, `approve_payment_run` — requires `--apply`.2829## Examples3031```bash32stateset --db ./store.db "list bills where supplier = 'Acme Corp'"33stateset --db ./store.db "create bill supplier='Acme Corp' amount=2500 due_date=2026-04-15" --apply34stateset --db ./store.db "approve bill BILL-2025-0050" --apply35stateset --db ./store.db "get ap aging"36```3738## Status Flows3940**Bill:** Draft -> Pending -> Approved -> PartiallyPaid -> Paid (or Cancelled/Disputed/Overdue)41**Payment Run:** Draft -> Pending -> Approved -> Processing -> Completed (or Cancelled)4243## Payment Methods4445- Check, ACH, Wire, CreditCard, Cash, Other4647## Aging Buckets4849- Current, 1-30 days, 31-60 days, 61-90 days, 90+ days5051## Output5253```json54{"status":"payment_recorded","bill_id":"BILL-2025-0050","amount_paid":2500.00,"balance_remaining":0.00,"payment_method":"ACH"}55```5657## Present Results to User5859- Bill number, supplier, and payment status.60- Amount paid and remaining balance.61- Aging summary with overdue amounts by bucket.62- Payment run totals and included bills.6364## Troubleshooting6566- Bill not approved: bills must be approved before payment.67- Payment exceeds balance: verify bill amount and prior payments.68- Duplicate bill: check existing bills for the same supplier invoice number.69- Payment run stuck processing: verify bank integration status and retry or cancel the run.7071## Error Codes7273- `AP_BILL_NOT_APPROVED`: Bill must be approved before payment can be recorded.74- `AP_PAYMENT_EXCEEDS_BALANCE`: Payment amount exceeds the outstanding bill balance.75- `AP_DUPLICATE_INVOICE`: A bill with the same supplier invoice number already exists.7677## Related Skills7879- **commerce-general-ledger**: Bill payments auto-post journal entries to GL.80- **commerce-receiving**: Match supplier bills against received PO quantities.81- **commerce-accounts-receivable**: Offset vendor debit memos against payables.8283## References84- references/ap-aging.md85- /home/dom/stateset-icommerce/crates/stateset-core/src/models/accounts_payable.rs86- /home/dom/stateset-icommerce/crates/stateset-embedded/src/accounts_payable.rs