@unchainedshop/plugins 2.0.0-rc.3 → 2.0.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.
- package/jest.config.js +12 -0
- package/lib/delivery/pick-mup.js +1 -1
- package/lib/delivery/pick-mup.js.map +1 -1
- package/lib/enrollments/licensed.d.ts +4 -1
- package/lib/enrollments/licensed.js +1 -1
- package/lib/enrollments/licensed.js.map +1 -1
- package/lib/files/gridfs/gridfs-adapter.d.ts +1 -1
- package/lib/files/gridfs/gridfs-adapter.js +1 -1
- package/lib/files/gridfs/gridfs-adapter.js.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.js +1 -1
- package/lib/files/gridfs/gridfs-webhook.js.map +1 -1
- package/lib/files/gridfs/index.js +12 -3
- package/lib/files/gridfs/index.js.map +1 -1
- package/lib/files/minio/minio-adapter.d.ts +1 -1
- package/lib/files/minio/minio-adapter.js +1 -1
- package/lib/files/minio/minio-adapter.js.map +1 -1
- package/lib/filters/local-search.d.ts +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
- package/lib/payment/apple-iap/index.d.ts +2 -2
- package/lib/payment/apple-iap/index.js +2 -2
- package/lib/payment/apple-iap/index.js.map +1 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +2 -2
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +1 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
- package/lib/payment/cryptopay/index.d.ts +3 -3
- package/lib/payment/cryptopay/index.js +3 -3
- package/lib/payment/cryptopay/index.js.map +1 -1
- package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts +2 -2
- package/lib/payment/cryptopay/module/configureCryptopayModule.js +1 -1
- package/lib/payment/cryptopay/module/configureCryptopayModule.js.map +1 -1
- package/lib/payment/cryptopay/plugin.d.ts +1 -1
- package/lib/payment/cryptopay/plugin.js +1 -1
- package/lib/payment/cryptopay/plugin.js.map +1 -1
- package/lib/payment/datatrans-v2/api/authorize.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/cancel.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/index.d.ts +8 -8
- package/lib/payment/datatrans-v2/api/index.js +9 -9
- package/lib/payment/datatrans-v2/api/index.js.map +1 -1
- package/lib/payment/datatrans-v2/api/init.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/init.js +1 -1
- package/lib/payment/datatrans-v2/api/init.js.map +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.js +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.js.map +1 -1
- package/lib/payment/datatrans-v2/api/settle.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/status.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/validate.d.ts +1 -1
- package/lib/payment/datatrans-v2/index.d.ts +1 -1
- package/lib/payment/datatrans-v2/index.js +4 -4
- package/lib/payment/datatrans-v2/index.js.map +1 -1
- package/lib/payment/datatrans-v2/middleware.js +1 -1
- package/lib/payment/datatrans-v2/middleware.js.map +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +4 -4
- package/lib/payment/datatrans-v2/parseRegistrationData.js +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +2 -2
- package/lib/payment/postfinance-checkout/index.d.ts +1 -1
- package/lib/payment/postfinance-checkout/index.js +4 -4
- package/lib/payment/postfinance-checkout/index.js.map +1 -1
- package/lib/payment/postfinance-checkout/middleware.js +1 -1
- package/lib/payment/postfinance-checkout/middleware.js.map +1 -1
- package/lib/payment/postfinance-checkout/types.js +2 -2
- package/lib/payment/postfinance-checkout/types.js.map +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts +1 -1
- package/lib/payment/worldline-saferpay/index.js +1 -1
- package/lib/payment/worldline-saferpay/index.js.map +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.d.ts +4 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js.map +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.d.ts +4 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js.map +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.d.ts +4 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.d.ts +4 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.d.ts +2 -2
- package/lib/plugins-index.d.ts +43 -42
- package/lib/plugins-index.js +51 -50
- package/lib/plugins-index.js.map +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
- package/lib/pricing/discount-100-off.d.ts +2 -1
- package/lib/pricing/discount-100-off.js +1 -1
- package/lib/pricing/discount-100-off.js.map +1 -1
- package/lib/pricing/discount-half-price-manual.d.ts +2 -1
- package/lib/pricing/discount-half-price-manual.js +1 -1
- package/lib/pricing/discount-half-price-manual.js.map +1 -1
- package/lib/pricing/discount-half-price.d.ts +2 -1
- package/lib/pricing/discount-half-price.js +1 -1
- package/lib/pricing/discount-half-price.js.map +1 -1
- package/lib/pricing/free-delivery.d.ts +1 -1
- package/lib/pricing/free-payment.d.ts +1 -1
- package/lib/pricing/order-delivery.d.ts +2 -1
- package/lib/pricing/order-delivery.js +1 -1
- package/lib/pricing/order-delivery.js.map +1 -1
- package/lib/pricing/order-discount.d.ts +10 -1
- package/lib/pricing/order-discount.js +6 -5
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-items-discount.js +5 -1
- package/lib/pricing/order-items-discount.js.map +1 -1
- package/lib/pricing/product-catalog-price.d.ts +2 -1
- package/lib/pricing/product-catalog-price.js +1 -1
- package/lib/pricing/product-catalog-price.js.map +1 -1
- package/lib/pricing/product-discount.d.ts +2 -1
- package/lib/pricing/product-discount.js +3 -3
- package/lib/pricing/product-discount.js.map +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts +2 -1
- package/lib/pricing/product-price-rateconversion.js +1 -1
- package/lib/pricing/product-price-rateconversion.js.map +1 -1
- package/lib/pricing/product-price-round.d.ts +3 -1
- package/lib/pricing/product-price-round.js +3 -3
- package/lib/pricing/product-price-round.js.map +1 -1
- package/lib/pricing/product-swiss-tax.d.ts +8 -0
- 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 +1 -1
- package/lib/warehousing/eth-minter.js.map +1 -1
- package/lib/warehousing/google-sheets.d.ts +1 -1
- package/lib/warehousing/google-sheets.js +1 -1
- package/lib/warehousing/google-sheets.js.map +1 -1
- package/lib/worker/bulk-import.d.ts +1 -1
- package/lib/worker/email.d.ts +1 -1
- package/lib/worker/email.js +1 -1
- package/lib/worker/email.js.map +1 -1
- package/lib/worker/export-token.d.ts +2 -2
- package/lib/worker/external.d.ts +1 -1
- package/lib/worker/http-request.d.ts +1 -1
- package/lib/worker/message.d.ts +1 -1
- package/lib/worker/push-notification.d.ts +1 -0
- package/lib/worker/push-notification.js +73 -0
- package/lib/worker/push-notification.js.map +1 -0
- package/lib/worker/update-token-ownership.d.ts +2 -2
- package/lib/worker/zombie-killer.d.ts +1 -1
- package/package.json +22 -22
- 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 +2 -2
- package/src/events/node-event-emitter.ts +1 -1
- package/src/events/redis.ts +1 -1
- package/src/files/gridfs/gridfs-adapter.ts +2 -2
- package/src/files/gridfs/gridfs-webhook.ts +1 -1
- package/src/files/gridfs/index.ts +14 -3
- package/src/files/minio/minio-adapter.ts +2 -2
- package/src/filters/local-search.ts +2 -2
- package/src/filters/strict-equal.ts +1 -1
- package/src/payment/apple-iap/adapter.ts +4 -4
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
- package/src/payment/apple-iap/index.ts +2 -2
- package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +2 -2
- package/src/payment/braintree.ts +1 -1
- package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
- package/src/payment/cryptopay/index.ts +3 -3
- package/src/payment/cryptopay/middleware.ts +4 -4
- package/src/payment/cryptopay/module/configureCryptopayModule.ts +2 -2
- package/src/payment/cryptopay/plugin.ts +4 -4
- package/src/payment/datatrans-v2/api/authorize.ts +1 -1
- package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +1 -1
- package/src/payment/datatrans-v2/api/cancel.ts +1 -1
- package/src/payment/datatrans-v2/api/index.ts +9 -9
- package/src/payment/datatrans-v2/api/init.ts +2 -2
- package/src/payment/datatrans-v2/api/secureFields.ts +2 -2
- package/src/payment/datatrans-v2/api/settle.ts +1 -1
- package/src/payment/datatrans-v2/api/status.ts +1 -1
- package/src/payment/datatrans-v2/api/validate.ts +1 -1
- package/src/payment/datatrans-v2/index.ts +6 -6
- package/src/payment/datatrans-v2/middleware.ts +3 -3
- package/src/payment/datatrans-v2/parseRegistrationData.ts +2 -2
- 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 +1 -1
- package/src/payment/postfinance-checkout/index.ts +5 -5
- package/src/payment/postfinance-checkout/middleware.ts +3 -3
- package/src/payment/postfinance-checkout/utils.ts +1 -1
- package/src/payment/stripe.ts +2 -2
- package/src/payment/worldline-saferpay/index.ts +2 -2
- package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.ts +5 -5
- package/src/payment/worldline-saferpay/worldline-saferpay-client/index.ts +4 -4
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.ts +4 -4
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts +4 -4
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.ts +2 -2
- package/src/plugins-index.ts +52 -51
- package/src/pricing/apply-rate.test.ts +92 -0
- package/src/pricing/configureProductPriceRounding.test.ts +44 -0
- package/src/pricing/delivery-swiss-tax.ts +1 -1
- package/src/pricing/discount-100-off.test.ts +31 -0
- package/src/pricing/discount-100-off.ts +2 -2
- package/src/pricing/discount-half-price-manual.test.ts +42 -0
- package/src/pricing/discount-half-price-manual.ts +2 -2
- package/src/pricing/discount-half-price.test.ts +40 -0
- package/src/pricing/discount-half-price.ts +2 -2
- package/src/pricing/free-delivery.test.ts +12 -0
- package/src/pricing/free-delivery.ts +1 -1
- package/src/pricing/free-payment.ts +1 -1
- package/src/pricing/getTaxRate.test.ts +69 -0
- package/src/pricing/licenced-enrollment.test.ts +37 -0
- package/src/pricing/order-delivery.test.ts +9 -0
- package/src/pricing/order-delivery.ts +2 -2
- package/src/pricing/order-discount.test.ts +206 -0
- package/src/pricing/order-discount.ts +7 -5
- package/src/pricing/order-items-discount.ts +5 -2
- package/src/pricing/order-items.ts +1 -1
- package/src/pricing/order-payment.ts +1 -1
- package/{tests/plugins-index.test.js → src/pricing/plugins-index.test.ts} +0 -0
- package/src/pricing/product-catalog-price.ts +2 -2
- package/src/pricing/product-discount.ts +4 -4
- package/src/pricing/product-price-rateconversion.ts +2 -2
- package/src/pricing/product-price-round.ts +5 -5
- package/src/pricing/product-swiss-tax.test.ts +141 -0
- package/src/pricing/product-swiss-tax.ts +4 -4
- package/src/pricing/roundToNext.test.ts +24 -0
- package/src/quotations/manual.ts +1 -1
- package/src/warehousing/eth-minter.ts +2 -2
- package/src/warehousing/google-sheets.ts +2 -2
- package/src/warehousing/store.ts +1 -1
- package/src/worker/bulk-import.ts +2 -2
- package/src/worker/email.ts +2 -2
- package/src/worker/enrollment-order-generator.ts +5 -5
- package/src/worker/export-token.ts +2 -2
- 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 -1
- package/src/worker/push-notification.ts +106 -0
- package/src/worker/sms.ts +1 -1
- package/src/worker/update-coinbase-rates.ts +2 -2
- package/src/worker/update-ecb-rates.ts +2 -2
- package/src/worker/update-token-ownership.ts +2 -2
- package/src/worker/zombie-killer.ts +1 -1
- package/tsconfig.json +3 -25
- package/lib/pricing/utils/cache.d.ts +0 -8
- package/lib/pricing/utils/cache.js +0 -28
- package/lib/pricing/utils/cache.js.map +0 -1
- package/src/pricing/utils/cache.js +0 -32
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
IPaymentActions,
|
|
3
3
|
IPaymentAdapter,
|
|
4
4
|
PaymentChargeActionResult,
|
|
5
|
-
} from '@unchainedshop/types/payments';
|
|
5
|
+
} from '@unchainedshop/types/payments.js';
|
|
6
6
|
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
|
|
7
7
|
import { createLogger } from '@unchainedshop/logger';
|
|
8
8
|
|
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
getTransaction,
|
|
18
18
|
refundTransaction,
|
|
19
19
|
voidTransaction,
|
|
20
|
-
} from './api';
|
|
21
|
-
import { orderIsPaid } from './utils';
|
|
22
|
-
import { CompletionModes, IntegrationModes, SignResponse } from './types';
|
|
20
|
+
} from './api.js';
|
|
21
|
+
import { orderIsPaid } from './utils.js';
|
|
22
|
+
import { CompletionModes, IntegrationModes, SignResponse } from './types.js';
|
|
23
23
|
|
|
24
|
-
export * from './middleware';
|
|
24
|
+
export * from './middleware.js';
|
|
25
25
|
|
|
26
26
|
const { PostFinanceCheckout } = pf;
|
|
27
27
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Context } from '@unchainedshop/types/api';
|
|
1
|
+
import { Context } from '@unchainedshop/types/api.js';
|
|
2
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
|
-
import { WebhookData } from './types';
|
|
4
|
-
import { getTransaction, getTransactionCompletion } from './api';
|
|
3
|
+
import { WebhookData } from './types.js';
|
|
4
|
+
import { getTransaction, getTransactionCompletion } from './api.js';
|
|
5
5
|
|
|
6
6
|
const logger = createLogger('unchained:core-payment:postfinance-checkout');
|
|
7
7
|
|
package/src/payment/stripe.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Context } from '@unchainedshop/types/api';
|
|
2
|
-
import { IPaymentAdapter } from '@unchainedshop/types/payments';
|
|
1
|
+
import { Context } from '@unchainedshop/types/api.js';
|
|
2
|
+
import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
|
|
3
3
|
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
|
|
4
4
|
import { createLogger } from '@unchainedshop/logger';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IPaymentAdapter, PaymentChargeActionResult } from '@unchainedshop/types/payments';
|
|
1
|
+
import { IPaymentAdapter, PaymentChargeActionResult } from '@unchainedshop/types/payments.js';
|
|
2
2
|
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
|
|
3
|
-
import { PaymentPageInitializeInput, SaferpayClient } from './worldline-saferpay-client';
|
|
3
|
+
import { PaymentPageInitializeInput, SaferpayClient } from './worldline-saferpay-client/index.js';
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
WORLDLINE_BASE_URL = 'https://test.saferpay.com/api',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { TransactionCancelInput, TransactionCancelResponse } from '../models/TransactionCancel';
|
|
2
|
-
import { PaymentPageAssertInput, PaymentPageAssertResponse } from '../models/PaymentPageAssert';
|
|
1
|
+
import { TransactionCancelInput, TransactionCancelResponse } from '../models/TransactionCancel.js';
|
|
2
|
+
import { PaymentPageAssertInput, PaymentPageAssertResponse } from '../models/PaymentPageAssert.js';
|
|
3
3
|
import {
|
|
4
4
|
PaymentPageInitializeInput,
|
|
5
5
|
PaymentPageInitializeResponse,
|
|
6
|
-
} from '../models/PaymentPageInitialize';
|
|
7
|
-
import { RequestHeader } from '../models/Request';
|
|
8
|
-
import { SaferpayConnection } from './SaferpayConnection';
|
|
6
|
+
} from '../models/PaymentPageInitialize.js';
|
|
7
|
+
import { RequestHeader } from '../models/Request.js';
|
|
8
|
+
import { SaferpayConnection } from './SaferpayConnection.js';
|
|
9
9
|
|
|
10
10
|
export class SaferpayClient {
|
|
11
11
|
private conn: SaferpayConnection;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { SaferpayClient } from './api/SaferpayClient';
|
|
1
|
+
export { SaferpayClient } from './api/SaferpayClient.js';
|
|
2
2
|
|
|
3
3
|
export type {
|
|
4
4
|
PaymentPageInitializeInput,
|
|
5
5
|
PaymentPageInitializeResponse,
|
|
6
|
-
} from './models/PaymentPageInitialize';
|
|
7
|
-
export type { PaymentPageAssertInput, PaymentPageAssertResponse } from './models/PaymentPageAssert';
|
|
8
|
-
export type { TransactionCancelInput, TransactionCancelResponse } from './models/TransactionCancel';
|
|
6
|
+
} from './models/PaymentPageInitialize.js';
|
|
7
|
+
export type { PaymentPageAssertInput, PaymentPageAssertResponse } from './models/PaymentPageAssert.js';
|
|
8
|
+
export type { TransactionCancelInput, TransactionCancelResponse } from './models/TransactionCancel.js';
|
package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Response } from './Response';
|
|
2
|
-
import { Request } from './Request';
|
|
3
|
-
import { TransactionAmount, TransactionStatus } from './Transaction';
|
|
4
|
-
import { PaymentMethods } from './PaymentMethods';
|
|
1
|
+
import { Response } from './Response.js';
|
|
2
|
+
import { Request } from './Request.js';
|
|
3
|
+
import { TransactionAmount, TransactionStatus } from './Transaction.js';
|
|
4
|
+
import { PaymentMethods } from './PaymentMethods.js';
|
|
5
5
|
|
|
6
6
|
export interface PaymentPageAssertInput extends Request {
|
|
7
7
|
Token: string;
|
package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PaymentMethods } from './PaymentMethods';
|
|
2
|
-
import { Request } from './Request';
|
|
3
|
-
import { Response } from './Response';
|
|
4
|
-
import { TransactionAmount } from './Transaction';
|
|
1
|
+
import { PaymentMethods } from './PaymentMethods.js';
|
|
2
|
+
import { Request } from './Request.js';
|
|
3
|
+
import { Response } from './Response.js';
|
|
4
|
+
import { TransactionAmount } from './Transaction.js';
|
|
5
5
|
|
|
6
6
|
export interface PaymentPageInitializeInput extends Request {
|
|
7
7
|
ConfigSet?: string;
|
package/src/plugins-index.ts
CHANGED
|
@@ -1,75 +1,76 @@
|
|
|
1
|
-
import { useMiddlewareWithCurrentContext } from '@unchainedshop/api/express';
|
|
2
|
-
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
1
|
+
import { useMiddlewareWithCurrentContext } from '@unchainedshop/api/express/index.js';
|
|
2
|
+
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
3
3
|
import express from 'express';
|
|
4
4
|
|
|
5
5
|
// Delivery
|
|
6
|
-
import './delivery/post';
|
|
7
|
-
import './delivery/pick-mup';
|
|
8
|
-
import './delivery/send-message';
|
|
9
|
-
import './delivery/stores';
|
|
6
|
+
import './delivery/post.js';
|
|
7
|
+
import './delivery/pick-mup.js';
|
|
8
|
+
import './delivery/send-message.js';
|
|
9
|
+
import './delivery/stores.js';
|
|
10
10
|
|
|
11
11
|
// Payment
|
|
12
|
-
import './payment/invoice';
|
|
13
|
-
import './payment/invoice-prepaid';
|
|
14
|
-
import './payment/paypal-checkout';
|
|
15
|
-
import './payment/worldline-saferpay';
|
|
16
|
-
import { datatransHandler } from './payment/datatrans-v2';
|
|
17
|
-
import { configureCryptopayModule, cryptopayHandler } from './payment/cryptopay';
|
|
18
|
-
import { appleIAPHandler, configureAppleTransactionsModule } from './payment/apple-iap';
|
|
19
|
-
import { stripeHandler } from './payment/stripe';
|
|
20
|
-
import { postfinanceCheckoutHandler } from './payment/postfinance-checkout';
|
|
12
|
+
import './payment/invoice.js';
|
|
13
|
+
import './payment/invoice-prepaid.js';
|
|
14
|
+
import './payment/paypal-checkout.js';
|
|
15
|
+
import './payment/worldline-saferpay/index.js';
|
|
16
|
+
import { datatransHandler } from './payment/datatrans-v2/index.js';
|
|
17
|
+
import { configureCryptopayModule, cryptopayHandler } from './payment/cryptopay/index.js';
|
|
18
|
+
import { appleIAPHandler, configureAppleTransactionsModule } from './payment/apple-iap/index.js';
|
|
19
|
+
import { stripeHandler } from './payment/stripe.js';
|
|
20
|
+
import { postfinanceCheckoutHandler } from './payment/postfinance-checkout/index.js';
|
|
21
21
|
|
|
22
22
|
// Warehousing
|
|
23
|
-
import './warehousing/store';
|
|
24
|
-
import './warehousing/eth-minter';
|
|
23
|
+
import './warehousing/store.js';
|
|
24
|
+
import './warehousing/eth-minter.js';
|
|
25
25
|
|
|
26
26
|
// Pricing
|
|
27
|
-
import './pricing/discount-half-price-manual';
|
|
28
|
-
import './pricing/discount-100-off';
|
|
29
|
-
import './pricing/free-payment';
|
|
30
|
-
import './pricing/free-delivery';
|
|
31
|
-
import './pricing/order-items';
|
|
32
|
-
import './pricing/order-discount';
|
|
33
|
-
import './pricing/order-delivery';
|
|
34
|
-
import './pricing/order-payment';
|
|
35
|
-
import './pricing/product-catalog-price';
|
|
36
|
-
import './pricing/product-price-rateconversion';
|
|
37
|
-
import './pricing/product-discount';
|
|
38
|
-
import './pricing/product-swiss-tax';
|
|
39
|
-
import './pricing/delivery-swiss-tax';
|
|
27
|
+
import './pricing/discount-half-price-manual.js';
|
|
28
|
+
import './pricing/discount-100-off.js';
|
|
29
|
+
import './pricing/free-payment.js';
|
|
30
|
+
import './pricing/free-delivery.js';
|
|
31
|
+
import './pricing/order-items.js';
|
|
32
|
+
import './pricing/order-discount.js';
|
|
33
|
+
import './pricing/order-delivery.js';
|
|
34
|
+
import './pricing/order-payment.js';
|
|
35
|
+
import './pricing/product-catalog-price.js';
|
|
36
|
+
import './pricing/product-price-rateconversion.js';
|
|
37
|
+
import './pricing/product-discount.js';
|
|
38
|
+
import './pricing/product-swiss-tax.js';
|
|
39
|
+
import './pricing/delivery-swiss-tax.js';
|
|
40
40
|
|
|
41
41
|
// Filter & Search
|
|
42
|
-
import './filters/strict-equal';
|
|
43
|
-
import './filters/local-search';
|
|
42
|
+
import './filters/strict-equal.js';
|
|
43
|
+
import './filters/local-search.js';
|
|
44
44
|
|
|
45
45
|
// Quotations
|
|
46
|
-
import './quotations/manual';
|
|
46
|
+
import './quotations/manual.js';
|
|
47
47
|
|
|
48
48
|
// Enrollments
|
|
49
|
-
import './enrollments/licensed';
|
|
49
|
+
import './enrollments/licensed.js';
|
|
50
50
|
|
|
51
51
|
// Event Queue
|
|
52
|
-
import './events/node-event-emitter';
|
|
52
|
+
import './events/node-event-emitter.js';
|
|
53
53
|
|
|
54
54
|
// Workers
|
|
55
|
-
import './worker/bulk-import';
|
|
56
|
-
import './worker/zombie-killer';
|
|
57
|
-
import './worker/message';
|
|
58
|
-
import './worker/external';
|
|
59
|
-
import './worker/http-request';
|
|
60
|
-
import './worker/heartbeat';
|
|
61
|
-
import './worker/email';
|
|
62
|
-
import './worker/sms';
|
|
63
|
-
import './worker/
|
|
64
|
-
import './worker/update-
|
|
65
|
-
import
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
55
|
+
import './worker/bulk-import.js';
|
|
56
|
+
import './worker/zombie-killer.js';
|
|
57
|
+
import './worker/message.js';
|
|
58
|
+
import './worker/external.js';
|
|
59
|
+
import './worker/http-request.js';
|
|
60
|
+
import './worker/heartbeat.js';
|
|
61
|
+
import './worker/email.js';
|
|
62
|
+
import './worker/sms.js';
|
|
63
|
+
import './worker/push-notification.js';
|
|
64
|
+
import './worker/update-ecb-rates.js';
|
|
65
|
+
import './worker/update-coinbase-rates.js';
|
|
66
|
+
import { configureExportToken } from './worker/export-token.js';
|
|
67
|
+
import { configureGenerateOrderAutoscheduling } from './worker/enrollment-order-generator.js';
|
|
68
|
+
import { configureUpdateTokenOwnership } from './worker/update-token-ownership.js';
|
|
68
69
|
|
|
69
70
|
// Asset Management
|
|
70
|
-
import './files/gridfs/gridfs-adapter';
|
|
71
|
-
import { gridfsHandler } from './files/gridfs/gridfs-webhook';
|
|
72
|
-
import { configureGridFSFileUploadModule } from './files/gridfs';
|
|
71
|
+
import './files/gridfs/gridfs-adapter.js';
|
|
72
|
+
import { gridfsHandler } from './files/gridfs/gridfs-webhook.js';
|
|
73
|
+
import { configureGridFSFileUploadModule } from './files/gridfs/index.js';
|
|
73
74
|
|
|
74
75
|
const {
|
|
75
76
|
CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay',
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {configureProductPriceRounding, ProductPriceRoundSettings } from './product-price-round.js'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
describe('configureProductPriceRounding', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
ProductPriceRoundSettings.configurations = {};
|
|
8
|
+
ProductPriceRoundSettings.defaultPrecision = 50;
|
|
9
|
+
ProductPriceRoundSettings.skip = [];
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('updates the default precision correctly', () => {
|
|
13
|
+
configureProductPriceRounding({ defaultPrecision: 100 } as any);
|
|
14
|
+
expect(ProductPriceRoundSettings.defaultPrecision).toBe(100);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('updates the configurations correctly', () => {
|
|
18
|
+
configureProductPriceRounding({ configurations: { 'product1': 25 } } as any);
|
|
19
|
+
expect(ProductPriceRoundSettings.configurations).toEqual({ 'product1': 25 });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('updates the skip list correctly', () => {
|
|
23
|
+
configureProductPriceRounding({ skip: ['product1'] } as any);
|
|
24
|
+
expect(ProductPriceRoundSettings.skip).toEqual(['product1']);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('updates multiple properties correctly', () => {
|
|
28
|
+
configureProductPriceRounding({
|
|
29
|
+
configurations: { 'product1': 25 },
|
|
30
|
+
defaultPrecision: 100,
|
|
31
|
+
skip: ['product1']
|
|
32
|
+
});
|
|
33
|
+
expect(ProductPriceRoundSettings.configurations).toEqual({ 'product1': 25 });
|
|
34
|
+
expect(ProductPriceRoundSettings.defaultPrecision).toBe(100);
|
|
35
|
+
expect(ProductPriceRoundSettings.skip).toEqual(['product1']);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('does not update any properties when no arguments are passed', () => {
|
|
39
|
+
configureProductPriceRounding({} as any);
|
|
40
|
+
expect(ProductPriceRoundSettings.configurations).toEqual({});
|
|
41
|
+
expect(ProductPriceRoundSettings.defaultPrecision).toBe(50);
|
|
42
|
+
expect(ProductPriceRoundSettings.skip).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -2,7 +2,7 @@ import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/
|
|
|
2
2
|
import {
|
|
3
3
|
DeliveryPricingAdapterContext,
|
|
4
4
|
IDeliveryPricingAdapter,
|
|
5
|
-
} from '@unchainedshop/types/delivery.pricing';
|
|
5
|
+
} from '@unchainedshop/types/delivery.pricing.js';
|
|
6
6
|
|
|
7
7
|
// https://www.ch.ch/de/mehrwertsteuersatz-schweiz/
|
|
8
8
|
export const SwissTaxCategories = {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HundredOff } from './discount-100-off.js';
|
|
2
|
+
|
|
3
|
+
describe('HundredOff', () => {
|
|
4
|
+
it('isManualAdditionAllowed', async () => {
|
|
5
|
+
let x
|
|
6
|
+
expect(await HundredOff.isManualAdditionAllowed(x)).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
it('isManualRemovalAllowed', async () => {
|
|
9
|
+
expect(await HundredOff.isManualRemovalAllowed()).toBeTruthy();
|
|
10
|
+
});
|
|
11
|
+
it('isValidForSystemTriggering', async () => {
|
|
12
|
+
const context = {};
|
|
13
|
+
const actions = await HundredOff.actions({ context } as any);
|
|
14
|
+
expect(await actions.isValidForSystemTriggering()).toBeFalsy();
|
|
15
|
+
});
|
|
16
|
+
it('isValidForCodeTriggering', async () => {
|
|
17
|
+
const context = {};
|
|
18
|
+
const actions = await HundredOff.actions({ context } as any);
|
|
19
|
+
expect(await actions.isValidForCodeTriggering({ code: '100OFF' })).toBeTruthy();
|
|
20
|
+
expect(await actions.isValidForCodeTriggering({ code: 'wrongcode' })).toBeFalsy();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('discountForPricingAdapterKey', async () => {
|
|
24
|
+
const context = {};
|
|
25
|
+
const actions = await HundredOff.actions({ context } as any);
|
|
26
|
+
expect(
|
|
27
|
+
actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.order-discount' } as any)
|
|
28
|
+
).toEqual({ fixedRate: 10000 });
|
|
29
|
+
expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.other-discount' } as any)).toBeNull();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
1
|
+
import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
|
|
2
2
|
import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
|
|
3
3
|
|
|
4
|
-
const HundredOff: IDiscountAdapter = {
|
|
4
|
+
export const HundredOff: IDiscountAdapter = {
|
|
5
5
|
...OrderDiscountAdapter,
|
|
6
6
|
|
|
7
7
|
key: 'shop.unchained.discount.100-off',
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HalfPriceManual } from './discount-half-price-manual.js';
|
|
2
|
+
|
|
3
|
+
describe('HalfPriceManual', () => {
|
|
4
|
+
it('isManualAdditionAllowed', async () => {
|
|
5
|
+
let x;
|
|
6
|
+
expect(await HalfPriceManual.isManualAdditionAllowed(x)).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('isManualRemovalAllowed', async () => {
|
|
10
|
+
expect(await HalfPriceManual.isManualRemovalAllowed()).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('isValidForSystemTriggering', async () => {
|
|
14
|
+
const context = {};
|
|
15
|
+
const actions = await HalfPriceManual.actions({ context } as any);
|
|
16
|
+
expect(await actions.isValidForSystemTriggering()).toBeFalsy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('isValidForCodeTriggering', async () => {
|
|
20
|
+
const context = {};
|
|
21
|
+
const actions = await HalfPriceManual.actions({ context } as any);
|
|
22
|
+
expect(await actions.isValidForCodeTriggering({ code: 'HALFPRICE' })).toBeTruthy();
|
|
23
|
+
expect(await actions.isValidForCodeTriggering({ code: 'othercode' })).toBeFalsy();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('discountForPricingAdapterKey', async () => {
|
|
27
|
+
const context = {};
|
|
28
|
+
const actions = await HalfPriceManual.actions({ context } as any);
|
|
29
|
+
expect(
|
|
30
|
+
actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.product-discount' } as any)
|
|
31
|
+
).toEqual({ rate: 0.5 });
|
|
32
|
+
expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.other-discount' } as any)).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('Actions', async () => {
|
|
36
|
+
const context = {};
|
|
37
|
+
const actions = await HalfPriceManual.actions({ context } as any);
|
|
38
|
+
expect(typeof actions.isValidForSystemTriggering).toBe('function');
|
|
39
|
+
expect(typeof actions.isValidForCodeTriggering).toBe('function');
|
|
40
|
+
expect(typeof actions.discountForPricingAdapterKey).toBe('function');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
1
|
+
import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
|
|
2
2
|
import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
|
|
3
3
|
|
|
4
|
-
const HalfPriceManual: IDiscountAdapter = {
|
|
4
|
+
export const HalfPriceManual: IDiscountAdapter = {
|
|
5
5
|
...OrderDiscountAdapter,
|
|
6
6
|
|
|
7
7
|
key: 'shop.unchained.discount.half-price-manual',
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HalfPrice } from './discount-half-price.js';
|
|
2
|
+
|
|
3
|
+
describe('HalfPrice', () => {
|
|
4
|
+
it('isManualAdditionAllowed', async () => {
|
|
5
|
+
expect(await HalfPrice.isManualAdditionAllowed('')).toBeFalsy();
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('isManualRemovalAllowed', async () => {
|
|
9
|
+
expect(await HalfPrice.isManualRemovalAllowed()).toBeFalsy();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('isValidForSystemTriggering', async () => {
|
|
13
|
+
const context = {
|
|
14
|
+
modules: {
|
|
15
|
+
users: {
|
|
16
|
+
findUserById: import.meta.jest.fn(() => Promise.resolve({ tags: ['half-price'] }))
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
order: { userId: 'user-id' }
|
|
20
|
+
};
|
|
21
|
+
const actions = await HalfPrice.actions({ context } as any);
|
|
22
|
+
expect(await actions.isValidForSystemTriggering()).toBeTruthy();
|
|
23
|
+
|
|
24
|
+
context.modules.users.findUserById.mockImplementationOnce(() => Promise.resolve({ tags: [] }));
|
|
25
|
+
expect(await actions.isValidForSystemTriggering()).toBeFalsy();
|
|
26
|
+
});
|
|
27
|
+
it('discountForPricingAdapterKey', async () => {
|
|
28
|
+
const context = {};
|
|
29
|
+
const actions = await HalfPrice.actions({ context } as any);
|
|
30
|
+
expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.product-discount' } as any)).toEqual({ rate: 0.5 });
|
|
31
|
+
expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.other-discount' } as any)).toBeNull();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('isValidForCodeTriggering', async () => {
|
|
35
|
+
const context = {};
|
|
36
|
+
const actions = await HalfPrice.actions({ context } as any);
|
|
37
|
+
|
|
38
|
+
expect(await actions.isValidForCodeTriggering({code: ''})).toBeFalsy();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
1
|
+
import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
|
|
2
2
|
import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
|
|
3
3
|
|
|
4
|
-
const HalfPrice: IDiscountAdapter = {
|
|
4
|
+
export const HalfPrice: IDiscountAdapter = {
|
|
5
5
|
...OrderDiscountAdapter,
|
|
6
6
|
|
|
7
7
|
key: 'shop.unchained.discount.half-price',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { IDeliveryPricingAdapter } from '@unchainedshop/types/delivery.pricing';
|
|
2
|
+
import { IDeliveryPricingAdapter } from '@unchainedshop/types/delivery.pricing.js';
|
|
3
3
|
|
|
4
4
|
export const DeliveryFreePrice: IDeliveryPricingAdapter = {
|
|
5
5
|
...DeliveryPricingAdapter,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PaymentPricingAdapter, PaymentPricingDirector } from '@unchainedshop/core-payment';
|
|
2
|
-
import { IPaymentPricingAdapter } from '@unchainedshop/types/payments.pricing';
|
|
2
|
+
import { IPaymentPricingAdapter } from '@unchainedshop/types/payments.pricing.js';
|
|
3
3
|
|
|
4
4
|
export const PaymentFreePrice: IPaymentPricingAdapter = {
|
|
5
5
|
...PaymentPricingAdapter,
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
})
|