Invoicing and Tax
Pathrule2 Rules • 1 Memory • 1 Skill
Invoicing and tax systems turn mutable product and customer data into financial evidence that must remain explainable after prices, addresses, rates, and providers change. This bundle snapshots invoice facts, separates calculation from presentation, controls finalization and corrections, and reconciles provider events. Unlike Stripe Billing, it is provider-independent and owns invoice and tax evidence rather than checkout integration.
Suggested path map
Pathrule places each piece on the matching path, so your assistant only sees it where it belongs. This is the scoping you get on import; you can adjust it in your workspace.
Rules
2Snapshot every fact printed on an invoice/src/billing/invoiceshighstrictFinal invoice lines preserve description, quantity, unit amount, currency, tax treatment, parties, and address evidence.
| 1 | Final invoice lines preserve description, quantity, unit amount, currency, tax treatment, parties, and address evidence. Rendering from live catalog or customer records rewrites history when a name, price, tax identifier, or address changes. Enforce this boundary in /src/billing/invoices so invalid work stops before it reaches another subsystem or creates an externally visible side effect. |
| 2 | |
| 3 | - Create immutable invoice-line and party snapshots when the invoice is finalized, not when a PDF is later requested. |
| 4 | - Store monetary values as integers in the currency's minor unit and preserve the currency with every amount. |
| 5 | - Retain the tax calculation inputs, jurisdiction result, exemption or reverse-charge evidence, and provider calculation identifier. |
| 6 | - Generate all human and machine exports from the same finalized snapshot. |
| 7 | |
| 8 | Verification: Change the live product, customer address, and tax configuration after finalization; confirm the invoice and its regenerated exports remain byte-for-byte equivalent where format permits. |
Correct finalized invoices with linked documents/src/billing/invoiceshighstrictA finalized invoice is never mutated; credits, voids, and replacement documents preserve the original audit chain.
| 1 | A finalized invoice is never mutated; credits, voids, and replacement documents preserve the original audit chain. In-place edits make ledger totals, customer copies, provider records, and tax reports disagree with no durable explanation. Enforce this boundary in /src/billing/invoices so invalid work stops before it reaches another subsystem or creates an externally visible side effect. |
| 2 | |
| 3 | - Restrict mutable drafts and make finalization an explicit, idempotent transition with authorization and audit evidence. |
| 4 | - Represent reductions with a credit note or equivalent linked document and preserve reason, amount, currency, and affected lines. |
| 5 | - Use a replacement document only through the jurisdiction and provider flow the business has approved. |
| 6 | - Keep document numbering unique and allocated by one transactional service, including retries and concurrent finalization. |
| 7 | |
| 8 | Verification: Race two finalization requests and retry a correction event; confirm one number is allocated, one immutable original remains, and ledger totals reconcile. |
Memories
1Tax calculation consumes evidence, not guesses/src/taxA billing country or card country alone may not represent the location evidence, registration, exemption, or product tax category required for a transaction.
| 1 | A billing country or card country alone may not represent the location evidence, registration, exemption, or product tax category required for a transaction. Define the evidence fields the tax engine receives and the precedence used when sources disagree. |
| 2 | |
| 3 | Keep product tax codes separate from marketing categories and version changes prospectively. Record why tax was charged, not charged, or reverse charged with the transaction snapshot. Send uncertain or conflicting evidence to an explicit review or collection path instead of silently selecting a favorable result. Keep the decision explicit at /src/tax; moving it into an incidental caller makes behavior depend on which route happened to execute first. |
| 4 | |
| 5 | See /src/billing/invoices for immutable snapshots and /src/webhooks for provider reconciliation. That related boundary consumes this decision and carries the evidence that proves it still holds. |
Skills
1reconcile-invoices/rootReconcile internal invoices, provider documents, payments, credits, and tax totals for a closed period.
| 1 | --- |
| 2 | name: reconcile-invoices |
| 3 | description: Reconcile internal invoices, provider documents, payments, credits, and tax totals for a closed period. |
| 4 | --- |
| 5 | |
| 6 | # Reconcile Invoices |
| 7 | |
| 8 | Run this procedure whenever the governed surface changes or its operational evidence becomes stale. |
| 9 | |
| 10 | 1. Freeze the period input set and export internal invoices, provider invoices, payments, refunds, credits, voids, and tax summaries using stable identifiers. |
| 11 | 2. Match documents by internal and provider IDs, then compare currency, subtotal, discount, tax, total, paid, credited, and outstanding amounts. |
| 12 | 3. Classify mismatches as timing, duplicate event, missing event, configuration, rounding, or manual provider change; never force a balancing row without cause. |
| 13 | 4. Resolve or accrue every difference, record evidence and owner, and rerun until the reconciliation is reproducible from the same input set. |
| 14 | |
| 15 | Record the decision, failed checks, and follow-up owner with the change. A successful run leaves reproducible evidence that another reviewer can inspect without repeating the investigation from memory. |
Why this pattern
Agents render invoices from live product and address records, recompute historical tax, or edit finalized documents, destroying the evidence needed for customers and finance.
Built for Teams issuing invoices, calculating transaction tax, and reconciling provider billing records.
Keeps your assistant from:
- Historical invoices changing after product or customer edits
- Tax decisions with no retained location and calculation evidence
- Finalized documents edited instead of corrected through linked records
- License
- Apache-2.0
- Version
- 1.0.0
- Updated
- 2026-08-25