# Pathrule Pattern: B2B Billing and Net Terms (1.0.0)
# ::pathrule:package:b2b-billing-net-terms

### [RULE] Net terms come from an approved credit decision  (path: /src/billing/accounts-receivable)
<!-- scope: folder | priority: high | strict -->

Net terms extend credit and cannot be accepted from a request field or copied from the last invoice. Resolve them from an approved customer credit record that names the legal entity, billing currency, payment method, term days, credit limit, effective dates, approver, and any purchase-order requirement.

- Check available credit using open receivables, unapplied cash, pending credits, and approved exceptions before finalization.
- Snapshot the applied terms and approval reference on the invoice so later customer changes do not rewrite history.
- Route limit overrides and term extensions through a named approval path with reason and expiration.
- Block invoice issuance when the customer identity, legal entity, currency, or required purchase order does not match the approval.

Verification: Change terms after drafting, exceed the limit concurrently, omit a required purchase order, and retry finalization; confirm only one approved snapshot becomes collectible.

---

### [RULE] Receivable state changes through posted documents and cash  (path: /src/billing/accounts-receivable)
<!-- scope: folder | priority: high | strict -->

An invoice is not paid because a user toggled a status. Derive receivable state from posted invoice amounts and explicit allocations of payments, credit notes, write-offs, reversals, and disputed amounts. Preserve each allocation with amount, currency, effective time, actor or import source, and linked document.

- Support partial and overpayments without erasing the remaining or unapplied balance.
- Define deterministic allocation order and require an explicit override when finance chooses another invoice or line.
- Reverse an incorrect allocation with a linked compensating record rather than editing history.
- Calculate open, partially paid, paid, overdue, disputed, written-off, and credit-balance states from the ledger evidence.

Verification: Apply one payment across invoices, reverse it, add a partial credit, receive an overpayment, and dispute one amount; confirm every open balance is reproducible.

---

### [MEMORY] The invoice carries the approved commercial chain  (path: /src/billing/invoices)

A collectible B2B invoice must be explainable to the buyer's accounts-payable process. Link the accepted quote or contract, internal order, customer purchase order and remaining amount, delivery or acceptance evidence, billing legal entities, remittance instructions, billing contact, tax evidence, and the approved credit-term snapshot.

Validate purchase-order number format, currency, entity, line limits, and expiration before consuming it, and track cumulative use across invoices. Keep buyer portal and email delivery receipts without treating delivery as acceptance unless the contract says so. See /src/billing/accounts-receivable for the open-balance model and the Invoicing and Tax pattern for immutable document correction.

---

### [MEMORY] Collections is a staged ownership workflow  (path: /ops/collections)

Define aging from the contractual due date and business calendar, not from the latest support message. Each aging band names the action, communication channel, owner, internal escalation, account hold policy, and evidence required before moving forward. A promise to pay, billing dispute, incorrect invoice, or missing purchase order is a case state with an amount and follow-up date, not free-form text.

Keep customer communications approved and consistent, record delivery, and separate disputed from undisputed balances. Coordinate service restrictions with contract and account policy rather than automatically disabling every overdue customer. See /src/billing/accounts-receivable for authoritative allocations and balances.

---

### [SKILL] review-b2b-receivables  (path: /ops/collections)

---
name: review-b2b-receivables
description: Review B2B receivables for allocation integrity, aging, disputes, ownership, and credit exposure.
---

# Review B2B Receivables

1. Freeze the review date and reconcile invoice totals, payments, credits, reversals, write-offs, disputes, and unapplied cash to the receivable ledger.
2. Inspect aging by customer, legal entity, currency, due date, credit limit, and owner; separate disputed and promised amounts from ordinary overdue balances.
3. Sample invoices for approved terms, purchase order, acceptance evidence, delivery, contact, and immutable allocation history.
4. Review limit overrides, term extensions, write-offs, service holds, and manual allocations for approver, reason, amount, and expiration.
5. Assign every material exception an owner and date, record portfolio totals, and rerun after corrections.

A successful review leaves no unexplained open balance and no overdue case without an accountable next action.
