@unchainedshop/plugins 3.0.0-alpha3 → 3.0.0-alpha4
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/lib/payment/stripe/stripe.js +2 -2
- package/lib/payment/stripe/stripe.js.map +1 -1
- package/lib/plugins-index.d.ts +2 -1
- package/lib/plugins-index.d.ts.map +1 -1
- package/lib/plugins-index.js.map +1 -1
- package/lib/presets/base-modules.d.ts +1 -1
- package/lib/presets/base-modules.d.ts.map +1 -1
- package/lib/presets/crypto-modules.d.ts +1 -1
- package/lib/presets/crypto-modules.d.ts.map +1 -1
- package/package.json +22 -22
- package/src/files/gridfs/gridfs-adapter.ts +1 -1
- package/src/files/minio/minio-adapter.ts +1 -1
- package/src/payment/stripe/stripe.ts +2 -2
- package/src/plugins-index.ts +2 -1
- package/src/presets/base-modules.ts +1 -1
- package/src/presets/crypto-modules.ts +1 -1
- package/src/pricing/discount-100-off.test.ts +13 -7
- package/src/pricing/discount-half-price-manual.test.ts +13 -7
- package/src/pricing/discount-half-price.test.ts +15 -7
- package/src/pricing/free-delivery.test.ts +3 -8
- package/src/pricing/licenced-enrollment.test.ts +33 -34
- package/src/pricing/order-delivery.test.ts +3 -5
- package/src/pricing/order-discount.test.ts +3 -3
- package/src/pricing/plugins-index.test.ts +1 -1
- package/src/pricing/product-swiss-tax.test.ts +112 -87
- package/src/pricing/tax/ch.test.ts +16 -16
|
@@ -38,7 +38,7 @@ export const upsertCustomer = async ({ userId, name, email }) => {
|
|
|
38
38
|
};
|
|
39
39
|
export const createRegistrationIntent = async ({ userId, name, email, paymentProviderId, descriptorPrefix, }, options = {}) => {
|
|
40
40
|
const customer = options?.customer || (await upsertCustomer({ userId, name, email }));
|
|
41
|
-
const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}
|
|
41
|
+
const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}`.trim();
|
|
42
42
|
const setupIntent = await stripe.setupIntents.create({
|
|
43
43
|
description,
|
|
44
44
|
customer,
|
|
@@ -53,7 +53,7 @@ export const createRegistrationIntent = async ({ userId, name, email, paymentPro
|
|
|
53
53
|
return setupIntent;
|
|
54
54
|
};
|
|
55
55
|
export const createOrderPaymentIntent = async ({ userId, name, email, order, orderPayment, pricing, descriptorPrefix, }, options = {}) => {
|
|
56
|
-
const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}
|
|
56
|
+
const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}`.trim();
|
|
57
57
|
const customer = options?.customer || (await upsertCustomer({ userId, name, email }));
|
|
58
58
|
const { currency, amount } = pricing.total({ useNetPrice: false });
|
|
59
59
|
const paymentIntent = await stripe.paymentIntents.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe.js","sourceRoot":"","sources":["../../../src/payment/stripe/stripe.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,EAAE,aAAa,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEtF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,EAAE;IACvC,UAAU,EAAE,YAAY;CACzB,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,0BAA0B,IAAI,IAAI,CAAC;AAEvD,eAAe,MAAM,CAAC;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAmB,EAAE;IAC/E,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,uBAAuB,MAAM,GAAG,EAAE,CAAC,CAAC;QAC5F,MAAM,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEjC,IACE,gBAAgB,CAAC,IAAI,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,QAAQ,CAAC,WAAW,EAAE;QAChC,WAAW;QACX,2BAA2B,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;QACzG,kBAAkB,EAAE,aAAa,EAAE,oEAAoE;QACvG,QAAQ;QACR,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,YAAY;QAC1C,QAAQ,EAAE;YACR,cAAc,EAAE,YAAY,CAAC,GAAG;YAChC,OAAO,EAAE,KAAK,CAAC,GAAG;YAClB,MAAM;YACN,WAAW;SACZ;QACD,GAAG,OAAO;KACX,CAAC,CAAC;IACH,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC"}
|
package/lib/plugins-index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
import { ModuleInput } from '@unchainedshop/mongodb';
|
|
2
3
|
import './presets/countries/ch.js';
|
|
3
4
|
import './delivery/send-message.js';
|
|
4
5
|
import './delivery/stores.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins-index.d.ts","sourceRoot":"","sources":["../src/plugins-index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugins-index.d.ts","sourceRoot":"","sources":["../src/plugins-index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,2BAA2B,CAAC;AAOnC,OAAO,4BAA4B,CAAC;AACpC,OAAO,sBAAsB,CAAC;AAG9B,OAAO,8BAA8B,CAAC;AACtC,OAAO,8BAA8B,CAAC;AAStC,OAAO,2BAA2B,CAAC;AACnC,OAAO,2BAA2B,CAAC;AAGnC,OAAO,iBAAiB,CAAC;AACzB,OAAO,+BAA+B,CAAC;AAYvC,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,MAAM,EACN;IACE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;CAC9C,CAUF,CAAC;AAEF,eAAO,MAAM,+BAA+B,+BAExB;IAAE,YAAY,EAAE,aAAa,CAAA;CAAE,SA4BlD,CAAC"}
|
package/lib/plugins-index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins-index.js","sourceRoot":"","sources":["../src/plugins-index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugins-index.js","sourceRoot":"","sources":["../src/plugins-index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,2BAA2B,CAAC;AACnC,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAExD,OAAO,sBAAsB,MAAM,6BAA6B,CAAC;AACjE,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAE7D,WAAW;AACX,OAAO,4BAA4B,CAAC;AACpC,OAAO,sBAAsB,CAAC;AAE9B,UAAU;AACV,OAAO,8BAA8B,CAAC;AACtC,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,mCAAmC,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,kBAAkB;AAClB,OAAO,2BAA2B,CAAC;AACnC,OA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,CAAC,oBAAoB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC;IAC1F,GAAG,CAAC,GAAG,CAAC,qBAAqB,EAAE,eAAe,CAAC,CAAC;IAEhD,oCAAoC,EAAE,CAAC;AACzC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-modules.d.ts","sourceRoot":"","sources":["../../src/presets/base-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"base-modules.d.ts","sourceRoot":"","sources":["../../src/presets/base-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,qBAAqB,CAAC;AAG7B,OAAO,uBAAuB,CAAC;AAG/B,OAAO,yBAAyB,CAAC;AAGjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,CAAC;AACnC,OAAO,8BAA8B,CAAC;AACtC,OAAO,8BAA8B,CAAC;AACtC,OAAO,6BAA6B,CAAC;AACrC,OAAO,qCAAqC,CAAC;AAC7C,OAAO,gCAAgC,CAAC;AAGxC,OAAO,yBAAyB,CAAC;AAGjC,OAAO,4BAA4B,CAAC;AAGpC,OAAO,iCAAiC,CAAC;AAGzC,OAAO,0BAA0B,CAAC;AAClC,OAAO,4BAA4B,CAAC;AACpC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAChC,OAAO,oBAAoB,CAAC;AAC5B,OAAO,kCAAkC,CAAC;AAG1C,OAAO,mCAAmC,CAAC;AAG3C,QAAA,MAAM,OAAO,EAAE,MAAM,CACnB,MAAM,EACN;IACE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;CAC9C,CAKF,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-modules.d.ts","sourceRoot":"","sources":["../../src/presets/crypto-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"crypto-modules.d.ts","sourceRoot":"","sources":["../../src/presets/crypto-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,OAAO,8BAA8B,CAAC;AAEtC,OAAO,4CAA4C,CAAC;AACpD,OAAO,+BAA+B,CAAC;AACvC,OAAO,oCAAoC,CAAC;AAC5C,OAAO,2BAA2B,CAAC;AAEnC,QAAA,MAAM,OAAO,EAAE,MAAM,CACnB,MAAM,EACN;IACE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;CAC9C,CAKF,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/plugins",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-alpha4",
|
|
4
4
|
"main": "lib/plugins-index.js",
|
|
5
5
|
"types": "lib/plugins-index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -76,37 +76,37 @@
|
|
|
76
76
|
"@redis/client": "^1.5.8",
|
|
77
77
|
"bip32": "^4.0.0",
|
|
78
78
|
"bitcoinjs-lib": "^6.1.6",
|
|
79
|
-
"ethers": "^6.13.
|
|
79
|
+
"ethers": "^6.13.4",
|
|
80
80
|
"express": "^4.x",
|
|
81
81
|
"memoizee": "^0.4.17",
|
|
82
82
|
"open": "^10.0.0",
|
|
83
83
|
"postfinancecheckout": "^4.1.1",
|
|
84
|
-
"stripe": "^16.
|
|
84
|
+
"stripe": "^16.12.0",
|
|
85
85
|
"tiny-secp256k1": "^2.2.3",
|
|
86
|
-
"twilio": "^5.3.
|
|
86
|
+
"twilio": "^5.3.4",
|
|
87
87
|
"web-push": "^3.6.3"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@redis/client": "^1.6.0",
|
|
91
|
-
"@types/node": "^22.
|
|
92
|
-
"@unchainedshop/api": "^3.0.0-
|
|
93
|
-
"@unchainedshop/core-delivery": "^3.0.0-
|
|
94
|
-
"@unchainedshop/core-enrollments": "^3.0.0-
|
|
95
|
-
"@unchainedshop/core-filters": "^3.0.0-
|
|
96
|
-
"@unchainedshop/core-messaging": "^3.0.0-
|
|
97
|
-
"@unchainedshop/core-orders": "^3.0.0-
|
|
98
|
-
"@unchainedshop/core-payment": "^3.0.0-
|
|
99
|
-
"@unchainedshop/core-products": "^3.0.0-
|
|
100
|
-
"@unchainedshop/core-quotations": "^3.0.0-
|
|
101
|
-
"@unchainedshop/core-warehousing": "^3.0.0-
|
|
102
|
-
"@unchainedshop/core-worker": "^3.0.0-
|
|
103
|
-
"@unchainedshop/events": "^3.0.0-
|
|
104
|
-
"@unchainedshop/file-upload": "^3.0.0-
|
|
105
|
-
"@unchainedshop/logger": "^3.0.0-
|
|
106
|
-
"@unchainedshop/utils": "^3.0.0-
|
|
91
|
+
"@types/node": "^22.7.8",
|
|
92
|
+
"@unchainedshop/api": "^3.0.0-alpha4",
|
|
93
|
+
"@unchainedshop/core-delivery": "^3.0.0-alpha4",
|
|
94
|
+
"@unchainedshop/core-enrollments": "^3.0.0-alpha4",
|
|
95
|
+
"@unchainedshop/core-filters": "^3.0.0-alpha4",
|
|
96
|
+
"@unchainedshop/core-messaging": "^3.0.0-alpha4",
|
|
97
|
+
"@unchainedshop/core-orders": "^3.0.0-alpha4",
|
|
98
|
+
"@unchainedshop/core-payment": "^3.0.0-alpha4",
|
|
99
|
+
"@unchainedshop/core-products": "^3.0.0-alpha4",
|
|
100
|
+
"@unchainedshop/core-quotations": "^3.0.0-alpha4",
|
|
101
|
+
"@unchainedshop/core-warehousing": "^3.0.0-alpha4",
|
|
102
|
+
"@unchainedshop/core-worker": "^3.0.0-alpha4",
|
|
103
|
+
"@unchainedshop/events": "^3.0.0-alpha4",
|
|
104
|
+
"@unchainedshop/file-upload": "^3.0.0-alpha4",
|
|
105
|
+
"@unchainedshop/logger": "^3.0.0-alpha4",
|
|
106
|
+
"@unchainedshop/utils": "^3.0.0-alpha4",
|
|
107
107
|
"bluebird": "^3.7.2",
|
|
108
108
|
"event-iterator": "^2.0.0",
|
|
109
|
-
"express": "^4.21.
|
|
109
|
+
"express": "^4.21.1",
|
|
110
110
|
"jest": "^29.7.0",
|
|
111
111
|
"JSONStream": "^1.3.5",
|
|
112
112
|
"minio": "^8.0.1",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"postfinancecheckout": "^4.5.0",
|
|
117
117
|
"request": "^2.88.2",
|
|
118
118
|
"ts-jest": "^29.2.5",
|
|
119
|
-
"typescript": "^5.6.
|
|
119
|
+
"typescript": "^5.6.3",
|
|
120
120
|
"web-push": "^3.6.7",
|
|
121
121
|
"xml-js": "^1.6.11"
|
|
122
122
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
resolveExpirationDate,
|
|
11
11
|
IFileAdapter,
|
|
12
12
|
} from '@unchainedshop/file-upload';
|
|
13
|
-
import { UploadFileData } from '@unchainedshop/
|
|
13
|
+
import { UploadFileData } from '@unchainedshop/file-upload';
|
|
14
14
|
import sign from './sign.js';
|
|
15
15
|
|
|
16
16
|
const { ROOT_URL } = process.env;
|
|
@@ -2,7 +2,7 @@ import https from 'https';
|
|
|
2
2
|
import http, { OutgoingHttpHeaders } from 'http';
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
4
|
import { URL } from 'url';
|
|
5
|
-
import { UploadFileData } from '@unchainedshop/
|
|
5
|
+
import { UploadFileData } from '@unchainedshop/file-upload';
|
|
6
6
|
import {
|
|
7
7
|
FileAdapter,
|
|
8
8
|
FileDirector,
|
|
@@ -65,7 +65,7 @@ export const createRegistrationIntent = async (
|
|
|
65
65
|
options: Record<string, any> = {},
|
|
66
66
|
) => {
|
|
67
67
|
const customer = options?.customer || (await upsertCustomer({ userId, name, email }));
|
|
68
|
-
const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}
|
|
68
|
+
const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}`.trim();
|
|
69
69
|
|
|
70
70
|
const setupIntent = await stripe.setupIntents.create({
|
|
71
71
|
description,
|
|
@@ -101,7 +101,7 @@ export const createOrderPaymentIntent = async (
|
|
|
101
101
|
},
|
|
102
102
|
options: Record<string, any> = {},
|
|
103
103
|
) => {
|
|
104
|
-
const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}
|
|
104
|
+
const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}`.trim();
|
|
105
105
|
const customer = options?.customer || (await upsertCustomer({ userId, name, email }));
|
|
106
106
|
const { currency, amount } = pricing.total({ useNetPrice: false });
|
|
107
107
|
|
package/src/plugins-index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ModuleInput, UnchainedCore } from '@unchainedshop/core';
|
|
2
1
|
import express from 'express';
|
|
2
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
3
|
+
import { ModuleInput } from '@unchainedshop/mongodb';
|
|
3
4
|
|
|
4
5
|
import baseModules from './presets/base-modules.js';
|
|
5
6
|
import './presets/countries/ch.js';
|
|
@@ -2,17 +2,17 @@ import { HundredOff } from './discount-100-off.js';
|
|
|
2
2
|
|
|
3
3
|
describe('HundredOff', () => {
|
|
4
4
|
it('isManualAdditionAllowed', async () => {
|
|
5
|
-
let x
|
|
6
|
-
|
|
5
|
+
let x;
|
|
6
|
+
expect(await HundredOff.isManualAdditionAllowed(x)).toBeTruthy();
|
|
7
7
|
});
|
|
8
8
|
it('isManualRemovalAllowed', async () => {
|
|
9
|
-
|
|
9
|
+
expect(await HundredOff.isManualRemovalAllowed()).toBeTruthy();
|
|
10
10
|
});
|
|
11
11
|
it('isValidForSystemTriggering', async () => {
|
|
12
12
|
const context = {};
|
|
13
13
|
const actions = await HundredOff.actions({ context } as any);
|
|
14
14
|
expect(await actions.isValidForSystemTriggering()).toBeFalsy();
|
|
15
|
-
|
|
15
|
+
});
|
|
16
16
|
it('isValidForCodeTriggering', async () => {
|
|
17
17
|
const context = {};
|
|
18
18
|
const actions = await HundredOff.actions({ context } as any);
|
|
@@ -24,8 +24,14 @@ describe('HundredOff', () => {
|
|
|
24
24
|
const context = {};
|
|
25
25
|
const actions = await HundredOff.actions({ context } as any);
|
|
26
26
|
expect(
|
|
27
|
-
|
|
27
|
+
actions.discountForPricingAdapterKey({
|
|
28
|
+
pricingAdapterKey: 'shop.unchained.pricing.order-discount',
|
|
29
|
+
} as any),
|
|
28
30
|
).toEqual({ fixedRate: 10000 });
|
|
29
|
-
expect(
|
|
30
|
-
|
|
31
|
+
expect(
|
|
32
|
+
actions.discountForPricingAdapterKey({
|
|
33
|
+
pricingAdapterKey: 'shop.unchained.pricing.other-discount',
|
|
34
|
+
} as any),
|
|
35
|
+
).toBeNull();
|
|
36
|
+
});
|
|
31
37
|
});
|
|
@@ -5,31 +5,37 @@ describe('HalfPriceManual', () => {
|
|
|
5
5
|
let x;
|
|
6
6
|
expect(await HalfPriceManual.isManualAdditionAllowed(x)).toBeTruthy();
|
|
7
7
|
});
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
it('isManualRemovalAllowed', async () => {
|
|
10
10
|
expect(await HalfPriceManual.isManualRemovalAllowed()).toBeTruthy();
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
it('isValidForSystemTriggering', async () => {
|
|
14
14
|
const context = {};
|
|
15
15
|
const actions = await HalfPriceManual.actions({ context } as any);
|
|
16
16
|
expect(await actions.isValidForSystemTriggering()).toBeFalsy();
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
it('isValidForCodeTriggering', async () => {
|
|
20
20
|
const context = {};
|
|
21
21
|
const actions = await HalfPriceManual.actions({ context } as any);
|
|
22
22
|
expect(await actions.isValidForCodeTriggering({ code: 'HALFPRICE' })).toBeTruthy();
|
|
23
23
|
expect(await actions.isValidForCodeTriggering({ code: 'othercode' })).toBeFalsy();
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
it('discountForPricingAdapterKey', async () => {
|
|
27
27
|
const context = {};
|
|
28
28
|
const actions = await HalfPriceManual.actions({ context } as any);
|
|
29
29
|
expect(
|
|
30
|
-
actions.discountForPricingAdapterKey({
|
|
30
|
+
actions.discountForPricingAdapterKey({
|
|
31
|
+
pricingAdapterKey: 'shop.unchained.pricing.product-discount',
|
|
32
|
+
} as any),
|
|
31
33
|
).toEqual({ rate: 0.5 });
|
|
32
|
-
expect(
|
|
34
|
+
expect(
|
|
35
|
+
actions.discountForPricingAdapterKey({
|
|
36
|
+
pricingAdapterKey: 'shop.unchained.pricing.other-discount',
|
|
37
|
+
} as any),
|
|
38
|
+
).toBeNull();
|
|
33
39
|
});
|
|
34
40
|
|
|
35
41
|
it('Actions', async () => {
|
|
@@ -39,4 +45,4 @@ describe('HalfPriceManual', () => {
|
|
|
39
45
|
expect(typeof actions.isValidForCodeTriggering).toBe('function');
|
|
40
46
|
expect(typeof actions.discountForPricingAdapterKey).toBe('function');
|
|
41
47
|
});
|
|
42
|
-
});
|
|
48
|
+
});
|
|
@@ -13,10 +13,10 @@ describe('HalfPrice', () => {
|
|
|
13
13
|
const context = {
|
|
14
14
|
modules: {
|
|
15
15
|
users: {
|
|
16
|
-
findUserById: import.meta.jest.fn(() => Promise.resolve({ tags: ['half-price'] }))
|
|
17
|
-
}
|
|
16
|
+
findUserById: import.meta.jest.fn(() => Promise.resolve({ tags: ['half-price'] })),
|
|
17
|
+
},
|
|
18
18
|
},
|
|
19
|
-
order: { userId: 'user-id' }
|
|
19
|
+
order: { userId: 'user-id' },
|
|
20
20
|
};
|
|
21
21
|
const actions = await HalfPrice.actions({ context } as any);
|
|
22
22
|
expect(await actions.isValidForSystemTriggering()).toBeTruthy();
|
|
@@ -27,14 +27,22 @@ describe('HalfPrice', () => {
|
|
|
27
27
|
it('discountForPricingAdapterKey', async () => {
|
|
28
28
|
const context = {};
|
|
29
29
|
const actions = await HalfPrice.actions({ context } as any);
|
|
30
|
-
expect(
|
|
31
|
-
|
|
30
|
+
expect(
|
|
31
|
+
actions.discountForPricingAdapterKey({
|
|
32
|
+
pricingAdapterKey: 'shop.unchained.pricing.product-discount',
|
|
33
|
+
} as any),
|
|
34
|
+
).toEqual({ rate: 0.5 });
|
|
35
|
+
expect(
|
|
36
|
+
actions.discountForPricingAdapterKey({
|
|
37
|
+
pricingAdapterKey: 'shop.unchained.pricing.other-discount',
|
|
38
|
+
} as any),
|
|
39
|
+
).toBeNull();
|
|
32
40
|
});
|
|
33
41
|
|
|
34
42
|
it('isValidForCodeTriggering', async () => {
|
|
35
43
|
const context = {};
|
|
36
44
|
const actions = await HalfPrice.actions({ context } as any);
|
|
37
|
-
|
|
38
|
-
expect(await actions.isValidForCodeTriggering({code: ''})).toBeFalsy();
|
|
45
|
+
|
|
46
|
+
expect(await actions.isValidForCodeTriggering({ code: '' })).toBeFalsy();
|
|
39
47
|
});
|
|
40
48
|
});
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { DeliveryFreePrice } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
describe("DeliveryFreePrice", () => {
|
|
1
|
+
import { DeliveryFreePrice } from './free-delivery.js';
|
|
6
2
|
|
|
3
|
+
describe('DeliveryFreePrice', () => {
|
|
7
4
|
it('should return true', () => {
|
|
8
5
|
expect(DeliveryFreePrice.isActivatedFor(undefined as any)).toBeTruthy();
|
|
9
|
-
|
|
10
6
|
});
|
|
11
|
-
|
|
12
|
-
})
|
|
7
|
+
});
|
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
import { rangeMatcher } from
|
|
1
|
+
import { rangeMatcher } from '../enrollments/licensed.js';
|
|
2
2
|
|
|
3
3
|
describe('rangeMatcher', () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
4
|
+
const now = new Date();
|
|
5
|
+
|
|
6
|
+
const tomorrow = new Date();
|
|
7
|
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
8
|
+
const tomorrowTimestamp = tomorrow.getTime();
|
|
9
|
+
const yesterday = new Date();
|
|
10
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
11
|
+
const yesterdayTimestamp = yesterday.getTime();
|
|
12
|
+
|
|
13
|
+
it('matches correctly when the date is within the range', () => {
|
|
14
|
+
const range = { start: yesterday, end: tomorrow };
|
|
15
|
+
const matcher = rangeMatcher(now);
|
|
16
|
+
expect(matcher(range)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('does not match when the date is before the start of the range', () => {
|
|
20
|
+
const range = { start: tomorrow, end: tomorrow };
|
|
21
|
+
const matcher = rangeMatcher(yesterday);
|
|
22
|
+
expect(matcher(range)).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('does not match when the date is after the end of the range', () => {
|
|
26
|
+
const range = { start: yesterday, end: yesterday };
|
|
27
|
+
const matcher = rangeMatcher(tomorrow);
|
|
28
|
+
expect(matcher(range)).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('matches correctly when the date is not provided', () => {
|
|
32
|
+
const range = { start: yesterdayTimestamp, end: tomorrowTimestamp };
|
|
33
|
+
const matcher = rangeMatcher();
|
|
34
|
+
expect(matcher(range)).toBe(true);
|
|
36
35
|
});
|
|
37
|
-
|
|
36
|
+
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { OrderDelivery } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe("OrderDelivery ", () => {
|
|
1
|
+
import { OrderDelivery } from './order-delivery.js';
|
|
5
2
|
|
|
3
|
+
describe('OrderDelivery ', () => {
|
|
6
4
|
it('isActivatedFor', () => {
|
|
7
5
|
expect(OrderDelivery.isActivatedFor({} as any)).toBeTruthy();
|
|
8
6
|
});
|
|
9
|
-
})
|
|
7
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OrderDiscount } from
|
|
1
|
+
import { OrderDiscount } from './order-discount.js';
|
|
2
2
|
|
|
3
|
-
describe(
|
|
3
|
+
describe('OrderDelivery ', () => {
|
|
4
4
|
it('isActivatedFor', () => {
|
|
5
5
|
expect(OrderDiscount.isActivatedFor({} as any)).toBeTruthy();
|
|
6
6
|
});
|
|
7
|
-
})
|
|
7
|
+
});
|
|
@@ -1,101 +1,126 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { getTaxRate, isDeliveryAddressInSwitzerland } from './product-swiss-tax.js';
|
|
3
2
|
|
|
4
|
-
describe(
|
|
3
|
+
describe('ProductSwissTax', () => {
|
|
4
|
+
describe('getTaxRate', () => {
|
|
5
|
+
it('default rate', () => {
|
|
6
|
+
expect(
|
|
7
|
+
getTaxRate({
|
|
8
|
+
product: {} as any,
|
|
9
|
+
order: {} as any,
|
|
10
|
+
} as any),
|
|
11
|
+
).toBe(0.081);
|
|
12
|
+
});
|
|
5
13
|
|
|
14
|
+
it('reduced rate', () => {
|
|
15
|
+
expect(
|
|
16
|
+
getTaxRate({
|
|
17
|
+
product: {
|
|
18
|
+
tags: ['swiss-tax-category:reduced'],
|
|
19
|
+
},
|
|
20
|
+
order: {},
|
|
21
|
+
} as any),
|
|
22
|
+
).toBe(0.026);
|
|
23
|
+
});
|
|
6
24
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
it('special rate', () => {
|
|
26
|
+
expect(
|
|
27
|
+
getTaxRate({
|
|
28
|
+
product: {
|
|
29
|
+
tags: ['swiss-tax-category:special'],
|
|
30
|
+
},
|
|
31
|
+
order: {},
|
|
32
|
+
} as any),
|
|
33
|
+
).toBe(0.038);
|
|
34
|
+
});
|
|
14
35
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
it('default rate', () => {
|
|
37
|
+
expect(
|
|
38
|
+
getTaxRate({
|
|
39
|
+
product: {
|
|
40
|
+
tags: ['swiss-tax-category:default'],
|
|
41
|
+
},
|
|
42
|
+
order: {},
|
|
43
|
+
} as any),
|
|
44
|
+
).toBe(0.081);
|
|
45
|
+
});
|
|
22
46
|
});
|
|
23
47
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
48
|
+
describe('isDeliveryAddressInSwitzerland', () => {
|
|
49
|
+
const context = {
|
|
50
|
+
modules: {
|
|
51
|
+
orders: {
|
|
52
|
+
deliveries: {
|
|
53
|
+
findDelivery: import.meta.jest.fn(async ({ orderDeliveryId }) => {
|
|
54
|
+
if (orderDeliveryId === 'CH' || orderDeliveryId === 'LI')
|
|
55
|
+
return { context: { address: { countryCode: 'CH' } } };
|
|
56
|
+
if (orderDeliveryId === null) return { context: { address: null } };
|
|
57
|
+
return { context: { address: { countryCode: 'RT' } } };
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
order: {
|
|
63
|
+
deliveryId: 'CH',
|
|
64
|
+
billingAddress: { countryCode: 'LI' },
|
|
65
|
+
},
|
|
66
|
+
country: 'CH',
|
|
67
|
+
};
|
|
68
|
+
it('Should return true when passed country code CH', async () => {
|
|
69
|
+
expect(
|
|
70
|
+
await isDeliveryAddressInSwitzerland({ ...context, country: 'ch', order: null } as any),
|
|
71
|
+
).toBe(true);
|
|
72
|
+
});
|
|
32
73
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
order: {} as any,
|
|
39
|
-
})).toBe(0.081);
|
|
40
|
-
});
|
|
74
|
+
it('Should return true when passed country code LI', async () => {
|
|
75
|
+
expect(
|
|
76
|
+
await isDeliveryAddressInSwitzerland({ ...context, country: 'LI', order: null } as any),
|
|
77
|
+
).toBe(true);
|
|
78
|
+
});
|
|
41
79
|
|
|
42
|
-
|
|
80
|
+
it('Should return false when country is neither CH nor LI and order is null', async () => {
|
|
81
|
+
expect(
|
|
82
|
+
await isDeliveryAddressInSwitzerland({ ...context, country: 'ET', order: null } as any),
|
|
83
|
+
).toBe(false);
|
|
84
|
+
});
|
|
43
85
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
order : {
|
|
60
|
-
deliveryId: 'CH',
|
|
61
|
-
billingAddress: {countryCode: 'LI'}
|
|
62
|
-
},
|
|
63
|
-
country: 'CH'
|
|
64
|
-
}
|
|
65
|
-
it('Should return true when passed country code CH', async () => {
|
|
66
|
-
expect(await isDeliveryAddressInSwitzerland({...context, country: 'ch', order: null})).toBe(true);
|
|
67
|
-
});
|
|
86
|
+
it('Order should take precedence over country parameter', async () => {
|
|
87
|
+
// not CH or LI order so returns false
|
|
88
|
+
expect(
|
|
89
|
+
await isDeliveryAddressInSwitzerland({
|
|
90
|
+
...context,
|
|
91
|
+
country: 'CH',
|
|
92
|
+
order: {
|
|
93
|
+
deliveryId: 'ET',
|
|
94
|
+
billingAddress: { countryCode: 'ET' },
|
|
95
|
+
},
|
|
96
|
+
} as any),
|
|
97
|
+
).toBe(false);
|
|
98
|
+
});
|
|
68
99
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
100
|
+
it('If order is not from CH and LI but billingAddress is, it should take precedence over country ', async () => {
|
|
101
|
+
expect(
|
|
102
|
+
await isDeliveryAddressInSwitzerland({
|
|
103
|
+
...context,
|
|
104
|
+
country: 'IT',
|
|
105
|
+
order: {
|
|
106
|
+
deliveryId: null,
|
|
107
|
+
billingAddress: { countryCode: 'CH' },
|
|
108
|
+
},
|
|
109
|
+
} as any),
|
|
110
|
+
).toBe(true);
|
|
111
|
+
});
|
|
76
112
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}})).toBe(true);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('Should return false if billingAddress is neither CH or LI and order does not have address', async () => {
|
|
93
|
-
expect(await isDeliveryAddressInSwitzerland({...context, country: null, order : {
|
|
94
|
-
deliveryId: null,
|
|
95
|
-
billingAddress: {countryCode: 'HH'}
|
|
96
|
-
}})).toBe(false);
|
|
113
|
+
it('Should return false if billingAddress is neither CH or LI and order does not have address', async () => {
|
|
114
|
+
expect(
|
|
115
|
+
await isDeliveryAddressInSwitzerland({
|
|
116
|
+
...context,
|
|
117
|
+
country: null,
|
|
118
|
+
order: {
|
|
119
|
+
deliveryId: null,
|
|
120
|
+
billingAddress: { countryCode: 'HH' },
|
|
121
|
+
},
|
|
122
|
+
} as any),
|
|
123
|
+
).toBe(false);
|
|
124
|
+
});
|
|
97
125
|
});
|
|
98
126
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
})
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { SwissTaxCategories } from
|
|
1
|
+
import { SwissTaxCategories } from './ch';
|
|
2
2
|
|
|
3
3
|
describe('SwissTaxCategories', () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
it('DEFAULT rate', () => {
|
|
5
|
+
expect(SwissTaxCategories.DEFAULT.rate(new Date(2023, 1, 1))).toBe(0.077);
|
|
6
|
+
expect(SwissTaxCategories.DEFAULT.rate(new Date(2024, 1, 1))).toBe(0.081);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('REDUCED rate', () => {
|
|
10
|
+
expect(SwissTaxCategories.REDUCED.rate(new Date(2023, 1, 1))).toBe(0.025);
|
|
11
|
+
expect(SwissTaxCategories.REDUCED.rate(new Date(2024, 1, 1))).toBe(0.026);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('SPECIAL rate', () => {
|
|
15
|
+
expect(SwissTaxCategories.SPECIAL.rate(new Date(2023, 1, 1))).toBe(0.037);
|
|
16
|
+
expect(SwissTaxCategories.SPECIAL.rate(new Date(2024, 1, 1))).toBe(0.038);
|
|
17
|
+
});
|
|
18
|
+
});
|