• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gflohr / e-invoice-eu / 14067914634

25 Mar 2025 06:59PM UTC coverage: 68.943%. First build
14067914634

Pull #110

github

web-flow
Merge 128bb09e8 into fbaf9faed
Pull Request #110: Move logic into core library

233 of 371 branches covered (62.8%)

Branch coverage included in aggregate %.

427 of 556 new or added lines in 22 files covered. (76.8%)

726 of 1020 relevant lines covered (71.18%)

72.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.0
/apps/server/src/invoice/invoice.service.ts
1
import {
6✔
2
        InvoiceService as CoreInvoiceService,
3
        InvoiceServiceOptions as CoreInvoiceServiceOptions,
4
} from '@e-invoice-eu/core';
5
import { Injectable, Logger } from '@nestjs/common';
6✔
6

7
import { AppConfigService } from '../app-config/app-config.service';
6✔
8

9
export type InvoiceAttachment = {
10
        /**
11
         * The uploaded file.
12
         */
13
        file: Express.Multer.File;
14

15
        /**
16
         * An optional ID.
17
         */
18
        id?: string;
19

20
        /**
21
         * An optional description.
22
         */
23
        description?: string;
24
};
25

26
type InvoiceServiceOptions = {
27
        /**
28
         * The invoice format like `XRECHNUNG-UBL` or `Factur-X-Extended`.
29
         */
30
        format: string;
31

32
        /**
33
         * The spreadsheet data.
34
         */
35
        data?: Express.Multer.File;
36

37
        /**
38
         * A PDF version of the invoice.  For Factur-X, either `data` or `pdf`
39
         * must be present.
40
         */
41
        pdf?: Express.Multer.File;
42

43
        /**
44
         * A language identifier like "fr-ca".
45
         */
46
        lang: string;
47

48
        /**
49
         * An array of supplementary attachments.
50
         */
51
        attachments: InvoiceAttachment[];
52

53
        /**
54
         * Set to invoice description if invoice should be embedded.
55
         */
56
        embedPDF?: boolean;
57

58
        /**
59
         * ID for an embedded PDF, defaults to the document id.
60
         */
61
        pdfID?: string;
62

63
        /**
64
         * Description for the embedded PDF.
65
         */
66
        pdfDescription?: string;
67
};
68

69
@Injectable()
70
export class InvoiceService {
6✔
71
        private readonly logger = new Logger(InvoiceService.name);
24✔
72

73
        constructor(private readonly appConfigService: AppConfigService) {}
24✔
74

75
        async generate(
76
                input: unknown,
77
                options: InvoiceServiceOptions,
78
        ): Promise<string | Buffer> {
79
                const coreOptions: CoreInvoiceServiceOptions = {
6✔
80
                        format: options.format,
81
                        lang: options.lang,
82
                        attachments: [],
83
                        embedPDF: options.embedPDF,
84
                };
85

86
                if (options.data) {
6!
NEW
87
                        coreOptions.data = {
×
88
                                buffer: options.data.buffer,
89
                                filename: options.data.originalname,
90
                                mimetype: options.data.mimetype,
91
                        };
92
                }
93

94
                if (options.pdf) {
6!
NEW
95
                        coreOptions.pdf = {
×
96
                                buffer: options.pdf.buffer,
97
                                filename: options.pdf.originalname,
98
                                mimetype: options.pdf.mimetype,
99
                                id: options.pdfID,
100
                                description: options.pdfDescription,
101
                        };
102
                }
103

104
                for (const attachment of options.attachments) {
6✔
NEW
105
                        coreOptions.attachments!.push({
×
106
                                buffer: attachment.file.buffer,
107
                                filename: attachment.file.originalname,
108
                                mimetype: attachment.file.mimetype,
109
                                id: attachment.id,
110
                                description: attachment.description,
111
                        });
112
                }
113

114
                coreOptions.libreOfficePath =
6✔
115
                        this.appConfigService.get('programs').libreOffice;
116

117
                const coreInvoiceService = new CoreInvoiceService(this.logger);
6✔
118

119
                return coreInvoiceService.generate(input, coreOptions);
6✔
120
        }
121
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc