Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 20 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { ConfigService } from '@nestjs/config'; |
||
2 | import { IDateUtils } from 'src/Application/IDateUtils'; |
||
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 | } |
||
19 | } |
||
20 |