1.14 · รายงานและ KPI
บทนี้รวมระบบรายงานของ VTRC — PDF, Excel และ KPI dashboards ที่ HR ใช้ส่งให้ผู้บริหารและ audit
VTRC ไม่ใช่ "BI tool" — ทุกรายงานเป็น batch export สำหรับกรณีเฉพาะ ไม่ใช่ interactive dashboard
ประเภทรายงาน
| ประเภท | Format | ใช้สำหรับ |
|---|---|---|
| ใบรับรอง, สลิป, รายงานการเงิน | เอกสารทางการ | |
| Excel | รายงานสรุป, รายการต่างๆ | วิเคราะห์ต่อ |
| Text | K-Cash input, SmartCredit input | ส่งธนาคาร |
Excel export — downloadExcel ทั่วไป
vtrc-api/api/src/typeDefs/downloadExcel.js:1-18
type Query {
downloadExcelUrl(
table: String!
startDate: Date
endDate: Date
empCode: String
): String
}table parameter — ชื่อตาราง/รายงานที่จะ export
REST endpoint — GET /download/excel/:table → downloadExcel(req, res) (routes.js:497-498)
Excel controller
vtrc-api/api/src/lib/controllers/excel/excel.js
Functions ที่ export ออกมา
| Function | หน้าที่ |
|---|---|
createExportFile | สร้างไฟล์ export ทั่วไป |
createExportFundApplicationFile | export ใบสมัครกองทุน |
createExportFundRateChangeFile | export การเปลี่ยน rate กองทุน |
downloadExcel | handler สำหรับ REST endpoint |
uploadExcel | handler สำหรับ import (เช่น KBANK result) |
รายงาน WDHospital — 12+ templates
vtrc-api/api/src/lib/controllers/withdraw/hospital.template.js (imported at routes.js:26)
แต่ละ template ผลิต PDF/Excel จากมุมมองต่างกัน
| Template | มุมมอง |
|---|---|
cancelPaymentReportTemplate | รายการ cancel payment |
failPaymentReportTemplate | รายการ FAILED |
successPaymentReportTemplate | รายการ PAID |
sumCoAReportAllOrgTemplate | สรุปตาม chart-of-accounts ทุก org |
sumCoAReportTemplate | สรุปตาม chart-of-accounts |
sumDivisionReportTemplate | สรุปตาม division |
sumOrganizeReportTemplate | สรุปตาม organization |
sumOverveiwReportTemplate | overview ทั้งหมด |
sumPayingPrepareTemplate | รายการเตรียมจ่าย |
sumPersonalReportTemplate | สรุปตามบุคคล |
sumWDHospitalPaidTemplate | สรุปจ่ายแล้ว |
createWDHospitalPaidExCelTemplate | Excel ของที่จ่ายแล้ว |
Queries ที่ trigger รายงาน WDHospital
vtrc-api/api/src/typeDefs/wdHospital.js:156-166
| Query | Template |
|---|---|
fetchUrlFailPaymentPDF | failPaymentReportTemplate |
fetchUrlAllWithdrawPDFReport | overview + variants |
fetchUrlWDHospitalApproverPDFReport | by CoA |
fetchUrlWDHospitalPaidPDFReport | sumWDHospitalPaidTemplate |
ทุก query คืน URL ที่มี hash — เปิดผ่าน browser จะ trigger PDF generation ฝั่ง routes.js
รายงาน Provident Fund
routes.js:1219-1274
| Endpoint | Output |
|---|---|
GET /fund/application/excel | ใบสมัคร Excel |
POST /fund/ratechange/excel | zip ของ rate change แยก sourceDB |
rate change Excel — วนลูป convertedData แยก sourceDB แต่ละตัว สร้าง Excel แต่ละอัน ชื่อ เปลี่ยนนโยบายกองทุน_${mapSourceDBName[key]}.xlsx แล้ว zip รวม
Queries ของ Provident Fund
providentFund.js:4-52
| Query | Output |
|---|---|
fetchUrlFundApplicationExcel | Excel ใบสมัคร |
fetchUrlFundRateChangeExcel | Excel เปลี่ยน rate |
fetchUrlFundRateChangeSummaryReport | PDF สรุปเปลี่ยน rate |
fetchUrlFundBenefitPersonSummaryReport | PDF สรุปผู้รับผลประโยชน์ |
Stat Log — KPI data collection
vtrc-api/api/src/typeDefs/statLog.js + lib/controllers/statLog/statLog.js
Cron statLog() — รันทุกวัน 00:30 (crons.js)
เก็บสถิติประจำวัน เช่น
- จำนวน active users
- จำนวน WDHospital ใหม่/อนุมัติ/จ่าย
- จำนวน leave documents แต่ละสถานะ
- response time API (บางตัว)
ใช้สำหรับ dashboard ในหน้า backoffice (pages/Dashboard/) และส่งให้ผู้บริหารเป็นรายงานประจำเดือน
Dashboard ใน backoffice
pages/Dashboard/ — หน้าแรกหลัง login HR
แสดง
- ตัวเลข statLog วันนี้ / เปรียบเทียบสัปดาห์
- คำขอที่รออนุมัติของ user คนนี้
- shortcut ไปเมนูที่ใช้บ่อย
ไม่ใช่ interactive BI — แค่ display ตัวเลขจาก statLog + count query
Backoffice report pages
| Folder | Report |
|---|---|
ReportWelfare | รายงานสวัสดิการรักษาพยาบาล |
TuitionFeesReport | รายงานค่าเล่าเรียน |
ApproveWelfareReport | รายงานการอนุมัติ |
HospitalFailed | รายการ FAILED |
WorkForce/Report/ | Workforce reports (หลาย sub) |
Workforce subsystem reports
pages/WorkForce/Report/ — 6 reports
| Report | มุมมอง |
|---|---|
Workforce | ภาพรวมพนักงาน |
StudyLeave | ลาศึกษา |
PersonnelDetail | รายบุคคลลึก |
Personnel | รายบุคคลสรุป |
Leave | การลา |
Learning | การเรียน/อบรม |
ใช้ axios-workforce.js — backend ของ Workforce subsystem เป็นคน query
ข้อจำกัดของระบบรายงาน
- ไม่มี real-time analytics — ทุกอย่าง batch
- รายงานใหญ่อาจค้างหลายวินาที (เช่น
sumOverveiwReportTemplateถ้าข้อมูลมาก) - ถ้า PDF มี font Thai พัง — ตรวจ font ใน Docker container
- รายงาน Excel ใช้
exceljs— ถ้า cell มาก memory จะเพิ่มสูง - ไม่มี scheduling — HR ต้อง download เองทุกครั้ง
Stat log — ข้อควรระวัง
statLog cron รันทุกวัน 00:30 — เก็บ snapshot ของวันนั้น
- ถ้า cron ไม่ทำงาน (เช่น server ดับตอน 00:30) — ข้อมูลวันนั้นหาย
- ไม่มี backfill — ถ้าหายต้อง accept ว่าหาย
- dashboard เปรียบเทียบสัปดาห์ — ถ้ามีวันหาย graph จะกระโดด