laravel-shop/tests/Feature/Ledger
Fabian @ Blax Software c170595ac8 feat(ledger): VAT per ledger row from Stripe's own data
stripe_transactions gets a nullable `tax` column: the VAT inside the
row's amount, in signed cents like amount, NULL = unknown.

- Charges/payments: the charge's invoice tax (tax, else total_tax_amounts
  / total_taxes) pro-rated by captured amount over invoice total, so a
  partly credit-paid invoice counts only the cash part; without an invoice,
  the Checkout Session of the payment intent (total_details.amount_tax).
- refund, payment_refund, payment_failure_refund, refund_failure carry the
  same share of the charge's VAT as their amount, signed like it.
- Fees, payouts, transfers, disputes and PayPal rows stay NULL.
- syncLedgerForCharge expands charge.invoice (falls back without it on API
  versions that lack Charge.invoice). A charge and its refunds share one
  lookup; refunds reuse the charge's ledger row; a re-import keeps a known
  value without a Stripe call. Stripe holding no VAT data is marked
  meta.tax_source=none and not asked again. A failed lookup leaves NULL and
  never breaks the import.
- shop:import-stripe-ledger --backfill-tax [--dry-run] [--since] [--recheck]
  and Shop::backfillLedgerTax() fill missing VAT read-only, idempotently.
- ledgerTotals, revenueLedgerByDay, ledgerTotalsByAccount and
  customerLedgerTotals gain a `tax` key (SUM(COALESCE(tax,0))); existing
  keys unchanged. Before the migration runs, rows save without tax and
  tax reads 0.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-02 12:10:11 +01:00
..
LedgerMetricsTest.php fix(ledger): count bounced direct debits and Stripe account fees 2026-10-07 10:51:09 +02:00
LedgerTaxTest.php feat(ledger): VAT per ledger row from Stripe's own data 2026-11-02 12:10:11 +01:00
PaypalLedgerTest.php feat(ledger): shop.paypal.required makes a missing or failing PayPal import throw 2026-10-07 12:48:05 +02:00