diff --git a/migrations/1719581515131-addRelocationLeave.ts b/migrations/1719581515131-addRelocationLeave.ts new file mode 100644 index 00000000..af9a3589 --- /dev/null +++ b/migrations/1719581515131-addRelocationLeave.ts @@ -0,0 +1,32 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddRelocationLeave1719581515131 + implements MigrationInterface { + name = 'AddRelocationLeave1719581515131'; + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query( + `ALTER TYPE "public"."leave_request_type_enum" RENAME TO "leave_request_type_enum_old"` + ); + await queryRunner.query( + `CREATE TYPE "public"."leave_request_type_enum" AS ENUM('paid', 'unpaid', 'special', 'medical', 'illimited', 'postponedWorkedFreeDay', 'relocation')` + ); + await queryRunner.query( + `ALTER TABLE "leave_request" ALTER COLUMN "type" TYPE "public"."leave_request_type_enum" USING "type"::"text"::"public"."leave_request_type_enum"` + ); + await queryRunner.query(`DROP TYPE "public"."leave_request_type_enum_old"`); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query( + `CREATE TYPE "public"."leave_request_type_enum_old" AS ENUM('paid', 'unpaid', 'special', 'medical', 'illimited', 'postponedWorkedFreeDay')` + ); + await queryRunner.query( + `ALTER TABLE "leave_request" ALTER COLUMN "type" TYPE "public"."leave_request_type_enum_old" USING "type"::"text"::"public"."leave_request_type_enum_old"` + ); + await queryRunner.query(`DROP TYPE "public"."leave_request_type_enum"`); + await queryRunner.query( + `ALTER TYPE "public"."leave_request_type_enum_old" RENAME TO "leave_request_type_enum"` + ); + } +} diff --git a/src/Application/HumanResource/Payslip/Query/GetUserElementsQueryHandler.spec.ts b/src/Application/HumanResource/Payslip/Query/GetUserElementsQueryHandler.spec.ts index d5db9254..2d341219 100644 --- a/src/Application/HumanResource/Payslip/Query/GetUserElementsQueryHandler.spec.ts +++ b/src/Application/HumanResource/Payslip/Query/GetUserElementsQueryHandler.spec.ts @@ -169,6 +169,7 @@ describe('GetUserElementsQueryHandler', () => { new UserLeavesView(0, []), new UserLeavesView(0, []), new UserLeavesView(0, []), + new UserLeavesView(0, []), new UserLeavesView(0, []) ) ]); diff --git a/src/Application/HumanResource/Payslip/Query/GetUsersElementsQueryHandler.ts b/src/Application/HumanResource/Payslip/Query/GetUsersElementsQueryHandler.ts index 6ac6841f..7ec3af78 100644 --- a/src/Application/HumanResource/Payslip/Query/GetUsersElementsQueryHandler.ts +++ b/src/Application/HumanResource/Payslip/Query/GetUsersElementsQueryHandler.ts @@ -65,7 +65,8 @@ export class GetUsersElementsQueryHandler { this.createUserLeavesView(userLeaves.unpaid, date), this.createUserLeavesView(userLeaves.medical, date), this.createUserLeavesView(userLeaves.special, date), - this.createUserLeavesView(userLeaves.postponedWorkedFreeDay, date) + this.createUserLeavesView(userLeaves.postponedWorkedFreeDay, date), + this.createUserLeavesView(userLeaves.relocation, date) ) ); } diff --git a/src/Application/HumanResource/Payslip/View/UserElementsView.ts b/src/Application/HumanResource/Payslip/View/UserElementsView.ts index 6e9fe055..979ca443 100644 --- a/src/Application/HumanResource/Payslip/View/UserElementsView.ts +++ b/src/Application/HumanResource/Payslip/View/UserElementsView.ts @@ -18,6 +18,7 @@ export class UserElementsView { public readonly unpaidLeaves: UserLeavesView, public readonly sickLeaves: UserLeavesView, public readonly exceptionalLeaves: UserLeavesView, - public readonly postponedWorkedFreeDayLeaves: UserLeavesView + public readonly postponedWorkedFreeDayLeaves: UserLeavesView, + public readonly relocationLeaves: UserLeavesView ) {} } diff --git a/src/Domain/HumanResource/Leave/LeaveRequest.entity.ts b/src/Domain/HumanResource/Leave/LeaveRequest.entity.ts index 2037aa6b..f338fabe 100644 --- a/src/Domain/HumanResource/Leave/LeaveRequest.entity.ts +++ b/src/Domain/HumanResource/Leave/LeaveRequest.entity.ts @@ -13,7 +13,8 @@ export enum Type { SPECIAL = 'special', MEDICAL = 'medical', ILLIMITED = 'illimited', - POSTPONED_WORKED_FREE_DAY = 'postponedWorkedFreeDay' + POSTPONED_WORKED_FREE_DAY = 'postponedWorkedFreeDay', + RELOCATION = 'relocation' } export interface ILeaveRequestModeration { diff --git a/src/Domain/HumanResource/Leave/UserLeavesCollection.spec.ts b/src/Domain/HumanResource/Leave/UserLeavesCollection.spec.ts index 8aeccb04..b1eb489b 100644 --- a/src/Domain/HumanResource/Leave/UserLeavesCollection.spec.ts +++ b/src/Domain/HumanResource/Leave/UserLeavesCollection.spec.ts @@ -16,13 +16,16 @@ describe('UserLeavesCollection', () => { when(postponedWorkedFreeDayLeave.getType()).thenReturn( Type.POSTPONED_WORKED_FREE_DAY ); + const relocationLeave = mock(LeaveRequest); + when(relocationLeave.getType()).thenReturn(Type.RELOCATION); const userLeaves = new UserLeavesCollection([ instance(paidLeave), instance(unpaidLeave), instance(specialLeave), instance(medicalLeave), - instance(postponedWorkedFreeDayLeave) + instance(postponedWorkedFreeDayLeave), + instance(relocationLeave) ]); expect(userLeaves.paid[0].getType()).toBe(Type.PAID); expect(userLeaves.unpaid[0].getType()).toBe(Type.UNPAID); @@ -31,5 +34,6 @@ describe('UserLeavesCollection', () => { expect(userLeaves.postponedWorkedFreeDay[0].getType()).toBe( Type.POSTPONED_WORKED_FREE_DAY ); + expect(userLeaves.relocation[0].getType()).toBe(Type.RELOCATION); }); }); diff --git a/src/Domain/HumanResource/Leave/UserLeavesCollection.ts b/src/Domain/HumanResource/Leave/UserLeavesCollection.ts index 0d8c6c67..bf0330fd 100644 --- a/src/Domain/HumanResource/Leave/UserLeavesCollection.ts +++ b/src/Domain/HumanResource/Leave/UserLeavesCollection.ts @@ -6,6 +6,7 @@ export class UserLeavesCollection { public special: LeaveRequest[] = []; public medical: LeaveRequest[] = []; public postponedWorkedFreeDay: LeaveRequest[] = []; + public relocation: LeaveRequest[] = []; constructor(leaves: LeaveRequest[]) { this.distributeLeavesByType(leaves); @@ -29,6 +30,9 @@ export class UserLeavesCollection { case Type.POSTPONED_WORKED_FREE_DAY: this.postponedWorkedFreeDay.push(leave); break; + case Type.RELOCATION: + this.relocation.push(leave); + break; } } } diff --git a/src/Infrastructure/HumanResource/PayrollElements/Table/PayrollElementsTableFactory.ts b/src/Infrastructure/HumanResource/PayrollElements/Table/PayrollElementsTableFactory.ts index a4db2a54..b19de3c4 100644 --- a/src/Infrastructure/HumanResource/PayrollElements/Table/PayrollElementsTableFactory.ts +++ b/src/Infrastructure/HumanResource/PayrollElements/Table/PayrollElementsTableFactory.ts @@ -24,7 +24,8 @@ export class PayrollElementsTableFactory { 'payroll-elements-unpaidLeaves', 'payroll-elements-medicalLeaves', 'payroll-elements-specialLeaves', - 'payroll-elements-postponedWorkedFreeDayLeaves' + 'payroll-elements-postponedWorkedFreeDayLeaves', + 'payroll-elements-relocationLeaves' ]; const rows = []; @@ -64,6 +65,9 @@ export class PayrollElementsTableFactory { .template('pages/payroll_elements/_leaves.njk', { leaves: item.postponedWorkedFreeDayLeaves }) + .template('pages/payroll_elements/_leaves.njk', { + leaves: item.relocationLeaves + }) .build(); rows.push(row); diff --git a/src/translations/fr-FR.ftl b/src/translations/fr-FR.ftl index 114b316b..55973e41 100644 --- a/src/translations/fr-FR.ftl +++ b/src/translations/fr-FR.ftl @@ -131,6 +131,7 @@ leaves-type-value = {$type -> [medical] Congé maladie [illimited] Congé illimité [postponedWorkedFreeDay] Congé jour férié glissant + [relocation] Congé déménagement *[other] Autre } leaves-type-value-plural = {$type -> @@ -140,6 +141,7 @@ leaves-type-value-plural = {$type -> [medical] Congés maladie [illimited] Congés illimités [postponedWorkedFreeDay] Congés jours fériés glissants + [relocation] Congés déménagement *[other] Autre } leaves-startDate = Du @@ -200,6 +202,7 @@ payroll-elements-unpaidLeaves = Congés sans solde payroll-elements-medicalLeaves = Congés maladie payroll-elements-specialLeaves = Congés exceptionnels payroll-elements-postponedWorkedFreeDayLeaves = Congés jours fériés glissants +payroll-elements-relocationLeaves = Congés déménagement payroll-elements-download = Télécharger payroll-elements-filename = Fairness - Éléments de paie - {$date}.csv payroll-elements-wiki = Voir le Wiki