From ac45a2ba264d3853388744f3a612af2c2aa7ea36 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sat, 20 Dec 2025 15:03:03 +0100 Subject: [PATCH] Refactor SQL joins in calcRegionalSellPrice function of FalukantService to use updated region type table for improved clarity and consistency in tax calculations. --- backend/services/falukantService.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index d564be2..e243dff 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -204,12 +204,12 @@ async function calcRegionalSellPrice(product, knowledgeFactor, regionId, worthPe `WITH RECURSIVE ancestors AS ( SELECT r.id, r.parent_id, r.tax_percent, rt.label_tr as region_type FROM falukant_data.region r - JOIN falukant_type.region_type rt ON rt.id = r.region_type_id + JOIN falukant_type.region rt ON rt.id = r.region_type_id WHERE r.id = :id UNION ALL SELECT reg.id, reg.parent_id, reg.tax_percent, rt2.label_tr FROM falukant_data.region reg - JOIN falukant_type.region_type rt2 ON rt2.id = reg.region_type_id + JOIN falukant_type.region rt2 ON rt2.id = reg.region_type_id JOIN ancestors a ON reg.id = a.parent_id ) SELECT COALESCE(SUM(CASE WHEN ${exemptTypesString} && ARRAY[region_type] THEN 0 ELSE tax_percent END),0) AS total FROM ancestors;`,