| Conditions | 4 |
| Total Lines | 28 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { Inject } from '@nestjs/common'; |
||
| 16 | |||
| 17 | public async convert(leaveRequest: LeaveRequest): Promise<void> { |
||
| 18 | const exceptions: MealTicketRemoval[] = []; |
||
| 19 | const dates = this.dateUtils.getWorkedDaysDuringAPeriod( |
||
| 20 | new Date(leaveRequest.getStartDate()), |
||
| 21 | new Date(leaveRequest.getEndDate()) |
||
| 22 | ); |
||
| 23 | |||
| 24 | if (!dates || 0 === dates.length) { |
||
| 25 | return; |
||
| 26 | } |
||
| 27 | |||
| 28 | const user = leaveRequest.getUser(); |
||
| 29 | |||
| 30 | for (const date of dates) { |
||
| 31 | if (true === (await this.isMealTicketRemovalAlreadyExist.isSatisfiedBy(user, date))) { |
||
| 32 | continue; |
||
| 33 | } |
||
| 34 | |||
| 35 | exceptions.push( |
||
| 36 | new MealTicketRemoval( |
||
| 37 | date.toISOString(), |
||
| 38 | leaveRequest.getUser() |
||
| 39 | ) |
||
| 40 | ); |
||
| 41 | } |
||
| 42 | |||
| 43 | await this.mealTicketRemovalRepository.save(exceptions); |
||
| 44 | } |
||
| 46 |