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