@unchainedshop/plugins 3.0.0-alpha2 → 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/delivery/pick-mup.js +1 -1
- package/lib/delivery/pick-mup.js.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts +1 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts.map +1 -1
- package/lib/filters/local-search.d.ts +1 -1
- package/lib/filters/local-search.d.ts.map +1 -1
- package/lib/filters/local-search.js.map +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts.map +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
- package/lib/payment/cryptopay/plugin.d.ts +1 -1
- package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/index.js +2 -2
- package/lib/payment/datatrans-v2/index.js.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +2 -2
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
- package/lib/payment/paypal-checkout.js +7 -1
- package/lib/payment/paypal-checkout.js.map +1 -1
- package/lib/payment/postfinance-checkout/api.js +3 -3
- package/lib/payment/postfinance-checkout/api.js.map +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
- package/lib/payment/saferpay/adapter.d.ts +1 -1
- package/lib/payment/saferpay/adapter.d.ts.map +1 -1
- package/lib/payment/saferpay/api/api/SaferpayClient.d.ts +1 -1
- package/lib/payment/saferpay/api/api/SaferpayClient.d.ts.map +1 -1
- package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts +1 -1
- package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts.map +1 -1
- package/lib/payment/stripe/middleware.d.ts.map +1 -1
- package/lib/payment/stripe/middleware.js +0 -3
- package/lib/payment/stripe/middleware.js.map +1 -1
- package/lib/payment/stripe/stripe.d.ts +3 -3
- package/lib/payment/stripe/stripe.d.ts.map +1 -1
- package/lib/payment/stripe/stripe.js +4 -4
- package/lib/payment/stripe/stripe.js.map +1 -1
- package/lib/plugins-index.d.ts +3 -31
- package/lib/plugins-index.d.ts.map +1 -1
- package/lib/plugins-index.js +10 -61
- package/lib/plugins-index.js.map +1 -1
- package/lib/presets/base-express.d.ts +3 -0
- package/lib/presets/base-express.d.ts.map +1 -0
- package/lib/presets/base-express.js +6 -0
- package/lib/presets/base-express.js.map +1 -0
- package/lib/presets/base-modules.d.ts +29 -0
- package/lib/presets/base-modules.d.ts.map +1 -0
- package/lib/presets/base-modules.js +40 -0
- package/lib/presets/base-modules.js.map +1 -0
- package/lib/presets/countries/ch.d.ts +4 -0
- package/lib/presets/countries/ch.d.ts.map +1 -0
- package/lib/presets/countries/ch.js +4 -0
- package/lib/presets/countries/ch.js.map +1 -0
- package/lib/presets/crypto-express.d.ts +4 -0
- package/lib/presets/crypto-express.d.ts.map +1 -0
- package/lib/presets/crypto-express.js +9 -0
- package/lib/presets/crypto-express.js.map +1 -0
- package/lib/presets/crypto-modules.d.ts +11 -0
- package/lib/presets/crypto-modules.d.ts.map +1 -0
- package/lib/presets/crypto-modules.js +14 -0
- package/lib/presets/crypto-modules.js.map +1 -0
- package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/delivery-swiss-tax.js +1 -1
- package/lib/pricing/delivery-swiss-tax.js.map +1 -1
- package/lib/pricing/discount-100-off.d.ts +1 -1
- package/lib/pricing/discount-100-off.d.ts.map +1 -1
- package/lib/pricing/discount-half-price-manual.d.ts +1 -1
- package/lib/pricing/discount-half-price-manual.d.ts.map +1 -1
- package/lib/pricing/discount-half-price.d.ts +1 -1
- package/lib/pricing/discount-half-price.d.ts.map +1 -1
- package/lib/pricing/free-delivery.d.ts +1 -1
- package/lib/pricing/free-delivery.d.ts.map +1 -1
- package/lib/pricing/free-delivery.js +1 -1
- package/lib/pricing/free-delivery.js.map +1 -1
- package/lib/pricing/free-payment.d.ts +1 -1
- package/lib/pricing/free-payment.d.ts.map +1 -1
- package/lib/pricing/free-payment.js +1 -1
- package/lib/pricing/free-payment.js.map +1 -1
- package/lib/pricing/order-delivery.d.ts +1 -1
- package/lib/pricing/order-delivery.d.ts.map +1 -1
- package/lib/pricing/order-discount.d.ts +1 -1
- package/lib/pricing/order-discount.d.ts.map +1 -1
- package/lib/pricing/order-discount.js +1 -1
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-items-discount.js +1 -1
- package/lib/pricing/order-items-discount.js.map +1 -1
- package/lib/pricing/order-round.d.ts +1 -1
- package/lib/pricing/order-round.d.ts.map +1 -1
- package/lib/pricing/order-round.js +1 -1
- package/lib/pricing/order-round.js.map +1 -1
- package/lib/pricing/product-catalog-price.d.ts +1 -1
- package/lib/pricing/product-catalog-price.d.ts.map +1 -1
- package/lib/pricing/product-discount.js +1 -1
- package/lib/pricing/product-discount.js.map +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts.map +1 -1
- package/lib/pricing/product-round.d.ts +1 -1
- package/lib/pricing/product-round.d.ts.map +1 -1
- package/lib/pricing/product-swiss-tax.d.ts +4 -12
- package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/product-swiss-tax.js +3 -3
- package/lib/pricing/product-swiss-tax.js.map +1 -1
- package/lib/warehousing/eth-minter.js +4 -3
- package/lib/warehousing/eth-minter.js.map +1 -1
- package/lib/worker/bulk-import.d.ts +1 -1
- package/lib/worker/bulk-import.d.ts.map +1 -1
- package/lib/worker/bulk-import.js.map +1 -1
- package/lib/worker/error-notifications.d.ts +1 -1
- package/lib/worker/error-notifications.d.ts.map +1 -1
- package/lib/worker/error-notifications.js +1 -1
- package/lib/worker/error-notifications.js.map +1 -1
- package/lib/worker/export-token.d.ts +2 -2
- package/lib/worker/export-token.d.ts.map +1 -1
- package/lib/worker/export-token.js +1 -1
- package/lib/worker/export-token.js.map +1 -1
- package/lib/worker/external.d.ts +1 -1
- package/lib/worker/external.d.ts.map +1 -1
- package/lib/worker/http-request.d.ts +1 -1
- package/lib/worker/http-request.d.ts.map +1 -1
- package/lib/worker/message.d.ts +1 -1
- package/lib/worker/message.d.ts.map +1 -1
- package/lib/worker/message.js.map +1 -1
- package/lib/worker/update-coinbase-rates.js +1 -1
- package/lib/worker/update-coinbase-rates.js.map +1 -1
- package/lib/worker/update-ecb-rates.js +1 -1
- package/lib/worker/update-ecb-rates.js.map +1 -1
- package/lib/worker/update-token-ownership.d.ts +1 -1
- package/lib/worker/update-token-ownership.d.ts.map +1 -1
- package/lib/worker/zombie-killer.d.ts +1 -1
- package/lib/worker/zombie-killer.d.ts.map +1 -1
- package/package.json +28 -26
- package/src/delivery/pick-mup.ts +1 -1
- package/src/delivery/post.ts +1 -1
- package/src/delivery/send-message.ts +1 -1
- package/src/delivery/stores.ts +1 -1
- package/src/enrollments/licensed.ts +1 -1
- package/src/files/gridfs/gridfs-adapter.ts +1 -1
- package/src/files/gridfs/gridfs-webhook.ts +1 -1
- package/src/files/minio/minio-adapter.ts +1 -1
- package/src/filters/local-search.ts +4 -4
- package/src/filters/strict-equal.ts +1 -1
- package/src/payment/apple-iap/adapter.ts +3 -3
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
- package/src/payment/braintree.ts +1 -1
- package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
- package/src/payment/cryptopay/middleware.ts +3 -3
- package/src/payment/cryptopay/plugin.ts +2 -2
- package/src/payment/datatrans-v2/index.ts +3 -3
- package/src/payment/datatrans-v2/middleware.ts +1 -1
- package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +2 -2
- package/src/payment/invoice-prepaid.ts +1 -1
- package/src/payment/invoice.ts +1 -1
- package/src/payment/paypal-checkout.ts +8 -2
- package/src/payment/payrexx/index.ts +1 -1
- package/src/payment/payrexx/middleware.ts +1 -1
- package/src/payment/postfinance-checkout/api.ts +3 -3
- package/src/payment/postfinance-checkout/index.ts +1 -1
- package/src/payment/postfinance-checkout/middleware.ts +1 -1
- package/src/payment/postfinance-checkout/utils.ts +1 -1
- package/src/payment/saferpay/adapter.ts +2 -2
- package/src/payment/saferpay/api/api/SaferpayClient.ts +1 -1
- package/src/payment/saferpay/db/SaferpayTransactionsCollection.ts +1 -1
- package/src/payment/saferpay/middleware.ts +1 -1
- package/src/payment/stripe/index.ts +1 -1
- package/src/payment/stripe/middleware.ts +1 -4
- package/src/payment/stripe/stripe.ts +7 -7
- package/src/plugins-index.ts +14 -70
- package/src/presets/base-express.ts +7 -0
- package/src/presets/base-modules.ts +56 -0
- package/src/presets/countries/ch.ts +3 -0
- package/src/presets/crypto-express.ts +12 -0
- package/src/presets/crypto-modules.ts +23 -0
- package/src/pricing/delivery-swiss-tax.ts +3 -6
- package/src/pricing/discount-100-off.test.ts +13 -7
- package/src/pricing/discount-100-off.ts +1 -1
- package/src/pricing/discount-half-price-manual.test.ts +13 -7
- package/src/pricing/discount-half-price-manual.ts +1 -1
- package/src/pricing/discount-half-price.test.ts +15 -7
- package/src/pricing/discount-half-price.ts +1 -1
- package/src/pricing/free-delivery.test.ts +3 -8
- package/src/pricing/free-delivery.ts +5 -2
- package/src/pricing/free-payment.ts +5 -2
- package/src/pricing/licenced-enrollment.test.ts +33 -34
- package/src/pricing/order-delivery.test.ts +3 -5
- package/src/pricing/order-delivery.ts +1 -1
- package/src/pricing/order-discount.test.ts +3 -3
- package/src/pricing/order-discount.ts +1 -1
- package/src/pricing/order-items-discount.ts +1 -1
- package/src/pricing/order-items.ts +1 -1
- package/src/pricing/order-payment.ts +1 -1
- package/src/pricing/order-round.ts +1 -1
- package/src/pricing/plugins-index.test.ts +1 -1
- package/src/pricing/product-catalog-price.ts +1 -1
- package/src/pricing/product-discount.ts +2 -5
- package/src/pricing/product-price-rateconversion.ts +1 -1
- package/src/pricing/product-round.ts +1 -1
- package/src/pricing/product-swiss-tax.test.ts +112 -86
- package/src/pricing/product-swiss-tax.ts +11 -8
- package/src/pricing/tax/ch.test.ts +16 -16
- package/src/quotations/manual.ts +1 -1
- package/src/warehousing/eth-minter.ts +8 -6
- package/src/warehousing/store.ts +1 -1
- package/src/worker/bulk-import.ts +2 -2
- package/src/worker/email.ts +1 -1
- package/src/worker/enrollment-order-generator.ts +5 -5
- package/src/worker/error-notifications.ts +1 -1
- package/src/worker/export-token.ts +8 -3
- package/src/worker/external.ts +1 -1
- package/src/worker/heartbeat.ts +1 -1
- package/src/worker/http-request.ts +1 -1
- package/src/worker/message.ts +1 -2
- package/src/worker/push-notification.ts +1 -1
- package/src/worker/sms.ts +1 -1
- package/src/worker/update-coinbase-rates.ts +3 -3
- package/src/worker/update-ecb-rates.ts +3 -3
- package/src/worker/update-token-ownership.ts +1 -1
- package/src/worker/zombie-killer.ts +1 -1
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import { IDiscountAdapter } from '@unchainedshop/
|
|
1
|
+
import { IDiscountAdapter } from '@unchainedshop/utils';
|
|
2
2
|
import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
|
|
3
3
|
import { ProductDiscountConfiguration } from '@unchainedshop/core-products';
|
|
4
4
|
|
|
@@ -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,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
DeliveryPricingAdapter,
|
|
3
|
+
DeliveryPricingDirector,
|
|
4
|
+
IDeliveryPricingAdapter,
|
|
5
|
+
} from '@unchainedshop/core-delivery';
|
|
3
6
|
|
|
4
7
|
export const DeliveryFreePrice: IDeliveryPricingAdapter = {
|
|
5
8
|
...DeliveryPricingAdapter,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
PaymentPricingAdapter,
|
|
3
|
+
PaymentPricingDirector,
|
|
4
|
+
IPaymentPricingAdapter,
|
|
5
|
+
} from '@unchainedshop/core-payment';
|
|
3
6
|
|
|
4
7
|
export const PaymentFreePrice: IPaymentPricingAdapter = {
|
|
5
8
|
...PaymentPricingAdapter,
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import { IOrderPricingAdapter } from '@unchainedshop/
|
|
1
|
+
import { IOrderPricingAdapter } from '@unchainedshop/core-orders';
|
|
2
2
|
import { OrderPricingDirector, OrderPricingAdapter } from '@unchainedshop/core-orders';
|
|
3
3
|
|
|
4
4
|
export const OrderDelivery: IOrderPricingAdapter = {
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import { IOrderPricingAdapter } from '@unchainedshop/
|
|
1
|
+
import { IOrderPricingAdapter } from '@unchainedshop/core-orders';
|
|
2
2
|
import { OrderPricingDirector, OrderPricingAdapter } from '@unchainedshop/core-orders';
|
|
3
3
|
|
|
4
4
|
const OrderItems: IOrderPricingAdapter = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IOrderPricingAdapter } from '@unchainedshop/
|
|
1
|
+
import { IOrderPricingAdapter } from '@unchainedshop/core-orders';
|
|
2
2
|
import { OrderPricingDirector, OrderPricingAdapter } from '@unchainedshop/core-orders';
|
|
3
3
|
|
|
4
4
|
const OrderPayment: IOrderPricingAdapter = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OrderPricingAdapter, OrderPricingDirector } from '@unchainedshop/core-orders';
|
|
2
|
-
import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/
|
|
2
|
+
import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/core-orders';
|
|
3
3
|
|
|
4
4
|
interface PriceRoundSettings {
|
|
5
5
|
defaultPrecision: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IProductPricingAdapter } from '@unchainedshop/
|
|
1
|
+
import { IProductPricingAdapter } from '@unchainedshop/core-products';
|
|
2
2
|
import { ProductPricingDirector, ProductPricingAdapter } from '@unchainedshop/core-products';
|
|
3
3
|
import { resolveBestCurrency } from '@unchainedshop/utils';
|
|
4
4
|
import memoizee from 'memoizee';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { Discount } from '@unchainedshop/
|
|
2
|
-
import {
|
|
3
|
-
IProductPricingAdapter,
|
|
4
|
-
ProductPricingRowCategory,
|
|
5
|
-
} from '@unchainedshop/types/products.pricing.js';
|
|
1
|
+
import type { Discount } from '@unchainedshop/utils';
|
|
2
|
+
import { IProductPricingAdapter, ProductPricingRowCategory } from '@unchainedshop/core-products';
|
|
6
3
|
import {
|
|
7
4
|
ProductPricingDirector,
|
|
8
5
|
ProductPricingAdapter,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IProductPricingAdapter } from '@unchainedshop/
|
|
1
|
+
import { IProductPricingAdapter } from '@unchainedshop/core-products';
|
|
2
2
|
import { ProductPricingDirector, ProductPricingAdapter } from '@unchainedshop/core-products';
|
|
3
3
|
|
|
4
4
|
export const ProductPriceRateConversion: IProductPricingAdapter = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IProductPricingAdapter } from '@unchainedshop/
|
|
1
|
+
import { IProductPricingAdapter } from '@unchainedshop/core-products';
|
|
2
2
|
import { ProductPricingAdapter, ProductPricingDirector } from '@unchainedshop/core-products';
|
|
3
3
|
|
|
4
4
|
interface PriceRoundSettings {
|
|
@@ -1,100 +1,126 @@
|
|
|
1
1
|
import { getTaxRate, isDeliveryAddressInSwitzerland } from './product-swiss-tax.js';
|
|
2
2
|
|
|
3
|
-
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
|
+
});
|
|
4
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
|
+
});
|
|
5
24
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
});
|
|
13
35
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
});
|
|
21
46
|
});
|
|
22
47
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
});
|
|
31
73
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
order: {} as any,
|
|
38
|
-
})).toBe(0.081);
|
|
39
|
-
});
|
|
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
|
+
});
|
|
40
79
|
|
|
41
|
-
|
|
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
|
+
});
|
|
42
85
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
order : {
|
|
59
|
-
deliveryId: 'CH',
|
|
60
|
-
billingAddress: {countryCode: 'LI'}
|
|
61
|
-
},
|
|
62
|
-
country: 'CH'
|
|
63
|
-
}
|
|
64
|
-
it('Should return true when passed country code CH', async () => {
|
|
65
|
-
expect(await isDeliveryAddressInSwitzerland({...context, country: 'ch', order: null})).toBe(true);
|
|
66
|
-
});
|
|
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
|
+
});
|
|
67
99
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
});
|
|
75
112
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}})).toBe(true);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('Should return false if billingAddress is neither CH or LI and order does not have address', async () => {
|
|
92
|
-
expect(await isDeliveryAddressInSwitzerland({...context, country: null, order : {
|
|
93
|
-
deliveryId: null,
|
|
94
|
-
billingAddress: {countryCode: 'HH'}
|
|
95
|
-
}})).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
|
+
});
|
|
96
125
|
});
|
|
97
126
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
})
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { ProductPricingDirector, ProductPricingAdapter } from '@unchainedshop/core-products';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
2
|
+
ProductPricingDirector,
|
|
3
|
+
ProductPricingAdapter,
|
|
4
|
+
ProductPricingAdapterContext,
|
|
5
|
+
} from '@unchainedshop/core-products';
|
|
6
|
+
import { IProductPricingAdapter, ProductPricingRowCategory } from '@unchainedshop/core-products';
|
|
8
7
|
import { SwissTaxCategories } from './tax/ch.js';
|
|
9
8
|
|
|
10
|
-
export const getTaxRate = (context:
|
|
9
|
+
export const getTaxRate = (context: ProductPricingAdapterContext) => {
|
|
11
10
|
const { product, order } = context;
|
|
12
11
|
|
|
13
12
|
const productSpecialTaxTag = product.tags?.find((tag) =>
|
|
@@ -21,7 +20,11 @@ export const getTaxRate = (context: { product: Product; order?: Order }) => {
|
|
|
21
20
|
return taxCategory.rate(order?.ordered);
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
export const isDeliveryAddressInSwitzerland = async ({
|
|
23
|
+
export const isDeliveryAddressInSwitzerland = async ({
|
|
24
|
+
order,
|
|
25
|
+
country,
|
|
26
|
+
modules,
|
|
27
|
+
}: ProductPricingAdapterContext) => {
|
|
25
28
|
let countryCode = country?.toUpperCase().trim();
|
|
26
29
|
|
|
27
30
|
if (order) {
|
|
@@ -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
|
+
});
|
package/src/quotations/manual.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IQuotationAdapter } from '@unchainedshop/
|
|
1
|
+
import { IQuotationAdapter } from '@unchainedshop/core-quotations';
|
|
2
2
|
import { QuotationDirector, QuotationAdapter } from '@unchainedshop/core-quotations';
|
|
3
3
|
|
|
4
4
|
const ManualOffering: IQuotationAdapter = {
|
|
@@ -3,15 +3,16 @@ import {
|
|
|
3
3
|
WarehousingAdapter,
|
|
4
4
|
WarehousingProviderType,
|
|
5
5
|
} from '@unchainedshop/core-warehousing';
|
|
6
|
-
import { ProductContractStandard
|
|
6
|
+
import { ProductContractStandard } from '@unchainedshop/core-products';
|
|
7
7
|
import {
|
|
8
8
|
IWarehousingAdapter,
|
|
9
9
|
WarehousingContext,
|
|
10
10
|
WarehousingError,
|
|
11
|
-
} from '@unchainedshop/
|
|
11
|
+
} from '@unchainedshop/core-warehousing';
|
|
12
12
|
import { systemLocale } from '@unchainedshop/utils';
|
|
13
13
|
import { generateDbObjectId } from '@unchainedshop/mongodb';
|
|
14
|
-
import {
|
|
14
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
15
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
15
16
|
|
|
16
17
|
const { MINTER_TOKEN_OFFSET = '0' } = process.env;
|
|
17
18
|
|
|
@@ -30,7 +31,8 @@ const ETHMinter: IWarehousingAdapter = {
|
|
|
30
31
|
},
|
|
31
32
|
|
|
32
33
|
actions: (configuration, context) => {
|
|
33
|
-
const { product, orderPosition, token, modules, locale } = context as WarehousingContext &
|
|
34
|
+
const { product, orderPosition, token, modules, locale } = context as WarehousingContext &
|
|
35
|
+
UnchainedCore;
|
|
34
36
|
const { contractAddress, contractStandard, tokenId, supply, ercMetadataProperties } =
|
|
35
37
|
product?.tokenization || {};
|
|
36
38
|
|
|
@@ -53,7 +55,7 @@ const ETHMinter: IWarehousingAdapter = {
|
|
|
53
55
|
...WarehousingAdapter.actions(configuration, context),
|
|
54
56
|
|
|
55
57
|
isActive() {
|
|
56
|
-
return product?.type ===
|
|
58
|
+
return product?.type === ProductTypes.TokenizedProduct;
|
|
57
59
|
},
|
|
58
60
|
|
|
59
61
|
configurationError() {
|
|
@@ -116,7 +118,7 @@ const ETHMinter: IWarehousingAdapter = {
|
|
|
116
118
|
const url = file && (await modules.files.getUrl(file, {}));
|
|
117
119
|
const text = await modules.products.texts.findLocalizedText({
|
|
118
120
|
productId: product._id,
|
|
119
|
-
locale: locale?.
|
|
121
|
+
locale: locale?.baseName || systemLocale.baseName,
|
|
120
122
|
});
|
|
121
123
|
|
|
122
124
|
const name = `${text.title} #${chainTokenId}`;
|
package/src/warehousing/store.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
WarehousingAdapter,
|
|
4
4
|
WarehousingProviderType,
|
|
5
5
|
} from '@unchainedshop/core-warehousing';
|
|
6
|
-
import { IWarehousingAdapter } from '@unchainedshop/
|
|
6
|
+
import { IWarehousingAdapter } from '@unchainedshop/core-warehousing';
|
|
7
7
|
|
|
8
8
|
const Store: IWarehousingAdapter = {
|
|
9
9
|
...WarehousingAdapter,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
|
|
2
1
|
import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
|
|
3
2
|
import { createLogger, LogLevel } from '@unchainedshop/logger';
|
|
4
3
|
import JSONStream from 'JSONStream';
|
|
5
4
|
import { EventIterator } from 'event-iterator';
|
|
6
|
-
import { UnchainedCore } from '@unchainedshop/
|
|
5
|
+
import { UnchainedCore } from '@unchainedshop/core';
|
|
6
|
+
import { IWorkerAdapter } from '@unchainedshop/core-worker';
|
|
7
7
|
|
|
8
8
|
const logger = createLogger('unchained:platform:bulk-import');
|
|
9
9
|
|
package/src/worker/email.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { join, isAbsolute } from 'path';
|
|
|
3
3
|
import { tmpdir } from 'os';
|
|
4
4
|
import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
|
|
5
5
|
import { createLogger } from '@unchainedshop/logger';
|
|
6
|
-
import { IWorkerAdapter } from '@unchainedshop/
|
|
6
|
+
import { IWorkerAdapter } from '@unchainedshop/core-worker';
|
|
7
7
|
import open from 'open';
|
|
8
8
|
import nodemailer from 'nodemailer';
|
|
9
9
|
|