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

gflohr / e-invoice-eu / 23892446385

02 Apr 2026 08:53AM UTC coverage: 81.77% (-0.8%) from 82.617%
23892446385

push

github

web-flow
Merge pull request #481 from gflohr/upgrade-dependencies

Upgrade dependencies

351 of 494 branches covered (71.05%)

Branch coverage included in aggregate %.

16 of 27 new or added lines in 6 files covered. (59.26%)

3 existing lines in 2 files now uncovered.

1026 of 1190 relevant lines covered (86.22%)

74.85 hits per line

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

89.74
/apps/server/src/mapping/mapping.controller.ts
1
import type { Invoice } from '@e-invoice-eu/core';
2
import {
1✔
3
        BadRequestException,
4
        Controller,
5
        InternalServerErrorException,
6
        Logger,
7
        Param,
8
        Post,
9
        UploadedFiles,
10
        UseInterceptors,
11
} from '@nestjs/common';
12
import { FileFieldsInterceptor } from '@nestjs/platform-express';
1✔
13
import { ApiBody, ApiConsumes, ApiResponse, ApiTags } from '@nestjs/swagger';
1✔
14
import { ValidationError } from 'ajv/dist/2019';
1✔
15

16
import { MappingService } from './mapping.service';
1✔
17

18
@ApiTags('mapping')
19
@Controller('mapping')
20
export class MappingController {
1✔
21
        constructor(
22
                private readonly mappingService: MappingService,
5!
23
                private readonly logger: Logger,
5✔
24
        ) {}
25

26
        @Post('transform/:format')
27
        @ApiConsumes('multipart/form-data')
28
        @ApiBody({
29
                description: 'The spreadsheet to be transformed.',
30
                required: true,
31
                schema: {
32
                        type: 'object',
33
                        properties: {
34
                                spreadsheet: {
35
                                        type: 'string',
36
                                        format: 'binary',
37
                                        nullable: true,
38
                                        description: 'The spreadsheet to be transformed.',
39
                                },
40
                                mapping: {
41
                                        type: 'string',
42
                                        format: 'binary',
43
                                        description: 'The mapping file in YAML or JSON format.',
44
                                },
45
                        },
46
                },
47
        })
48
        @ApiResponse({
49
                status: 201,
50
                description:
51
                        'Transformation successful. The output is an invoice' +
52
                        ' document that can be used as input for the' +
53
                        ' `/api/invoice/generate` endpoint.',
54
                links: {
55
                        generateInvoice: {
56
                                operationRef: './invoice/generate',
57
                                parameters: {
58
                                        invoice: '$response.body',
59
                                },
60
                        },
61
                },
62
        })
63
        @ApiResponse({
64
                status: 400,
65
                description: 'Bad request with error details',
66
        })
67
        @UseInterceptors(
68
                FileFieldsInterceptor([
69
                        { name: 'spreadsheet', maxCount: 1 },
70
                        { name: 'mapping', maxCount: 1 },
71
                ]),
72
        )
73
        transform(
1✔
74
                @Param('format') format: string,
75
                @UploadedFiles()
76
                files: {
77
                        spreadsheet?: Express.Multer.File[];
78
                        mapping?: Express.Multer.File[];
79
                },
80
        ): Invoice {
81
                const dataFile = files.spreadsheet;
5✔
82
                if (!dataFile) {
5✔
83
                        throw new BadRequestException('No invoice file uploaded');
1✔
84
                }
85

86
                const mappingFile = files.mapping?.[0];
4✔
87
                if (!mappingFile) {
4✔
88
                        throw new BadRequestException('No mapping file uploaded');
1✔
89
                }
90

91
                try {
3✔
92
                        return this.mappingService.transform(
3✔
93
                                format,
94
                                mappingFile.buffer.toString(),
95
                                dataFile[0].buffer,
96
                        );
97
                } catch (error) {
98
                        if (error instanceof ValidationError) {
2✔
99
                                throw new BadRequestException({
1✔
100
                                        message: 'Transformation failed.',
101
                                        details: error,
102
                                });
103
                        } else {
104
                                if (error instanceof Error) {
1!
105
                                        this.logger.error(`unknown error: ${error.message}\n${error.stack}`);
1✔
106
                                } else {
NEW
107
                                        this.logger.error('unknown error: ', error);
×
108
                                }
109
                                throw new InternalServerErrorException();
1✔
110
                        }
111
                }
112
        }
113
}
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