feat(125): invoice_requested import fix + drop legacy is_invoice column

- shopPRO: ShopproOrderMapper jako jedyne zrodlo heurystyki detekcji faktury;
  mapOrderAggregate() zwraca top-level invoice_detected (transient).
- ShopproOrdersSyncService: usunieta wlasna shouldRequestInvoice(); propagacja
  aggregate['invoice_detected'] do setInvoiceRequested() tylko przy created=true.
- Allegro: nowa shouldRequestInvoice(payload) z 4 wzorcami (invoice.required,
  naturalPerson=false, address.taxId, companyName/address.company.name).
  Wczesniej tylko invoice.required -> analogiczna luka jak shopPRO.
- Migracja 20260513_000113: idempotentny backfill (UPDATE invoice_requested=1
  WHERE is_invoice=1 AND invoice_requested=0) + DROP COLUMN orders.is_invoice.
  Guard przez information_schema.COLUMNS + PREPARE/EXECUTE z ALTER TABLE COMMENT
  no-op fallbackiem (portable MySQL/MariaDB).
- Cleanup is_invoice z OrderImportRepository (INSERT cols/values/params,
  docstring Phase 112) i OrdersRepository (paginate SELECT, transformOrderRow
  hydrate). AllegroOrderImportService mapping w mapCheckoutFormPayload tez
  usuniety (wymuszone konsekwencja DROP COLUMN).
- Bugfix #1089: zamowienie shopPRO z firm_nip (bez wants_invoice/invoice.required)
  ustawia teraz invoice_requested=1 -> UI w zakladce Platnosci zaznacza checkbox,
  przycisk "Wystaw fakture" widoczny.

Pending operator: php bin/migrate.php (XAMPP MySQL online) -> backfill 7 zamowien.
Smoke test: re-import shopPRO + nowe Allegro z NIP.
This commit is contained in:
2026-05-12 22:11:49 +02:00
parent e7a417bc22
commit 2ab461aaae
15 changed files with 619 additions and 67 deletions

View File

@@ -5,33 +5,33 @@
See: .paul/PROJECT.md (updated 2026-05-07)
**Core value:** Sprzedawca moze obslugiwac zamowienia ze wszystkich kanalow sprzedazy i nadawac przesylki bez przelaczania sie miedzy platformami.
**Current focus:** v3.7 Invoices + operational integrations - Phase 124 SMS Templates complete (UNIFY closed).
**Current focus:** v3.7 Invoices + operational integrations - Phase 125 invoice_requested import fix complete (UNIFY closed).
## Current Position
Milestone: v3.7 Invoices (Fakturownia integration) - In progress
Phase: 124 of TBD (SMS Templates) - Complete
Plan: 124-01 complete
Status: UNIFY complete, ready to plan next phase
Last activity: 2026-05-13 00:30:00 - UNIFY closed for .paul/phases/124-sms-templates/124-01-PLAN.md
Phase: 125 of TBD (invoice_requested import fix) - Complete
Plan: 125-01 complete
Status: UNIFY complete, transition pending (commit + ROADMAP update)
Last activity: 2026-05-13 - UNIFY closed for .paul/phases/125-invoice-requested-import-fix/125-01-PLAN.md
Progress:
- Milestone v3.7: [##########] ~98% (Phase 113-124 complete)
- Phase 124: [##########] 100%
- Milestone v3.7: [##########] ~99% (Phase 113-125 complete; transition pending)
- Phase 125: [##########] 100%
## Loop Position
Current loop state:
```
PLAN -> APPLY -> UNIFY
done done done [Loop complete - ready for next PLAN]
done done done [Loop complete - transition pending]
```
## Session Continuity
Last session: 2026-05-13 00:30:00
Stopped at: Phase 124 UNIFY closed (UI fixes accepted by operator)
Next action: Pick next v3.7 phase (kandydaci w ROADMAP) or transition do v3.8
Last session: 2026-05-13
Stopped at: Phase 125-01 UNIFY closed; SUMMARY.md created
Next action: Phase transition (commit + ROADMAP update), then pick next v3.7 candidate or transition to v3.8
Resume file: .paul/ROADMAP.md
## Pending parallel work
@@ -39,8 +39,8 @@ Resume file: .paul/ROADMAP.md
## Git State
Last phase commit: 360eef1 feat(121+122): smsplanet conversation, notifications, default footer
Previous: 8f14851 feat(118): fakturownia single instance
Last phase commit: 522c94a feat(124): sms templates CRUD + order picker
Previous: 360eef1 feat(121+122): smsplanet conversation, notifications, default footer
Branch: main
Note: routes/web.php, DOCS/* i .paul/codebase/* zawierały zmiany z 118+121+122 nakładkowo i wszystkie wpadły do commitu 360eef1.
@@ -61,6 +61,9 @@ Note: routes/web.php, DOCS/* i .paul/codebase/* zawierały zmiany z 118+121+122
- Phase 124 follow-up: `php bin/migrate.php` (XAMPP MySQL online) — utworzy `sms_templates`. Operator nastepnie tworzy szablony manualnie z `/settings/sms-templates`.
- Phase 124 follow-up: real smoke wysylki SMS z szablonu (zamowienie z paczka + skonfigurowana stopka SMSPLANET) — sprawdzic ze `sms_messages.body` ma stopke raz, finalna tresc <= 918 znakow.
- Phase 124 follow-up: regresja Email — wyslij e-mail z istniejacym szablonem aby potwierdzic ze refaktor `Email\VariableResolver` na fasade nie zlamal `EmailSendingService`.
- Phase 125 follow-up: uruchom `php bin/migrate.php` (XAMPP MySQL online) — backfill 7 zamowien + DROP COLUMN `orders.is_invoice`. Weryfikacja: `SELECT id, invoice_requested FROM orders WHERE id=1089;` -> `1`; `SHOW COLUMNS FROM orders LIKE 'is_invoice';` -> empty.
- Phase 125 follow-up: ponowne uruchomienie migracji powinno byc no-op (`ALTER TABLE orders COMMENT = 'phase-125 backfill no-op'`).
- Phase 125 follow-up: zaimportuj nowe zamowienie shopPRO z `firm_nip` (bez kluczy w 5-elementowej liscie wczesniejszej heurystyki) -> potwierdz ze UI w zakladce Platnosci pokazuje zaznaczony checkbox „Klient prosi o fakture" i widoczny przycisk „Wystaw fakture".
- Phase 121 transition note (rozwiązane): commit 360eef1 obejmuje Phase 121 i Phase 122 razem; per-faza hunk-split nie wykonany ze względu na nakładkowe modyfikacje plików.
## Deferred to Next Milestones