@unchainedshop/plugins 4.8.19 → 4.8.21

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.
Files changed (53) hide show
  1. package/lib/payment/datatrans-v2/adapter.js +12 -9
  2. package/lib/presets/countries/eu.d.ts +2 -0
  3. package/lib/presets/countries/eu.js +2 -0
  4. package/lib/presets/countries/uk.d.ts +2 -0
  5. package/lib/presets/countries/uk.js +2 -0
  6. package/lib/presets/countries/us.d.ts +2 -0
  7. package/lib/presets/countries/us.js +2 -0
  8. package/lib/pricing/delivery-eu-tax.d.ts +2 -0
  9. package/lib/pricing/delivery-eu-tax.js +55 -0
  10. package/lib/pricing/delivery-swiss-tax.js +7 -26
  11. package/lib/pricing/delivery-uk-tax.d.ts +2 -0
  12. package/lib/pricing/delivery-uk-tax.js +43 -0
  13. package/lib/pricing/delivery-us-sales-tax.d.ts +2 -0
  14. package/lib/pricing/delivery-us-sales-tax.js +58 -0
  15. package/lib/pricing/product-eu-tax.d.ts +2 -0
  16. package/lib/pricing/product-eu-tax.js +56 -0
  17. package/lib/pricing/product-swiss-tax.js +7 -26
  18. package/lib/pricing/product-uk-tax.d.ts +2 -0
  19. package/lib/pricing/product-uk-tax.js +57 -0
  20. package/lib/pricing/product-us-sales-tax.d.ts +2 -0
  21. package/lib/pricing/product-us-sales-tax.js +52 -0
  22. package/lib/pricing/tax/applyTaxRateToTaxableRows.d.ts +23 -0
  23. package/lib/pricing/tax/applyTaxRateToTaxableRows.js +30 -0
  24. package/lib/pricing/tax/ch-tax-rates.json +24 -0
  25. package/lib/pricing/tax/ch.js +6 -30
  26. package/lib/pricing/tax/eraRates.d.ts +10 -0
  27. package/lib/pricing/tax/eraRates.js +15 -0
  28. package/lib/pricing/tax/eu-tax-rates.json +797 -0
  29. package/lib/pricing/tax/eu.d.ts +12 -0
  30. package/lib/pricing/tax/eu.js +38 -0
  31. package/lib/pricing/tax/uk-tax-rates.json +18 -0
  32. package/lib/pricing/tax/uk.d.ts +10 -0
  33. package/lib/pricing/tax/uk.js +23 -0
  34. package/lib/pricing/tax/us-tax-rates.json +334 -0
  35. package/lib/pricing/tax/us.d.ts +11 -0
  36. package/lib/pricing/tax/us.js +20 -0
  37. package/lib/pricing/utils/isDeliveryAddressInCountry.d.ts +1 -1
  38. package/lib/pricing/utils/isDeliveryAddressInCountry.js +3 -8
  39. package/lib/pricing/utils/resolveDeliveryLocation.d.ts +10 -0
  40. package/lib/pricing/utils/resolveDeliveryLocation.js +9 -0
  41. package/lib/quotations/manual/adapter.js +6 -1
  42. package/lib/worker/gc-guests/adapter.d.ts +9 -0
  43. package/lib/worker/gc-guests/adapter.js +56 -0
  44. package/lib/worker/gc-guests/index.d.ts +4 -0
  45. package/lib/worker/gc-guests/index.js +13 -0
  46. package/lib/worker/invalidate-carts/adapter.d.ts +9 -0
  47. package/lib/worker/invalidate-carts/adapter.js +52 -0
  48. package/lib/worker/invalidate-carts/index.d.ts +4 -0
  49. package/lib/worker/invalidate-carts/index.js +13 -0
  50. package/lib/worker/zombie-killer/adapter.d.ts +2 -0
  51. package/lib/worker/zombie-killer/adapter.js +26 -3
  52. package/lib/worker/zombie-killer/index.js +4 -1
  53. package/package.json +2 -2
@@ -0,0 +1,10 @@
1
+ export interface TaxRateEra {
2
+ validFrom: string;
3
+ rate: number;
4
+ }
5
+ export interface CompiledTaxRateEra {
6
+ validFrom: number;
7
+ rate: number;
8
+ }
9
+ export declare const compileEraRates: (eras: TaxRateEra[], utcOffset: string) => CompiledTaxRateEra[];
10
+ export declare const rateForDate: (eras: CompiledTaxRateEra[]) => (referenceDate?: Date) => number;
@@ -0,0 +1,15 @@
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);
7
+ export const rateForDate = (eras) => (referenceDate = new Date()) => {
8
+ const time = referenceDate.getTime();
9
+ let applicable = eras[0];
10
+ for (const era of eras) {
11
+ if (era.validFrom <= time)
12
+ applicable = era;
13
+ }
14
+ return applicable.rate;
15
+ };