feat(126): invoice GUS field mapping fix (JDG/KRS heuristic)

MfWhitelistApiClient.lookupByNip() exposes is_jdg/krs from MF Biala Lista.
InvoiceController.nipLookup propagates is_jdg in JSON response.
invoice_form.php JS conditionally targets buyer_name (JDG) or
buyer_company_name (spolka z KRS); second field keeps zamowienie pre-fill.

Fixes apparent field swap on /orders/{id}/invoice/create after GUS lookup
for JDG (sole trader) where MF returns natural person in subject.name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 22:29:55 +02:00
parent 2ab461aaae
commit c758ec7c92
10 changed files with 386 additions and 18 deletions

View File

@@ -5,19 +5,19 @@
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 125 invoice_requested import fix complete (UNIFY closed).
**Current focus:** v3.7 Invoices + operational integrations - Phase 126 GUS field mapping fix complete (UNIFY closed).
## Current Position
Milestone: v3.7 Invoices (Fakturownia integration) - In progress
Phase: 125 of TBD (invoice_requested import fix) - Complete
Plan: 125-01 complete
Phase: 126 of TBD (Invoice GUS field mapping fix) - Complete
Plan: 126-01 complete (SUMMARY.md created)
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
Last activity: 2026-05-13 - Phase 126-01 UNIFY zakonczony
Progress:
- Milestone v3.7: [##########] ~99% (Phase 113-125 complete; transition pending)
- Phase 125: [##########] 100%
- Milestone v3.7: [##########] ~99% (Phase 113-126 complete; transition pending)
- Phase 126: [##########] 100%
## Loop Position
@@ -30,8 +30,8 @@ PLAN -> APPLY -> UNIFY
## Session Continuity
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
Stopped at: Phase 126-01 UNIFY closed; SUMMARY.md created
Next action: Phase transition (commit + ROADMAP update), then manual smoke (AC-1) i wybor kolejnego kandydata v3.7
Resume file: .paul/ROADMAP.md
## Pending parallel work
@@ -39,10 +39,9 @@ Resume file: .paul/ROADMAP.md
## Git State
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.
Last phase commit: 2ab461a feat(125): invoice_requested import fix + drop legacy is_invoice column
Previous: 522c94a feat(124): sms templates CRUD + order picker
Branch: main (4 commits ahead of origin/main)
## Pending Actions
@@ -65,6 +64,7 @@ Note: routes/web.php, DOCS/* i .paul/codebase/* zawierały zmiany z 118+121+122
- 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.
- Phase 126 follow-up: manual smoke `/orders/1090/invoice/create` (JDG, NIP 5170167517) -> "Imie i nazwisko"="JACEK PYZIAK", "Nazwa firmy"="Project-Pro Pyziak Jacek" niezmieniona; drugi smoke na zamowieniu spolki z aktywnym KRS; `curl /api/nip/lookup?nip=5170167517` -> `data.is_jdg=true`.
## Deferred to Next Milestones