@stamhoofd/vies 2.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +32 -0
- package/dist/PeppolDirectoryService.d.ts +22 -0
- package/dist/PeppolDirectoryService.d.ts.map +1 -0
- package/dist/PeppolDirectoryService.js +99 -0
- package/dist/PeppolDirectoryService.js.map +1 -0
- package/dist/ViesApi.d.ts +7 -0
- package/dist/ViesApi.d.ts.map +1 -0
- package/dist/ViesApi.js +36 -0
- package/dist/ViesApi.js.map +1 -0
- package/dist/ViesService.d.ts +22 -0
- package/dist/ViesService.d.ts.map +1 -0
- package/dist/ViesService.js +208 -0
- package/dist/ViesService.js.map +1 -0
- package/package.json +51 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Free Use License for Non-Profit Organizations
|
|
2
|
+
|
|
3
|
+
Copyright 2020 Codawood BV
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any non-profit organization with fewer than 2,000 members (each, a “Licensee”), to use this software and associated documentation files (the “Software”), subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
1. Eligibility:
|
|
8
|
+
This license applies only if neither the Licensee nor, if applicable, its parent or umbrella organization, is already subject to an existing license for this project. For the purposes of this license, a “parent or umbrella organization” means any organization with which the Licensee is affiliated, coordinated, or represented as part of a larger collective, including but not limited to national associations or federations.
|
|
9
|
+
|
|
10
|
+
2. Modifications:
|
|
11
|
+
Modifications to the Software are permitted only if they are published publicly under the MIT License, covering only the modifications; the original Software remains under this license and may not be sublicensed without a separate agreement. Any modification made by a Licensee (other than modifications by the original author, its representatives, or the copyright owner) shall be deemed to be distributed under the MIT License. Submission of modifications through publicly accessible channels, including but not limited to pull requests on code repositories such as GitHub, shall be considered an explicit acknowledgment and grant by the Licensee that such modifications are made available under the MIT License. Licensees may not sublicense, transfer, or assign the rights granted under this license except as expressly permitted herein.
|
|
12
|
+
|
|
13
|
+
3. Precedence of Existing Licenses:
|
|
14
|
+
If the Licensee, or its parent or umbrella organization, is already subject to an existing license for this project, that license shall take precedence, and no additional free license is granted. Nothing in this license shall be construed to override any pre-existing exclusive license agreement.
|
|
15
|
+
|
|
16
|
+
4. Data Protection / GDPR Responsibility:
|
|
17
|
+
Licensees are solely responsible for ensuring that any processing of personal data using this software complies with applicable data protection laws, including the EU General Data Protection Regulation (GDPR).
|
|
18
|
+
|
|
19
|
+
5. Termination and Revocation:
|
|
20
|
+
The copyright holders may revoke this license at any time, at their sole discretion.
|
|
21
|
+
|
|
22
|
+
6. Governing Law:
|
|
23
|
+
This license shall be governed by and construed in accordance with the laws of Belgium, without regard to conflict of law principles.
|
|
24
|
+
|
|
25
|
+
7. Third-Party Licenses:
|
|
26
|
+
Certain files or components included in the Software may be governed by separate licenses, including open-source licenses, or contributed by third parties under different terms. Such files are not automatically covered by this license. Licensees are responsible for reviewing and complying with any additional license terms that apply to these files.
|
|
27
|
+
|
|
28
|
+
For the purposes of this license, a “non-profit organization” means an entity recognized as non-profit under applicable law in its jurisdiction, which does not distribute profits to its members or owners.
|
|
29
|
+
|
|
30
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
31
|
+
|
|
32
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PeppolEndointId } from '@stamhoofd/structures';
|
|
2
|
+
/**
|
|
3
|
+
* The PEPPOL schemes (ISO 6523 ICD codes) we currently support for a custom
|
|
4
|
+
* PEPPOL endpoint id. The scheme identifier is the numeric code used in the
|
|
5
|
+
* PEPPOL participant identifier (e.g. `iso6523-actorid-upis::0208:...`).
|
|
6
|
+
*/
|
|
7
|
+
export declare const supportedPeppolSchemes: string[];
|
|
8
|
+
export declare class PeppolDirectoryServiceStatic {
|
|
9
|
+
/**
|
|
10
|
+
* Validates a custom PEPPOL endpoint id: the scheme must be supported and the
|
|
11
|
+
* participant must be registered in the PEPPOL directory. Throws a SimpleError
|
|
12
|
+
* (with field `customPeppolEndpointId`) when the id is invalid or unknown.
|
|
13
|
+
*/
|
|
14
|
+
validate(endpointId: PeppolEndointId): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Best-effort extraction of the registered entity name from a PEPPOL directory match.
|
|
17
|
+
* The directory returns one or more entities, each with a list of localized names.
|
|
18
|
+
*/
|
|
19
|
+
private extractEntityName;
|
|
20
|
+
}
|
|
21
|
+
export declare const PeppolDirectoryService: PeppolDirectoryServiceStatic;
|
|
22
|
+
//# sourceMappingURL=PeppolDirectoryService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PeppolDirectoryService.d.ts","sourceRoot":"","sources":["../src/PeppolDirectoryService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAAgC,CAAC;AAE5E,qBAAa,4BAA4B;IACrC;;;;OAIG;IACG,QAAQ,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IA0E1D;;;OAGG;IACH,OAAO,CAAC,iBAAiB;CAY5B;AAED,eAAO,MAAM,sBAAsB,8BAAqC,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { SimpleError } from '@simonbackx/simple-errors';
|
|
2
|
+
import { PeppolScheme } from '@stamhoofd/structures';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
/**
|
|
5
|
+
* The PEPPOL schemes (ISO 6523 ICD codes) we currently support for a custom
|
|
6
|
+
* PEPPOL endpoint id. The scheme identifier is the numeric code used in the
|
|
7
|
+
* PEPPOL participant identifier (e.g. `iso6523-actorid-upis::0208:...`).
|
|
8
|
+
*/
|
|
9
|
+
export const supportedPeppolSchemes = Object.values(PeppolScheme);
|
|
10
|
+
export class PeppolDirectoryServiceStatic {
|
|
11
|
+
/**
|
|
12
|
+
* Validates a custom PEPPOL endpoint id: the scheme must be supported and the
|
|
13
|
+
* participant must be registered in the PEPPOL directory. Throws a SimpleError
|
|
14
|
+
* (with field `customPeppolEndpointId`) when the id is invalid or unknown.
|
|
15
|
+
*/
|
|
16
|
+
async validate(endpointId) {
|
|
17
|
+
const schemeID = endpointId.schemeID.trim();
|
|
18
|
+
const id = endpointId.id.trim();
|
|
19
|
+
if (!supportedPeppolSchemes.includes(schemeID)) {
|
|
20
|
+
throw new SimpleError({
|
|
21
|
+
code: 'invalid_field',
|
|
22
|
+
message: 'Unsupported PEPPOL scheme ' + schemeID,
|
|
23
|
+
human: $t('%ZcX'),
|
|
24
|
+
field: 'customPeppolEndpointId',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (id.length === 0) {
|
|
28
|
+
throw new SimpleError({
|
|
29
|
+
code: 'invalid_field',
|
|
30
|
+
message: 'Missing PEPPOL endpoint id',
|
|
31
|
+
human: $t('%ZcY'),
|
|
32
|
+
field: 'customPeppolEndpointId',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const participant = `iso6523-actorid-upis::${schemeID}:${id}`;
|
|
36
|
+
let data;
|
|
37
|
+
try {
|
|
38
|
+
const response = await axios.request({
|
|
39
|
+
method: 'GET',
|
|
40
|
+
url: 'https://directory.peppol.eu/search/1.0/json',
|
|
41
|
+
params: { participant },
|
|
42
|
+
});
|
|
43
|
+
data = response.data;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
// The directory is unavailable: we can't validate the id right now.
|
|
47
|
+
console.error('PEPPOL directory error', e);
|
|
48
|
+
throw new SimpleError({
|
|
49
|
+
code: 'service_unavailable',
|
|
50
|
+
message: 'PEPPOL directory unavailable',
|
|
51
|
+
human: $t('%Zcf'),
|
|
52
|
+
field: 'customPeppolEndpointId',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (typeof data !== 'object' || data === null || !Array.isArray(data.matches)) {
|
|
56
|
+
throw new SimpleError({
|
|
57
|
+
code: 'service_unavailable',
|
|
58
|
+
message: 'Invalid response from PEPPOL directory',
|
|
59
|
+
human: $t('%Zcf'),
|
|
60
|
+
field: 'customPeppolEndpointId',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
console.log('PEPPOL lookup', participant, data);
|
|
64
|
+
const expected = `${schemeID}:${id}`.toLowerCase();
|
|
65
|
+
const match = data.matches.find((m) => {
|
|
66
|
+
return typeof m?.participantID?.value === 'string'
|
|
67
|
+
&& m.participantID.value.toLowerCase() === expected;
|
|
68
|
+
});
|
|
69
|
+
if (!match) {
|
|
70
|
+
throw new SimpleError({
|
|
71
|
+
code: 'invalid_field',
|
|
72
|
+
message: 'PEPPOL participant not found in directory: ' + participant,
|
|
73
|
+
human: $t('%Zcr', { id: `${schemeID}:${id}` }),
|
|
74
|
+
field: 'customPeppolEndpointId',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
// Store the registered entity name from the directory. This is server-controlled
|
|
78
|
+
// and overwrites any value the client may have sent (see ViesService.checkCompany).
|
|
79
|
+
endpointId.entityName = this.extractEntityName(match);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Best-effort extraction of the registered entity name from a PEPPOL directory match.
|
|
83
|
+
* The directory returns one or more entities, each with a list of localized names.
|
|
84
|
+
*/
|
|
85
|
+
extractEntityName(match) {
|
|
86
|
+
const entities = Array.isArray(match?.entities) ? match.entities : [];
|
|
87
|
+
for (const entity of entities) {
|
|
88
|
+
const names = Array.isArray(entity?.name) ? entity.name : [];
|
|
89
|
+
for (const n of names) {
|
|
90
|
+
if (typeof n?.name === 'string' && n.name.trim().length > 0) {
|
|
91
|
+
return n.name.trim();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export const PeppolDirectoryService = new PeppolDirectoryServiceStatic();
|
|
99
|
+
//# sourceMappingURL=PeppolDirectoryService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PeppolDirectoryService.js","sourceRoot":"","sources":["../src/PeppolDirectoryService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAa,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAE5E,MAAM,OAAO,4BAA4B;IACrC;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,UAA2B;QACtC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC5C,MAAM,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QAEhC,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,WAAW,CAAC;gBAClB,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,4BAA4B,GAAG,QAAQ;gBAChD,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC;gBACjB,KAAK,EAAE,wBAAwB;aAClC,CAAC,CAAC;QACP,CAAC;QAED,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC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AE,CAAC;oBAC1D,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,4BAA4B,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Country } from '@stamhoofd/types/Country';
|
|
2
|
+
export declare class ViesApiStatic {
|
|
3
|
+
private request;
|
|
4
|
+
checkVATNumber(country: Country, vatNumber: string): Promise<boolean>;
|
|
5
|
+
}
|
|
6
|
+
export declare const ViesApi: ViesApiStatic;
|
|
7
|
+
//# sourceMappingURL=ViesApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViesApi.d.ts","sourceRoot":"","sources":["../src/ViesApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,qBAAa,aAAa;YACR,OAAO;IA0Bf,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAa9E;AAED,eAAO,MAAM,OAAO,eAAsB,CAAC"}
|
package/dist/ViesApi.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class ViesApiStatic {
|
|
2
|
+
async request(method, url, content) {
|
|
3
|
+
const json = JSON.stringify(content);
|
|
4
|
+
console.log('[VIES REQUEST]', method, url, '\n [VIES REQUEST] ', json);
|
|
5
|
+
const response = await fetch(url, {
|
|
6
|
+
method,
|
|
7
|
+
headers: {
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
},
|
|
10
|
+
body: json,
|
|
11
|
+
signal: AbortSignal.timeout(5_000),
|
|
12
|
+
});
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
throw new Error(`VIES request failed with status ${response.status}`);
|
|
15
|
+
}
|
|
16
|
+
const data = await response.json();
|
|
17
|
+
console.log('[VIES RESPONSE]', method, url, '\n[VIES RESPONSE]', JSON.stringify(data));
|
|
18
|
+
return {
|
|
19
|
+
data,
|
|
20
|
+
response,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async checkVATNumber(country, vatNumber) {
|
|
24
|
+
const { data, response } = await this.request('POST', 'https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-number', {
|
|
25
|
+
countryCode: country,
|
|
26
|
+
vatNumber: vatNumber.substring(2),
|
|
27
|
+
});
|
|
28
|
+
if (typeof data !== 'object' || data === null || !('valid' in data) || typeof data.valid !== 'boolean') {
|
|
29
|
+
console.error('VIES error', response.status, response.statusText, data);
|
|
30
|
+
throw new Error('Invalid response from VIES');
|
|
31
|
+
}
|
|
32
|
+
return data.valid;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const ViesApi = new ViesApiStatic();
|
|
36
|
+
//# sourceMappingURL=ViesApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViesApi.js","sourceRoot":"","sources":["../src/ViesApi.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IACd,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,GAAW,EAAE,OAAgB;QAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAErC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;QAEvE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC9B,MAAM;YACN,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;aACrC;YACD,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;SACrC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,mCAAmC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1E,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QACvF,OAAO;YACH,IAAI;YACJ,QAAQ;SACX,CAAC;IACN,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAgB,EAAE,SAAiB;QACpD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,sEAAsE,EAAE;YAC1H,WAAW,EAAE,OAAO;YACpB,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;SACpC,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACrG,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YACxE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AutoEncoderPatchType } from '@simonbackx/simple-encoding';
|
|
2
|
+
import type { Company } from '@stamhoofd/structures';
|
|
3
|
+
import { Country } from '@stamhoofd/types/Country';
|
|
4
|
+
export declare class ViesServiceStatic {
|
|
5
|
+
/**
|
|
6
|
+
* Validate a company.
|
|
7
|
+
*
|
|
8
|
+
* If validating a company before a patch is applied, also send the patch (make sure company is already patched with that patch).
|
|
9
|
+
* This will also apply small corrections to the patch itself, so it is safe to apply later.
|
|
10
|
+
*/
|
|
11
|
+
checkCompany(company: Company, patch?: AutoEncoderPatchType<Company> | null, { forceValidation }?: {
|
|
12
|
+
forceValidation?: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
checkCompanyNumber(country: Country, companyNumber: string): Promise<{
|
|
15
|
+
companyNumber: string | null;
|
|
16
|
+
VATNumber?: string | null;
|
|
17
|
+
}>;
|
|
18
|
+
checkVATNumber(country: Country, vatNumber: string): Promise<string>;
|
|
19
|
+
private isVATNumberValid;
|
|
20
|
+
}
|
|
21
|
+
export declare const ViesService: ViesServiceStatic;
|
|
22
|
+
//# sourceMappingURL=ViesService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViesService.d.ts","sourceRoot":"","sources":["../src/ViesService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAOnD,qBAAa,iBAAiB;IAC1B;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,GAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE,eAAuB,EAAE,GAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAO;IAmGlJ,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAqDjI,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAwC5D,gBAAgB;CAwBjC;AAED,eAAO,MAAM,WAAW,mBAA0B,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { isSimpleError, isSimpleErrors, SimpleError } from '@simonbackx/simple-errors';
|
|
2
|
+
import { ViesCachedResult } from '@stamhoofd/models/models/ViesCachedResult.js';
|
|
3
|
+
import { PeppolScheme } from '@stamhoofd/structures';
|
|
4
|
+
import { Country } from '@stamhoofd/types/Country';
|
|
5
|
+
import jsvat from 'jsvat-next';
|
|
6
|
+
import { PeppolDirectoryService } from './PeppolDirectoryService.js';
|
|
7
|
+
import { ViesApi } from './ViesApi.js';
|
|
8
|
+
const CacheMonths = 6;
|
|
9
|
+
export class ViesServiceStatic {
|
|
10
|
+
/**
|
|
11
|
+
* Validate a company.
|
|
12
|
+
*
|
|
13
|
+
* If validating a company before a patch is applied, also send the patch (make sure company is already patched with that patch).
|
|
14
|
+
* This will also apply small corrections to the patch itself, so it is safe to apply later.
|
|
15
|
+
*/
|
|
16
|
+
async checkCompany(company, patch = null, { forceValidation = false } = {}) {
|
|
17
|
+
// Validate the custom PEPPOL endpoint id, but only when it actually changed.
|
|
18
|
+
// In a patch, `customPeppolEndpointId` is undefined unless the client changed it;
|
|
19
|
+
// for a full company it is always set (null or a value), so we validate a set value.
|
|
20
|
+
if ((forceValidation || (patch && patch.customPeppolEndpointId !== undefined)) && company.customPeppolEndpointId) {
|
|
21
|
+
const endpointId = company.customPeppolEndpointId;
|
|
22
|
+
// A KBO (0208) endpoint id is the Belgian enterprise number, so it must belong to a
|
|
23
|
+
// Belgian company and be identical to this company's own company number.
|
|
24
|
+
if (endpointId.schemeID === PeppolScheme.KBO) {
|
|
25
|
+
if (company.address?.country !== Country.Belgium) {
|
|
26
|
+
throw new SimpleError({
|
|
27
|
+
code: 'invalid_field',
|
|
28
|
+
message: 'A KBO PEPPOL id can only be used for a Belgian company',
|
|
29
|
+
human: $t('%Zck'),
|
|
30
|
+
field: 'customPeppolEndpointId',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const companyPeppolId = company.peppolCompanyId;
|
|
34
|
+
if (!companyPeppolId || endpointId.id.replace(/\D+/g, '') !== companyPeppolId.id.replace(/\D+/g, '')) {
|
|
35
|
+
throw new SimpleError({
|
|
36
|
+
code: 'invalid_field',
|
|
37
|
+
message: 'A KBO PEPPOL id must match the company number',
|
|
38
|
+
human: $t('%ZcZ'),
|
|
39
|
+
field: 'customPeppolEndpointId',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// validate() fills in the server-controlled entityName from the PEPPOL directory.
|
|
44
|
+
await PeppolDirectoryService.validate(endpointId);
|
|
45
|
+
// Write the validated endpoint id back as a full replacement so any client-supplied
|
|
46
|
+
// entityName is discarded: entityName can only ever be set by the server.
|
|
47
|
+
if (patch) {
|
|
48
|
+
patch.customPeppolEndpointId = endpointId;
|
|
49
|
+
}
|
|
50
|
+
company.customPeppolEndpointId = endpointId;
|
|
51
|
+
}
|
|
52
|
+
if (!company.address) {
|
|
53
|
+
// Not allowed to set
|
|
54
|
+
if (patch) {
|
|
55
|
+
patch.companyNumber = null;
|
|
56
|
+
patch.VATNumber = null;
|
|
57
|
+
}
|
|
58
|
+
company.companyNumber = null;
|
|
59
|
+
company.VATNumber = null;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (company.name.length < 3 || company.name.toLowerCase() === 'vzw') {
|
|
63
|
+
throw new SimpleError({
|
|
64
|
+
code: 'invalid_company_name',
|
|
65
|
+
message: 'Company name is too short',
|
|
66
|
+
human: $t('%1LF'),
|
|
67
|
+
field: 'companyName',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (company.VATNumber !== null) {
|
|
71
|
+
// Changed VAT number
|
|
72
|
+
const VATNumber = await this.checkVATNumber(company.address.country, company.VATNumber);
|
|
73
|
+
if (patch) {
|
|
74
|
+
patch.VATNumber = VATNumber;
|
|
75
|
+
}
|
|
76
|
+
company.VATNumber = VATNumber;
|
|
77
|
+
if (company.address.country === Country.Belgium) {
|
|
78
|
+
if (patch) {
|
|
79
|
+
patch.companyNumber = VATNumber.substring(2);
|
|
80
|
+
}
|
|
81
|
+
company.companyNumber = VATNumber.substring(2);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (company.companyNumber) {
|
|
85
|
+
if (company.VATNumber !== null && company.address.country === Country.Belgium) {
|
|
86
|
+
// Already validated
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Need to validate
|
|
90
|
+
const result = await this.checkCompanyNumber(company.address.country, company.companyNumber);
|
|
91
|
+
if (patch) {
|
|
92
|
+
patch.companyNumber = result.companyNumber;
|
|
93
|
+
}
|
|
94
|
+
company.companyNumber = result.companyNumber;
|
|
95
|
+
if (result.VATNumber !== undefined) {
|
|
96
|
+
if (patch) {
|
|
97
|
+
patch.VATNumber = result.VATNumber;
|
|
98
|
+
}
|
|
99
|
+
company.VATNumber = result.VATNumber;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async checkCompanyNumber(country, companyNumber) {
|
|
105
|
+
if (country !== Country.Belgium) {
|
|
106
|
+
// Not supported
|
|
107
|
+
return {
|
|
108
|
+
companyNumber,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// In Belgium, the company number syntax is the same as VAT number
|
|
112
|
+
let correctedVATNumber = companyNumber;
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
114
|
+
if (companyNumber.length > 2 && companyNumber.substr(0, 2).toUpperCase() !== country) {
|
|
115
|
+
// Add required country in VAT number
|
|
116
|
+
correctedVATNumber = country + companyNumber;
|
|
117
|
+
}
|
|
118
|
+
const result = jsvat.checkVAT(correctedVATNumber, [jsvat.belgium]);
|
|
119
|
+
if (!result.isValid) {
|
|
120
|
+
throw new SimpleError({
|
|
121
|
+
code: 'invalid_field',
|
|
122
|
+
message: 'Ongeldig ondernemingsnummer: ' + companyNumber,
|
|
123
|
+
field: 'companyNumber',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// If this is a valid VAT number, we can assume it's a valid company number
|
|
127
|
+
try {
|
|
128
|
+
const corrected = await this.checkVATNumber(Country.Belgium, correctedVATNumber);
|
|
129
|
+
// this is a VAT number, not a company number
|
|
130
|
+
return {
|
|
131
|
+
companyNumber: corrected.substring(2),
|
|
132
|
+
VATNumber: corrected,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
if ((isSimpleError(e) || isSimpleErrors(e)) && e.hasCode('invalid_field')) {
|
|
137
|
+
// Ignore: normal that it is not a valid VAT number
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// Other errors should be thrown
|
|
141
|
+
throw e;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
companyNumber: result.value?.substring(2) ?? companyNumber,
|
|
146
|
+
// VATNumber should always be set to null if it is not a valid VAT number
|
|
147
|
+
VATNumber: null,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
async checkVATNumber(country, vatNumber) {
|
|
151
|
+
const result = jsvat.checkVAT(vatNumber, country === Country.Belgium ? [jsvat.belgium] : [jsvat.netherlands]);
|
|
152
|
+
if (!result.isValid) {
|
|
153
|
+
throw new SimpleError({
|
|
154
|
+
code: 'invalid_field',
|
|
155
|
+
message: $t('%1To', { number: vatNumber }),
|
|
156
|
+
field: 'VATNumber',
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const formatted = result.value ?? vatNumber;
|
|
160
|
+
if (STAMHOOFD.environment === 'development' && formatted === 'NL301828519B01') {
|
|
161
|
+
return formatted;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
if (!await this.isVATNumberValid(country, formatted)) {
|
|
165
|
+
throw new SimpleError({
|
|
166
|
+
code: 'invalid_field',
|
|
167
|
+
message: $t('%1TG', { 'vat-number': formatted }),
|
|
168
|
+
field: 'VATNumber',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
if (isSimpleError(e) || isSimpleErrors(e)) {
|
|
174
|
+
throw e;
|
|
175
|
+
}
|
|
176
|
+
// Unavailable: ignore for now
|
|
177
|
+
throw new SimpleError({
|
|
178
|
+
code: 'service_unavailable',
|
|
179
|
+
message: $t('%1Sf'),
|
|
180
|
+
field: 'VATNumber',
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return formatted;
|
|
184
|
+
}
|
|
185
|
+
async isVATNumberValid(country, VATNumber) {
|
|
186
|
+
const cached = await ViesCachedResult.getByID(VATNumber);
|
|
187
|
+
const freshAfter = new Date();
|
|
188
|
+
freshAfter.setMonth(freshAfter.getMonth() - CacheMonths);
|
|
189
|
+
if (cached && cached.checkedAt >= freshAfter) {
|
|
190
|
+
return cached.result;
|
|
191
|
+
}
|
|
192
|
+
let result;
|
|
193
|
+
try {
|
|
194
|
+
result = await ViesApi.checkVATNumber(country, VATNumber);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
console.error('VIES error', error);
|
|
198
|
+
if (cached) {
|
|
199
|
+
return cached.result;
|
|
200
|
+
}
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
await ViesCachedResult.saveResult(VATNumber, result, new Date());
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
export const ViesService = new ViesServiceStatic();
|
|
208
|
+
//# sourceMappingURL=ViesService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViesService.js","sourceRoot":"","sources":["../src/ViesService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,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amhoofd/vies",
|
|
3
|
+
"version": "2.145.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/ViesService.js",
|
|
6
|
+
"types": "./dist/ViesService.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/ViesService.d.ts",
|
|
11
|
+
"import": "./dist/ViesService.js",
|
|
12
|
+
"require": "./dist/ViesService.js"
|
|
13
|
+
},
|
|
14
|
+
"./PeppolDirectoryService.js": {
|
|
15
|
+
"types": "./dist/PeppolDirectoryService.d.ts",
|
|
16
|
+
"import": "./dist/PeppolDirectoryService.js",
|
|
17
|
+
"require": "./dist/PeppolDirectoryService.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc --build tsconfig.build.json",
|
|
25
|
+
"lint": "eslint",
|
|
26
|
+
"typecheck": "tsc --build tsconfig.test.json",
|
|
27
|
+
"test": "vitest",
|
|
28
|
+
"test:coverage": "vitest --coverage"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@simonbackx/simple-encoding": "2.26.11",
|
|
32
|
+
"@simonbackx/simple-errors": "1.5.0",
|
|
33
|
+
"@stamhoofd/models": "2.145.0",
|
|
34
|
+
"@stamhoofd/structures": "2.145.0",
|
|
35
|
+
"@stamhoofd/types": "2.145.0",
|
|
36
|
+
"axios": "1.18.1",
|
|
37
|
+
"jsvat-next": "3.0.4"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@simonbackx/simple-database": "1.37.1",
|
|
41
|
+
"@stamhoofd/backend-i18n": "2.145.0",
|
|
42
|
+
"@stamhoofd/test-utils": "2.145.0",
|
|
43
|
+
"nock": "14.0.16",
|
|
44
|
+
"vitest": "4.1.10"
|
|
45
|
+
},
|
|
46
|
+
"license": "UNLICENCED",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"gitHead": "ee58cd6383c03df39218d8589679638019241e15"
|
|
51
|
+
}
|