| Total Complexity | 1 |
| Total Lines | 15 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import {Injectable, Inject} from '@nestjs/common'; |
||
| 4 | |||
| 5 | @Injectable() |
||
| 6 | export class QuoteIdGenerator { |
||
| 7 | constructor( |
||
| 8 | @Inject('IQuoteRepository') |
||
| 9 | private readonly quoteRepository: IQuoteRepository, |
||
| 10 | @Inject('IDateUtils') |
||
| 11 | private readonly dateUtils: IDateUtils |
||
| 12 | ) {} |
||
| 13 | |||
| 14 | public async generate(): Promise<string> { |
||
| 15 | const year = this.dateUtils.getCurrentDate().getFullYear(); |
||
| 16 | const nbItem = await this.quoteRepository.countByYear(year); |
||
| 17 | |||
| 18 | return `FS-DEVIS-${year}-${String(nbItem + 1).padStart(4, '0')}`; |
||
| 19 | } |
||
| 21 |