Skip to content

1.14 · รายงานและ KPI

บทนี้รวมระบบรายงานของ VTRC — PDF, Excel และ KPI dashboards ที่ HR ใช้ส่งให้ผู้บริหารและ audit

VTRC ไม่ใช่ "BI tool" — ทุกรายงานเป็น batch export สำหรับกรณีเฉพาะ ไม่ใช่ interactive dashboard


ประเภทรายงาน

ประเภทFormatใช้สำหรับ
PDFใบรับรอง, สลิป, รายงานการเงินเอกสารทางการ
Excelรายงานสรุป, รายการต่างๆวิเคราะห์ต่อ
TextK-Cash input, SmartCredit inputส่งธนาคาร

Excel export — downloadExcel ทั่วไป

vtrc-api/api/src/typeDefs/downloadExcel.js:1-18

graphql
type Query {
  downloadExcelUrl(
    table: String!
    startDate: Date
    endDate: Date
    empCode: String
  ): String
}

table parameter — ชื่อตาราง/รายงานที่จะ export

REST endpoint — GET /download/excel/:tabledownloadExcel(req, res) (routes.js:497-498)


Excel controller

vtrc-api/api/src/lib/controllers/excel/excel.js

Functions ที่ export ออกมา

Functionหน้าที่
createExportFileสร้างไฟล์ export ทั่วไป
createExportFundApplicationFileexport ใบสมัครกองทุน
createExportFundRateChangeFileexport การเปลี่ยน rate กองทุน
downloadExcelhandler สำหรับ REST endpoint
uploadExcelhandler สำหรับ 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
sumOverveiwReportTemplateoverview ทั้งหมด
sumPayingPrepareTemplateรายการเตรียมจ่าย
sumPersonalReportTemplateสรุปตามบุคคล
sumWDHospitalPaidTemplateสรุปจ่ายแล้ว
createWDHospitalPaidExCelTemplateExcel ของที่จ่ายแล้ว

Queries ที่ trigger รายงาน WDHospital

vtrc-api/api/src/typeDefs/wdHospital.js:156-166

QueryTemplate
fetchUrlFailPaymentPDFfailPaymentReportTemplate
fetchUrlAllWithdrawPDFReportoverview + variants
fetchUrlWDHospitalApproverPDFReportby CoA
fetchUrlWDHospitalPaidPDFReportsumWDHospitalPaidTemplate

ทุก query คืน URL ที่มี hash — เปิดผ่าน browser จะ trigger PDF generation ฝั่ง routes.js


รายงาน Provident Fund

routes.js:1219-1274

EndpointOutput
GET /fund/application/excelใบสมัคร Excel
POST /fund/ratechange/excelzip ของ rate change แยก sourceDB

rate change Excel — วนลูป convertedData แยก sourceDB แต่ละตัว สร้าง Excel แต่ละอัน ชื่อ เปลี่ยนนโยบายกองทุน_${mapSourceDBName[key]}.xlsx แล้ว zip รวม


Queries ของ Provident Fund

providentFund.js:4-52

QueryOutput
fetchUrlFundApplicationExcelExcel ใบสมัคร
fetchUrlFundRateChangeExcelExcel เปลี่ยน rate
fetchUrlFundRateChangeSummaryReportPDF สรุปเปลี่ยน rate
fetchUrlFundBenefitPersonSummaryReportPDF สรุปผู้รับผลประโยชน์

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

FolderReport
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 จะกระโดด

ขั้นตอนถัดไป

ไป บท 1.15 ข้อจำกัดทางธุรกิจ + edge cases →