@unchainedshop/plugins 2.2.2 → 2.3.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.
Files changed (50) hide show
  1. package/lib/payment/cryptopay/plugin.js +3 -2
  2. package/lib/payment/cryptopay/plugin.js.map +1 -1
  3. package/lib/payment/postfinance-checkout/types.js +2 -2
  4. package/lib/payment/postfinance-checkout/types.js.map +1 -1
  5. package/lib/pricing/order-discount.d.ts +2 -10
  6. package/lib/pricing/order-discount.js +12 -47
  7. package/lib/pricing/order-discount.js.map +1 -1
  8. package/lib/pricing/order-items-discount.js +3 -37
  9. package/lib/pricing/order-items-discount.js.map +1 -1
  10. package/lib/pricing/product-discount.d.ts +1 -2
  11. package/lib/pricing/product-discount.js +2 -5
  12. package/lib/pricing/product-discount.js.map +1 -1
  13. package/lib/pricing/product-price-round.d.ts +0 -1
  14. package/lib/pricing/product-price-round.js +2 -2
  15. package/lib/pricing/product-price-round.js.map +1 -1
  16. package/lib/warehousing/google-sheets.js +2 -2
  17. package/lib/warehousing/google-sheets.js.map +1 -1
  18. package/lib/worker/email.js +2 -2
  19. package/lib/worker/email.js.map +1 -1
  20. package/lib/worker/enrollment-order-generator.js +1 -1
  21. package/lib/worker/enrollment-order-generator.js.map +1 -1
  22. package/lib/worker/sms.js +7 -0
  23. package/lib/worker/sms.js.map +1 -1
  24. package/lib/worker/update-coinbase-rates.js +0 -4
  25. package/lib/worker/update-coinbase-rates.js.map +1 -1
  26. package/lib/worker/update-ecb-rates.js +0 -3
  27. package/lib/worker/update-ecb-rates.js.map +1 -1
  28. package/lib/worker/update-token-ownership.js +1 -5
  29. package/lib/worker/update-token-ownership.js.map +1 -1
  30. package/package.json +29 -26
  31. package/src/payment/cryptopay/plugin.ts +5 -3
  32. package/src/pricing/configureProductPriceRounding.test.ts +0 -2
  33. package/src/pricing/free-delivery.test.ts +1 -1
  34. package/src/pricing/order-delivery.test.ts +1 -1
  35. package/src/pricing/order-discount.test.ts +4 -203
  36. package/src/pricing/order-discount.ts +21 -65
  37. package/src/pricing/order-items-discount.ts +4 -45
  38. package/src/pricing/product-discount.ts +3 -6
  39. package/src/pricing/product-price-round.ts +2 -4
  40. package/src/warehousing/google-sheets.ts +2 -2
  41. package/src/worker/email.ts +2 -2
  42. package/src/worker/enrollment-order-generator.ts +1 -1
  43. package/src/worker/sms.ts +8 -0
  44. package/src/worker/update-coinbase-rates.ts +0 -4
  45. package/src/worker/update-ecb-rates.ts +0 -3
  46. package/src/worker/update-token-ownership.ts +1 -5
  47. package/tsconfig.json +3 -7
  48. package/src/pricing/apply-rate.test.ts +0 -92
  49. package/src/pricing/getTaxRate.test.ts +0 -69
  50. package/src/pricing/roundToNext.test.ts +0 -24
