This commit is contained in:
seb
2026-10-07 16:46:41 +02:00
parent 95ef6f2dd1
commit e02bbd65c5
18 changed files with 78 additions and 176 deletions

View File

@@ -562,14 +562,12 @@ SELECT
asup.pu,
asup.stock,
asup.sort,
asup.price_id AS priceId,
p.net AS [price.net],
p.tax_id AS [price.taxId],
asup.net AS [price.net],
asup.tax_id AS [price.taxId],
t.rate AS [price.taxRate]
FROM articlesupplier asup
INNER JOIN entity e ON e.id = asup.entity_id
LEFT JOIN price p ON p.id = asup.price_id
LEFT JOIN tax t ON t.id = p.tax_id
LEFT JOIN tax t ON t.id = asup.tax_id
WHERE asup.article_id = a.id
ORDER BY asup.sort ASC, asup.id ASC
FOR JSON PATH

View File

@@ -8,15 +8,13 @@ SELECT
asup.pu,
asup.stock,
asup.sort,
asup.price_id AS priceId,
p.net AS priceNet,
p.tax_id AS priceTaxId,
asup.net AS priceNet,
asup.tax_id AS priceTaxId,
t.rate AS priceTaxRate
FROM articlesupplier asup
INNER JOIN entity e ON e.id = asup.entity_id
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
LEFT JOIN price p ON p.id = asup.price_id
LEFT JOIN tax t ON t.id = p.tax_id
LEFT JOIN tax t ON t.id = asup.tax_id
WHERE asup.article_id = @articleId
AND cg.company_id = @companyId
ORDER BY asup.sort ASC, asup.id ASC;
@@ -32,15 +30,13 @@ SELECT
asup.pu,
asup.stock,
asup.sort,
asup.price_id AS priceId,
p.net AS priceNet,
p.tax_id AS priceTaxId,
asup.net AS priceNet,
asup.tax_id AS priceTaxId,
t.rate AS priceTaxRate
FROM articlesupplier asup
INNER JOIN entity e ON e.id = asup.entity_id
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
LEFT JOIN price p ON p.id = asup.price_id
LEFT JOIN tax t ON t.id = p.tax_id
LEFT JOIN tax t ON t.id = asup.tax_id
WHERE asup.id = @id
AND asup.article_id = @articleId
AND cg.company_id = @companyId;
@@ -59,9 +55,9 @@ WHERE article_id = @articleId;
`;
export const CREATE = `
INSERT INTO articlesupplier (article_id, entity_id, price_id, sku, stock, pu, sort)
INSERT INTO articlesupplier (article_id, entity_id, net, tax_id, sku, stock, pu, sort)
OUTPUT INSERTED.id
VALUES (@articleId, @entityId, @priceId, @sku, @stock, @pu, @sort);
VALUES (@articleId, @entityId, @net, @taxId, @sku, @stock, @pu, @sort);
`;
export const UPDATE = `
@@ -70,7 +66,8 @@ SET
sku = @sku,
stock = @stock,
pu = @pu,
price_id = @priceId,
net = @net,
tax_id = @taxId,
sort = @sort
WHERE id = @id AND article_id = @articleId;
`;
@@ -99,19 +96,6 @@ SET sort = @sort
WHERE id = @id AND article_id = @articleId;
`;
export const UPDATE_PRICE = `
UPDATE price
SET
net = @net,
tax_id = @taxId
WHERE id = @id AND article_id = @articleId;
`;
export const DELETE_PRICE = `
DELETE FROM price
WHERE id = @id AND article_id = @articleId;
`;
export const GET_COMPANY_DEFAULT_TAX = `
SELECT taxrate
FROM company
@@ -128,9 +112,8 @@ SELECT
asup.pu,
asup.stock,
asup.sort,
asup.price_id AS priceId,
p.net AS priceNet,
p.tax_id AS priceTaxId,
asup.net AS priceNet,
asup.tax_id AS priceTaxId,
t.rate AS priceTaxRate,
a.id AS a_id,
a.sku AS a_sku,
@@ -161,8 +144,7 @@ INNER JOIN entity e ON e.id = asup.entity_id
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
INNER JOIN article a ON a.id = asup.article_id
LEFT JOIN articletext at ON at.article_id = a.id AND at.language_id = @languageId
LEFT JOIN price p ON p.id = asup.price_id
LEFT JOIN tax t ON t.id = p.tax_id
LEFT JOIN tax t ON t.id = asup.tax_id
WHERE asup.entity_id = @entityId
AND cg.company_id = @companyId
AND (