129 lines
4.6 KiB
Markdown
129 lines
4.6 KiB
Markdown
---
|
|
phase: 90-delivery-price-import-fix
|
|
plan: 01
|
|
subsystem: database, import
|
|
tags: [allegro, shoppro, receipts, delivery_price, backfill]
|
|
|
|
requires:
|
|
- phase: 70-receipt-shipping-cost
|
|
provides: ReceiptService odczyt delivery_price z orders
|
|
provides:
|
|
- Zapis delivery_price przy imporcie zamowien (Allegro + shopPRO)
|
|
- Backfill delivery_price z preferences_json/payload_json
|
|
affects: [receipts, order-import]
|
|
|
|
tech-stack:
|
|
added: []
|
|
patterns: [resolveDeliveryCost helper w AllegroOrderImportService]
|
|
|
|
key-files:
|
|
created:
|
|
- database/migrations/20260408_000090_backfill_delivery_price.sql
|
|
- bin/reissue_receipt.php
|
|
modified:
|
|
- src/Modules/Orders/OrderImportRepository.php
|
|
- src/Modules/Settings/AllegroOrderImportService.php
|
|
- src/Modules/Settings/ShopproOrderMapper.php
|
|
|
|
key-decisions:
|
|
- "ALTER TABLE w migracji backfill — kolumna nie istniala na serwerze mimo ze byla w CREATE TABLE"
|
|
- "resolveDeliveryCost reuse amountToFloat — Allegro cost moze byc obiekt {amount,currency} lub plain number"
|
|
|
|
patterns-established: []
|
|
|
|
duration: ~25min
|
|
started: 2026-04-08T19:00:00Z
|
|
completed: 2026-04-08T19:25:00Z
|
|
---
|
|
|
|
# Phase 90 Plan 01: Delivery Price Import Fix Summary
|
|
|
|
**Naprawiono brak zapisu delivery_price przy imporcie zamowien — paragony teraz poprawnie uwzgledniaja koszt wysylki**
|
|
|
|
## Performance
|
|
|
|
| Metric | Value |
|
|
|--------|-------|
|
|
| Duration | ~25min |
|
|
| Started | 2026-04-08 |
|
|
| Completed | 2026-04-08 |
|
|
| Tasks | 2 completed |
|
|
| Files modified | 5 |
|
|
|
|
## Acceptance Criteria Results
|
|
|
|
| Criterion | Status | Notes |
|
|
|-----------|--------|-------|
|
|
| AC-1: Import Allegro zapisuje delivery_price | Pass | resolveDeliveryCost + amountToFloat |
|
|
| AC-2: Import shopPRO zapisuje delivery_price | Pass | $transportCost mapowany do delivery_price |
|
|
| AC-3: Backfill istniejacych zamowien | Pass | ALTER TABLE + UPDATE z JSON_EXTRACT |
|
|
| AC-4: Paragon zawiera koszt wysylki | Pass | Zweryfikowano na zamowieniu #134: 10.00 + 13.50 = 23.50 |
|
|
|
|
## Accomplishments
|
|
|
|
- Import Allegro i shopPRO zapisuja delivery_price do tabeli orders
|
|
- Backfill migracja wypelnia delivery_price z preferences_json (Allegro) i payload_json (shopPRO)
|
|
- Paragon #134 prawidlowo zawiera pozycje "Koszt wysylki" 13.50 zl
|
|
|
|
## Files Created/Modified
|
|
|
|
| File | Change | Purpose |
|
|
|------|--------|---------|
|
|
| `src/Modules/Orders/OrderImportRepository.php` | Modified | Dodano delivery_price do INSERT, UPDATE i orderParams |
|
|
| `src/Modules/Settings/AllegroOrderImportService.php` | Modified | Dodano delivery_price + metoda resolveDeliveryCost |
|
|
| `src/Modules/Settings/ShopproOrderMapper.php` | Modified | Dodano delivery_price = $transportCost do tablicy $order |
|
|
| `database/migrations/20260408_000090_backfill_delivery_price.sql` | Created | ALTER TABLE + backfill z JSON |
|
|
| `bin/reissue_receipt.php` | Created | Skrypt CLI do usuwania i ponownego wystawiania paragonu |
|
|
|
|
## Decisions Made
|
|
|
|
| Decision | Rationale | Impact |
|
|
|----------|-----------|--------|
|
|
| ALTER TABLE w migracji backfill | Kolumna delivery_price byla w CREATE TABLE ale tabela na serwerze jej nie miala (starsza wersja) | Migracja jest self-contained |
|
|
| resolveDeliveryCost reuse amountToFloat | Allegro cost moze byc obiekt {amount,currency} — istniejacy helper juz to obsluguje | Brak duplikacji kodu |
|
|
| bin/reissue_receipt.php z DB_HOST_REMOTE | Lokalny XAMPP nie dziala, potrzeba dostepu do remote DB | Skrypt narzędziowy do testow |
|
|
|
|
## Deviations from Plan
|
|
|
|
### Summary
|
|
|
|
| Type | Count | Impact |
|
|
|------|-------|--------|
|
|
| Auto-fixed | 1 | Krytyczny — bez ALTER TABLE migracja by nie zadziałała |
|
|
| Scope additions | 1 | bin/reissue_receipt.php — narzedzie testowe |
|
|
| Deferred | 0 | - |
|
|
|
|
**Total impact:** ALTER TABLE bylo niezbedne. Skrypt testowy dodany dla weryfikacji.
|
|
|
|
### Auto-fixed Issues
|
|
|
|
**1. Brak kolumny delivery_price na serwerze**
|
|
- **Found during:** Task 2 (migracja backfill)
|
|
- **Issue:** Kolumna byla w pliku CREATE TABLE ale nie istniala faktycznie w bazie (tabela starsza niz migracja)
|
|
- **Fix:** Dodano ALTER TABLE ADD COLUMN na poczatku migracji
|
|
- **Verification:** Migracja przeszla, delivery_price=13.50 dla zamowienia #134
|
|
|
|
## Issues Encountered
|
|
|
|
| Issue | Resolution |
|
|
|-------|------------|
|
|
| SQLSTATE[42S22] Column not found delivery_price | Dodano ALTER TABLE do migracji |
|
|
| Brak polaczenia z DB (XAMPP off) | Stworzono bin/reissue_receipt.php z DB_HOST_REMOTE |
|
|
|
|
## Next Phase Readiness
|
|
|
|
**Ready:**
|
|
- delivery_price jest poprawnie zapisywane przy kazdym nowym imporcie
|
|
- Istniejace zamowienia maja backfill
|
|
- Paragony dzialaja poprawnie
|
|
|
|
**Concerns:**
|
|
- None
|
|
|
|
**Blockers:**
|
|
- None
|
|
|
|
---
|
|
*Phase: 90-delivery-price-import-fix, Plan: 01*
|
|
*Completed: 2026-04-08*
|