---
phase: 70-receipt-shipping-cost
plan: 01
subsystem: accounting
tags: [receipts, delivery, shipping-cost]

requires:
  - phase: 10-receipt-issuing
    provides: ReceiptService, buildItemsSnapshot, receipt creation flow
provides:
  - Shipping cost included as receipt line item
  - delivery_price reflected in receipt total
affects: []

tech-stack:
  added: []
  patterns: []

key-files:
  created: []
  modified:
    - src/Modules/Accounting/ReceiptService.php
    - src/Modules/Accounting/ReceiptController.php
    - resources/views/orders/receipt-create.php

key-decisions:
  - "Shipping cost added as regular line item in items_json (same structure as product items)"

patterns-established: []

duration: 5min
started: 2026-04-06T00:00:00Z
completed: 2026-04-06T00:05:00Z
---

# Phase 70 Plan 01: Receipt Shipping Cost Summary

**Bugfix: paragony zawieraja teraz pozycje "Koszt wysylki" gdy zamowienie ma delivery_price > 0**

## Performance

| Metric | Value |
|--------|-------|
| Duration | ~5min |
| Tasks | 2 completed |
| Files modified | 3 |

## Acceptance Criteria Results

| Criterion | Status | Notes |
|-----------|--------|-------|
| AC-1: Koszt wysylki jako pozycja paragonu | Pass | buildItemsSnapshot dodaje wiersz gdy delivery_price > 0 |
| AC-2: Brak pozycji wysylki gdy delivery_price = 0/NULL | Pass | Warunek `if ($deliveryPrice > 0)` chroni |
| AC-3: Podglad formularza wystawienia paragonu | Pass | Widok wyswietla wiersz "Koszt wysylki" warunkowo |

## Accomplishments

- `buildItemsSnapshot()` rozszerzony o parametr `$order` — dodaje pozycje "Koszt wysylki" do snapshot i total
- `calculateTotalGross()` rozszerzony o opcjonalny `$deliveryPrice` — kontroler przekazuje wartosc do widoku
- Widok `receipt-create.php` wyswietla wiersz kosztu wysylki w tabeli pozycji

## Files Created/Modified

| File | Change | Purpose |
|------|--------|---------|
| `src/Modules/Accounting/ReceiptService.php` | Modified | buildItemsSnapshot($items, $order) + calculateTotalGross($items, $deliveryPrice) |
| `src/Modules/Accounting/ReceiptController.php` | Modified | Przekazuje deliveryPrice do widoku i calculateTotalGross |
| `resources/views/orders/receipt-create.php` | Modified | Warunkowy wiersz "Koszt wysylki" w tabeli pozycji |

## Decisions Made

| Decision | Rationale | Impact |
|----------|-----------|--------|
| Koszt wysylki jako zwykly item w items_json | Taka sama struktura jak produkty — widoki show/print automatycznie pokaza nowa pozycje | Brak zmian w widokach podgladu/wydruku paragonu |

## Deviations from Plan

None — plan executed exactly as written.

## Issues Encountered

None.

## Next Phase Readiness

**Ready:**
- Istniejace widoki podgladu/wydruku paragonow czytaja z items_json i automatycznie pokaza pozycje wysylki

**Concerns:**
- None

**Blockers:**
- None

---
*Phase: 70-receipt-shipping-cost, Plan: 01*
*Completed: 2026-04-06*
