Saltar al contenido
Pathrule

patrones

Esta página solo está disponible en inglés.

Invoicing and Tax

Pathrule2 reglas • 1 memoria • 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.

Mapa de rutas sugerido

Pathrule coloca cada pieza en la ruta que le corresponde, para que tu asistente solo la vea donde tiene sentido. Esta es la vinculación a rutas que obtienes al importarlo; puedes ajustarla en tu espacio de trabajo.

/ raíz del espacio de trabajo
reconcile-invoices
src/
billing/
invoices/
Snapshot every fact printed on an invoice
Correct finalized invoices with linked documents
tax/
Tax calculation consumes evidence, not guesses

Reglas

2
Snapshot every fact printed on an invoice/src/billing/invoicesaltaestrictaFinal invoice lines preserve description, quantity, unit amount, currency, tax treatment, parties, and address evidence.
1Final 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 
8Verification: 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/invoicesaltaestrictaA finalized invoice is never mutated; credits, voids, and replacement documents preserve the original audit chain.
1A 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 
8Verification: Race two finalization requests and retry a correction event; confirm one number is allocated, one immutable original remains, and ledger totals reconcile.

Memorias

1
Tax 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.
1A 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 
3Keep 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 
5See /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

1
reconcile-invoices/rootReconcile internal invoices, provider documents, payments, credits, and tax totals for a closed period.
1---
2name: reconcile-invoices
3description: Reconcile internal invoices, provider documents, payments, credits, and tax totals for a closed period.
4---
5 
6# Reconcile Invoices
7 
8Run this procedure whenever the governed surface changes or its operational evidence becomes stale.
9 
101. Freeze the period input set and export internal invoices, provider invoices, payments, refunds, credits, voids, and tax summaries using stable identifiers.
112. Match documents by internal and provider IDs, then compare currency, subtotal, discount, tax, total, paid, credited, and outstanding amounts.
123. Classify mismatches as timing, duplicate event, missing event, configuration, rounding, or manual provider change; never force a balancing row without cause.
134. Resolve or accrue every difference, record evidence and owner, and rerun until the reconciliation is reproducible from the same input set.
14 
15Record 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.

Por qué este patrón

Agents render invoices from live product and address records, recompute historical tax, or edit finalized documents, destroying the evidence needed for customers and finance.

Pensado para Teams issuing invoices, calculating transaction tax, and reconciling provider billing records.

Evita que tu asistente caiga en:

  • 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
Licencia
Apache-2.0
Versión
1.0.0
Actualizado
2026-08-25
Ver el código fuente