refactor: refs #8106 Requested changes
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-10-18 07:15:26 +02:00
parent 28e957fecd
commit 865da7bba2
1 changed files with 15 additions and 20 deletions

View File

@ -36,8 +36,7 @@ BEGIN
(PRIMARY KEY (ticketFk, code, rate))
ENGINE = MEMORY
WITH sales AS (
SELECT s.id,
s.ticketFk,
SELECT s.ticketFk,
s.itemFk,
s.quantity * s.price * (100 - s.discount) / 100 total,
t.companyFk,
@ -54,8 +53,7 @@ BEGIN
JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk
AND itc.countryFk = su.countryFk
HAVING total
),
ticketTax AS (
)
SELECT s.ticketFk,
bp.pgcFk,
SUM(s.total) taxableBase,
@ -70,9 +68,6 @@ BEGIN
JOIN vn.taxClass tc ON tc.id = bp.taxClassFk
GROUP BY s.ticketFk, pgc.code, pgc.rate
HAVING taxableBase
)
SELECT *
FROM ticketTax
ORDER BY priority;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax