| Total Complexity | 2 |
| Total Lines | 15 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { ConfigService } from '@nestjs/config'; |
||
| 3 | |||
| 4 | export abstract class AbstractGenerator { |
||
| 5 | constructor( |
||
| 6 | protected readonly dateUtils: IDateUtils, |
||
| 7 | protected readonly configService: ConfigService |
||
| 8 | ) {} |
||
| 9 | |||
| 10 | protected async format(prefix: string, nbItem: number): Promise<string> { |
||
| 11 | const pad = await this.configService.get<number>('ACCOUNTING_PAD'); |
||
| 12 | |||
| 13 | return `${prefix}-${this.getCurrentYear()}-${String(nbItem + 1).padStart(pad, '0')}`; |
||
| 14 | } |
||
| 15 | |||
| 16 | protected getCurrentYear(): number { |
||
| 17 | return this.dateUtils.getCurrentDate().getFullYear(); |
||
| 18 | } |
||
| 20 |