Add POS terminal category visibility system
Add posterminal and posterminalcategory tables to control which categories are visible on each POS terminal. The existence of a row in posterminalcategory means the category is visible on that terminal. Store methods: - posterminal.list/upsert/delete - CRUD for terminals - posterminal.setOn/setOff - toggle single category on a terminal - posterminal.setOnAll/setOffAll - toggle all categories on a terminal - posterminal.getCategoryPosterminalIds - internal, used by category tree The category tree (getTreeForCompany) now includes a posterminalIds array on each node listing which terminals have that category enabled.
This commit is contained in:
@@ -568,6 +568,34 @@ BEGIN
|
||||
END
|
||||
`;
|
||||
|
||||
export const INIT_POSTERMINAL = `
|
||||
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'posterminal')
|
||||
BEGIN
|
||||
CREATE TABLE posterminal (
|
||||
id INT IDENTITY(1,1) PRIMARY KEY,
|
||||
company_id INT NOT NULL,
|
||||
token NVARCHAR(255) NULL,
|
||||
pairingpin NVARCHAR(50) NOT NULL,
|
||||
CONSTRAINT FK_posterminal_company FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE,
|
||||
CONSTRAINT UQ_posterminal_token UNIQUE (token)
|
||||
);
|
||||
END
|
||||
`;
|
||||
|
||||
export const INIT_POSTERMINALCATEGORY = `
|
||||
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'posterminalcategory')
|
||||
BEGIN
|
||||
CREATE TABLE posterminalcategory (
|
||||
id INT IDENTITY(1,1) PRIMARY KEY,
|
||||
posterminal_id INT NOT NULL,
|
||||
category_id INT NOT NULL,
|
||||
CONSTRAINT FK_posterminalcategory_posterminal FOREIGN KEY (posterminal_id) REFERENCES posterminal(id) ON DELETE CASCADE,
|
||||
CONSTRAINT FK_posterminalcategory_category FOREIGN KEY (category_id) REFERENCES category(id) ON DELETE NO ACTION,
|
||||
CONSTRAINT UQ_posterminalcategory_posterminal_category UNIQUE (posterminal_id, category_id)
|
||||
);
|
||||
END
|
||||
`;
|
||||
|
||||
/** DDL scripts in dependency order for schema init. */
|
||||
export const SCHEMA_SCRIPTS = [
|
||||
INIT_META,
|
||||
@@ -604,4 +632,6 @@ export const SCHEMA_SCRIPTS = [
|
||||
INIT_COMPANYUSER,
|
||||
INIT_SYNCPOS,
|
||||
INIT_COMPANYSETTING,
|
||||
INIT_POSTERMINAL,
|
||||
INIT_POSTERMINALCATEGORY,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user