Skip to content

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 ConstantPathParamsComponent
ROUTE_SALARY/salaryLayout.tsx
ROUTE_SALARY_LIST/salary/listSalaryList.tsx (legacy)
ROUTE_SALARY_DETAIL/salary/:user_id/:month/detailuser_id, monthSalaryDetail.tsx (legacy)
ROUTE_SALARY_GENERAL/salary/generalSalaryGeneral.tsx
ROUTE_SALARY_BRANCH/salary/branchSalaryBranch.tsx
ROUTE_SALARY_BRANCH_DETAIL/salary/branch/:branchIdbranchIdSalaryBranchDetail.tsx
ROUTE_SALARY_EMPLOYEE_BRANCH_DETAIL/salary/branch/:userId/:targetMonthuserId, targetMonthSalaryEmployee.tsx
ROUTE_SALARY_OFFICE/salary/officeSalaryOffice.tsx
ROUTE_SALARY_OFFICE_DETAIL/salary/office/:officeIdofficeIdSalaryOfficeDetail.tsx
ROUTE_SALARY_EMPLOYEE_OFFICE_DETAIL/salary/office/:officeId/:userId/:targetMonthofficeId, userId, targetMonthSalaryEmployee.tsx
ROUTE_SALARY_DOCTOR/salary/doctorSalaryDoctor.tsx
ROUTE_SALARY_EMPLOYEE_DOCTOR_DETAIL/salary/doctor/:userId/:targetMonthuserId, targetMonthSalaryEmployee.tsx
ROUTE_SALARY_FILE_DOWNLOAD_HISTORY/salary/file-download-historySalaryFileHistory.tsx

Permissions: ITLeader · ITStaff · BOD

FE Pages (11 files)

PagePath (từ diva-admin/src/modules/salary/)
SalaryList.tsxpages/SalaryList.tsx (legacy)
SalaryDetail.tsxpages/SalaryDetail.tsx (legacy)
SalaryGeneral.tsxpages/general/SalaryGeneral.tsx
SalaryBranch.tsxpages/branch/SalaryBranch.tsx
SalaryBranchDetail.tsxpages/branch/SalaryBranchDetail.tsx
SalaryBranchImport.tsxpages/branch/SalaryBranchImport.tsx
SalaryOffice.tsxpages/office/SalaryOffice.tsx
SalaryOfficeDetail.tsxpages/office/SalaryOfficeDetail.tsx
SalaryOfficeImport.tsxpages/office/SalaryOfficeImport.tsx
SalaryDoctor.tsxpages/doctor/SalaryDoctor.tsx
SalaryDoctorImport.tsxpages/doctor/SalaryDoctorImport.tsx

FE Components (33 files)

NhómComponentPath (từ diva-admin/src/modules/salary/)
ChungMonthPickerWithButtoncomponents/MonthPickerWithButton.tsx
SalaryDetailcomponents/SalaryDetail.tsx
SalaryFileHistorycomponents/SalaryFileHistory.tsx
SalaryGroupInfoCardcomponents/SalaryGroupInfoCard.tsx
SalaryImportcomponents/SalaryImport.tsx
SalaryShowListcomponents/SalaryShowList.tsx
SalarySummarycomponents/SalarySummary.tsx
SalarySummaryCardcomponents/SalarySummaryCard.tsx
SalaryTablecomponents/SalaryTable.tsx
SalaryToolbarcomponents/SalaryToolbar.tsx
Employee GeneralEmployeeInfocomponents/employee/general/EmployeeInfo.tsx
SalaryEmployeeBasicInfocomponents/employee/general/SalaryEmployeeBasicInfo.tsx
SalaryEmployeeGeneralcomponents/employee/general/SalaryEmployeeGeneral.tsx
SalaryEmployeeSalaryInfocomponents/employee/general/SalaryEmployeeSalaryInfo.tsx
Employee DetailSalaryEmployeeDetailcomponents/employee/detail/SalaryEmployeeDetail.tsx
SalaryEmployeeSalaryDetailcomponents/employee/detail/SalaryEmployeeSalaryDetail.tsx
SalaryEmployeeSalaryDetailCardcomponents/employee/detail/SalaryEmployeeSalaryDetailCard.tsx
SalaryEmployeeSalaryDetailOtherCardcomponents/employee/detail/SalaryEmployeeSalaryDetailOtherCard.tsx
SalaryEmployeeSalaryDetailRevenueCardscomponents/employee/detail/SalaryEmployeeSalaryDetailRevenueCards.tsx
SalaryEmployeeSalaryInfoCardcomponents/employee/detail/SalaryEmployeeSalaryInfoCard.tsx
SalaryEmployeeSalaryTablecomponents/employee/detail/SalaryEmployeeSalaryTable.tsx
BranchSalaryBranchTablecomponents/branch/SalaryBranchTable.tsx
SalaryBranchDetailTablecomponents/branch/SalaryBranchDetailTable.tsx
StaffSalaryInforcomponents/StaffSalaryInfor.tsx
OfficeSalaryOfficeTablecomponents/office/SalaryOfficeTable.tsx
SalaryOfficeDetailTablecomponents/office/SalaryOfficeDetailTable.tsx
DoctorSalaryDoctorTablecomponents/doctor/SalaryDoctorTable.tsx
GeneralSalaryGroupCardcomponents/general/SalaryGroupCard.tsx
SalaryGroupscomponents/general/SalaryGroups.tsx

GraphQL Queries & Mutations

File: diva-admin/src/modules/salary/graphql/salary.graphql

