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:
@@ -147,16 +147,19 @@ async function calcRegionalSellPrice(product, knowledgeFactor, regionId, worthPe
|
|||||||
async function getCumulativeTaxPercentWithExemptions(userId, regionId) {
|
async function getCumulativeTaxPercentWithExemptions(userId, regionId) {
|
||||||
if (!regionId) return 0;
|
if (!regionId) return 0;
|
||||||
// fetch user's political offices (active) and their region types
|
// 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({
|
const offices = await PoliticalOffice.findAll({
|
||||||
|
where: { characterId: character.id },
|
||||||
include: [
|
include: [
|
||||||
{
|
|
||||||
model: FalukantCharacter,
|
|
||||||
as: 'holder',
|
|
||||||
where: { userId },
|
|
||||||
required: true,
|
|
||||||
attributes: []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
model: PoliticalOfficeType,
|
model: PoliticalOfficeType,
|
||||||
as: 'type',
|
as: 'type',
|
||||||
|
|||||||
Reference in New Issue
Block a user