From e3df88bea065a0534ebe0cb478c75dadd319d380 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sat, 20 Dec 2025 11:09:03 +0100 Subject: [PATCH] Enhance getCumulativeTaxPercentWithExemptions function in FalukantService to first retrieve the character associated with the userId, ensuring accurate filtering of political offices by characterId for regional tax calculations. --- backend/services/falukantService.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 3f9fd51..0b159b2 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -147,16 +147,19 @@ async function calcRegionalSellPrice(product, knowledgeFactor, regionId, worthPe async function getCumulativeTaxPercentWithExemptions(userId, regionId) { if (!regionId) return 0; // fetch user's political offices (active) and their region types - // PoliticalOffice hat keine userId Spalte, daher müssen wir über FalukantCharacter filtern + // PoliticalOffice hat keine userId Spalte, daher müssen wir zuerst den Character finden + const character = await FalukantCharacter.findOne({ + where: { userId }, + attributes: ['id'] + }); + if (!character) { + // Wenn kein Character existiert, gibt es keine politischen Ämter + return 0; + } + const offices = await PoliticalOffice.findAll({ + where: { characterId: character.id }, include: [ - { - model: FalukantCharacter, - as: 'holder', - where: { userId }, - required: true, - attributes: [] - }, { model: PoliticalOfficeType, as: 'type',