e401491947
Task 4 — integration:
- handle() / createDealCopyForProject() — +5-й параметр LedgerService.
- Заменён старый balance_leads-- + BalanceTransaction блок на
\$ledger->chargeForDelivery(\$tenant, \$deal, \$lead) с try/catch для
InsufficientBalanceException (Log::warning + rethrow; auto-pause flow
в Task 6).
- LeadRouter::matchEligibleProjects — расширен фильтр tenant balance с
(balance_leads > 0) на (balance_leads > 0 OR balance_rub > 0), чтобы
rub-only tenant дошёл до LedgerService (single arbiter for dual-balance).
- 4 E2E теста в tests/Feature/Supplier/RouteSupplierLeadJobBillingTest.php:
prepaid charge + BalanceTransaction (carry-over M-2), rub charge + BT,
supplier_lead_costs gap-fix (2 deal-копии), retry idempotency.
Plan 4 Task 3 carry-overs (минорные правки по code-review d2030f9):
- I-2: PHPDoc на LedgerService::chargeForDelivery — @throws + @precondition
(caller wraps в DB::transaction с lockForUpdate Tenant).
- I-4: trim() на raw_payload['project'] в resolveSupplierId (defense
against whitespace).
Прочие правки:
- tests/Feature/Jobs/RouteSupplierLeadJobTest.php — +PricingTierSeeder
в beforeEach + +5-й LedgerService параметр в runRouteJob().
- tests/Feature/Integration/SupplierLeadFlowTest.php — +PricingTierSeeder
в beforeEach (test использует full webhook→job pipeline).
- tests/Feature/Services/LeadRouterTest.php — rename теста про balance_leads
→ \"zero in BOTH balance_leads AND balance_rub\" + новый тест
\"rub-only tenant ДОЛЖЕН пройти\".
- phpstan-baseline.neon — +5 entries для TestCall::seed() + Tenant/LeadCharge
property.notFound в новых файлах (IDE helper @mixin re-generation —
отдельная задача).
Метрики: Pint clean, PHPStan 0 errors, Pest 646/643+3 skipped/0 failed
(21.1s parallel). Plan 4 Task 4 закрыт.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>