# 2026-05-10

## Co zrobiono

- [Phase 115, Plan 01] Wystawianie faktury z zamowienia — vertical slice "zamowienie z NIP -> faktura PDF" w trybach lokalnym (Dompdf+counter) i delegowanym (POST do Fakturowni + redirect 302 do natywnego PDF)
- Phase 115 Task 1: InvoiceRepository + InvoiceService (dual-flow orchestrator) + InvoiceIssueException + FakturowniaApiClient::createInvoice (POST /invoices.json) + buildPdfUrl
- Phase 115 Task 2: InvoiceController + OrdersController::toggleInvoiceRequested + OrdersRepository::setInvoiceRequested + auto-import flagi z Allegro (`invoice.required`) i shopPRO (flexible 5-key parser) + show.php (toggle w zakladce Platnosci + warunkowy przycisk Wystaw fakture)
- Phase 115 Task 3: Lista wystawionych `/settings/accounting/invoices/issued` z filtrami + invoice_preview + invoice_pdf Dompdf template + hub link
- Phase 115 Task 3b (dodany): NIP lookup przez MF Biala Lista (publiczne API, bez rejestracji) — `MfWhitelistApiClient` + endpoint `/api/nip/lookup` + przycisk "Pobierz z GUS" w formularzu
- Auto-fix: GUS endpoint Fakturowni nie istnial (zwracal HTML 404 -> "json is not valid"); switch na MF Biala Liste
- Auto-fix: PHP 8.5 `curl_close()` deprecation wycieka HTML przed JSON; usuniete z MfWhitelistApiClient + FakturowniaApiClient (3 miejsca)
- Auto-fix: Fakturownia payload nieistniejace `payment_to_kind_days` -> usuniete (sama data `payment_to` wystarcza)
- Auto-fix: Generic `error` w 422 -> parser plaskuje `errors: {pole: [...]}` na czytelne komunikaty + error_log z raw body
- Auto-fix: Fakturownia security odrzuca `seller_*`/`department_id` jako "create new department" -> usuniete z payloadu (Fakturownia uzywa danych konta)
- Phase 115 transition: pending (STATE.md update, PROJECT.md, ROADMAP.md, git commit)

- [Phase 114, Plan 01] Accounting Configs Refactor — `/settings/accounting` jako hub-rozdroze, osobne podstrony Paragony/Faktury, pelen CRUD `invoice_configs` z delegacja do Fakturowni
- Phase 114 Task 1: migracja seed `Domyslny VAT` (idempotentna NOT EXISTS) + `InvoiceConfigRepository` z walidacja delegacji
- Phase 114 Task 2: `InvoiceConfigController` + widoki listy/edycji + `invoice-config-form.js` (conditional integration_id select) + 6 routes
- Phase 114 Task 3: `ReceiptConfigController` refactor (hub/list/edit split) + hub view + 2 widoki paragonow + legacy aliasy + docs
- Auto-fix: globalny `confirm-delete.js` zastapil rozsiane inline scripts (po user feedback "Usuwanie konfiguracji faktur nie dziala")
- Auto-fix: `OrderProAlerts.confirm` poprawiony z pozycyjnych argumentow na options-object API
- Phase 114 transition: PROJECT.md (4 nowe Key Decisions) + ROADMAP.md zaktualizowane

- [Phase 113, Plan 01] Fakturownia Integration Foundation — fundament v3.7 Invoices
- Task 1: 3 migracje SQL (invoices, invoice_configs, invoice_number_counters, fakturownia_integration_settings, orders.invoice_requested)
- Task 2: FakturowniaIntegrationRepository + FakturowniaApiClient (testConnection + STUB createInvoice/downloadPdf) + IntegrationsRepository::updateTestResult()
- Task 3: FakturowniaIntegrationController + 2 widoki + 6 routes + karta w hubie integracji
- Auto-fix: migracja 105 - usunieto `AFTER notes` (kolumna nie istnieje, notatki w `order_notes`)
- Auto-fix: migracja 106 - `ALTER TABLE COMMENT` zamiast `SELECT 1;` (PDO unbuffered conflict)
- Auto-fix: widok listy przepisany w stylu `table.table + table-wrap + badge` po feedbacku
- Phase 113 transition: PROJECT.md + ROADMAP.md zaktualizowane; v3.7 status In progress

## Zmienione pliki

- `src/Modules/Accounting/InvoiceRepository.php`
- `src/Modules/Accounting/InvoiceService.php`
- `src/Modules/Accounting/InvoiceController.php`
- `src/Modules/Accounting/InvoiceIssueException.php`
- `src/Core/Http/MfWhitelistApiClient.php`
- `src/Modules/Orders/OrdersController.php`
- `src/Modules/Orders/OrdersRepository.php`
- `src/Modules/Settings/AllegroOrderImportService.php`
- `src/Modules/Settings/ShopproOrdersSyncService.php`
- `resources/views/orders/show.php`
- `resources/views/accounting/invoice_form.php`
- `resources/views/accounting/invoice_preview.php`
- `resources/views/accounting/invoice_pdf.php`
- `resources/views/accounting/invoices_issued_list.php`
- `public/assets/js/modules/invoice-requested-toggle.js`
- `.paul/phases/115-invoice-from-order/115-01-PLAN.md`
- `.paul/phases/115-invoice-from-order/115-01-SUMMARY.md`
- `.paul/codebase/todo.md`
- `database/migrations/20260511_000107_seed_default_invoice_config.sql`
- `src/Modules/Settings/InvoiceConfigRepository.php`
- `src/Modules/Settings/InvoiceConfigController.php`
- `src/Modules/Settings/ReceiptConfigController.php`
- `resources/views/settings/accounting.php`
- `resources/views/settings/accounting-receipts.php`
- `resources/views/settings/accounting-receipt-edit.php`
- `resources/views/settings/accounting-invoices.php`
- `resources/views/settings/accounting-invoice-edit.php`
- `resources/views/layouts/app.php`
- `public/assets/js/modules/invoice-config-form.js`
- `public/assets/js/modules/confirm-delete.js`
- `.paul/phases/114-accounting-configs-refactor/114-01-PLAN.md`
- `.paul/phases/114-accounting-configs-refactor/114-01-SUMMARY.md`
- `database/migrations/20260510_000104_create_invoices_tables.sql`
- `database/migrations/20260510_000105_add_invoice_requested_to_orders.sql`
- `database/migrations/20260510_000106_seed_fakturownia_integration_type.sql`
- `src/Modules/Settings/FakturowniaIntegrationRepository.php`
- `src/Modules/Settings/FakturowniaApiClient.php`
- `src/Modules/Settings/FakturowniaIntegrationController.php`
- `src/Modules/Settings/IntegrationsHubController.php`
- `src/Modules/Settings/IntegrationsRepository.php`
- `resources/views/settings/fakturownia.php`
- `resources/views/settings/fakturownia-edit.php`
- `routes/web.php`
- `.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/113-fakturownia-integration/113-01-PLAN.md`
- `.paul/phases/113-fakturownia-integration/113-01-SUMMARY.md`
