-ต้นแบบ โครงสร้าง ไฟล์ API เส้น /api/ttc

This commit is contained in:
2025-11-17 09:03:36 +07:00
parent eefbb8e5dd
commit 9f9c9aa80d
25 changed files with 1019 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { GeneralService } from '../share/generalservice.js'
export class AccountingSearchService {
constructor() {
this.generalService = new GeneralService()
}
async getAccountingSearch(database, id, username) {
const sql = `
SELECT
actseq,
actnum,
acttyp,
${database}.translatedtl('ACTTYP', acttyp) as acttypnam,
${database}.translatedtl_multi(ARRAY['ACTCAT_INC', 'ACTCAT_EXP'], actcat) as actcatnam,
actqty,
actcmt,
actacpdtm
FROM ${database}.actmst
WHERE actnum = $1
`
const params = [id]
const result = await this.generalService.executeQueryParam(database, sql, params);
return result
}
}

View File

@@ -0,0 +1,27 @@
import { GeneralService } from '../share/generalservice.js'
export class AccountingSetupService {
constructor() {
this.generalService = new GeneralService()
}
async getAccountingSetup(database) {
const sql = `
SELECT
dtlnam,
dtlcod,
dtltblcod
FROM ${database}.dtlmst
WHERE dtltblcod IN ('ACTTYP', 'ACTCAT_INC', 'ACTCAT_EXP');
`
const params = []
const result = await this.generalService.executeQueryParam(database, sql, params);
return result
}
}
// SELECT
// acttyp,
// dtlname
// FROM ${database}.actmst
// LEFT JOIN ${database}.dtlmst ON dtltblcod = 'acttyp' and acttyp = dtlcod

View File

@@ -0,0 +1,44 @@
import { GeneralService } from '../share/generalservice.js'
export class AccountingSumService {
constructor() {
this.generalService = new GeneralService()
}
async getAccountingSum(database, id) {
const sql = `
SELECT
actseq,
actnum,
acttyp,
${database}.translatedtl('ACTTYP', acttyp) as acttypnam,
${database}.translatedtl_multi(ARRAY['ACTCAT_INC', 'ACTCAT_EXP'], actcat) as actcatnam,
actqty,
actcmt,
actacpdtm
FROM ${database}.actmst
WHERE actnum = $1
`
const params = [id]
const result = await this.generalService.executeQueryParam(database, sql, params);
return result
}
async getCategoryColorMap(database) {
const sql = `
SELECT dtlcod, dtlnam, dtlmsc as dtlclr
FROM ${database}.dtlmst
WHERE dtltblcod IN ('ACTCAT_INC', 'ACTCAT_EXP')
`;
const params = []
const rows = await this.generalService.executeQueryParam(database, sql, params);
const map = {};
rows.forEach(r => {
map[r.dtlnam] = r.dtlclr; // ใช้ชื่อหมวดเป็น key
});
return map;
}
}