72 lines
1.5 KiB
JavaScript
72 lines
1.5 KiB
JavaScript
export const GET_BY_NAME = `
|
|
SELECT id, name, root_category_id, default_language_id, taxrate, reducedtaxrate, taxfreerate
|
|
FROM company
|
|
WHERE name = @name
|
|
`;
|
|
|
|
export const GET_BY_ID = `
|
|
SELECT id, name, root_category_id, default_language_id, taxrate, reducedtaxrate, taxfreerate
|
|
FROM company
|
|
WHERE id = @id
|
|
`;
|
|
|
|
export const GET_COMPANY_ROOT_CATEGORY = `
|
|
SELECT root_category_id AS rootCategoryId FROM company WHERE id = @companyId
|
|
`;
|
|
|
|
export const CREATE = `
|
|
INSERT INTO company (
|
|
name,
|
|
root_category_id,
|
|
default_language_id,
|
|
taxrate,
|
|
reducedtaxrate,
|
|
taxfreerate,
|
|
poscustomergroup_id
|
|
)
|
|
OUTPUT INSERTED.id
|
|
VALUES (
|
|
@name,
|
|
@rootCategoryId,
|
|
@languageId,
|
|
@taxrate,
|
|
@reducedtaxrate,
|
|
@taxfreerate,
|
|
@posCustomerGroupId
|
|
)
|
|
`;
|
|
|
|
export const UPDATE = `
|
|
UPDATE company
|
|
SET
|
|
name = @name,
|
|
default_language_id = @languageId,
|
|
taxrate = @taxrate,
|
|
reducedtaxrate = @reducedtaxrate
|
|
WHERE id = @id
|
|
`;
|
|
|
|
export const LIST = `
|
|
SELECT
|
|
c.id,
|
|
c.name,
|
|
c.root_category_id AS rootCategoryId,
|
|
c.default_language_id AS languageId,
|
|
l.iso639,
|
|
tr.rate AS taxrate,
|
|
rtr.rate AS reducedtaxrate,
|
|
tfr.rate AS taxfreerate
|
|
FROM company c
|
|
INNER JOIN companyuser cu ON cu.company_id = c.id
|
|
LEFT JOIN language l ON l.id = c.default_language_id
|
|
LEFT JOIN tax tr ON tr.id = c.taxrate
|
|
LEFT JOIN tax rtr ON rtr.id = c.reducedtaxrate
|
|
LEFT JOIN tax tfr ON tfr.id = c.taxfreerate
|
|
WHERE cu.google_auth_id = @googleAuthId
|
|
`;
|
|
|
|
export const DELETE = `
|
|
DELETE FROM company
|
|
WHERE id = @companyId
|
|
`;
|