Sync up POs with receivings, fix and optimize PO import, show total time

This commit is contained in:
2025-01-26 22:31:32 -05:00
parent 5cbc2152a1
commit 7c7c27a71c
2 changed files with 283 additions and 77 deletions

View File

@@ -135,18 +135,22 @@ CREATE TABLE purchase_orders (
pid BIGINT NOT NULL,
sku VARCHAR(50) NOT NULL,
cost_price DECIMAL(10, 3) NOT NULL,
status VARCHAR(20) DEFAULT 'pending' COMMENT 'canceled,created,electronically_ready_send,ordered,preordered,electronically_sent,receiving_started,closed',
status TINYINT UNSIGNED DEFAULT 1 COMMENT '0=canceled,1=created,10=electronically_ready_send,11=ordered,12=preordered,13=electronically_sent,15=receiving_started,50=done',
receiving_status TINYINT UNSIGNED DEFAULT 1 COMMENT '0=canceled,1=created,30=partial_received,40=full_received,50=paid',
notes TEXT,
long_note TEXT,
ordered INT NOT NULL,
received INT DEFAULT 0,
received_date DATE,
received_date DATE COMMENT 'Date of first receiving',
last_received_date DATE COMMENT 'Date of most recent receiving',
received_by INT,
receiving_history JSON COMMENT 'Array of receiving records with qty, date, cost, receiving_id, and alt_po flag',
FOREIGN KEY (pid) REFERENCES products(pid),
FOREIGN KEY (sku) REFERENCES products(SKU),
INDEX idx_po_id (po_id),
INDEX idx_vendor (vendor),
INDEX idx_status (status),
INDEX idx_receiving_status (receiving_status),
INDEX idx_purchase_orders_metrics (pid, date, status, ordered, received),
INDEX idx_po_product_date (pid, date),
INDEX idx_po_product_status (pid, status),