gongxiangp2/lib/performance-salary-details-contract.ts

41 lines
1.9 KiB
TypeScript

import type { SalaryRole } from './performance-salary-roles'
import type { SalaryPosition } from './salary-position-contract'
import type { SalaryTemplate } from './performance-salary-templates'
import type { MarketIntentEvidence } from './salary-market-intent-contract'
import type { DepartmentDeliveryEvidence } from './salary-department-contract'
import { salaryMonthLabel } from './performance-salary-templates'
import type { SurveyMatchReason } from './salary-survey-scores'
export type SalaryCell = string | number | null
export type SalaryDetailRow = {
employeeProfileId: string
employeeLabel: string
hasSalaryBase: boolean
positionGroupCode: string
values: Record<string, SalaryCell>
metrics: Record<string, number | null>
metricEvidence?: Record<string, MarketIntentEvidence | DepartmentDeliveryEvidence>
totalScore: number | null
positionId?: string
jobGrade?: string
performancePositionId?: string | null
performanceMatch?: 'matched' | 'unmatched'
}
export type SalaryDetails = {
displayMonth: string
sourceMonth: string
marketSourceMonth: string
isFallback: boolean
roles: Record<SalaryRole, SalaryDetailRow[]>
positionGroups: Array<{ position: SalaryPosition; template: SalaryTemplate; rows: SalaryDetailRow[] }>
surveyMatchIssues?: Array<{ employeeProfileId: string; employeeLabel: string; salaryRole: SalaryRole; reason: SurveyMatchReason; message: string }>
departmentMatchIssues?: Array<{ employeeProfileId: string; employeeLabel: string; message: string }>
}
export function salarySourceLabel(data: Pick<SalaryDetails, 'displayMonth' | 'sourceMonth' | 'marketSourceMonth' | 'isFallback'>) {
const source = data.isFallback
? `${Number(data.displayMonth.slice(5))}月暂无调研数据,当前使用${salaryMonthLabel(data.sourceMonth)}数据测试`
: `数据月份:${salaryMonthLabel(data.sourceMonth)}`
return `${source};市场验证考核月份:${salaryMonthLabel(data.marketSourceMonth)}`
}