@fin.cx/opendata 4.2.0 → 4.3.1
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/.smartconfig.json +10 -2
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/plugins.d.ts +2 -2
- package/dist_ts/plugins.js +3 -3
- package/dist_ts/stocks/classes.baseproviderservice.js +2 -2
- package/dist_ts/stocks/classes.fundamentalsservice.js +2 -2
- package/dist_ts/stocks/classes.stockdataservice.js +2 -2
- package/dist_ts/stocks/classes.stockservice.js +2 -2
- package/dist_ts/stocks/providers/provider.coingecko.js +3 -3
- package/dist_ts/stocks/providers/provider.secedgar.js +2 -2
- package/dist_ts/vatid/classes.evatrclient.d.ts +15 -0
- package/dist_ts/vatid/classes.evatrclient.js +169 -0
- package/dist_ts/vatid/classes.vatiderror.d.ts +51 -0
- package/dist_ts/vatid/classes.vatiderror.js +29 -0
- package/dist_ts/vatid/classes.viesclient.d.ts +12 -0
- package/dist_ts/vatid/classes.viesclient.js +118 -0
- package/dist_ts/vatid/constants.d.ts +28 -0
- package/dist_ts/vatid/constants.js +37 -0
- package/dist_ts/vatid/index.d.ts +6 -0
- package/dist_ts/vatid/index.js +10 -0
- package/dist_ts/vatid/interfaces.d.ts +141 -0
- package/dist_ts/vatid/interfaces.js +2 -0
- package/dist_ts/vatid/request.d.ts +16 -0
- package/dist_ts/vatid/request.js +65 -0
- package/dist_ts/vatid/vatid.d.ts +8 -0
- package/dist_ts/vatid/vatid.js +22 -0
- package/package.json +8 -5
- package/readme.md +50 -3
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/plugins.ts +2 -2
- package/ts/stocks/classes.baseproviderservice.ts +1 -1
- package/ts/stocks/classes.fundamentalsservice.ts +1 -1
- package/ts/stocks/classes.stockdataservice.ts +1 -1
- package/ts/stocks/classes.stockservice.ts +1 -1
- package/ts/stocks/providers/provider.coingecko.ts +2 -2
- package/ts/stocks/providers/provider.secedgar.ts +1 -1
- package/ts/vatid/classes.evatrclient.ts +182 -0
- package/ts/vatid/classes.vatiderror.ts +83 -0
- package/ts/vatid/classes.viesclient.ts +123 -0
- package/ts/vatid/constants.ts +40 -0
- package/ts/vatid/index.ts +17 -0
- package/ts/vatid/interfaces.ts +154 -0
- package/ts/vatid/request.ts +77 -0
- package/ts/vatid/vatid.ts +25 -0
- /package/{license → license.md} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { vatIdCountryCodes } from './constants.js';
|
|
2
|
+
import type { IVatIdParts, TVatIdCountryCode } from './interfaces.js';
|
|
3
|
+
|
|
4
|
+
/** A VAT ID as it is printed: spaces, dots and hyphens between its characters are left out. */
|
|
5
|
+
const SEPARATORS = /[\s.\-]+/gu;
|
|
6
|
+
|
|
7
|
+
/** After the country code: letters and digits, 2 to 13 of them (the longest form, France and the Netherlands, has 12). */
|
|
8
|
+
const NUMBER_PART = /^[A-Z0-9+*]{2,13}$/u;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Takes a VAT identification number apart: its country code and the number after it, without the
|
|
12
|
+
* spaces, dots and hyphens it is often printed with, in capitals. `GR` is written `EL`, as VAT IDs of
|
|
13
|
+
* Greece are. Answers `undefined` for anything that does not start with a member state's code or has
|
|
14
|
+
* no number after it; whether the number has its member state's form is the service's to say.
|
|
15
|
+
*/
|
|
16
|
+
export const splitVatId = (valueArg: string): IVatIdParts | undefined => {
|
|
17
|
+
const compact = valueArg.replace(SEPARATORS, '').toUpperCase();
|
|
18
|
+
const prefix = compact.slice(0, 2);
|
|
19
|
+
const countryCode = prefix === 'GR' ? 'EL' : prefix;
|
|
20
|
+
const number = compact.slice(2);
|
|
21
|
+
if (!(vatIdCountryCodes as readonly string[]).includes(countryCode) || !NUMBER_PART.test(number)) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return { countryCode: countryCode as TVatIdCountryCode, number, vatId: `${countryCode}${number}` };
|
|
25
|
+
};
|
/package/{license → license.md}
RENAMED
|
File without changes
|