u
This commit is contained in:
@@ -1000,6 +1000,73 @@ CREATE INDEX IF NOT EXISTS IX_deliverysummary_company_supplier
|
||||
ON deliverysummary (company_id, supplier_id);
|
||||
`;
|
||||
|
||||
export const INIT_RETURNSUMMARY = `
|
||||
CREATE TABLE IF NOT EXISTS returnsummary (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
company_id INTEGER NOT NULL,
|
||||
manifest_id INTEGER NOT NULL UNIQUE,
|
||||
return_number TEXT NOT NULL,
|
||||
external_number TEXT,
|
||||
return_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_returnsummary_company_date
|
||||
ON returnsummary (company_id, return_date DESC, manifest_id DESC);
|
||||
CREATE INDEX IF NOT EXISTS IX_returnsummary_company_number
|
||||
ON returnsummary (company_id, return_number);
|
||||
CREATE INDEX IF NOT EXISTS IX_returnsummary_company_booked
|
||||
ON returnsummary (company_id, is_booked);
|
||||
CREATE INDEX IF NOT EXISTS IX_returnsummary_company_supplier
|
||||
ON returnsummary (company_id, supplier_id);
|
||||
`;
|
||||
|
||||
export const INIT_RETOURESUMMARY = `
|
||||
CREATE TABLE IF NOT EXISTS retouresummary (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
company_id INTEGER NOT NULL,
|
||||
manifest_id INTEGER NOT NULL UNIQUE,
|
||||
retoure_number TEXT NOT NULL,
|
||||
retoure_date TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
|
||||
entity_id INTEGER NULL,
|
||||
customer_name TEXT NULL,
|
||||
positions INTEGER NOT NULL DEFAULT 0,
|
||||
gross_total REAL NOT NULL DEFAULT 0,
|
||||
paid_total REAL NOT NULL DEFAULT 0,
|
||||
ordered_quantity REAL NOT NULL DEFAULT 0,
|
||||
shipped_quantity REAL NOT NULL DEFAULT 0,
|
||||
is_paid INTEGER NOT NULL DEFAULT 0,
|
||||
is_shipped 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 (entity_id) REFERENCES entity(id) ON DELETE SET NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS IX_retouresummary_company_date
|
||||
ON retouresummary (company_id, retoure_date DESC, manifest_id DESC);
|
||||
CREATE INDEX IF NOT EXISTS IX_retouresummary_company_shipped
|
||||
ON retouresummary (company_id, is_shipped);
|
||||
CREATE INDEX IF NOT EXISTS IX_retouresummary_company_paid
|
||||
ON retouresummary (company_id, is_paid);
|
||||
CREATE INDEX IF NOT EXISTS IX_retouresummary_company_number
|
||||
ON retouresummary (company_id, retoure_number);
|
||||
`;
|
||||
|
||||
export const INIT_ARTICLEWAREHOUSESUMMARY = `
|
||||
CREATE TABLE IF NOT EXISTS articlewarehousesummary (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -1153,6 +1220,8 @@ export const SCHEMA_SCRIPTS = [
|
||||
INIT_QUOTESUMMARY,
|
||||
INIT_SHIPMENTSUMMARY,
|
||||
INIT_DELIVERYSUMMARY,
|
||||
INIT_RETURNSUMMARY,
|
||||
INIT_RETOURESUMMARY,
|
||||
INIT_ARTICLEWAREHOUSESUMMARY,
|
||||
INIT_MCP_CLIENT,
|
||||
INIT_MCP_AUTH_CODE,
|
||||
|
||||
Reference in New Issue
Block a user