update
This commit is contained in:
145
.paul/phases/70-receipt-shipping-cost/70-01-PLAN.md
Normal file
145
.paul/phases/70-receipt-shipping-cost/70-01-PLAN.md
Normal file
@@ -0,0 +1,145 @@
|
||||
---
|
||||
phase: 70-receipt-shipping-cost
|
||||
plan: 01
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
files_modified:
|
||||
- src/Modules/Accounting/ReceiptService.php
|
||||
- src/Modules/Accounting/ReceiptController.php
|
||||
- resources/views/orders/receipt-create.php
|
||||
autonomous: true
|
||||
delegation: off
|
||||
---
|
||||
|
||||
<objective>
|
||||
## Goal
|
||||
Naprawic brak pozycji kosztu wysylki na paragonach. Aktualnie `buildItemsSnapshot()` iteruje tylko po produktach zamowienia, pomijajac `delivery_price` z tabeli orders.
|
||||
|
||||
## Purpose
|
||||
Paragony musza zawierac wszystkie pozycje kosztowe zamowienia, w tym koszt dostawy, aby byly zgodne z rzeczywista kwota zamowienia.
|
||||
|
||||
## Output
|
||||
- `ReceiptService::buildItemsSnapshot()` dodaje pozycje "Koszt wysylki" gdy `delivery_price > 0`
|
||||
- `ReceiptService::calculateTotalGross()` uwzglednia `delivery_price`
|
||||
- `ReceiptController::create()` przekazuje `delivery_price` do widoku i wlicza do `totalGross`
|
||||
- Widok `receipt-create.php` wyswietla wiersz kosztu wysylki w tabeli pozycji
|
||||
</objective>
|
||||
|
||||
<context>
|
||||
## Project Context
|
||||
@.paul/PROJECT.md
|
||||
@.paul/ROADMAP.md
|
||||
@.paul/STATE.md
|
||||
|
||||
## Source Files
|
||||
@src/Modules/Accounting/ReceiptService.php
|
||||
@src/Modules/Accounting/ReceiptController.php
|
||||
@resources/views/orders/receipt-create.php
|
||||
@src/Modules/Orders/OrdersRepository.php (findDetails zwraca SELECT o.* wiec delivery_price jest dostepne)
|
||||
</context>
|
||||
|
||||
<acceptance_criteria>
|
||||
|
||||
## AC-1: Koszt wysylki jako pozycja paragonu
|
||||
```gherkin
|
||||
Given zamowienie z delivery_price = 15.00 i produktami
|
||||
When uzytkownik wystawia paragon
|
||||
Then paragon zawiera dodatkowa pozycje "Koszt wysylki" z cena 15.00 i iloscia 1
|
||||
And total_gross paragonu zawiera sume produktow + 15.00
|
||||
```
|
||||
|
||||
## AC-2: Brak pozycji wysylki gdy delivery_price = 0 lub NULL
|
||||
```gherkin
|
||||
Given zamowienie z delivery_price = 0 lub NULL
|
||||
When uzytkownik wystawia paragon
|
||||
Then paragon NIE zawiera pozycji "Koszt wysylki"
|
||||
And total_gross paragonu zawiera tylko sume produktow
|
||||
```
|
||||
|
||||
## AC-3: Podglad formularza wystawienia paragonu
|
||||
```gherkin
|
||||
Given zamowienie z delivery_price > 0
|
||||
When uzytkownik otwiera formularz wystawienia paragonu
|
||||
Then tabela pozycji wyswietla wiersz "Koszt wysylki" z prawidlowa kwota
|
||||
And suma w stopce tabeli zawiera koszt wysylki
|
||||
```
|
||||
|
||||
</acceptance_criteria>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 1: Dodac koszt wysylki do buildItemsSnapshot i calculateTotalGross</name>
|
||||
<files>src/Modules/Accounting/ReceiptService.php</files>
|
||||
<action>
|
||||
1. Zmienic sygnature `buildItemsSnapshot()` na `buildItemsSnapshot(array $items, array $order)` — dodac parametr `$order`
|
||||
2. Po petli foreach nad produktami, sprawdzic `$order['delivery_price']`:
|
||||
- Jesli `delivery_price` istnieje i jest > 0, dodac pozycje do `$itemsSnapshot`:
|
||||
- name: "Koszt wysylki"
|
||||
- quantity: 1
|
||||
- price: (float) delivery_price
|
||||
- total: (float) delivery_price
|
||||
- sku: ''
|
||||
- ean: ''
|
||||
- Dodac wartosc do `$totalGross`
|
||||
3. Zaktualizowac wywolanie w `issue()` linia 64: `$this->buildItemsSnapshot($items, $order)`
|
||||
4. Zmienic `calculateTotalGross()` — dodac opcjonalny parametr `float $deliveryPrice = 0.0` i dodac go do sumy
|
||||
</action>
|
||||
<verify>Przegladnac kod — buildItemsSnapshot przyjmuje $order i dodaje wiersz wysylki</verify>
|
||||
<done>AC-1 i AC-2 satisfied: paragon zawiera/nie zawiera pozycji wysylki w zaleznosci od delivery_price</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Zaktualizowac kontroler i widok formularza</name>
|
||||
<files>src/Modules/Accounting/ReceiptController.php, resources/views/orders/receipt-create.php</files>
|
||||
<action>
|
||||
1. W `ReceiptController::create()`:
|
||||
- Pobrac delivery_price: `$deliveryPrice = (float) ($order['delivery_price'] ?? 0);`
|
||||
- Przekazac do `calculateTotalGross()`: `$totalGross = $this->receiptService->calculateTotalGross($items, $deliveryPrice);`
|
||||
- Przekazac `deliveryPrice` do widoku w tablicy render
|
||||
2. W `receipt-create.php`:
|
||||
- Po petli `foreach ($itemsList ...)` a przed zamknieciem `</tbody>`:
|
||||
- Dodac warunek: `if ($deliveryPrice > 0)`
|
||||
- Wyswietlic wiersz: Lp = count($itemsList)+1, nazwa "Koszt wysylki", qty 1, cena i suma = deliveryPrice
|
||||
- Na gorze widoku dodac: `$deliveryPrice = (float) ($deliveryPrice ?? 0);`
|
||||
</action>
|
||||
<verify>Otworzyc formularz wystawienia paragonu dla zamowienia z kosztem wysylki — wiersz "Koszt wysylki" widoczny w tabeli</verify>
|
||||
<done>AC-3 satisfied: formularz wyswietla pozycje kosztu wysylki</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<boundaries>
|
||||
|
||||
## DO NOT CHANGE
|
||||
- database/migrations/* (schemat bazy danych)
|
||||
- src/Modules/Orders/OrdersRepository.php (findDetails juz zwraca delivery_price)
|
||||
- resources/views/receipts/show.php, receipts/print.php (wyswietlaja dane z items_json — automatycznie pokaza nowa pozycje)
|
||||
|
||||
## SCOPE LIMITS
|
||||
- Nie dodawac obslugi VAT dla pozycji wysylki (paragony nie rozdzielajaja netto/brutto)
|
||||
- Nie zmieniac widokow podgladu/wydruku paragonu — one czytaja z items_json i automatycznie pokaza nowy wiersz
|
||||
|
||||
</boundaries>
|
||||
|
||||
<verification>
|
||||
Before declaring plan complete:
|
||||
- [ ] buildItemsSnapshot przyjmuje $order i dodaje pozycje wysylki gdy delivery_price > 0
|
||||
- [ ] calculateTotalGross uwzglednia delivery_price
|
||||
- [ ] Kontroler przekazuje deliveryPrice do widoku
|
||||
- [ ] Widok wyswietla wiersz "Koszt wysylki" warunkow
|
||||
- [ ] Brak bledow skladni PHP
|
||||
- [ ] Istniejace paragony (bez wysylki) nie sa naruszone
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- Paragon wystawiony dla zamowienia z delivery_price zawiera pozycje "Koszt wysylki"
|
||||
- Paragon wystawiony dla zamowienia bez delivery_price nie zawiera dodatkowej pozycji
|
||||
- Formularz wystawienia paragonu pokazuje koszt wysylki w tabeli
|
||||
- Total paragonu = suma produktow + koszt wysylki
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.paul/phases/70-receipt-shipping-cost/70-01-SUMMARY.md`
|
||||
</output>
|
||||
Reference in New Issue
Block a user