u
This commit is contained in:
@@ -17,6 +17,29 @@ WHERE id = @articleId
|
||||
`;
|
||||
|
||||
|
||||
export const CREATE_TOMBSTONE = `
|
||||
INSERT INTO articletombstone (company_id, article_id, sku, name, taxrate, net)
|
||||
SELECT
|
||||
a.company_id,
|
||||
a.id AS article_id,
|
||||
a.sku,
|
||||
COALESCE(
|
||||
(SELECT TOP 1 at.name FROM articletext at WHERE at.article_id = a.id AND at.language_id = co.default_language_id),
|
||||
(SELECT TOP 1 at.name FROM articletext at WHERE at.article_id = a.id ORDER BY at.id ASC)
|
||||
) AS name,
|
||||
COALESCE(
|
||||
(SELECT TOP 1 t.rate FROM price pr INNER JOIN tax t ON t.id = pr.tax_id WHERE pr.article_id = a.id AND pr.customergroup_id = co.poscustomergroup_id AND pr.minmultiplier = 1),
|
||||
(SELECT TOP 1 t.rate FROM price pr INNER JOIN tax t ON t.id = pr.tax_id WHERE pr.article_id = a.id ORDER BY pr.id ASC)
|
||||
) AS taxrate,
|
||||
COALESCE(
|
||||
(SELECT TOP 1 pr.net FROM price pr WHERE pr.article_id = a.id AND pr.customergroup_id = co.poscustomergroup_id AND pr.minmultiplier = 1),
|
||||
(SELECT TOP 1 pr.net FROM price pr WHERE pr.article_id = a.id ORDER BY pr.id ASC)
|
||||
) AS net
|
||||
FROM article a
|
||||
INNER JOIN company co ON co.id = a.company_id
|
||||
WHERE a.id = @articleId
|
||||
`;
|
||||
|
||||
export const DELETE_PICS_BY_ARTICLE = `
|
||||
DELETE p
|
||||
FROM pic p
|
||||
|
||||
@@ -9,3 +9,10 @@ FROM articlehistory
|
||||
WHERE article_id = @articleId
|
||||
ORDER BY [date] DESC, id DESC
|
||||
`;
|
||||
|
||||
export const LIST_BY_ARTICLE_ID_LIMITED = `
|
||||
SELECT TOP (@limit) id, companyuser_id AS companyuserId, [date], [text]
|
||||
FROM articlehistory
|
||||
WHERE article_id = @articleId
|
||||
ORDER BY [date] DESC, id DESC
|
||||
`;
|
||||
|
||||
@@ -8,3 +8,13 @@ UPDATE articletext
|
||||
SET name = @name, slug = @slug
|
||||
WHERE article_id = @articleId AND language_id = @languageId
|
||||
`;
|
||||
|
||||
export const LIST_SLUGS_BY_COMPANY_AND_LANGUAGE = `
|
||||
SELECT at.slug, at.article_id AS articleId
|
||||
FROM articletext at
|
||||
INNER JOIN article a ON a.id = at.article_id
|
||||
WHERE a.company_id = @companyId
|
||||
AND at.language_id = @languageId
|
||||
AND (at.slug = @baseSlug OR at.slug LIKE @likePattern)
|
||||
`;
|
||||
|
||||
|
||||
41
src/providers/mssql/queries/categoryattributevalue.js
Normal file
41
src/providers/mssql/queries/categoryattributevalue.js
Normal file
@@ -0,0 +1,41 @@
|
||||
export const LIST_BY_CATEGORY_ID = `
|
||||
SELECT
|
||||
cav.id,
|
||||
cav.category_id AS categoryId,
|
||||
an.id AS attributeId,
|
||||
an.name AS attributeName,
|
||||
an.exclusive,
|
||||
av.id AS attributeValueId,
|
||||
av.value,
|
||||
cav.sort
|
||||
FROM categoryattributevalue cav
|
||||
INNER JOIN attributevalue av ON av.id = cav.attributevalue_id
|
||||
INNER JOIN attributename an ON an.id = av.attribute_id
|
||||
WHERE cav.category_id = @categoryId
|
||||
ORDER BY an.sort ASC, an.id ASC, cav.sort ASC, cav.id ASC
|
||||
`;
|
||||
|
||||
export const DELETE_BY_CATEGORY_ID = `
|
||||
DELETE FROM categoryattributevalue
|
||||
WHERE category_id = @categoryId
|
||||
`;
|
||||
|
||||
export const INSERT_ROW = `
|
||||
INSERT INTO categoryattributevalue (category_id, attributevalue_id, sort)
|
||||
OUTPUT INSERTED.id, INSERTED.category_id AS categoryId, INSERTED.attributevalue_id AS attributeValueId, INSERTED.sort
|
||||
VALUES (@categoryId, @attributeValueId, @sort)
|
||||
`;
|
||||
|
||||
export const GET_VALUE_DETAIL = `
|
||||
SELECT
|
||||
av.id AS attributeValueId,
|
||||
av.value,
|
||||
av.sort,
|
||||
an.id AS attributeId,
|
||||
an.name AS attributeName,
|
||||
an.exclusive,
|
||||
an.company_id AS companyId
|
||||
FROM attributevalue av
|
||||
INNER JOIN attributename an ON an.id = av.attribute_id
|
||||
WHERE av.id = @attributeValueId
|
||||
`;
|
||||
30
src/providers/mssql/queries/categoryproperty.js
Normal file
30
src/providers/mssql/queries/categoryproperty.js
Normal file
@@ -0,0 +1,30 @@
|
||||
export const LIST_BY_CATEGORY_ID = `
|
||||
SELECT
|
||||
cp.id,
|
||||
cp.category_id AS categoryId,
|
||||
cp.property_id AS propertyId,
|
||||
pn.name AS name,
|
||||
pn.exclusive,
|
||||
cp.value,
|
||||
cp.sort
|
||||
FROM categoryproperty cp
|
||||
INNER JOIN propertyname pn ON pn.id = cp.property_id
|
||||
WHERE cp.category_id = @categoryId
|
||||
ORDER BY cp.sort ASC, cp.id ASC
|
||||
`;
|
||||
|
||||
export const DELETE_BY_CATEGORY_ID = `
|
||||
DELETE FROM categoryproperty
|
||||
WHERE category_id = @categoryId
|
||||
`;
|
||||
|
||||
export const DELETE_BY_CATEGORY_AND_PROPERTY_ID = `
|
||||
DELETE FROM categoryproperty
|
||||
WHERE category_id = @categoryId AND property_id = @propertyId
|
||||
`;
|
||||
|
||||
export const INSERT_ROW = `
|
||||
INSERT INTO categoryproperty (category_id, property_id, value, sort)
|
||||
OUTPUT INSERTED.id, INSERTED.category_id AS categoryId, INSERTED.property_id AS propertyId, INSERTED.value, INSERTED.sort
|
||||
VALUES (@categoryId, @propertyId, @value, @sort)
|
||||
`;
|
||||
@@ -108,3 +108,28 @@ VALUES (
|
||||
@taxrate
|
||||
)
|
||||
`;
|
||||
|
||||
export const CHECK_ARTICLE_IS_FATHER = `
|
||||
SELECT
|
||||
a.id,
|
||||
a.is_father AS isFather,
|
||||
COALESCE(
|
||||
(SELECT at.name FROM articletext at WHERE at.article_id = a.id AND at.language_id = co.default_language_id),
|
||||
(SELECT MIN(at2.name) FROM articletext at2 WHERE at2.article_id = a.id),
|
||||
a.sku
|
||||
) AS articleName,
|
||||
COALESCE(
|
||||
(SELECT MIN(asup.pu) FROM articlesupplier asup WHERE asup.article_id = a.id AND asup.sku = @sku),
|
||||
(SELECT MIN(asup2.pu) FROM articlesupplier asup2 WHERE asup2.article_id = a.id),
|
||||
a.unitamount,
|
||||
1
|
||||
) AS pu
|
||||
FROM article a
|
||||
INNER JOIN manifest m ON m.company_id = a.company_id
|
||||
INNER JOIN company co ON co.id = m.company_id
|
||||
WHERE m.id = @manifestId
|
||||
AND (a.sku = @sku OR EXISTS (
|
||||
SELECT 1 FROM articlesupplier asup WHERE asup.article_id = a.id AND asup.sku = @sku
|
||||
))
|
||||
`;
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ SELECT
|
||||
token,
|
||||
pairingpin,
|
||||
paired_at AS pairedAt,
|
||||
clientserial AS clientserial
|
||||
clientserial AS clientserial,
|
||||
maxknowntombstoneid AS maxknowntombstoneid
|
||||
FROM posterminal
|
||||
WHERE company_id = @companyId
|
||||
ORDER BY id
|
||||
@@ -19,7 +20,8 @@ SELECT
|
||||
token,
|
||||
pairingpin,
|
||||
paired_at AS pairedAt,
|
||||
clientserial AS clientserial
|
||||
clientserial AS clientserial,
|
||||
maxknowntombstoneid AS maxknowntombstoneid
|
||||
FROM posterminal
|
||||
WHERE id = @id
|
||||
`;
|
||||
@@ -32,7 +34,8 @@ SELECT
|
||||
token,
|
||||
pairingpin,
|
||||
paired_at AS pairedAt,
|
||||
clientserial AS clientserial
|
||||
clientserial AS clientserial,
|
||||
maxknowntombstoneid AS maxknowntombstoneid
|
||||
FROM posterminal
|
||||
WHERE pairingpin = @pairingpin
|
||||
`;
|
||||
@@ -44,17 +47,23 @@ WHERE id = @id
|
||||
`;
|
||||
|
||||
export const CREATE = `
|
||||
INSERT INTO posterminal (company_id, name, token, pairingpin, paired_at, clientserial)
|
||||
OUTPUT INSERTED.id, INSERTED.name, INSERTED.token, INSERTED.pairingpin, INSERTED.paired_at AS pairedAt, INSERTED.clientserial AS clientserial
|
||||
VALUES (@companyId, @name, @token, @pairingpin, @pairedAt, @clientserial)
|
||||
INSERT INTO posterminal (company_id, name, token, pairingpin, paired_at, clientserial, maxknowntombstoneid)
|
||||
OUTPUT INSERTED.id, INSERTED.name, INSERTED.token, INSERTED.pairingpin, INSERTED.paired_at AS pairedAt, INSERTED.clientserial AS clientserial, INSERTED.maxknowntombstoneid AS maxknowntombstoneid
|
||||
VALUES (@companyId, @name, @token, @pairingpin, @pairedAt, @clientserial, @maxknowntombstoneid)
|
||||
`;
|
||||
|
||||
export const UPDATE = `
|
||||
UPDATE posterminal
|
||||
SET name = @name, token = @token, pairingpin = @pairingpin, paired_at = @pairedAt, clientserial = @clientserial
|
||||
SET name = @name, token = @token, pairingpin = @pairingpin, paired_at = @pairedAt, clientserial = @clientserial, maxknowntombstoneid = @maxknowntombstoneid
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const SET_MAX_KNOWN_TOMBSTONE_ID = `
|
||||
UPDATE posterminal
|
||||
SET maxknowntombstoneid = @maxknowntombstoneid
|
||||
WHERE id = @id
|
||||
`;
|
||||
|
||||
export const DELETE_BY_COMPANY_AND_ID = `
|
||||
DELETE FROM posterminal
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
@@ -122,7 +131,8 @@ SELECT
|
||||
token,
|
||||
pairingpin,
|
||||
paired_at AS pairedAt,
|
||||
clientserial AS clientserial
|
||||
clientserial AS clientserial,
|
||||
maxknowntombstoneid AS maxknowntombstoneid
|
||||
FROM posterminal
|
||||
WHERE token = @token
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user