From b61a533eaca2f8fdfe5050a93d4f1fa9ac9216ba Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 25 Mar 2026 11:51:25 +0100 Subject: [PATCH] Enhance FalukantService to include certificate attribute: Add 'certificate' to user attributes and ensure default value is set if absent. Update product type retrieval logic to utilize effective certificate value for filtering. --- backend/services/falukantService.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 527551a..5febd83 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -847,9 +847,12 @@ class FalukantService extends BaseService { ] }, ], - attributes: ['id', 'money', 'creditAmount', 'todayCreditTaken'] + attributes: ['id', 'money', 'creditAmount', 'todayCreditTaken', 'certificate'] }); if (!u) throw new Error('User not found'); + if (u.certificate == null) { + u.setDataValue('certificate', 1); + } // Load UserHouse and HouseType in separate queries to avoid EagerLoadingError let userHouse = null; if (u.id != null) { @@ -897,7 +900,7 @@ class FalukantService extends BaseService { const nobility = await TitleOfNobility.findOne({ where: { labelTr: 'noncivil' } }); if (!nobility) throw new Error('No title of nobility found with the label "noncivil".'); const falukantUser = await FalukantUser.create({ - userId: user.id, money: 50, creditAmount: 0, todayCreditTaken: 0, creditInterestRate: 0, mainBranchRegionId: region.id + userId: user.id, money: 50, creditAmount: 0, todayCreditTaken: 0, creditInterestRate: 0, certificate: 1, mainBranchRegionId: region.id }); const date = new Date(); date.setDate(date.getDate() - 14); const ch = await FalukantCharacter.create({ @@ -2017,8 +2020,9 @@ class FalukantService extends BaseService { if (!c) { throw new Error(`No FalukantCharacter found for user with id ${u.id}`); } + const effectiveCertificate = u.certificate ?? 1; const ps = await ProductType.findAll({ - where: { category: { [Op.lte]: u.certificate } }, + where: { category: { [Op.lte]: effectiveCertificate } }, include: [{ model: Knowledge, as: 'knowledges', attributes: ['knowledge'], where: { characterId: c.id } }], attributes: ['labelTr', 'id', 'sellCost', 'productionTime', 'category'] });