NameTypeSourceMô tả
ListSalaryFileHistoryquerysalary_excel table + aggregateLịch sử file upload
getSalariesquerysalary table (HRM legacy)Danh sách lương (legacy)
GetSalaryByPkquerysalary_by_pkLương 1 NV theo PK
SalaryExcelquerysalary_excel tableFile Excel mới nhất
SalaryGeneralquerysearch_salary_report (SQL function)Summary 5 loại
SalaryBranchCardsquerygetUserSalaryDataAggregate (action) + search_salary_branch_reportAggregate branch
SalaryBranchTablequerysearch_salary_branch_report (SQL function)Bảng branch
SalaryOfficeCardsquerysearch_salary_office_report (SQL function)Aggregate office
SalaryOfficeTablequerysearch_salary_office_report (SQL function)Bảng office
SalaryDetailCards + SalaryDetailTablequerysearch_salary_detail_report (SQL function)Chi tiết NV
SalaryEmployeeDetailquerygetUserSalaryData (action)1 NV, merge temp+official
SalaryEmployeeFilequerygetUserSalaryData (action)NV cho file export
DownloadSalarymutationreportSalary (action, async)Export Excel
UploadUserSalaryFilemutationinsert salary_excelLưu metadata file
InsertUserSalarymutationinsert user_salaryImport data

Hasura Actions

ActionHandlerKindTimeout
getUserSalaryData{\{ECOMMERCE_BASE_URL}\}/actionssync
getUserSalaryDataAggregate{\{ECOMMERCE_BASE_URL}\}/actionssync
reportSalary{\{EXPORT_BASE_URL}\}/actionsasync900s (15 phút)

Event Triggers

EventTableOperationColumnsHandlerGhi chú
user_salary_insertuser_salary (ecommerce)INSERT* (tất cả){\{ECOMMERCE_BASE_URL}\}/eventsFire cho MỌI insert — logic filter is_official nằm trong Go handler
user_salary_update_versionuser_salary (ecommerce)UPDATEhistory_version only{\{ECOMMERCE_BASE_URL}\}/eventsChỉ fire khi history_version thay đổi

Lưu ý: user_salary_insert KHÔNG có filter is_official=true ở Hasura level. Handler Go (user_salary_insert.go dòng 164) tự query record is_official=false để so sánh.

Schedulers (Cron)

NameScheduleThángHandler
export_salary_280 17 28 2 *Tháng 2 (28 ngày){\{EXPORT_BASE_URL}\}/schedulers
export_salary_290 17 29 2 *Tháng 2 (năm nhuận){\{EXPORT_BASE_URL}\}/schedulers
export_salary_300 17 30 4,6,9,11 *Tháng 30 ngày{\{EXPORT_BASE_URL}\}/schedulers
export_salary_310 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)

TableLoạiMô tả
user_salaryMasterBản ghi lương NV (PK: id, unique: user_id+month+is_official)
general_salaryDetailCột chung (27 fields), FK → user_salary
branch_salaryDetailCột branch (13 fields), FK → user_salary
telesales_salaryDetailCột telesales (3 fields), FK → user_salary
marketing_salaryDetailCột marketing (4 fields), FK → user_salary
doctor_salaryDetailCột doctor (8 fields), FK → user_salary
user_salary_historyAuditchanged_columns (text[]), version_id
salary_reportViewAggregate theo loại lương
salary_branch_detail_reportViewChi tiết branch
salary_detail_reportViewChi tiết từng NV
user_monthly_salary_reportViewBáo cáo hàng tháng

DB: hrm (2 tables)

TableMô tả
salary_excelFile upload history
salaryDEPRECATED — legacy flat structure, vẫn tồn tại

SQL Functions (ecommerce, 5 functions)

FunctionMô 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

FileLinesChức năng
diva-backend/services/ecommerce-api/action/get_user_salary_data.go233Action: query + merge temp/official
diva-backend/services/ecommerce-api/action/get_user_salary_data_aggregate.go100Count records
diva-backend/services/ecommerce-api/event/user_salary_insert.go741Event: compare official vs draft, save changed_columns
diva-backend/services/ecommerce-api/event/user_salary_update_version.go202Event: recalc draft
diva-backend/services/ecommerce-api/event/violation_user_change_for_salary.go169Violation → update fine_amount + recalc

export-api

FileLinesChức năng
diva-backend/services/export-api/action/report_salary.go1039Export Excel: query tất cả data, fill 5 sheets, upload GCP
diva-backend/services/export-api/event/salary_excel_insert.go244DEPRECATED — event đã xóa khỏi Hasura metadata, file Go vẫn tồn tại
diva-backend/services/export-api/scheduler/export_salary.go93Cron: GenerateSalary cho tất cả NV active

Core store

FileLinesChức năng
diva-backend/pkg/store/user_salary.go~870Types, GenerateSalary, InitThisMonthSalary, MergeSalary, GetSubSalaryType

Liên quan (ảnh hưởng salary gián tiếp)

FileLinesChức năng
diva-backend/services/ecommerce-api/event/invoice_insert_update.go2086Invoice → revenue cho salary
diva-backend/services/ecommerce-api/event/request_working_schedule_update.go2121Lịch làm việc → ngày công
diva-backend/services/auth/event/employee_profile_update.go388Employee profile → salary impact

FE Khác

FileChức năng
diva-admin/src/modules/salary/compositions/useSalary.tsExcel validation, column mapping, sheet templates
diva-admin/src/modules/salary/i18n/vi.ts80+ labels tiếng Việt
diva-admin/src/modules/salary/types.tsConstants, route names, SalaryImportItemType (37 fields)