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'] });