feat(Director): add autoAdjustIncome feature and enhance director data handling
All checks were successful
Deploy to production / deploy (push) Successful in 1m54s
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:
@@ -33,6 +33,10 @@ Director.init({
|
|||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: true},
|
defaultValue: true},
|
||||||
|
autoAdjustIncome: {
|
||||||
|
type: DataTypes.BOOLEAN,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: false},
|
||||||
lastSalaryPayout: {
|
lastSalaryPayout: {
|
||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
|
|||||||
@@ -3328,7 +3328,7 @@ class FalukantService extends BaseService {
|
|||||||
{
|
{
|
||||||
model: RegionData,
|
model: RegionData,
|
||||||
as: 'region',
|
as: 'region',
|
||||||
attributes: ['name']
|
attributes: ['id', 'name']
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -3351,6 +3351,7 @@ class FalukantService extends BaseService {
|
|||||||
return {
|
return {
|
||||||
director: {
|
director: {
|
||||||
id: director.id,
|
id: director.id,
|
||||||
|
directorCharacterId: director.directorCharacterId,
|
||||||
character: {
|
character: {
|
||||||
name: `${director.character.definedFirstName.name} ${director.character.definedLastName.name}`,
|
name: `${director.character.definedFirstName.name} ${director.character.definedLastName.name}`,
|
||||||
title: director.character.nobleTitle.labelTr,
|
title: director.character.nobleTitle.labelTr,
|
||||||
@@ -3366,6 +3367,8 @@ class FalukantService extends BaseService {
|
|||||||
mayProduce: director.mayProduce,
|
mayProduce: director.mayProduce,
|
||||||
maySell: director.maySell,
|
maySell: director.maySell,
|
||||||
mayStartTransport: director.mayStartTransport,
|
mayStartTransport: director.mayStartTransport,
|
||||||
|
autoAdjustIncome: director.autoAdjustIncome,
|
||||||
|
regionId: director.character.region?.id || director.character.regionId || null,
|
||||||
region: director.character.region?.name || null,
|
region: director.character.region?.name || null,
|
||||||
wishedIncome,
|
wishedIncome,
|
||||||
},
|
},
|
||||||
@@ -3420,7 +3423,7 @@ class FalukantService extends BaseService {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
attributes: ['id', 'satisfaction', 'income'],
|
attributes: ['id', 'satisfaction', 'income', 'autoAdjustIncome'],
|
||||||
});
|
});
|
||||||
return directors
|
return directors
|
||||||
.filter(director => director.character != null)
|
.filter(director => director.character != null)
|
||||||
@@ -3436,10 +3439,13 @@ class FalukantService extends BaseService {
|
|||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
id: director.id,
|
id: director.id,
|
||||||
|
directorCharacterId: char.id,
|
||||||
satisfaction: director.satisfaction,
|
satisfaction: director.satisfaction,
|
||||||
character: char,
|
character: char,
|
||||||
age: calcAge(char.birthdate),
|
age: calcAge(char.birthdate),
|
||||||
income: director.income,
|
income: director.income,
|
||||||
|
autoAdjustIncome: director.autoAdjustIncome,
|
||||||
|
regionId: char.region?.id ?? null,
|
||||||
region: char.region?.name ?? '',
|
region: char.region?.name ?? '',
|
||||||
wishedIncome,
|
wishedIncome,
|
||||||
};
|
};
|
||||||
@@ -3488,8 +3494,18 @@ class FalukantService extends BaseService {
|
|||||||
if (!director) {
|
if (!director) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const allowedKeys = new Set([
|
||||||
|
'mayProduce',
|
||||||
|
'maySell',
|
||||||
|
'mayStartTransport',
|
||||||
|
'mayRepairVehicles',
|
||||||
|
'autoAdjustIncome',
|
||||||
|
]);
|
||||||
|
if (!allowedKeys.has(settingKey)) {
|
||||||
|
throw new Error('Invalid setting key');
|
||||||
|
}
|
||||||
const updateData = {};
|
const updateData = {};
|
||||||
updateData[settingKey] = value || false;
|
updateData[settingKey] = !!value;
|
||||||
|
|
||||||
await Director.update(updateData, {
|
await Director.update(updateData, {
|
||||||
where: {
|
where: {
|
||||||
@@ -8905,15 +8921,18 @@ async function enrichNotificationsWithCharacterNames(notifications) {
|
|||||||
where: { id: { [Op.in]: ids } },
|
where: { id: { [Op.in]: ids } },
|
||||||
include: [
|
include: [
|
||||||
{ model: FalukantPredefineFirstname, as: 'definedFirstName', attributes: ['name'] },
|
{ 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) {
|
for (const c of characters) {
|
||||||
|
const title = String(c.nobleTitle?.labelTr || '').trim();
|
||||||
const first = c.definedFirstName?.name || '';
|
const first = c.definedFirstName?.name || '';
|
||||||
const last = c.definedLastName?.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}`);
|
nameMap.set(Number(c.id), display || `#${c.id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
backend/sql/add_director_auto_adjust_income.sql
Normal file
15
backend/sql/add_director_auto_adjust_income.sql
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
-- Adds opt-in flag for automatic director salary adjustment (daemon-controlled)
|
||||||
|
-- Default is OFF for all existing and future directors.
|
||||||
|
|
||||||
|
ALTER TABLE falukant_data.director
|
||||||
|
ADD COLUMN IF NOT EXISTS auto_adjust_income boolean;
|
||||||
|
|
||||||
|
UPDATE falukant_data.director
|
||||||
|
SET auto_adjust_income = false
|
||||||
|
WHERE auto_adjust_income IS NULL;
|
||||||
|
|
||||||
|
ALTER TABLE falukant_data.director
|
||||||
|
ALTER COLUMN auto_adjust_income SET DEFAULT false;
|
||||||
|
|
||||||
|
ALTER TABLE falukant_data.director
|
||||||
|
ALTER COLUMN auto_adjust_income SET NOT NULL;
|
||||||
@@ -104,6 +104,14 @@
|
|||||||
/>
|
/>
|
||||||
{{ $t('falukant.branch.director.starttransport') }}
|
{{ $t('falukant.branch.director.starttransport') }}
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
v-model="director.autoAdjustIncome"
|
||||||
|
@change="saveSetting('autoAdjustIncome', director.autoAdjustIncome)"
|
||||||
|
/>
|
||||||
|
{{ $t('falukant.branch.director.autoAdjustIncome') }}
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|||||||
@@ -427,7 +427,8 @@ export default {
|
|||||||
params.threshold_percent = base.threshold_percent;
|
params.threshold_percent = base.threshold_percent;
|
||||||
}
|
}
|
||||||
const isDirectorResign = base.event === 'director_resignation_risk_high'
|
const isDirectorResign = base.event === 'director_resignation_risk_high'
|
||||||
|| (typeof base.tr === 'string' && base.tr.includes('director.resignation'));
|
|| base.event === 'director_resigned'
|
||||||
|
|| (typeof base.tr === 'string' && (base.tr.includes('director.resignation') || base.tr.includes('director.resigned')));
|
||||||
if (isDirectorResign) {
|
if (isDirectorResign) {
|
||||||
params.directorName = params.characterName
|
params.directorName = params.characterName
|
||||||
|| base.character_name
|
|| base.character_name
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
"notify_election_created": "Giskedyul ang usa ka bag-ong eleksiyon.",
|
"notify_election_created": "Giskedyul ang usa ka bag-ong eleksiyon.",
|
||||||
"notify_office_filled": "Na puno ang usa ka politikal nga opisina.",
|
"notify_office_filled": "Na puno ang usa ka politikal nga opisina.",
|
||||||
"director": {
|
"director": {
|
||||||
"resignation_risk_high": "Taas ang risgo nga mobiya ang direktor nga si {directorName}: risgo {risk_percent}% (threshold {threshold_percent}%). Karon nga satisfaction {satisfaction}."
|
"resignation_risk_high": "Taas ang risgo nga mobiya ang direktor nga si {directorName}: risgo {risk_percent}% (threshold {threshold_percent}%). Karon nga satisfaction {satisfaction}.",
|
||||||
|
"resigned": "Nibiya ang direktor nga si {directorName} (satisfaction {satisfaction}, resignation value {resignation_percent}%). Rehiyon: {regionName}."
|
||||||
},
|
},
|
||||||
"director_death": "Namatay si {characterName} sa edad nga {ageYears}. Isip amo, kinahanglan kang magtudlo og bag-ong direktor.{regionLabel}{spouses}{children}{lovers}",
|
"director_death": "Namatay si {characterName} sa edad nga {ageYears}. Isip amo, kinahanglan kang magtudlo og bag-ong direktor.{regionLabel}{spouses}{children}{lovers}",
|
||||||
"relationship_death": "Namatay si {characterName} sa edad nga {ageYears}.{regionLabel}{spouses}{children}{lovers}",
|
"relationship_death": "Namatay si {characterName} sa edad nga {ageYears}.{regionLabel}{spouses}{children}{lovers}",
|
||||||
@@ -467,6 +468,7 @@
|
|||||||
"income": "Kita",
|
"income": "Kita",
|
||||||
"incomeUpdated": "Malampuson nga na-update ang sweldo.",
|
"incomeUpdated": "Malampuson nga na-update ang sweldo.",
|
||||||
"starttransport": "Makapagsugod og transport",
|
"starttransport": "Makapagsugod og transport",
|
||||||
|
"autoAdjustIncome": "Awtomatikong i-adjust ang sweldo",
|
||||||
"emptyTransport": {
|
"emptyTransport": {
|
||||||
"title": "Transporte without products",
|
"title": "Transporte without products",
|
||||||
"description": "Move vehicles gikan sa this sangang opisina ngadto sa another ngadto sa use them better.",
|
"description": "Move vehicles gikan sa this sangang opisina ngadto sa another ngadto sa use them better.",
|
||||||
|
|||||||
@@ -49,7 +49,8 @@
|
|||||||
"notify_election_created": "Es wurde eine neue Wahl ausgeschrieben.",
|
"notify_election_created": "Es wurde eine neue Wahl ausgeschrieben.",
|
||||||
"notify_office_filled": "Ein politisches Amt wurde neu besetzt.",
|
"notify_office_filled": "Ein politisches Amt wurde neu besetzt.",
|
||||||
"director": {
|
"director": {
|
||||||
"resignation_risk_high": "Hohe Kündigungsgefahr für den Direktor {directorName}: Risiko {risk_percent} % (Schwelle {threshold_percent} %). Zufriedenheit aktuell {satisfaction}."
|
"resignation_risk_high": "Hohe Kündigungsgefahr für den Direktor {directorName}: Risiko {risk_percent} % (Schwelle {threshold_percent} %). Zufriedenheit aktuell {satisfaction}.",
|
||||||
|
"resigned": "Direktor {directorName} hat gekündigt (Zufriedenheit {satisfaction}, Kündigungswert {resignation_percent} %). Region: {regionName}."
|
||||||
},
|
},
|
||||||
"director_death": "{characterName} ist im Alter von {ageYears} Jahren verstorben. Als Arbeitgeber musst du die Direktion neu besetzen.{regionLabel}{spouses}{children}{lovers}",
|
"director_death": "{characterName} ist im Alter von {ageYears} Jahren verstorben. Als Arbeitgeber musst du die Direktion neu besetzen.{regionLabel}{spouses}{children}{lovers}",
|
||||||
"relationship_death": "{characterName} ist im Alter von {ageYears} Jahren verstorben.{regionLabel}{spouses}{children}{lovers}",
|
"relationship_death": "{characterName} ist im Alter von {ageYears} Jahren verstorben.{regionLabel}{spouses}{children}{lovers}",
|
||||||
@@ -398,6 +399,7 @@
|
|||||||
"produce": "Darf produzieren",
|
"produce": "Darf produzieren",
|
||||||
"sell": "Darf verkaufen",
|
"sell": "Darf verkaufen",
|
||||||
"starttransport": "Darf Transporte veranlassen",
|
"starttransport": "Darf Transporte veranlassen",
|
||||||
|
"autoAdjustIncome": "Gehalt automatisch anpassen",
|
||||||
"emptyTransport": {
|
"emptyTransport": {
|
||||||
"title": "Transport ohne Produkte",
|
"title": "Transport ohne Produkte",
|
||||||
"description": "Bewege Transportmittel von dieser Niederlassung zu einer anderen, um sie besser zu nutzen.",
|
"description": "Bewege Transportmittel von dieser Niederlassung zu einer anderen, um sie besser zu nutzen.",
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
"notify_election_created": "A new election has been scheduled.",
|
"notify_election_created": "A new election has been scheduled.",
|
||||||
"notify_office_filled": "A political office has been filled.",
|
"notify_office_filled": "A political office has been filled.",
|
||||||
"director": {
|
"director": {
|
||||||
"resignation_risk_high": "High resignation risk for director {directorName}: risk {risk_percent}% (threshold {threshold_percent}%). Current satisfaction {satisfaction}."
|
"resignation_risk_high": "High resignation risk for director {directorName}: risk {risk_percent}% (threshold {threshold_percent}%). Current satisfaction {satisfaction}.",
|
||||||
|
"resigned": "Director {directorName} resigned (satisfaction {satisfaction}, resignation value {resignation_percent}%). Region: {regionName}."
|
||||||
},
|
},
|
||||||
"director_death": "{characterName} died at the age of {ageYears}. As employer you need to appoint a new director.{regionLabel}{spouses}{children}{lovers}",
|
"director_death": "{characterName} died at the age of {ageYears}. As employer you need to appoint a new director.{regionLabel}{spouses}{children}{lovers}",
|
||||||
"relationship_death": "{characterName} died at the age of {ageYears}.{regionLabel}{spouses}{children}{lovers}",
|
"relationship_death": "{characterName} died at the age of {ageYears}.{regionLabel}{spouses}{children}{lovers}",
|
||||||
@@ -442,6 +443,7 @@
|
|||||||
"income": "Income",
|
"income": "Income",
|
||||||
"incomeUpdated": "Salary has been successfully updated.",
|
"incomeUpdated": "Salary has been successfully updated.",
|
||||||
"starttransport": "May start transports",
|
"starttransport": "May start transports",
|
||||||
|
"autoAdjustIncome": "Automatically adjust salary",
|
||||||
"emptyTransport": {
|
"emptyTransport": {
|
||||||
"title": "Transport without products",
|
"title": "Transport without products",
|
||||||
"description": "Move vehicles from this branch to another to use them better.",
|
"description": "Move vehicles from this branch to another to use them better.",
|
||||||
|
|||||||
@@ -49,7 +49,8 @@
|
|||||||
"notify_election_created": "Se ha convocado una nueva elección.",
|
"notify_election_created": "Se ha convocado una nueva elección.",
|
||||||
"notify_office_filled": "Se ha cubierto un cargo político.",
|
"notify_office_filled": "Se ha cubierto un cargo político.",
|
||||||
"director": {
|
"director": {
|
||||||
"resignation_risk_high": "Alto riesgo de renuncia del director {directorName}: riesgo {risk_percent}% (umbral {threshold_percent}%). Satisfacción actual {satisfaction}."
|
"resignation_risk_high": "Alto riesgo de renuncia del director {directorName}: riesgo {risk_percent}% (umbral {threshold_percent}%). Satisfacción actual {satisfaction}.",
|
||||||
|
"resigned": "El director {directorName} ha dimitido (satisfacción {satisfaction}, valor de dimisión {resignation_percent}%). Región: {regionName}."
|
||||||
},
|
},
|
||||||
"director_death": "{characterName} ha fallecido a la edad de {ageYears} años. Como empleador debes nombrar un nuevo director.{regionLabel}{spouses}{children}{lovers}",
|
"director_death": "{characterName} ha fallecido a la edad de {ageYears} años. Como empleador debes nombrar un nuevo director.{regionLabel}{spouses}{children}{lovers}",
|
||||||
"relationship_death": "{characterName} ha fallecido a la edad de {ageYears} años.{regionLabel}{spouses}{children}{lovers}",
|
"relationship_death": "{characterName} ha fallecido a la edad de {ageYears} años.{regionLabel}{spouses}{children}{lovers}",
|
||||||
@@ -399,6 +400,7 @@
|
|||||||
"produce": "Puede producir",
|
"produce": "Puede producir",
|
||||||
"sell": "Puede vender",
|
"sell": "Puede vender",
|
||||||
"starttransport": "Puede iniciar transportes",
|
"starttransport": "Puede iniciar transportes",
|
||||||
|
"autoAdjustIncome": "Ajustar salario automáticamente",
|
||||||
"emptyTransport": {
|
"emptyTransport": {
|
||||||
"title": "Transporte sin productos",
|
"title": "Transporte sin productos",
|
||||||
"description": "Mueve medios de transporte de esta sucursal a otra para aprovecharlos mejor.",
|
"description": "Mueve medios de transporte de esta sucursal a otra para aprovecharlos mejor.",
|
||||||
|
|||||||
@@ -49,7 +49,8 @@
|
|||||||
"notify_election_created": "Une nouvelle élection a été déclenchée.",
|
"notify_election_created": "Une nouvelle élection a été déclenchée.",
|
||||||
"notify_office_filled": "Une fonction politique a été pourvue.",
|
"notify_office_filled": "Une fonction politique a été pourvue.",
|
||||||
"director": {
|
"director": {
|
||||||
"resignation_risk_high": "Risque élevé de démission du directeur {directorName} : risque {risk_percent}% (seuil {threshold_percent}%). Satisfaction actuelle {satisfaction}."
|
"resignation_risk_high": "Risque élevé de démission du directeur {directorName} : risque {risk_percent}% (seuil {threshold_percent}%). Satisfaction actuelle {satisfaction}.",
|
||||||
|
"resigned": "Le directeur {directorName} a démissionné (satisfaction {satisfaction}, valeur de démission {resignation_percent} %). Région : {regionName}."
|
||||||
},
|
},
|
||||||
"director_death": "{characterName} est décédé à l'âge de {ageYears}. En tant qu'employeur, vous devez remplir le conseil d'administration.{regionLabel}{spouses}{children}{lovers}",
|
"director_death": "{characterName} est décédé à l'âge de {ageYears}. En tant qu'employeur, vous devez remplir le conseil d'administration.{regionLabel}{spouses}{children}{lovers}",
|
||||||
"relationship_death": "{characterName} est décédé à l'âge de {ageYears}.{regionLabel}{spouses}{children}{lovers}",
|
"relationship_death": "{characterName} est décédé à l'âge de {ageYears}.{regionLabel}{spouses}{children}{lovers}",
|
||||||
@@ -397,6 +398,7 @@
|
|||||||
"produce": "Peut produire",
|
"produce": "Peut produire",
|
||||||
"sell": "Peut vendre",
|
"sell": "Peut vendre",
|
||||||
"starttransport": "Peut organiser le transport",
|
"starttransport": "Peut organiser le transport",
|
||||||
|
"autoAdjustIncome": "Ajuster automatiquement le salaire",
|
||||||
"emptyTransport": {
|
"emptyTransport": {
|
||||||
"title": "Transport sans produits",
|
"title": "Transport sans produits",
|
||||||
"description": "Déplacez le transport de cette branche à une autre pour en faire un meilleur usage.",
|
"description": "Déplacez le transport de cette branche à une autre pour en faire un meilleur usage.",
|
||||||
|
|||||||
Reference in New Issue
Block a user