u
This commit is contained in:
@@ -931,6 +931,42 @@ CREATE INDEX IF NOT EXISTS IX_shipmentsummary_company_order
|
||||
ON shipmentsummary (company_id, order_id);
|
||||
`;
|
||||
|
||||
export const INIT_DELIVERYSUMMARY = `
|
||||
CREATE TABLE IF NOT EXISTS deliverysummary (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
company_id INTEGER NOT NULL,
|
||||
manifest_id INTEGER NOT NULL UNIQUE,
|
||||
delivery_number TEXT NOT NULL,
|
||||
external_number TEXT,
|
||||
delivery_date TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
|
||||
supplier_id INTEGER NULL,
|
||||
supplier_name TEXT NULL,
|
||||
positions INTEGER NOT NULL DEFAULT 0,
|
||||
gross_total REAL NOT NULL DEFAULT 0,
|
||||
net_total REAL NOT NULL DEFAULT 0,
|
||||
total_quantity REAL NOT NULL DEFAULT 0,
|
||||
stock_positions INTEGER NOT NULL DEFAULT 0,
|
||||
booked_positions INTEGER NOT NULL DEFAULT 0,
|
||||
unbooked_positions INTEGER NOT NULL DEFAULT 0,
|
||||
stock_quantity REAL NOT NULL DEFAULT 0,
|
||||
booked_quantity REAL NOT NULL DEFAULT 0,
|
||||
unbooked_quantity REAL NOT NULL DEFAULT 0,
|
||||
is_booked INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE NO ACTION,
|
||||
FOREIGN KEY (manifest_id) REFERENCES manifest(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (supplier_id) REFERENCES entity(id) ON DELETE SET NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS IX_deliverysummary_company_date
|
||||
ON deliverysummary (company_id, delivery_date DESC, manifest_id DESC);
|
||||
CREATE INDEX IF NOT EXISTS IX_deliverysummary_company_number
|
||||
ON deliverysummary (company_id, delivery_number);
|
||||
CREATE INDEX IF NOT EXISTS IX_deliverysummary_company_booked
|
||||
ON deliverysummary (company_id, is_booked);
|
||||
CREATE INDEX IF NOT EXISTS IX_deliverysummary_company_supplier
|
||||
ON deliverysummary (company_id, supplier_id);
|
||||
`;
|
||||
|
||||
export const INIT_MCP_CLIENT = `
|
||||
CREATE TABLE IF NOT EXISTS mcp_client (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -1042,6 +1078,7 @@ export const SCHEMA_SCRIPTS = [
|
||||
INIT_ORDERSUMMARY,
|
||||
INIT_QUOTESUMMARY,
|
||||
INIT_SHIPMENTSUMMARY,
|
||||
INIT_DELIVERYSUMMARY,
|
||||
INIT_MCP_CLIENT,
|
||||
INIT_MCP_AUTH_CODE,
|
||||
INIT_MCP_TOKEN,
|
||||
|
||||
Reference in New Issue
Block a user