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.

This commit is contained in:
Torsten Schulz (local)
2025-12-20 11:09:03 +01:00
parent c69a414f78
commit e3df88bea0

View File

@@ -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',