docs(plans): Plan 4 (Billing + CSV Reconcile + Admin) — 12 Tasks TDD decomposition

writing-plans skill output для Plan 4 spec (commit 901cf98). 12 атомарных
Task'ов в 3 фазах:

Фаза I — Billing core (Tasks 1-4):
  1. Schema delta v8.18 → v8.19 (+1 таблица supplier_csv_reconcile_log,
     +3 колонки, +3 индекса, +2 CHECK) + Eloquent fillable/casts +
     PricingTierSeeder с 7 дефолтными ступенями.
  2. PricingTierResolver (pure resolver) + PricingTierRepository (DB-обёртка
     для активной сетки) с 7 + 4 тестами.
  3. LedgerService::chargeForDelivery — dual-balance (prepaid-first + bcmath
     rub) + lead_charges/balance_transactions/supplier_lead_costs INSERT с
     6 integration тестами.
  4. Integration LedgerService в RouteSupplierLeadJob с 4 E2E sharing-flow
     тестами + retry-idempotency.

Фаза II — Operations (Tasks 5-8):
  5. ResetMonthlyCountersCommand + Schedule monthlyOn(1, '00:00') Europe/Moscow
     через pgsql_supplier BYPASSRLS, 4 теста.
  6. Auto-pause flow + ZeroBalancePausedMail + 1/час/tenant rate-limit через
     Redis SETNX, 5 sharing-isolation тестов.
  7. SupplierCsvParser (streaming generator) + SupplierPortalClient::downloadLeadsCsv
     с 5 + 3 unit/Http::fake тестами.
  8. CsvReconcileJob (hourly + 25h окно + drift > 5% email) + CsvDriftAlertMail
     + Schedule entry с 6 integration тестами.

Фаза III — UI (Tasks 9-12):
  9. AdminPricingTiersController + AdminPricingTiersView (7-tier CRUD + audit)
     + 4 Histoire variants + 5 Vitest тестов.
  10. AdminSuppliersController + AdminSupplierPricesView (B1/B2/B3 cost editor)
      + 2 Histoire + 3 Vitest.
  11. TenantChargesController + ChargesTab в BillingView + CSV export через
      StreamedResponse + 3 Histoire + 4 Vitest.
  12. Verification gate (14-step CV) + 7 новых Биз-вопросов в реестр +
      CLAUDE.md/memory bumps + FF-merge.

Каждый Task имеет TDD-цикл (failing test → run FAIL → impl → run PASS →
pint + stan + parallel pest → commit) с exact commands и полным кодом
(нет placeholders). Self-review против spec — все 7 разделов покрыты.

+1 термин в cspell-words.txt (bcmath) для прохождения lefthook cspell stage.

Inherits from: Plan 1+2+2.5+2.6+3 (HEAD origin/main = 901cf98 spec).
Parent spec: docs/superpowers/specs/2026-05-11-plan4-billing-csv-admin-design.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-05-11 08:10:51 +03:00
parent 901cf98281
commit 0802f7cf4c
2 changed files with 4635 additions and 0 deletions
+1
View File
@@ -922,3 +922,4 @@ choco
Подписочный
bcdiv
TRUNC
bcmath
File diff suppressed because it is too large Load Diff