Conditions | 1 |
Total Lines | 14 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {InjectRepository} from '@nestjs/typeorm'; |
||
16 | |||
17 | public findOneByUserAndDate( |
||
18 | user: User, |
||
19 | date: Date |
||
20 | ): Promise<PayStub | undefined> { |
||
21 | const month = new Date(date).getMonth() + 1; |
||
22 | const year = new Date(date).getFullYear(); |
||
23 | |||
24 | return this.repository |
||
25 | .createQueryBuilder('payStub') |
||
26 | .select(['payStub.id']) |
||
27 | .where('payStub.user = :userId', {userId: user.getId()}) |
||
28 | .andWhere('extract(month FROM payStub.date) = :month', {month}) |
||
29 | .andWhere('extract(year FROM payStub.date) = :year', {year}) |
||
30 | .getOne(); |
||
33 |