Erfasse Shopify-Bestellungen trotz Fehlbestand
This commit is contained in:
1 parent
ba23c58dea
commit
ed8927b37d
7 files changed
+266
-31
No files matched your search
@@ -10,6 +10,7 @@
|
||||
6. `db/migrations/0006_phase1_otc_products.sql`
|
||||
7. `db/migrations/0007_phase1_excel_webhook.sql`
|
||||
8. `db/migrations/0008_shopify_sync_technical.sql`
|
||||
9. `db/migrations/0013_virtual_shortage_lot_allocations.sql`
|
||||
|
||||
## Beispielausfuehrung
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
-- Keep order capture independent from physical stock availability.
|
||||
|
||||
ALTER TABLE stock_lot
|
||||
DROP CONSTRAINT IF EXISTS chk_stock_lot_status;
|
||||
|
||||
ALTER TABLE stock_lot
|
||||
ADD CONSTRAINT chk_stock_lot_status
|
||||
CHECK (status IN ('open', 'current', 'closed', 'virtual_shortage'));
|
||||
|
||||
ALTER TABLE stock_lot
|
||||
DROP CONSTRAINT IF EXISTS chk_stock_lot_number_required_for_non_open;
|
||||
|
||||
ALTER TABLE stock_lot
|
||||
ADD CONSTRAINT chk_stock_lot_number_required_for_non_open
|
||||
CHECK (status = 'open' OR lot_number IS NOT NULL);
|
||||
|
||||
CREATE TABLE stock_lot_allocation_replacement (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
from_allocation_id BIGINT NOT NULL REFERENCES sales_order_line_lot_allocation(id) ON DELETE RESTRICT,
|
||||
to_allocation_id BIGINT NOT NULL REFERENCES sales_order_line_lot_allocation(id) ON DELETE RESTRICT,
|
||||
from_lot_id BIGINT NOT NULL REFERENCES stock_lot(id) ON DELETE RESTRICT,
|
||||
to_lot_id BIGINT NOT NULL REFERENCES stock_lot(id) ON DELETE RESTRICT,
|
||||
product_id BIGINT NOT NULL REFERENCES product(id) ON DELETE RESTRICT,
|
||||
qty NUMERIC(14, 4) NOT NULL,
|
||||
changed_by TEXT NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT chk_stock_lot_allocation_replacement_qty_positive CHECK (qty > 0),
|
||||
CONSTRAINT chk_stock_lot_allocation_replacement_distinct_lots CHECK (from_lot_id <> to_lot_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_stock_lot_allocation_replacement_from
|
||||
ON stock_lot_allocation_replacement(from_allocation_id);
|
||||
CREATE INDEX idx_stock_lot_allocation_replacement_to
|
||||
ON stock_lot_allocation_replacement(to_allocation_id);
|
||||
Reference in new issue
Block a user