| Conditions | 6 |
| Total Lines | 31 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {Event, EventType} from './Event.entity'; |
||
| 35 | |||
| 36 | public calculateNumberOfMealTicket( |
||
| 37 | overview: IEventsOverview, |
||
| 38 | eventsByDate: any[] |
||
| 39 | ): IEventsOverview { |
||
| 40 | const excludedType = [ |
||
| 41 | EventType.WORK_FREE, |
||
| 42 | EventType.MEDICAL_LEAVE, |
||
| 43 | EventType.HOLIDAY, |
||
| 44 | EventType.OTHER |
||
| 45 | ]; |
||
| 46 | |||
| 47 | for (const sortedEvent of eventsByDate) { |
||
| 48 | if (!sortedEvent) { |
||
| 49 | continue; |
||
| 50 | } |
||
| 51 | |||
| 52 | let totalPerDay = 0; |
||
| 53 | |||
| 54 | for (const {time, type} of sortedEvent) { |
||
| 55 | if (!excludedType.includes(type)) { |
||
| 56 | totalPerDay += time; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | if (totalPerDay > 0.5) { |
||
| 61 | overview.mealTicket++; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | return overview; |
||
| 66 | } |
||
| 68 |