feat(Director): add autoAdjustIncome feature and enhance director data handling
All checks were successful
Deploy to production / deploy (push) Successful in 1m54s

- Introduced a new boolean field `autoAdjustIncome` in the Director model to manage income adjustments automatically.
- Updated the FalukantService to include `autoAdjustIncome` in director data responses and settings management.
- Enhanced the DirectorInfo component to allow users to toggle the `autoAdjustIncome` setting.
- Updated internationalization files to include translations for the new feature across multiple languages.
This commit is contained in:
Torsten Schulz (local)
2026-05-07 13:29:09 +02:00
parent ddd8ca49d8
commit 42d0652e48
10 changed files with 69 additions and 12 deletions

View File

@@ -3328,7 +3328,7 @@ class FalukantService extends BaseService {
{
model: RegionData,
as: 'region',
attributes: ['name']
attributes: ['id', 'name']
}
]
},
@@ -3351,6 +3351,7 @@ class FalukantService extends BaseService {
return {
director: {
id: director.id,
directorCharacterId: director.directorCharacterId,
character: {
name: `${director.character.definedFirstName.name} ${director.character.definedLastName.name}`,
title: director.character.nobleTitle.labelTr,
@@ -3366,6 +3367,8 @@ class FalukantService extends BaseService {
mayProduce: director.mayProduce,
maySell: director.maySell,
mayStartTransport: director.mayStartTransport,
autoAdjustIncome: director.autoAdjustIncome,
regionId: director.character.region?.id || director.character.regionId || null,
region: director.character.region?.name || null,
wishedIncome,
},
@@ -3420,7 +3423,7 @@ class FalukantService extends BaseService {
]
},
],
attributes: ['id', 'satisfaction', 'income'],
attributes: ['id', 'satisfaction', 'income', 'autoAdjustIncome'],
});
return directors
.filter(director => director.character != null)
@@ -3436,10 +3439,13 @@ class FalukantService extends BaseService {
);
return {
id: director.id,
directorCharacterId: char.id,
satisfaction: director.satisfaction,
character: char,
age: calcAge(char.birthdate),
income: director.income,
autoAdjustIncome: director.autoAdjustIncome,
regionId: char.region?.id ?? null,
region: char.region?.name ?? '',
wishedIncome,
};
@@ -3488,8 +3494,18 @@ class FalukantService extends BaseService {
if (!director) {
return null;
}
const allowedKeys = new Set([
'mayProduce',
'maySell',
'mayStartTransport',
'mayRepairVehicles',
'autoAdjustIncome',
]);
if (!allowedKeys.has(settingKey)) {
throw new Error('Invalid setting key');
}
const updateData = {};
updateData[settingKey] = value || false;
updateData[settingKey] = !!value;
await Director.update(updateData, {
where: {
@@ -8905,15 +8921,18 @@ async function enrichNotificationsWithCharacterNames(notifications) {
where: { id: { [Op.in]: ids } },
include: [
{ model: FalukantPredefineFirstname, as: 'definedFirstName', attributes: ['name'] },
{ model: FalukantPredefineLastname, as: 'definedLastName', attributes: ['name'] }
{ model: FalukantPredefineLastname, as: 'definedLastName', attributes: ['name'] },
{ model: TitleOfNobility, as: 'nobleTitle', attributes: ['labelTr'] },
],
attributes: ['id']
attributes: ['id', 'gender']
});
for (const c of characters) {
const title = String(c.nobleTitle?.labelTr || '').trim();
const first = c.definedFirstName?.name || '';
const last = c.definedLastName?.name || '';
const display = `${first} ${last}`.trim() || null;
const baseName = `${first} ${last}`.trim();
const display = [title, baseName].filter(Boolean).join(' ').trim() || null;
nameMap.set(Number(c.id), display || `#${c.id}`);
}
}