Skip to content

Commit 8ec2fab

Browse files
committed
Add sports pass fee
1 parent 1ac13df commit 8ec2fab

21 files changed

+92
-25
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class addSportsPassFeeToUserAdministrative1710429580134 implements MigrationInterface {
4+
name = 'addSportsPassFeeToUserAdministrative1710429580134'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`ALTER TABLE "user_administrative" ADD "sportsPassFee" integer DEFAULT '0'`);
8+
}
9+
10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(`ALTER TABLE "user_administrative" DROP COLUMN "sportsPassFee"`);
12+
}
13+
}

src/Application/HumanResource/Payslip/Query/GetUserElementsQueryHandler.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ describe('GetUserElementsQueryHandler', () => {
5757
const earnings = 2000000;
5858
const rawTransportFee = 7500;
5959
const rawSustainableMobilityFee = 7000;
60+
const rawSportsPassFee = 3000;
6061
const userAdministrative = mock(UserAdministrative);
6162
when(userAdministrative.getContract()).thenReturn(ContractType.CDI);
6263
when(userAdministrative.isExecutivePosition()).thenReturn(true);
@@ -70,6 +71,7 @@ describe('GetUserElementsQueryHandler', () => {
7071
when(userAdministrative.getSustainableMobilityFee()).thenReturn(
7172
rawSustainableMobilityFee
7273
);
74+
when(userAdministrative.getSportsPassFee()).thenReturn(rawSportsPassFee);
7375
when(userAdministrative.haveHealthInsurance()).thenReturn(true);
7476

7577
when(user.getId()).thenReturn('3b8a1954-2ade-44a2-a03c-338985c327ef');
@@ -146,6 +148,7 @@ describe('GetUserElementsQueryHandler', () => {
146148
const yearlyEarning = earnings * 0.01;
147149
const transportFee = rawTransportFee * 0.01;
148150
const sustainableMobilityFee = rawSustainableMobilityFee * 0.01;
151+
const sportsPassFee = rawSportsPassFee * 0.01;
149152

150153
expect(await queryHandler.execute(query)).toMatchObject([
151154
new UserElementsView(
@@ -159,6 +162,7 @@ describe('GetUserElementsQueryHandler', () => {
159162
WorkingTimeType.FULL_TIME,
160163
transportFee,
161164
sustainableMobilityFee,
165+
sportsPassFee,
162166
5,
163167
true,
164168
new UserLeavesView(0, [

src/Application/HumanResource/Payslip/Query/GetUsersElementsQueryHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class GetUsersElementsQueryHandler {
5959
user.getUserAdministrative().getWorkingTime(),
6060
user.getUserAdministrative().getTransportFee() * 0.01,
6161
user.getUserAdministrative().getSustainableMobilityFee() * 0.01,
62+
user.getUserAdministrative().getSportsPassFee() * 0.01,
6263
mealTicketsByUser[user.getId()],
6364
user.getUserAdministrative().haveHealthInsurance(),
6465
this.createUserLeavesView(userLeaves.paid, date),

src/Application/HumanResource/Payslip/View/UserElementsView.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class UserElementsView {
1212
public readonly workingTime: string,
1313
public readonly transportFee: number,
1414
public readonly sustainableMobilityFee: number,
15+
public readonly sportsPassFee: number,
1516
public readonly mealTickets: number,
1617
public readonly healthInsurance: boolean,
1718
public readonly paidLeaves: UserLeavesView,

src/Application/HumanResource/User/Command/CreateUserCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface IUserAdministrativeCommand {
1515
leavingDate: string;
1616
transportFee: number;
1717
sustainableMobilityFee: number;
18+
sportsPassFee: number;
1819
}
1920

2021
export class CreateUserCommand implements ICommand {

src/Application/HumanResource/User/Command/CreateUserCommandHandler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export class CreateUserCommandHandler {
7676
joiningDate,
7777
leavingDate,
7878
transportFee,
79-
sustainableMobilityFee
79+
sustainableMobilityFee,
80+
sportsPassFee
8081
} = userAdministrative;
8182

8283
return await this.userAdministrativeRepository.save(
@@ -89,7 +90,8 @@ export class CreateUserCommandHandler {
8990
joiningDate,
9091
leavingDate ? leavingDate : null,
9192
transportFee ? Math.round(transportFee * 100) : 0,
92-
sustainableMobilityFee ? Math.round(sustainableMobilityFee * 100) : 0
93+
sustainableMobilityFee ? Math.round(sustainableMobilityFee * 100) : 0,
94+
sportsPassFee ? Math.round(sportsPassFee * 100) : 0
9395
)
9496
);
9597
}

src/Application/HumanResource/User/Command/UpdateUserCommand.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class UpdateUserCommand implements ICommand {
1717
public readonly joiningDate: string,
1818
public readonly leavingDate: string,
1919
public readonly transportFee: number,
20-
public readonly sustainableMobilityFee: number
20+
public readonly sustainableMobilityFee: number,
21+
public readonly sportsPassFee: number
2122
) {}
2223
}

src/Application/HumanResource/User/Command/UpdateUserCommandHandler.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ describe('UpdateProfileCommandHandler', () => {
3131
'2018-01-01',
3232
null,
3333
75.2,
34-
70
34+
70,
35+
30
3536
);
3637

3738
beforeEach(() => {
@@ -74,7 +75,8 @@ describe('UpdateProfileCommandHandler', () => {
7475
'2017-08-01',
7576
'2018-12-31',
7677
null,
77-
7000
78+
7000,
79+
3000
7880
);
7981
const user = new User(
8082
'John',
@@ -105,7 +107,8 @@ describe('UpdateProfileCommandHandler', () => {
105107
'2018-01-01',
106108
null,
107109
7520,
108-
7000
110+
7000,
111+
3000
109112
);
110113
verify(
111114
userRepository.save(
@@ -137,7 +140,8 @@ describe('UpdateProfileCommandHandler', () => {
137140
'2017-08-01',
138141
'2018-12-31',
139142
null,
140-
7000
143+
7000,
144+
3000
141145
);
142146
const user = new User(
143147
'John',

src/Application/HumanResource/User/Command/UpdateUserCommandHandler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export class UpdateUserCommandHandler {
2727
joiningDate,
2828
leavingDate,
2929
transportFee,
30-
sustainableMobilityFee
30+
sustainableMobilityFee,
31+
sportsPassFee
3132
} = command;
3233

3334
const user = await this.userRepository.findOneById(id);
@@ -53,7 +54,8 @@ export class UpdateUserCommandHandler {
5354
joiningDate,
5455
leavingDate ? leavingDate : null,
5556
transportFee ? Math.round(transportFee * 100) : 0,
56-
sustainableMobilityFee ? Math.round(sustainableMobilityFee * 100) : 0
57+
sustainableMobilityFee ? Math.round(sustainableMobilityFee * 100) : 0,
58+
sportsPassFee ? Math.round(sportsPassFee * 100) : 0
5759
);
5860

5961
await this.userRepository.save(user);

src/Application/HumanResource/User/Query/GetUserAdministrativeByIdQueryHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export class GetUserAdministrativeByIdQueryHandler {
3737
userAdministrative.getJoiningDate(),
3838
userAdministrative.getLeavingDate(),
3939
userAdministrative.getTransportFee() * 0.01,
40-
userAdministrative.getSustainableMobilityFee() * 0.01
40+
userAdministrative.getSustainableMobilityFee() * 0.01,
41+
userAdministrative.getSportsPassFee() * 0.01
4142
);
4243
}
4344

0 commit comments

Comments
 (0)