import { Base } from './base'; import { Dictionary } from './dictionary'; import { EmployeeMin } from './employeeMin'; import { CompanyMin } from './companyMin'; export class RegionInformation extends Base { regionID?: string; regionName?: string; constructor(data: any | null = null) { super(); this.regionID = ''; this.regionName = ''; this.load(data); } } export class CostCenter extends Base { costCenterID?: string; costCenterName?: string; constructor(data: any | null = null) { super(); this.costCenterID = ''; this.costCenterName = ''; this.load(data); } } export class WorkCenter extends Base { workCenterID?: string; workCenterName?: string; constructor(data: any | null = null) { super(); this.workCenterID = ''; this.workCenterName = ''; this.load(data); } } export class Department extends Base { departmentID?: string; departmentName?: string; constructor(data: any | null = null) { super(); this.departmentID = ''; this.departmentName = ''; this.load(data); } } export class Income extends Base { payrollID: string; date: Date; amount: number; constructor(data: any | null = null) { super(); this.payrollID = ''; this.date = new Date(); this.amount = 0; this.load(data); } } export class Wage extends Base { amount: number; typeID: string; typeName: string; payrollType: string; historical: Dictionary; constructor(data: any | null = null) { super(); this.amount = 0; this.typeID = ''; this.typeName = ''; this.payrollType = ''; this.historical = new Dictionary(Income); this.load(data); } get periodWage() { const pt = Number(this.typeID); if (pt === 2 || pt === 4) { return this.amount * 14; } return this.amount * 7; } get wageLiq(): number { if (this.payrollType === 'QU' || this.payrollType === 'PR') { return this.periodWage; } else { const values = this.historical.Values(); let avg = 0; if (values.length) { const sum = values.map(element => element.amount).reduce((a, b) => a + b); avg = sum / 3; } return avg; } } } export class Contract extends Base { contractID?: string; description?: string; constructor(data: any | null = null) { super(); this.contractID = ''; this.description = ''; this.load(data); } } export class WorkInformation extends Base { employeeNumber?: string; seniorityDate?: Date; seniorityYears?: number; jobTitle?: string; shift?: string; laidOff?: boolean; supervisor?: EmployeeMin; supervising?: Dictionary; companyRef?: CompanyMin; wage?: Wage; department?: Department; workCenter?: WorkCenter; costCenter?: CostCenter; contract?: Contract; region?: RegionInformation; constructor(data: any | null = null) { super(); this.employeeNumber = ''; this.seniorityDate = new Date(); this.jobTitle = ''; this.shift = ''; this.laidOff = false; this.supervisor = new EmployeeMin(); this.supervising = new Dictionary(EmployeeMin); this.companyRef = new CompanyMin(); this.wage = new Wage(); this.department = new Department(); this.workCenter = new WorkCenter(); this.costCenter = new CostCenter(); this.contract = new Contract(); this.region = new RegionInformation(); this.load(data); } }