Passed
Pull Request — master (#70)
by Mathieu
01:43
created

server/src/Domain/Billing/QuoteIdGenerator.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 18
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 15
mnd 0
bc 0
fnc 1
dl 0
loc 18
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A QuoteIdGenerator.generate 0 6 1
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