| Conditions | 2 |
| Total Lines | 18 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { CommandHandler } from '@nestjs/cqrs'; |
||
| 17 | |||
| 18 | public async execute(command: IncreaseUserSavingsRecordCommand): Promise<string> { |
||
| 19 | const { userId, amount } = command; |
||
| 20 | |||
| 21 | const user = await this.userRepository.findOneById(userId); |
||
| 22 | if (!user) { |
||
| 23 | throw new UserNotFoundException(); |
||
| 24 | } |
||
| 25 | |||
| 26 | const userSavingsRecord = await this.userSavingsRecordRepository.save( |
||
| 27 | new UserSavingsRecord( |
||
| 28 | Math.round(amount * 100), |
||
| 29 | SavingsRecordType.INPUT, |
||
| 30 | user, |
||
| 31 | ) |
||
| 32 | ); |
||
| 33 | |||
| 34 | return userSavingsRecord.getId(); |
||
| 35 | } |
||
| 37 |