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;`,