Phase 08 — DB Foundation: - 3 new tables: receipt_configs, receipts, receipt_number_counters - company_settings extended with BDO, REGON, KRS, logo fields Phase 09 — Receipt Config: - CRUD for receipt configurations (Settings > Accounting) - ReceiptConfigController + ReceiptConfigRepository Phase 10 — Receipt Issuing: - ReceiptRepository with atomic numbering (INSERT ON DUPLICATE KEY UPDATE) - ReceiptController with snapshot pattern (seller/buyer/items as JSON) - "Wystaw paragon" button in order view - Documents tab showing both receipts and marketplace documents - Activity log entry on receipt creation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
132 lines
4.5 KiB
Markdown
132 lines
4.5 KiB
Markdown
---
|
|
phase: 08-db-foundation
|
|
plan: 01
|
|
subsystem: database
|
|
tags: [mysql, migrations, receipts, company-settings]
|
|
|
|
requires: []
|
|
provides:
|
|
- receipt_configs table
|
|
- receipts table
|
|
- receipt_number_counters table
|
|
- company_settings extended fields (bdo, regon, krs, logo)
|
|
affects: [09-receipt-config, 10-receipt-issue, 11-receipt-print, 12-accounting-list]
|
|
|
|
tech-stack:
|
|
added: []
|
|
patterns: [snapshot-json-pattern for receipts]
|
|
|
|
key-files:
|
|
created:
|
|
- database/migrations/20260315_000050_create_receipt_configs_table.sql
|
|
- database/migrations/20260315_000051_create_receipts_table.sql
|
|
- database/migrations/20260315_000052_create_receipt_number_counters_table.sql
|
|
- database/migrations/20260315_000053_extend_company_settings_extra_fields.sql
|
|
modified:
|
|
- src/Modules/Settings/CompanySettingsRepository.php
|
|
- resources/views/settings/company.php
|
|
- DOCS/DB_SCHEMA.md
|
|
- DOCS/ARCHITECTURE.md
|
|
|
|
key-decisions:
|
|
- "receipts.order_id as BIGINT UNSIGNED (match orders.id type)"
|
|
- "receipts uses JSON snapshots for seller/buyer/items data"
|
|
- "receipt_configs ON DELETE RESTRICT (nie usuwaj konfiguracji z istniejacymi paragonami)"
|
|
|
|
patterns-established:
|
|
- "Snapshot pattern: dane sprzedawcy/nabywcy/pozycji zapisywane jako JSON w momencie wystawienia"
|
|
|
|
duration: ~15min
|
|
completed: 2026-03-15
|
|
---
|
|
|
|
# Phase 8 Plan 01: DB Foundation + Company Settings Summary
|
|
|
|
**Migracje bazodanowe dla modulu paragonow (3 nowe tabele) + rozszerzenie company_settings o BDO/REGON/KRS/logo.**
|
|
|
|
## Performance
|
|
|
|
| Metric | Value |
|
|
|--------|-------|
|
|
| Duration | ~15min |
|
|
| Completed | 2026-03-15 |
|
|
| Tasks | 4 completed |
|
|
| Files modified | 8 |
|
|
|
|
## Acceptance Criteria Results
|
|
|
|
| Criterion | Status | Notes |
|
|
|-----------|--------|-------|
|
|
| AC-1: Tabele paragonow istnieja po migracji | Pass | receipt_configs, receipts, receipt_number_counters utworzone |
|
|
| AC-2: Company settings rozszerzony | Pass | bdo_number, regon, court_register, logo_path dodane |
|
|
| AC-3: Formularz wyswietla i zapisuje nowe pola | Pass | Zweryfikowane manualnie przez uzytkownika |
|
|
| AC-4: Dokumentacja zaktualizowana | Pass | DB_SCHEMA.md i ARCHITECTURE.md zaktualizowane |
|
|
|
|
## Accomplishments
|
|
|
|
- 3 nowe tabele bazodanowe dla modulu paragonow (receipt_configs, receipts, receipt_number_counters)
|
|
- Rozszerzenie company_settings o 4 pola wymagane na dokumentach ksiegowych
|
|
- Formularz danych firmy zaktualizowany o nowe pola z pelnym zapisem/odczytem
|
|
|
|
## Files Created/Modified
|
|
|
|
| File | Change | Purpose |
|
|
|------|--------|---------|
|
|
| `database/migrations/20260315_000050_*.sql` | Created | Tabela receipt_configs |
|
|
| `database/migrations/20260315_000051_*.sql` | Created | Tabela receipts |
|
|
| `database/migrations/20260315_000052_*.sql` | Created | Tabela receipt_number_counters |
|
|
| `database/migrations/20260315_000053_*.sql` | Created | Rozszerzenie company_settings |
|
|
| `src/Modules/Settings/CompanySettingsRepository.php` | Modified | Dodano 4 nowe pola (get/save/defaults) |
|
|
| `resources/views/settings/company.php` | Modified | Dodano pola REGON, BDO, KRS, Logo |
|
|
| `DOCS/DB_SCHEMA.md` | Modified | Dokumentacja 3 nowych tabel + nowe kolumny |
|
|
| `DOCS/ARCHITECTURE.md` | Modified | Dodano modul Accounting (w budowie) |
|
|
|
|
## Decisions Made
|
|
|
|
| Decision | Rationale | Impact |
|
|
|----------|-----------|--------|
|
|
| receipts.order_id BIGINT UNSIGNED | orders.id jest BIGINT UNSIGNED — FK musi sie zgadzac | Fix bledu errno 150 |
|
|
| ON DELETE RESTRICT dla receipt_configs | Nie mozna usunac konfiguracji jesli istnieja paragony | Bezpieczenstwo danych |
|
|
| Logo jako sciezka tekstowa | Upload w przyszlosci, na razie pole tekstowe | Uproszczenie fazy 08 |
|
|
|
|
## Deviations from Plan
|
|
|
|
### Summary
|
|
|
|
| Type | Count | Impact |
|
|
|------|-------|--------|
|
|
| Auto-fixed | 1 | Krytyczny fix typu FK |
|
|
|
|
**Total impact:** Jeden fix krytyczny, brak scope creep.
|
|
|
|
### Auto-fixed Issues
|
|
|
|
**1. FK type mismatch receipts.order_id**
|
|
- **Found during:** Task 1 (migracje)
|
|
- **Issue:** receipts.order_id bylo INT UNSIGNED, orders.id jest BIGINT UNSIGNED
|
|
- **Fix:** Zmieniono na BIGINT UNSIGNED
|
|
- **Files:** database/migrations/20260315_000051_create_receipts_table.sql
|
|
- **Verification:** Migracja wykonana pomyslnie po poprawce
|
|
|
|
## Issues Encountered
|
|
|
|
| Issue | Resolution |
|
|
|-------|------------|
|
|
| errno 150 FK constraint | Poprawiono typ order_id z INT na BIGINT UNSIGNED |
|
|
|
|
## Next Phase Readiness
|
|
|
|
**Ready:**
|
|
- Tabele bazodanowe gotowe pod CRUD konfiguracji (faza 09)
|
|
- Company settings kompletne pod snapshot danych sprzedawcy
|
|
|
|
**Concerns:**
|
|
- Brak
|
|
|
|
**Blockers:**
|
|
- Brak
|
|
|
|
---
|
|
*Phase: 08-db-foundation, Plan: 01*
|
|
*Completed: 2026-03-15*
|