Add supplier CRUD on entity with Lieferanten group and entityhistory
This commit is contained in:
@@ -15,3 +15,9 @@ UPDATE customergroup
|
||||
SET company_id = @companyId
|
||||
WHERE id = @id
|
||||
`;
|
||||
|
||||
export const GET_BY_COMPANY_AND_NAME = `
|
||||
SELECT id
|
||||
FROM customergroup
|
||||
WHERE company_id = @companyId AND name = @name
|
||||
`;
|
||||
|
||||
59
src/sql/entity.js
Normal file
59
src/sql/entity.js
Normal file
@@ -0,0 +1,59 @@
|
||||
export const SUPPLIER_GROUP_NAME = 'Lieferanten';
|
||||
|
||||
export const LIST_SUPPLIERS_BY_COMPANY = `
|
||||
SELECT
|
||||
e.id,
|
||||
e.name,
|
||||
e.created_at AS createdAt,
|
||||
e.updated_at AS updatedAt
|
||||
FROM entity e
|
||||
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
|
||||
WHERE cg.company_id = @companyId
|
||||
AND cg.name = @groupName
|
||||
ORDER BY e.name, e.id
|
||||
`;
|
||||
|
||||
export const GET_SUPPLIER_BY_ID = `
|
||||
SELECT
|
||||
e.id,
|
||||
e.name,
|
||||
e.created_at AS createdAt,
|
||||
e.updated_at AS updatedAt
|
||||
FROM entity e
|
||||
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
|
||||
WHERE e.id = @id
|
||||
AND cg.company_id = @companyId
|
||||
AND cg.name = @groupName
|
||||
`;
|
||||
|
||||
export const CREATE = `
|
||||
INSERT INTO entity (customergroup_id, name)
|
||||
OUTPUT INSERTED.id, INSERTED.name, INSERTED.created_at AS createdAt, INSERTED.updated_at AS updatedAt
|
||||
VALUES (@customergroupId, @name)
|
||||
`;
|
||||
|
||||
export const UPDATE_NAME = `
|
||||
UPDATE entity
|
||||
SET name = @name, updated_at = SYSUTCDATETIME()
|
||||
OUTPUT INSERTED.id, INSERTED.name, INSERTED.created_at AS createdAt, INSERTED.updated_at AS updatedAt
|
||||
WHERE id = @id
|
||||
AND customergroup_id = @customergroupId
|
||||
`;
|
||||
|
||||
export const DELETE_BY_ID = `
|
||||
DELETE e
|
||||
FROM entity e
|
||||
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
|
||||
WHERE e.id = @id
|
||||
AND cg.company_id = @companyId
|
||||
AND cg.name = @groupName
|
||||
`;
|
||||
|
||||
export const GET_GROUP_ID_FOR_SUPPLIER = `
|
||||
SELECT e.customergroup_id AS customergroupId, e.name
|
||||
FROM entity e
|
||||
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
|
||||
WHERE e.id = @id
|
||||
AND cg.company_id = @companyId
|
||||
AND cg.name = @groupName
|
||||
`;
|
||||
11
src/sql/entityhistory.js
Normal file
11
src/sql/entityhistory.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export const INSERT = `
|
||||
INSERT INTO entityhistory (entity_id, companyuser_id, [text])
|
||||
VALUES (@entityId, @companyuserId, @text)
|
||||
`;
|
||||
|
||||
export const LIST_BY_ENTITY_ID = `
|
||||
SELECT id, companyuser_id AS companyuserId, [date], [text]
|
||||
FROM entityhistory
|
||||
WHERE entity_id = @entityId
|
||||
ORDER BY [date] DESC, id DESC
|
||||
`;
|
||||
@@ -19,6 +19,7 @@ export const TABLES = [
|
||||
'articlepic',
|
||||
'articleean',
|
||||
'articlehistory',
|
||||
'entityhistory',
|
||||
'article',
|
||||
'brand',
|
||||
'articlelist',
|
||||
|
||||
Reference in New Issue
Block a user