@unchainedshop/plugins 5.0.0-alpha.4 → 5.0.0-alpha.5

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "source": "https://www.estv.admin.ch/estv/en/home/value-added-tax/vat-rates-switzerland.html",
3
3
  "verifiedAt": "2026-08-20",
4
- "timezone": "+01:00",
4
+ "timezone": "Europe/Zurich",
5
5
  "categories": {
6
6
  "default": [
7
7
  { "validFrom": "2001-01-01", "rate": 0.076 },
@@ -3,8 +3,9 @@ export interface TaxRateEra {
3
3
  rate: number;
4
4
  }
5
5
  export interface CompiledTaxRateEra {
6
- validFrom: number;
6
+ validFrom: string;
7
7
  rate: number;
8
+ timeZone: string;
8
9
  }
9
- export declare const compileEraRates: (eras: TaxRateEra[], utcOffset: string) => CompiledTaxRateEra[];
10
+ export declare const compileEraRates: (eras: TaxRateEra[], timeZone: string) => CompiledTaxRateEra[];
10
11
  export declare const rateForDate: (eras: CompiledTaxRateEra[]) => (referenceDate?: Date) => number;
@@ -1,14 +1,40 @@
1
- export const compileEraRates = (eras, utcOffset) => eras
2
- .map(({ validFrom, rate }) => ({
3
- validFrom: new Date(`${validFrom}T00:00:00.000${utcOffset}`).getTime(),
4
- rate,
5
- }))
6
- .sort((left, right) => left.validFrom - right.validFrom);
1
+ const formatDateInTimeZone = (date, timeZone) => {
2
+ const parts = new Intl.DateTimeFormat('en-US', {
3
+ timeZone,
4
+ year: 'numeric',
5
+ month: '2-digit',
6
+ day: '2-digit',
7
+ }).formatToParts(date);
8
+ const value = (type) => parts.find((part) => part.type === type)?.value;
9
+ return `${value('year')}-${value('month')}-${value('day')}`;
10
+ };
11
+ const isIsoDate = (value) => {
12
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value))
13
+ return false;
14
+ const [year, month, day] = value.split('-').map(Number);
15
+ const parsed = new Date(Date.UTC(year, month - 1, day));
16
+ return (parsed.getUTCFullYear() === year && parsed.getUTCMonth() === month - 1 && parsed.getUTCDate() === day);
17
+ };
18
+ export const compileEraRates = (eras, timeZone) => {
19
+ new Intl.DateTimeFormat('en-US', { timeZone });
20
+ return eras
21
+ .map(({ validFrom, rate }) => {
22
+ if (!isIsoDate(validFrom)) {
23
+ throw new TypeError(`Invalid tax era date '${validFrom}'`);
24
+ }
25
+ return { validFrom, rate, timeZone };
26
+ })
27
+ .sort((left, right) => left.validFrom.localeCompare(right.validFrom));
28
+ };
7
29
  export const rateForDate = (eras) => (referenceDate = new Date()) => {
8
- const time = referenceDate.getTime();
30
+ if (!eras.length)
31
+ throw new TypeError('Cannot resolve a tax rate from an empty era list');
32
+ if (!Number.isFinite(referenceDate.getTime()))
33
+ throw new TypeError('Invalid tax reference date');
34
+ const localDate = formatDateInTimeZone(referenceDate, eras[0].timeZone);
9
35
  let applicable = eras[0];
10
36
  for (const era of eras) {
11
- if (era.validFrom <= time)
37
+ if (era.validFrom <= localDate)
12
38
  applicable = era;
13
39
  }
14
40
  return applicable.rate;
@@ -1,7 +1,35 @@
1
1
  {
2
2
  "source": "https://ec.europa.eu/taxation_customs/tedb/#/vat-search",
3
3
  "verifiedAt": "2026-08-20",
4
- "timezone": "+01:00",
4
+ "timezones": {
5
+ "AT": "Europe/Vienna",
6
+ "BE": "Europe/Brussels",
7
+ "BG": "Europe/Sofia",
8
+ "CY": "Asia/Nicosia",
9
+ "CZ": "Europe/Prague",
10
+ "DE": "Europe/Berlin",
11
+ "DK": "Europe/Copenhagen",
12
+ "EE": "Europe/Tallinn",
13
+ "ES": "Europe/Madrid",
14
+ "FI": "Europe/Helsinki",
15
+ "FR": "Europe/Paris",
16
+ "GR": "Europe/Athens",
17
+ "HR": "Europe/Zagreb",
18
+ "HU": "Europe/Budapest",
19
+ "IE": "Europe/Dublin",
20
+ "IT": "Europe/Rome",
21
+ "LT": "Europe/Vilnius",
22
+ "LU": "Europe/Luxembourg",
23
+ "LV": "Europe/Riga",
24
+ "MT": "Europe/Malta",
25
+ "NL": "Europe/Amsterdam",
26
+ "PL": "Europe/Warsaw",
27
+ "PT": "Europe/Lisbon",
28
+ "RO": "Europe/Bucharest",
29
+ "SE": "Europe/Stockholm",
30
+ "SI": "Europe/Ljubljana",
31
+ "SK": "Europe/Bratislava"
32
+ },
5
33
  "countries": {
6
34
  "AT": {
7
35
  "standard": [
@@ -213,6 +241,10 @@
213
241
  }
214
242
  ],
215
243
  "reduced2": [
244
+ {
245
+ "validFrom": "2009-01-01",
246
+ "rate": 0.09
247
+ },
216
248
  {
217
249
  "validFrom": "2025-01-01",
218
250
  "rate": 0.13
@@ -6,7 +6,7 @@ const countryRates = Object.fromEntries(Object.entries(euTaxRates.countries).map
6
6
  countryCode,
7
7
  Object.fromEntries(Object.entries(categories).map(([category, eras]) => [
8
8
  category,
9
- rateForDate(compileEraRates(eras, euTaxRates.timezone)),
9
+ rateForDate(compileEraRates(eras, euTaxRates.timezones[countryCode])),
10
10
  ])),
11
11
  ]));
12
12
  const normalizeCountryCode = (countryCode) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "source": "https://www.gov.uk/vat-rates",
3
3
  "verifiedAt": "2026-08-20",
4
- "timezone": "+00:00",
4
+ "timezone": "Europe/London",
5
5
  "categories": {
6
6
  "standard": [
7
7
  { "validFrom": "1991-04-01", "rate": 0.175 },
@@ -1,7 +1,59 @@
1
1
  {
2
2
  "source": "https://taxfoundation.org/data/all/state/2026-sales-tax-rates-midyear/",
3
3
  "verifiedAt": "2026-08-20",
4
- "timezone": "-06:00",
4
+ "timezones": {
5
+ "AK": "America/Anchorage",
6
+ "AL": "America/Chicago",
7
+ "AR": "America/Chicago",
8
+ "AZ": "America/Phoenix",
9
+ "CA": "America/Los_Angeles",
10
+ "CO": "America/Denver",
11
+ "CT": "America/New_York",
12
+ "DC": "America/New_York",
13
+ "DE": "America/New_York",
14
+ "FL": "America/New_York",
15
+ "GA": "America/New_York",
16
+ "HI": "Pacific/Honolulu",
17
+ "IA": "America/Chicago",
18
+ "ID": "America/Boise",
19
+ "IL": "America/Chicago",
20
+ "IN": "America/Indiana/Indianapolis",
21
+ "KS": "America/Chicago",
22
+ "KY": "America/New_York",
23
+ "LA": "America/Chicago",
24
+ "MA": "America/New_York",
25
+ "MD": "America/New_York",
26
+ "ME": "America/New_York",
27
+ "MI": "America/Detroit",
28
+ "MN": "America/Chicago",
29
+ "MO": "America/Chicago",
30
+ "MS": "America/Chicago",
31
+ "MT": "America/Denver",
32
+ "NC": "America/New_York",
33
+ "ND": "America/Chicago",
34
+ "NE": "America/Chicago",
35
+ "NH": "America/New_York",
36
+ "NJ": "America/New_York",
37
+ "NM": "America/Denver",
38
+ "NV": "America/Los_Angeles",
39
+ "NY": "America/New_York",
40
+ "OH": "America/New_York",
41
+ "OK": "America/Chicago",
42
+ "OR": "America/Los_Angeles",
43
+ "PA": "America/New_York",
44
+ "RI": "America/New_York",
45
+ "SC": "America/New_York",
46
+ "SD": "America/Chicago",
47
+ "TN": "America/Chicago",
48
+ "TX": "America/Chicago",
49
+ "UT": "America/Denver",
50
+ "VA": "America/New_York",
51
+ "VT": "America/New_York",
52
+ "WA": "America/Los_Angeles",
53
+ "WI": "America/Chicago",
54
+ "WV": "America/New_York",
55
+ "WY": "America/Denver"
56
+ },
5
57
  "states": {
6
58
  "AK": [
7
59
  {
@@ -268,10 +320,18 @@
268
320
  }
269
321
  ],
270
322
  "SD": [
323
+ {
324
+ "validFrom": "2016-06-01",
325
+ "rate": 0.045
326
+ },
271
327
  {
272
328
  "validFrom": "2023-07-01",
273
- "rate": 0.042,
274
- "note": "HB 1137 temporary cut; reverts to 4.5% on 2027-07-01 unless extended"
329
+ "rate": 0.042
330
+ },
331
+ {
332
+ "validFrom": "2027-07-01",
333
+ "rate": 0.045,
334
+ "note": "HB 1137 temporary cut expires after 2027-06-30"
275
335
  }
276
336
  ],
277
337
  "TN": [
@@ -4,7 +4,7 @@ export const US_COUNTRY_CODE = 'US';
4
4
  export const US_SALES_TAX_EXEMPT_VALUE = 'exempt';
5
5
  const stateRates = Object.fromEntries(Object.entries(usTaxRates.states).map(([stateCode, eras]) => [
6
6
  stateCode,
7
- rateForDate(compileEraRates(eras, usTaxRates.timezone)),
7
+ rateForDate(compileEraRates(eras, usTaxRates.timezones[stateCode])),
8
8
  ]));
9
9
  export const US_STATE_CODES = Object.keys(stateRates);
10
10
  export const resolveUsSalesTaxRate = ({ regionCode, referenceDate, }) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
3
  "description": "Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters",
4
- "version": "5.0.0-alpha.4",
4
+ "version": "5.0.0-alpha.5",
5
5
  "main": "lib/plugins-index.js",
6
6
  "types": "lib/plugins-index.d.ts",
7
7
  "exports": {
@@ -48,24 +48,24 @@
48
48
  },
49
49
  "homepage": "https://github.com/unchainedshop/unchained#readme",
50
50
  "dependencies": {
51
- "@unchainedshop/api": "^5.0.0-alpha.1",
52
- "@unchainedshop/core": "^5.0.0-alpha.1",
53
- "@unchainedshop/core-countries": "^5.0.0-alpha.1",
54
- "@unchainedshop/core-delivery": "^5.0.0-alpha.1",
55
- "@unchainedshop/core-enrollments": "^5.0.0-alpha.1",
56
- "@unchainedshop/core-files": "^5.0.0-alpha.1",
57
- "@unchainedshop/core-languages": "^5.0.0-alpha.1",
58
- "@unchainedshop/core-orders": "^5.0.0-alpha.1",
59
- "@unchainedshop/core-payment": "^5.0.0-alpha.1",
60
- "@unchainedshop/core-products": "^5.0.0-alpha.1",
61
- "@unchainedshop/core-users": "^5.0.0-alpha.1",
62
- "@unchainedshop/core-warehousing": "^5.0.0-alpha.1",
63
- "@unchainedshop/core-worker": "^5.0.0-alpha.1",
64
- "@unchainedshop/events": "^5.0.0-alpha.1",
65
- "@unchainedshop/logger": "^5.0.0-alpha.1",
66
- "@unchainedshop/mongodb": "^5.0.0-alpha.1",
67
- "@unchainedshop/roles": "^5.0.0-alpha.1",
68
- "@unchainedshop/utils": "^5.0.0-alpha.1"
51
+ "@unchainedshop/api": "^5.0.0-alpha.5",
52
+ "@unchainedshop/core": "^5.0.0-alpha.5",
53
+ "@unchainedshop/core-countries": "^5.0.0-alpha.5",
54
+ "@unchainedshop/core-delivery": "^5.0.0-alpha.5",
55
+ "@unchainedshop/core-enrollments": "^5.0.0-alpha.5",
56
+ "@unchainedshop/core-files": "^5.0.0-alpha.5",
57
+ "@unchainedshop/core-languages": "^5.0.0-alpha.5",
58
+ "@unchainedshop/core-orders": "^5.0.0-alpha.5",
59
+ "@unchainedshop/core-payment": "^5.0.0-alpha.5",
60
+ "@unchainedshop/core-products": "^5.0.0-alpha.5",
61
+ "@unchainedshop/core-users": "^5.0.0-alpha.5",
62
+ "@unchainedshop/core-warehousing": "^5.0.0-alpha.5",
63
+ "@unchainedshop/core-worker": "^5.0.0-alpha.5",
64
+ "@unchainedshop/events": "^5.0.0-alpha.5",
65
+ "@unchainedshop/logger": "^5.0.0-alpha.5",
66
+ "@unchainedshop/mongodb": "^5.0.0-alpha.5",
67
+ "@unchainedshop/roles": "^5.0.0-alpha.5",
68
+ "@unchainedshop/utils": "^5.0.0-alpha.5"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@aws-sdk/client-eventbridge": ">= 3.714 < 4",