feat(Ticket): refs #7984 add currency
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
55c8e191f9
commit
630836cd8e
|
@ -54,16 +54,10 @@ BEGIN
|
|||
WHERE tp.id IS NULL
|
||||
HAVING resto <> 0) t;
|
||||
|
||||
IF vCode <> 'renewPrices' THEN
|
||||
REPLACE INTO saleComponent(saleFk, componentFk, value)
|
||||
SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif
|
||||
FROM sale s
|
||||
JOIN tmp.sale tmps ON tmps.saleFk = s.id
|
||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE sc.saleFk <> vComponentFk
|
||||
GROUP BY s.id
|
||||
HAVING dif <> 0;
|
||||
ELSE
|
||||
IF vCode = 'renewPrices' THEN
|
||||
SET vComponentFk = 21;
|
||||
END IF;
|
||||
|
||||
UPDATE sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN item i on i.id = s.itemFk
|
||||
|
@ -72,19 +66,18 @@ BEGIN
|
|||
FROM saleComponent sc
|
||||
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
|
||||
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
|
||||
SET s.price = sumValue / ((100 - s.discount) / 100),
|
||||
SET s.price = IF(vCode <> 'renewPrices', sumValue / ((100 - s.discount) / 100), s.price),
|
||||
s.foreignPrice = currency_getRate(t.currencyFk, NULL) * (sumValue / ((100 - s.discount) / 100))
|
||||
WHERE it.code <> 'PRT' ;
|
||||
|
||||
REPLACE INTO saleComponent(saleFk, componentFk, value)
|
||||
SELECT s.id, 21, ROUND((s.price * (100 - s.discount) / 100) - SUM(value), 3) saleValue
|
||||
SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif
|
||||
FROM sale s
|
||||
JOIN tmp.sale tmps ON tmps.saleFk = s.id
|
||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE sc.componentFk <> 21
|
||||
WHERE sc.saleFk <> vComponentFk
|
||||
GROUP BY s.id
|
||||
HAVING ROUND(saleValue, 4) <> 0;
|
||||
END IF;
|
||||
HAVING dif <> 0;
|
||||
|
||||
UPDATE sale s
|
||||
JOIN (
|
||||
|
|
|
@ -26,6 +26,7 @@ BEGIN
|
|||
i.category,
|
||||
IFNULL(s.quantity, 0) quantity,
|
||||
IFNULL(s.price, 0) price,
|
||||
IFNULL(s.foreignPrice, 0) foreignPrice,
|
||||
ROUND(SUM(tc.cost), 2) newPrice,
|
||||
s.id saleFk
|
||||
FROM vn.sale s
|
||||
|
@ -42,10 +43,9 @@ BEGIN
|
|||
GROUP BY s.id ORDER BY s.id
|
||||
) SELECT
|
||||
*,
|
||||
currency_getRate(vCurrencyFk, NULL) * price foreignPrice,
|
||||
currency_getRate(vCurrencyFk, NULL) * newPrice newForeignPrice,
|
||||
quantity * (price - newPrice) difference,
|
||||
currency_getRate(vCurrencyFk, NULL) * quantity * (price - newPrice) foreignDifference
|
||||
quantity * (foreignPrice - currency_getRate(vCurrencyFk, NULL) * newPrice) foreignDifference
|
||||
FROM ticketPriceDifference;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticketComponentPreview;
|
||||
|
|
|
@ -240,6 +240,7 @@ module.exports = Self => {
|
|||
t.clientFk,
|
||||
t.totalWithoutVat,
|
||||
t.totalWithVat,
|
||||
t.foreignTotalWithVat,
|
||||
io.id invoiceOutId,
|
||||
a.provinceFk,
|
||||
p.name province,
|
||||
|
@ -266,7 +267,8 @@ module.exports = Self => {
|
|||
JOIN item i2 ON i2.id = s2.itemFk
|
||||
WHERE s2.ticketFk = t.id
|
||||
) AS packing,
|
||||
c.credit
|
||||
c.credit,
|
||||
cu.code currencyCode
|
||||
FROM ticket t
|
||||
LEFT JOIN invoiceOut io ON t.refFk = io.ref
|
||||
LEFT JOIN zone z ON z.id = t.zoneFk
|
||||
|
@ -280,6 +282,7 @@ module.exports = Self => {
|
|||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||
LEFT JOIN account.user u ON u.id = wk.id
|
||||
LEFT JOIN route r ON r.id = t.routeFk
|
||||
JOIN currency cu ON cu.id = t.currencyFk
|
||||
`);
|
||||
|
||||
if (args.orderFk) {
|
||||
|
|
|
@ -103,7 +103,8 @@ module.exports = Self => {
|
|||
scope: {
|
||||
fields: ['id']
|
||||
}
|
||||
}
|
||||
},
|
||||
{relation: 'currency'}
|
||||
],
|
||||
where: {id: ticketFk}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue