# 2026-05-13

## Co zrobiono

- [Phase 124, Plan 01] Wdrozono szablony SMS: CRUD w `/settings/sms-templates` (name + body + is_active) plus dropdown "Wybierz szablon" w zakladce SMS na `/orders/{id}` wstawiajacy tresc z rozwinietymi zmiennymi `{{zamowienie.numer}}`, `{{kupujacy.imie_nazwisko}}`, `{{przesylka.numer}}` itd. do textarea.
- [Phase 124, Plan 01] Wydzielono `Sms\SmsVariableResolver` ze wspolna logika `buildVariableMap` + `resolve`; `Email\VariableResolver` zostal cienka fasada delegujaca — `EmailSendingService` niezmieniony, kontrakt Phase 14 zachowany.
- [Phase 124, Plan 01] Dodano endpoint `GET /orders/{id}/sms/template?template_id=N` (JSON z rozwinietym body per zamowienie); JS module `sms-template-picker.js` z idempotentnym guard i `OrderProAlerts.confirm` (options-object API) przy nadpisaniu niepustej textarea.
- [Phase 124, Plan 01] Migracja `20260512_000112_create_sms_templates.sql` (CREATE TABLE, DDL). Stopka SMSPLANET dalej doklejana wylacznie przez `SmsConversationService::buildFinalOutboundBody()` (Phase 122 contract preserved).
- [Phase 124, Plan 01] UI fixes po UAT operatora: paleta zmiennych przeniesiona pod textarea z pill chipami `{{var}} + opis` (border-radius 999px, hover indigo); akcje w liscie szablonow uzywaja `display: flex; flex-wrap: nowrap` zamiast `white-space: nowrap` (form-children byly blokowe).
- [Phase 124, Plan 01] UNIFY zamkniety; `php bin/migrate.php` i real smoke wysylki SMS z szablonu zalezne od XAMPP MySQL online.
- [Phase 125, Plan 01] Bugfix #1089: shopPRO order z `firm_nip` ustawia teraz `invoice_requested=1` przy imporcie (mapper jako jedyne zrodlo heurystyki, sync service propaguje `aggregate['invoice_detected']`).
- [Phase 125, Plan 01] Allegro rozszerzenie `shouldRequestInvoice()`: detekcja `invoice.naturalPerson=false`, `invoice.address.taxId`, `invoice.companyName` (wczesniej tylko `invoice.required`).
- [Phase 125, Plan 01] Migracja `20260513_000113_drop_orders_is_invoice_and_backfill_invoice_requested.sql` — idempotentna (information_schema guard); backfill 7 zamowien + DROP COLUMN `orders.is_invoice` (legacy z Phase 115).
- [Phase 125, Plan 01] Cleanup `is_invoice` z `OrderImportRepository` (INSERT/params/docstring) i `OrdersRepository` (SELECT/hydrate); usuniete `shouldRequestInvoice()` z `ShopproOrdersSyncService` (zastapione heurystyka mappera).
- [Phase 126, Plan 01] Bugfix `/orders/{id}/invoice/create` GUS lookup: dla JDG (MF `subject.krs=''`) nazwa z MF trafia do "Imie i nazwisko"; dla spolki z KRS — do "Nazwa firmy". Drugiego pola nie nadpisuje — pre-fill z `order_addresses.name` zachowany (czesto trzyma pelna nazwe firmy JDG, np. "Project-Pro Pyziak Jacek" vs MF "JACEK PYZIAK").
- [Phase 126, Plan 01] `MfWhitelistApiClient::lookupByNip()` zwraca dodatkowo `krs: string` i `is_jdg: bool` (true gdy `subject.krs === ''`). `InvoiceController::nipLookup` propaguje `is_jdg` w `data` JSON. JS `btn-gus-lookup` warunkowo wybiera target field.

## Zmienione pliki

- `database/migrations/20260512_000112_create_sms_templates.sql`
- `src/Modules/Sms/SmsTemplateRepository.php`
- `src/Modules/Sms/SmsVariableResolver.php`
- `src/Modules/Email/VariableResolver.php`
- `src/Modules/Settings/SmsTemplateController.php`
- `src/Modules/Orders/OrdersController.php`
- `routes/web.php`
- `resources/views/settings/sms-templates.php`
- `resources/views/settings/sms-templates-form.php`
- `resources/views/orders/show.php`
- `resources/views/layouts/app.php`
- `resources/lang/pl.php`
- `resources/scss/app.scss`
- `resources/scss/modules/_sms-templates.scss`
- `public/assets/css/app.css`
- `public/assets/js/modules/sms-template-picker.js`
- `.paul/codebase/db_schema.md`
- `.paul/codebase/architecture.md`
- `.paul/codebase/tech_changelog.md`
- `.paul/PROJECT.md`
- `.paul/ROADMAP.md`
- `.paul/STATE.md`
- `.paul/phases/124-sms-templates/124-01-PLAN.md`
- `.paul/phases/124-sms-templates/124-01-SUMMARY.md`
- `src/Modules/Settings/ShopproOrderMapper.php`
- `src/Modules/Settings/ShopproOrdersSyncService.php`
- `src/Modules/Settings/AllegroOrderImportService.php`
- `src/Modules/Orders/OrderImportRepository.php`
- `src/Modules/Orders/OrdersRepository.php`
- `database/migrations/20260513_000113_drop_orders_is_invoice_and_backfill_invoice_requested.sql`
- `.paul/phases/125-invoice-requested-import-fix/125-01-PLAN.md`
- `.paul/phases/125-invoice-requested-import-fix/125-01-SUMMARY.md`
- `src/Core/Http/MfWhitelistApiClient.php`
- `src/Modules/Accounting/InvoiceController.php`
- `resources/views/accounting/invoice_form.php`
- `.paul/phases/126-invoice-gus-field-mapping/126-01-PLAN.md`
- `.paul/phases/126-invoice-gus-field-mapping/126-01-SUMMARY.md`
