Appearance
Salary — Technical Map
Auto-generated bởi codebase-doc-generator ngày 2026-03-23 (v2 — verified từ code thực). Không chỉnh sửa thủ công. Re-generate khi code thay đổi lớn.
Routes
| Route Constant | Path | Params | Component |
|---|---|---|---|
ROUTE_SALARY | /salary | — | Layout.tsx |
ROUTE_SALARY_LIST | /salary/list | — | SalaryList.tsx (legacy) |
ROUTE_SALARY_DETAIL | /salary/:user_id/:month/detail | user_id, month | SalaryDetail.tsx (legacy) |
ROUTE_SALARY_GENERAL | /salary/general | — | SalaryGeneral.tsx |
ROUTE_SALARY_BRANCH | /salary/branch | — | SalaryBranch.tsx |
ROUTE_SALARY_BRANCH_DETAIL | /salary/branch/:branchId | branchId | SalaryBranchDetail.tsx |
ROUTE_SALARY_EMPLOYEE_BRANCH_DETAIL | /salary/branch/:userId/:targetMonth | userId, targetMonth | SalaryEmployee.tsx |
ROUTE_SALARY_OFFICE | /salary/office | — | SalaryOffice.tsx |
ROUTE_SALARY_OFFICE_DETAIL | /salary/office/:officeId | officeId | SalaryOfficeDetail.tsx |
ROUTE_SALARY_EMPLOYEE_OFFICE_DETAIL | /salary/office/:officeId/:userId/:targetMonth | officeId, userId, targetMonth | SalaryEmployee.tsx |
ROUTE_SALARY_DOCTOR | /salary/doctor | — | SalaryDoctor.tsx |
ROUTE_SALARY_EMPLOYEE_DOCTOR_DETAIL | /salary/doctor/:userId/:targetMonth | userId, targetMonth | SalaryEmployee.tsx |
ROUTE_SALARY_FILE_DOWNLOAD_HISTORY | /salary/file-download-history | — | SalaryFileHistory.tsx |
Permissions: ITLeader · ITStaff · BOD
FE Pages (11 files)
| Page | Path (từ diva-admin/src/modules/salary/) |
|---|---|
| SalaryList.tsx | pages/SalaryList.tsx (legacy) |
| SalaryDetail.tsx | pages/SalaryDetail.tsx (legacy) |
| SalaryGeneral.tsx | pages/general/SalaryGeneral.tsx |
| SalaryBranch.tsx | pages/branch/SalaryBranch.tsx |
| SalaryBranchDetail.tsx | pages/branch/SalaryBranchDetail.tsx |
| SalaryBranchImport.tsx | pages/branch/SalaryBranchImport.tsx |
| SalaryOffice.tsx | pages/office/SalaryOffice.tsx |
| SalaryOfficeDetail.tsx | pages/office/SalaryOfficeDetail.tsx |
| SalaryOfficeImport.tsx | pages/office/SalaryOfficeImport.tsx |
| SalaryDoctor.tsx | pages/doctor/SalaryDoctor.tsx |
| SalaryDoctorImport.tsx | pages/doctor/SalaryDoctorImport.tsx |
FE Components (33 files)
| Nhóm | Component | Path (từ diva-admin/src/modules/salary/) |
|---|---|---|
| Chung | MonthPickerWithButton | components/MonthPickerWithButton.tsx |
| SalaryDetail | components/SalaryDetail.tsx | |
| SalaryFileHistory | components/SalaryFileHistory.tsx | |
| SalaryGroupInfoCard | components/SalaryGroupInfoCard.tsx | |
| SalaryImport | components/SalaryImport.tsx | |
| SalaryShowList | components/SalaryShowList.tsx | |
| SalarySummary | components/SalarySummary.tsx | |
| SalarySummaryCard | components/SalarySummaryCard.tsx | |
| SalaryTable | components/SalaryTable.tsx | |
| SalaryToolbar | components/SalaryToolbar.tsx | |
| Employee General | EmployeeInfo | components/employee/general/EmployeeInfo.tsx |
| SalaryEmployeeBasicInfo | components/employee/general/SalaryEmployeeBasicInfo.tsx | |
| SalaryEmployeeGeneral | components/employee/general/SalaryEmployeeGeneral.tsx | |
| SalaryEmployeeSalaryInfo | components/employee/general/SalaryEmployeeSalaryInfo.tsx | |
| Employee Detail | SalaryEmployeeDetail | components/employee/detail/SalaryEmployeeDetail.tsx |
| SalaryEmployeeSalaryDetail | components/employee/detail/SalaryEmployeeSalaryDetail.tsx | |
| SalaryEmployeeSalaryDetailCard | components/employee/detail/SalaryEmployeeSalaryDetailCard.tsx | |
| SalaryEmployeeSalaryDetailOtherCard | components/employee/detail/SalaryEmployeeSalaryDetailOtherCard.tsx | |
| SalaryEmployeeSalaryDetailRevenueCards | components/employee/detail/SalaryEmployeeSalaryDetailRevenueCards.tsx | |
| SalaryEmployeeSalaryInfoCard | components/employee/detail/SalaryEmployeeSalaryInfoCard.tsx | |
| SalaryEmployeeSalaryTable | components/employee/detail/SalaryEmployeeSalaryTable.tsx | |
| Branch | SalaryBranchTable | components/branch/SalaryBranchTable.tsx |
| SalaryBranchDetailTable | components/branch/SalaryBranchDetailTable.tsx | |
| StaffSalaryInfor | components/StaffSalaryInfor.tsx | |
| Office | SalaryOfficeTable | components/office/SalaryOfficeTable.tsx |
| SalaryOfficeDetailTable | components/office/SalaryOfficeDetailTable.tsx | |
| Doctor | SalaryDoctorTable | components/doctor/SalaryDoctorTable.tsx |
| General | SalaryGroupCard | components/general/SalaryGroupCard.tsx |
| SalaryGroups | components/general/SalaryGroups.tsx |
GraphQL Queries & Mutations
File: diva-admin/src/modules/salary/graphql/salary.graphql
| Name | Type | Source | Mô tả |
|---|---|---|---|
| ListSalaryFileHistory | query | salary_excel table + aggregate | Lịch sử file upload |
| getSalaries | query | salary table (HRM legacy) | Danh sách lương (legacy) |
| GetSalaryByPk | query | salary_by_pk | Lương 1 NV theo PK |
| SalaryExcel | query | salary_excel table | File Excel mới nhất |
| SalaryGeneral | query | search_salary_report (SQL function) | Summary 5 loại |
| SalaryBranchCards | query | getUserSalaryDataAggregate (action) + search_salary_branch_report | Aggregate branch |
| SalaryBranchTable | query | search_salary_branch_report (SQL function) | Bảng branch |
| SalaryOfficeCards | query | search_salary_office_report (SQL function) | Aggregate office |
| SalaryOfficeTable | query | search_salary_office_report (SQL function) | Bảng office |
| SalaryDetailCards + SalaryDetailTable | query | search_salary_detail_report (SQL function) | Chi tiết NV |
| SalaryEmployeeDetail | query | getUserSalaryData (action) | 1 NV, merge temp+official |
| SalaryEmployeeFile | query | getUserSalaryData (action) | NV cho file export |
| DownloadSalary | mutation | reportSalary (action, async) | Export Excel |
| UploadUserSalaryFile | mutation | insert salary_excel | Lưu metadata file |
| InsertUserSalary | mutation | insert user_salary | Import data |
Hasura Actions
| Action | Handler | Kind | Timeout |
|---|---|---|---|
getUserSalaryData | {\{ECOMMERCE_BASE_URL}\}/actions | sync | — |
getUserSalaryDataAggregate | {\{ECOMMERCE_BASE_URL}\}/actions | sync | — |
reportSalary | {\{EXPORT_BASE_URL}\}/actions | async | 900s (15 phút) |
Event Triggers
| Event | Table | Operation | Columns | Handler | Ghi chú |
|---|---|---|---|---|---|
user_salary_insert | user_salary (ecommerce) | INSERT | * (tất cả) | {\{ECOMMERCE_BASE_URL}\}/events | Fire cho MỌI insert — logic filter is_official nằm trong Go handler |
user_salary_update_version | user_salary (ecommerce) | UPDATE | history_version only | {\{ECOMMERCE_BASE_URL}\}/events | Chỉ fire khi history_version thay đổi |
Lưu ý:
user_salary_insertKHÔNG có filteris_official=trueở Hasura level. Handler Go (user_salary_insert.godòng 164) tự query recordis_official=falseđể so sánh.
Schedulers (Cron)
| Name | Schedule | Tháng | Handler |
|---|---|---|---|
export_salary_28 | 0 17 28 2 * | Tháng 2 (28 ngày) | {\{EXPORT_BASE_URL}\}/schedulers |
export_salary_29 | 0 17 29 2 * | Tháng 2 (năm nhuận) | {\{EXPORT_BASE_URL}\}/schedulers |
export_salary_30 | 0 17 30 4,6,9,11 * | Tháng 30 ngày | {\{EXPORT_BASE_URL}\}/schedulers |
export_salary_31 | 0 17 31 1,3,5,7,8,10,12 * | Tháng 31 ngày | {\{EXPORT_BASE_URL}\}/schedulers |
→ Chạy lúc 17:00 UTC ngày cuối mỗi tháng (tuỳ tháng 28/29/30/31).
Database Tables
DB: ecommerce (11 tables)
| Table | Loại | Mô tả |
|---|---|---|
user_salary | Master | Bản ghi lương NV (PK: id, unique: user_id+month+is_official) |
general_salary | Detail | Cột chung (27 fields), FK → user_salary |
branch_salary | Detail | Cột branch (13 fields), FK → user_salary |
telesales_salary | Detail | Cột telesales (3 fields), FK → user_salary |
marketing_salary | Detail | Cột marketing (4 fields), FK → user_salary |
doctor_salary | Detail | Cột doctor (8 fields), FK → user_salary |
user_salary_history | Audit | changed_columns (text[]), version_id |
salary_report | View | Aggregate theo loại lương |
salary_branch_detail_report | View | Chi tiết branch |
salary_detail_report | View | Chi tiết từng NV |
user_monthly_salary_report | View | Báo cáo hàng tháng |
DB: hrm (2 tables)
| Table | Mô tả |
|---|---|
salary_excel | File upload history |
salary | DEPRECATED — legacy flat structure, vẫn tồn tại |
SQL Functions (ecommerce, 5 functions)
| Function | Mô tả |
|---|---|
search_salary_report() | Summary theo loại (general/branch/doctor) |
search_salary_branch_report() | Theo branch với aggregate |
search_salary_office_report() | Theo office/department |
search_salary_detail_report() | Chi tiết từng NV |
get_user_monthly_salary_report() | Báo cáo hàng tháng |
Go Source Files
ecommerce-api
| File | Lines | Chức năng |
|---|---|---|
diva-backend/services/ecommerce-api/action/get_user_salary_data.go | 233 | Action: query + merge temp/official |
diva-backend/services/ecommerce-api/action/get_user_salary_data_aggregate.go | 100 | Count records |
diva-backend/services/ecommerce-api/event/user_salary_insert.go | 741 | Event: compare official vs draft, save changed_columns |
diva-backend/services/ecommerce-api/event/user_salary_update_version.go | 202 | Event: recalc draft |
diva-backend/services/ecommerce-api/event/violation_user_change_for_salary.go | 169 | Violation → update fine_amount + recalc |
export-api
| File | Lines | Chức năng |
|---|---|---|
diva-backend/services/export-api/action/report_salary.go | 1039 | Export Excel: query tất cả data, fill 5 sheets, upload GCP |
diva-backend/services/export-api/event/salary_excel_insert.go | 244 | DEPRECATED — event đã xóa khỏi Hasura metadata, file Go vẫn tồn tại |
diva-backend/services/export-api/scheduler/export_salary.go | 93 | Cron: GenerateSalary cho tất cả NV active |
Core store
| File | Lines | Chức năng |
|---|---|---|
diva-backend/pkg/store/user_salary.go | ~870 | Types, GenerateSalary, InitThisMonthSalary, MergeSalary, GetSubSalaryType |
Liên quan (ảnh hưởng salary gián tiếp)
| File | Lines | Chức năng |
|---|---|---|
diva-backend/services/ecommerce-api/event/invoice_insert_update.go | 2086 | Invoice → revenue cho salary |
diva-backend/services/ecommerce-api/event/request_working_schedule_update.go | 2121 | Lịch làm việc → ngày công |
diva-backend/services/auth/event/employee_profile_update.go | 388 | Employee profile → salary impact |
FE Khác
| File | Chức năng |
|---|---|
diva-admin/src/modules/salary/compositions/useSalary.ts | Excel validation, column mapping, sheet templates |
diva-admin/src/modules/salary/i18n/vi.ts | 80+ labels tiếng Việt |
diva-admin/src/modules/salary/types.ts | Constants, route names, SalaryImportItemType (37 fields) |