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>
24 lines
1.1 KiB
SQL
24 lines
1.1 KiB
SQL
CREATE TABLE IF NOT EXISTS `receipts` (
|
|
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
`order_id` BIGINT UNSIGNED NOT NULL,
|
|
`config_id` INT UNSIGNED NOT NULL,
|
|
`receipt_number` VARCHAR(64) NOT NULL,
|
|
`issue_date` DATE NOT NULL,
|
|
`sale_date` DATE NOT NULL,
|
|
`seller_data_json` JSON NOT NULL,
|
|
`buyer_data_json` JSON DEFAULT NULL,
|
|
`items_json` JSON NOT NULL,
|
|
`total_net` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
|
`total_gross` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
|
|
`order_reference_value` VARCHAR(128) DEFAULT NULL,
|
|
`created_by` INT UNSIGNED DEFAULT NULL,
|
|
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `receipts_number_unique` (`receipt_number`),
|
|
KEY `receipts_order_idx` (`order_id`),
|
|
KEY `receipts_config_idx` (`config_id`),
|
|
KEY `receipts_issue_date_idx` (`issue_date`),
|
|
CONSTRAINT `receipts_order_fk` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
CONSTRAINT `receipts_config_fk` FOREIGN KEY (`config_id`) REFERENCES `receipt_configs` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|