@@ -32,7 +32,7 @@ export const RefreshTokens: IWorkerAdapter<void, any> = {
32
32
  const { modules } = unchainedAPI;
33
33
 
34
34
  const tokens = await modules.warehousing.findTokens({});
35
- const users = await modules.users.findUsers({ includeGuests: true });
35
+ const users = await modules.users.findUsers({ includeGuests: true, 'services.web3.verified': true });
36
36
  const accounts = users.flatMap((user) => {
37
37
  return user?.services?.web3?.flatMap((service) => {
38
38
  if (service.verified) return [service.address];
@@ -79,8 +79,4 @@ WorkerDirector.registerAdapter(UpdateTokenOwnership);
79
79
 
80
80
  WorkerDirector.configureAutoscheduling(RefreshTokens, {
81
81
  schedule: everyMinute,
82
- retries: 5,
83
- input: () => {
84
- /* */
85
- },
86
82
  });
package/tsconfig.json CHANGED
@@ -4,13 +4,9 @@
4
4
  "rootDir": "src",
5
5
  "outDir": "lib",
6
6
  "paths": {
7
- "postfinancecheckout": [
8
- "./src/payment/postfinance-checkout/silence-postfinancecheckout.d.ts"
9
- ],
7
+ "postfinancecheckout": ["./src/payment/postfinance-checkout/silence-postfinancecheckout.d.ts"]
10
8
  }
11
9
  },
12
10
  "exclude": ["**/*.test.ts", "**/*.test.js", "tests"],
13
- "include": [
14
- "./src"
15
- ]
16
- }
11
+ "include": ["./src", "../utils/src/roundToNext.test.ts"]
12
+ }
@@ -1,92 +0,0 @@
1
- import {applyRate} from './product-discount.js'
2
- describe('applyRate', () => {
3
- it('applies the rate correctly when a rate is provided', () => {
4
- const configuration = {
5
- rate: 0.1
6
- };
7
- const amount = 100;
8
- expect(applyRate(configuration, amount)).toBe(10);
9
- });
10
-
11
- it('applies the fixed rate correctly when a fixed rate is provided', () => {
12
- const configuration = {
13
- fixedRate: 50
14
- };
15
- const amount = 100;
16
- expect(applyRate(configuration, amount)).toBe(50);
17
- });
18
-
19
- it('applies the fixed rate correctly when a fixed rate is provided and the amount is less than fixed rate', () => {
20
- const configuration = {
21
- fixedRate: 150
22
- };
23
- const amount = 100;
24
- expect(applyRate(configuration, amount)).toBe(100);
25
- });
26
-
27
- it('applies the rate correctly when rate is less than or equal to 0', () => {
28
- const configuration = {
29
- rate: -0.1
30
- };
31
- const amount = 100;
32
- expect(applyRate(configuration, amount)).toBe(-10);
33
- });
34
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
35
- const configuration = {
36
- rate: 0.1
37
- };
38
- const amount = -100;
39
- expect(applyRate(configuration, amount)).toBe(-10);
40
- });
41
-
42
-
43
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
44
- const configuration = {
45
- rate: 0.1
46
- };
47
- const amount = -100;
48
- expect(applyRate(configuration, amount)).toBe(-10);
49
- });
50
-
51
-
52
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
53
- const configuration = {
54
- rate: 0.1
55
- };
56
- const amount = -100;
57
- expect(applyRate(configuration, amount)).toBe(-10);
58
- });
59
-
60
-
61
-
62
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
63
- const configuration = {
64
- rate: 0.1
65
- };
66
- const amount = -100;
67
- expect(applyRate(configuration, amount)).toBe(-10);
68
- });
69
-
70
-
71
- it('returns 0 when rate and fixed rate are not provided', () => {
72
- const configuration = {};
73
- const amount = 100;
74
- expect(applyRate(configuration, amount)).toBe(0);
75
- });
76
-
77
- it('applies the rate correctly when only rate is provided and amount is negative', () => {
78
- const configuration = {
79
- rate: 0.1
80
- };
81
- const amount = -100;
82
- expect(applyRate(configuration, amount)).toBe(-10);
83
- });
84
-
85
- it('returns 0 when rate and fixed rate are not provided', () => {
86
- const configuration = {};
87
- const amount = 100;
88
- expect(applyRate(configuration, amount)).toBe(0);
89
- });
90
-
91
-
92
- });
@@ -1,69 +0,0 @@
1
- import { SwissTaxCategories, getTaxRate } from './product-swiss-tax.js';
2
-
3
-
4
-
5
- describe('getTaxRate', () => {
6
- it('default rate', () => {
7
- const context: any = {
8
- product: {
9
- tags: []
10
- },
11
- provider: {
12
- configuration: [],
13
- },
14
- };
15
- expect(getTaxRate(context)).toBe(0.077);
16
- });
17
-
18
- it('reduced rate', () => {
19
- const context: any = {
20
- product: {
21
- tags: ['swiss-tax-category:reduced']
22
- },
23
- provider: {
24
- configuration: [
25
- {
26
- key: 'swiss-tax-category',
27
- value: SwissTaxCategories.REDUCED.rate(),
28
- },
29
- ],
30
- },
31
- };
32
- expect(getTaxRate(context)).toBe(0.025);
33
- });
34
-
35
- it('special rate', () => {
36
- const context: any = {
37
- product: {
38
- tags: ['swiss-tax-category:special']
39
- },
40
- provider: {
41
- configuration: [
42
- {
43
- key: 'swiss-tax-category',
44
- value: SwissTaxCategories.SPECIAL.rate(),
45
- },
46
- ],
47
- },
48
- };
49
- expect(getTaxRate(context)).toBe(0.037);
50
- });
51
-
52
- it('default rate', () => {
53
- const context: any = {
54
- product: {
55
- tags: ['swiss-tax-category:default']
56
- },
57
- provider: {
58
- configuration: [
59
- {
60
- key: 'swiss-tax-category',
61
- value: SwissTaxCategories.DEFAULT.rate(),
62
- },
63
- ],
64
- },
65
- };
66
- expect(getTaxRate(context)).toBe(0.077);
67
- });
68
-
69
- })
@@ -1,24 +0,0 @@
1
- import { roundToNext } from "./product-price-round.js";
2
-
3
- describe('roundToNext', () => {
4
- it('rounds to the next multiple of precision correctly when the value is positive', () => {
5
- expect(roundToNext(5, 2)).toBe(6);
6
- expect(roundToNext(10, 5)).toBe(10);
7
- expect(roundToNext(13, 5)).toBe(15);
8
- });
9
-
10
- it('rounds to the next multiple of precision correctly when the value is negative', () => {
11
- expect(roundToNext(-5, 2)).toBe(-4);
12
- expect(roundToNext(-10, 5)).toBe(-10);
13
- expect(roundToNext(-13, 5)).toBe(-10);
14
- });
15
-
16
- it('returns 0 when the value is 0', () => {
17
- expect(roundToNext(0, 5)).toBe(0);
18
- });
19
-
20
- it('returns the same value when the precision is 1', () => {
21
- expect(roundToNext(5, 1)).toBe(5);
22
- });
23
-
24
- });