Skip to content

Commit 212dbf4

Browse files
committed
Add sports pass fee
1 parent 1ac13df commit 212dbf4

File tree

12 files changed

+52
-17
lines changed

12 files changed

+52
-17
lines changed

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

src/Application/HumanResource/User/View/UserAdministrativeView.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class UserAdministrativeView {
1313
public readonly joiningDate: string,
1414
public readonly leavingDate: string,
1515
public readonly transportFee: number,
16-
public readonly sustainableMobilityFee: number
16+
public readonly sustainableMobilityFee: number,
17+
public readonly sportsPassFee: number
1718
) {}
1819
}

src/Domain/HumanResource/User/UserAdministrative.entity.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ describe('UserAdministrative.entity', () => {
1515
'2020-01-01',
1616
'2021-01-01',
1717
7550,
18-
7000
18+
7000,
19+
3000,
1920
);
2021

2122
expect(admin.getId()).toBe(undefined);
@@ -28,6 +29,7 @@ describe('UserAdministrative.entity', () => {
2829
expect(admin.isExecutivePosition()).toBe(true);
2930
expect(admin.haveHealthInsurance()).toBe(true);
3031
expect(admin.getSustainableMobilityFee()).toBe(7000);
32+
expect(admin.getSportsPassFee()).toBe(3000);
3133
});
3234

3335
it('testUpdate', () => {
@@ -40,7 +42,8 @@ describe('UserAdministrative.entity', () => {
4042
'2020-01-01',
4143
null,
4244
7550,
43-
7000
45+
7000,
46+
3000,
4447
);
4548

4649
admin.update(
@@ -52,7 +55,8 @@ describe('UserAdministrative.entity', () => {
5255
'2020-01-02',
5356
'2021-01-02',
5457
null,
55-
3000
58+
3000,
59+
2000,
5660
);
5761
expect(admin.getAnnualEarnings()).toBe(3000000);
5862
expect(admin.getContract()).toBe(ContractType.APPRENTICESHIP);
@@ -63,5 +67,6 @@ describe('UserAdministrative.entity', () => {
6367
expect(admin.getLeavingDate()).toBe('2021-01-02');
6468
expect(admin.getTransportFee()).toBe(null);
6569
expect(admin.getSustainableMobilityFee()).toBe(3000);
70+
expect(admin.getSportsPassFee()).toBe(2000);
6671
});
6772
});

src/Domain/HumanResource/User/UserAdministrative.entity.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export class UserAdministrative {
3434
@Column({ type: 'integer', default: 0, nullable: true })
3535
private sustainableMobilityFee: number;
3636

37+
@Column({ type: 'integer', default: 0, nullable: true })
38+
private sportsPassFee: number;
39+
3740
@Column({ type: 'boolean', nullable: false })
3841
private healthInsurance: boolean;
3942

@@ -61,7 +64,8 @@ export class UserAdministrative {
6164
joiningDate: string,
6265
leavingDate?: string,
6366
transportFee?: number,
64-
sustainableMobilityFee?: number
67+
sustainableMobilityFee?: number,
68+
sportsPassFee?: number
6569
) {
6670
this.annualEarnings = annualEarnings;
6771
this.healthInsurance = healthInsurance;
@@ -72,6 +76,7 @@ export class UserAdministrative {
7276
this.leavingDate = leavingDate;
7377
this.transportFee = transportFee;
7478
this.sustainableMobilityFee = sustainableMobilityFee;
79+
this.sportsPassFee = sportsPassFee;
7580
}
7681

7782
public getId(): string {
@@ -98,6 +103,10 @@ export class UserAdministrative {
98103
return this.sustainableMobilityFee;
99104
}
100105

106+
public getSportsPassFee(): number {
107+
return this.sportsPassFee;
108+
}
109+
101110
public haveHealthInsurance(): boolean {
102111
return this.healthInsurance;
103112
}
@@ -123,7 +132,8 @@ export class UserAdministrative {
123132
joiningDate: string,
124133
leavingDate: string | null,
125134
transportFee: number,
126-
sustainableMobilityFee: number
135+
sustainableMobilityFee: number,
136+
sportsPassFee: number
127137
): void {
128138
this.annualEarnings = annualEarnings;
129139
this.contract = contract;
@@ -134,5 +144,6 @@ export class UserAdministrative {
134144
this.leavingDate = leavingDate;
135145
this.transportFee = transportFee;
136146
this.sustainableMobilityFee = sustainableMobilityFee;
147+
this.sportsPassFee = sportsPassFee;
137148
}
138149
}

src/Infrastructure/HumanResource/User/DTO/UserAdministrativeDTO.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('UserAdministrativeDTO', () => {
1616
dto.executivePosition = true;
1717
dto.healthInsurance = true;
1818
dto.transportFee = 75.2;
19+
dto.sportsPassFee = 30;
1920
dto.joiningDate = '2020-12-17T03:24:00';
2021
dto.leavingDate = '2021-12-17T03:24:00';
2122

0 commit comments

Comments
 (0)