diff --git a/exthernal-accountingwep-api/src/controllers/accountingSearchController.js b/exthernal-accountingwep-api/src/controllers/accountingSearchController.js index 6890fc8..0b6c410 100644 --- a/exthernal-accountingwep-api/src/controllers/accountingSearchController.js +++ b/exthernal-accountingwep-api/src/controllers/accountingSearchController.js @@ -25,12 +25,12 @@ export class accountingSearch { try { // let username = req.body.request.username; // let password = req.body.request.password; - let token = req.body.request.token; - const decoded = verifyToken(token); + let token = req.headers.authorization?.split(' ')[1];'' + const decoded = verifyToken(token); - let id = decoded.id - let username = decoded.name - database = decoded.organization + let id = decoded.id + let username = decoded.name + database = decoded.organization aryResult = await this.accountingSearchService.getAccountingSearch(database, id, username); // เช็คกับ db กลาง ส่ง jwttoken ออกมา // this.generalService.devhint(1, 'accountingSearch.js', 'Login success'); diff --git a/exthernal-accountingwep-api/src/controllers/accountingSetupController.js b/exthernal-accountingwep-api/src/controllers/accountingSetupController.js index 2651508..a4dacf8 100644 --- a/exthernal-accountingwep-api/src/controllers/accountingSetupController.js +++ b/exthernal-accountingwep-api/src/controllers/accountingSetupController.js @@ -25,7 +25,7 @@ export class accountingSetup { try { // let username = req.body.request.username; // let password = req.body.request.password; - let token = req.body.request.token; + let token = req.headers.authorization?.split(' ')[1]; const decoded = verifyToken(token); database = decoded.organization diff --git a/exthernal-accountingwep-api/src/controllers/accountingSumController.js b/exthernal-accountingwep-api/src/controllers/accountingSumController.js index 6b51e11..021bfc4 100644 --- a/exthernal-accountingwep-api/src/controllers/accountingSumController.js +++ b/exthernal-accountingwep-api/src/controllers/accountingSumController.js @@ -24,7 +24,7 @@ export class accountingSum { let result = [] var aryResult try { - let token = req.body.request.token; + let token = req.headers.authorization?.split(' ')[1]; const decoded = verifyToken(token); let id = decoded.id diff --git a/exthernal-accountingwep-api/src/controllers/reportController.js b/exthernal-accountingwep-api/src/controllers/reportController.js index 8fcd412..c282596 100644 --- a/exthernal-accountingwep-api/src/controllers/reportController.js +++ b/exthernal-accountingwep-api/src/controllers/reportController.js @@ -28,7 +28,7 @@ export class reportController { let token = req.headers.authorization?.split(' ')[1]; const decoded = verifyToken(token); - let actnum = req.body.request.actnum; + let actnum = decoded.id; database = decoded.organization; aryResult = await this.reportService.getReportController(database, actnum); @@ -52,7 +52,7 @@ export class reportController { return aryResult; } - // ✅ 2) แยก income / expense + // 2) แยก income / expense const incomeList = data.filter(i => i.acttyp === 'i'); const expenseList = data.filter(e => e.acttyp === 'e'); @@ -63,11 +63,13 @@ export class reportController { const profitRate = totalIncome > 0 ? (netProfit / totalIncome) * 100 : 0; const adjustedProfitRate = profitRate + 1.9; - // ✅ 3) แนบ summary (เหมือนที่เราทำไปก่อนหน้า) + // 3) แนบ summary (เหมือนที่เราทำไปก่อนหน้า) var summary = { totalIncome: totalIncome.toFixed(2), totalExpense: totalExpense.toFixed(2), netProfit: netProfit.toFixed(2), + profitRate: profitRate.toFixed(2) + ' %', + period: '30 วัน' }; // ✅ 3.5) Create actdata table with required fields grouped by actnum