@unchainedshop/plugins 4.8.26 → 4.8.27
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/post/adapter.d.ts +2 -0
- package/lib/delivery/post/adapter.js +22 -0
- package/lib/delivery/post/index.d.ts +4 -0
- package/lib/delivery/post/index.js +10 -0
- package/lib/delivery/send-message/adapter.d.ts +2 -0
- package/lib/delivery/send-message/adapter.js +39 -0
- package/lib/delivery/send-message/index.d.ts +4 -0
- package/lib/delivery/send-message/index.js +10 -0
- package/lib/delivery/stores/adapter.d.ts +2 -0
- package/lib/delivery/stores/adapter.js +42 -0
- package/lib/delivery/stores/index.d.ts +4 -0
- package/lib/delivery/stores/index.js +10 -0
- package/lib/enrollments/licensed/adapter.d.ts +6 -0
- package/lib/enrollments/licensed/adapter.js +51 -0
- package/lib/enrollments/licensed/index.d.ts +4 -0
- package/lib/enrollments/licensed/index.js +10 -0
- package/lib/files/gridfs/api.d.ts +7 -0
- package/lib/files/gridfs/api.js +163 -0
- package/lib/files/minio/adapter.d.ts +4 -0
- package/lib/files/minio/adapter.js +160 -0
- package/lib/files/minio/api.d.ts +2 -0
- package/lib/files/minio/api.js +40 -0
- package/lib/files/temp-upload/api.d.ts +8 -0
- package/lib/files/temp-upload/api.js +48 -0
- package/lib/files/temp-upload/index.d.ts +3 -0
- package/lib/files/temp-upload/index.js +15 -0
- package/lib/filters/local-search/adapter.d.ts +2 -0
- package/lib/filters/local-search/adapter.js +56 -0
- package/lib/filters/local-search/index.d.ts +4 -0
- package/lib/filters/local-search/index.js +10 -0
- package/lib/filters/strict-equal/adapter.d.ts +2 -0
- package/lib/filters/strict-equal/adapter.js +23 -0
- package/lib/filters/strict-equal/index.d.ts +4 -0
- package/lib/filters/strict-equal/index.js +10 -0
- package/lib/payment/apple-iap/api.d.ts +2 -0
- package/lib/payment/apple-iap/api.js +119 -0
- package/lib/payment/cryptopay/adapter.d.ts +2 -0
- package/lib/payment/cryptopay/adapter.js +157 -0
- package/lib/payment/cryptopay/api.d.ts +2 -0
- package/lib/payment/cryptopay/api.js +23 -0
- package/lib/payment/datatrans-v2/adapter.d.ts +2 -0
- package/lib/payment/datatrans-v2/adapter.js +417 -0
- package/lib/payment/datatrans-v2/api.d.ts +2 -0
- package/lib/payment/datatrans-v2/api.js +108 -0
- package/lib/payment/invoice/adapter.d.ts +2 -0
- package/lib/payment/invoice/adapter.js +26 -0
- package/lib/payment/invoice/index.d.ts +4 -0
- package/lib/payment/invoice/index.js +10 -0
- package/lib/payment/invoice-prepaid/adapter.d.ts +2 -0
- package/lib/payment/invoice-prepaid/adapter.js +29 -0
- package/lib/payment/invoice-prepaid/index.d.ts +4 -0
- package/lib/payment/invoice-prepaid/index.js +10 -0
- package/lib/payment/payrexx/adapter.d.ts +2 -0
- package/lib/payment/payrexx/adapter.js +161 -0
- package/lib/payment/payrexx/api.d.ts +2 -0
- package/lib/payment/payrexx/api.js +97 -0
- package/lib/payment/postfinance-checkout/adapter.d.ts +2 -0
- package/lib/payment/postfinance-checkout/adapter.js +189 -0
- package/lib/payment/postfinance-checkout/webhook.d.ts +2 -0
- package/lib/payment/postfinance-checkout/webhook.js +48 -0
- package/lib/payment/saferpay/webhook.d.ts +2 -0
- package/lib/payment/saferpay/webhook.js +64 -0
- package/lib/payment/stripe/adapter.d.ts +2 -0
- package/lib/payment/stripe/adapter.js +121 -0
- package/lib/payment/stripe/api.d.ts +6 -0
- package/lib/payment/stripe/api.js +165 -0
- package/lib/pricing/delivery-eu-tax/adapter.d.ts +3 -0
- package/lib/pricing/delivery-eu-tax/adapter.js +55 -0
- package/lib/pricing/delivery-eu-tax/index.d.ts +4 -0
- package/lib/pricing/delivery-eu-tax/index.js +10 -0
- package/lib/pricing/delivery-swiss-tax/adapter.d.ts +3 -0
- package/lib/pricing/delivery-swiss-tax/adapter.js +43 -0
- package/lib/pricing/delivery-swiss-tax/index.d.ts +4 -0
- package/lib/pricing/delivery-swiss-tax/index.js +10 -0
- package/lib/pricing/delivery-uk-tax/adapter.d.ts +3 -0
- package/lib/pricing/delivery-uk-tax/adapter.js +43 -0
- package/lib/pricing/delivery-uk-tax/index.d.ts +4 -0
- package/lib/pricing/delivery-uk-tax/index.js +10 -0
- package/lib/pricing/delivery-us-sales-tax/adapter.d.ts +3 -0
- package/lib/pricing/delivery-us-sales-tax/adapter.js +58 -0
- package/lib/pricing/delivery-us-sales-tax/index.d.ts +4 -0
- package/lib/pricing/delivery-us-sales-tax/index.js +10 -0
- package/lib/pricing/discount-100-off/adapter.d.ts +3 -0
- package/lib/pricing/discount-100-off/adapter.js +30 -0
- package/lib/pricing/discount-100-off/index.d.ts +4 -0
- package/lib/pricing/discount-100-off/index.js +10 -0
- package/lib/pricing/discount-half-price-manual/adapter.d.ts +3 -0
- package/lib/pricing/discount-half-price-manual/adapter.js +30 -0
- package/lib/pricing/discount-half-price-manual/index.d.ts +4 -0
- package/lib/pricing/discount-half-price-manual/index.js +10 -0
- package/lib/pricing/free-delivery/adapter.d.ts +3 -0
- package/lib/pricing/free-delivery/adapter.js +27 -0
- package/lib/pricing/free-delivery/index.d.ts +4 -0
- package/lib/pricing/free-delivery/index.js +10 -0
- package/lib/pricing/free-payment/adapter.d.ts +3 -0
- package/lib/pricing/free-payment/adapter.js +27 -0
- package/lib/pricing/free-payment/index.d.ts +4 -0
- package/lib/pricing/free-payment/index.js +10 -0
- package/lib/pricing/order-delivery/adapter.d.ts +3 -0
- package/lib/pricing/order-delivery/adapter.js +33 -0
- package/lib/pricing/order-delivery/index.d.ts +4 -0
- package/lib/pricing/order-delivery/index.js +10 -0
- package/lib/pricing/order-discount/adapter.d.ts +3 -0
- package/lib/pricing/order-discount/adapter.js +74 -0
- package/lib/pricing/order-discount/index.d.ts +4 -0
- package/lib/pricing/order-discount/index.js +10 -0
- package/lib/pricing/order-items/adapter.d.ts +3 -0
- package/lib/pricing/order-items/adapter.js +43 -0
- package/lib/pricing/order-items/index.d.ts +4 -0
- package/lib/pricing/order-items/index.js +10 -0
- package/lib/pricing/order-payment/adapter.d.ts +3 -0
- package/lib/pricing/order-payment/adapter.js +33 -0
- package/lib/pricing/order-payment/index.d.ts +4 -0
- package/lib/pricing/order-payment/index.js +10 -0
- package/lib/pricing/product-catalog-price/adapter.d.ts +3 -0
- package/lib/pricing/product-catalog-price/adapter.js +60 -0
- package/lib/pricing/product-catalog-price/index.d.ts +4 -0
- package/lib/pricing/product-catalog-price/index.js +10 -0
- package/lib/pricing/product-discount/adapter.d.ts +3 -0
- package/lib/pricing/product-discount/adapter.js +69 -0
- package/lib/pricing/product-discount/index.d.ts +4 -0
- package/lib/pricing/product-discount/index.js +10 -0
- package/lib/pricing/product-eu-tax/adapter.d.ts +3 -0
- package/lib/pricing/product-eu-tax/adapter.js +56 -0
- package/lib/pricing/product-eu-tax/index.d.ts +4 -0
- package/lib/pricing/product-eu-tax/index.js +10 -0
- package/lib/pricing/product-price-rateconversion/adapter.d.ts +3 -0
- package/lib/pricing/product-price-rateconversion/adapter.js +53 -0
- package/lib/pricing/product-price-rateconversion/index.d.ts +4 -0
- package/lib/pricing/product-price-rateconversion/index.js +10 -0
- package/lib/pricing/product-quotation-price.d.ts +2 -0
- package/lib/pricing/product-quotation-price.js +40 -0
- package/lib/pricing/product-swiss-tax/adapter.d.ts +3 -0
- package/lib/pricing/product-swiss-tax/adapter.js +57 -0
- package/lib/pricing/product-swiss-tax/index.d.ts +4 -0
- package/lib/pricing/product-swiss-tax/index.js +10 -0
- package/lib/pricing/product-uk-tax/adapter.d.ts +3 -0
- package/lib/pricing/product-uk-tax/adapter.js +57 -0
- package/lib/pricing/product-uk-tax/index.d.ts +4 -0
- package/lib/pricing/product-uk-tax/index.js +10 -0
- package/lib/pricing/product-us-sales-tax/adapter.d.ts +3 -0
- package/lib/pricing/product-us-sales-tax/adapter.js +52 -0
- package/lib/pricing/product-us-sales-tax/index.d.ts +4 -0
- package/lib/pricing/product-us-sales-tax/index.js +10 -0
- package/lib/quotations/manual/adapter.d.ts +2 -0
- package/lib/quotations/manual/adapter.js +24 -0
- package/lib/quotations/manual/index.d.ts +4 -0
- package/lib/quotations/manual/index.js +10 -0
- package/lib/warehousing/erc-metadata/api.d.ts +12 -0
- package/lib/warehousing/erc-metadata/api.js +43 -0
- package/lib/warehousing/erc-metadata/index.d.ts +3 -0
- package/lib/warehousing/erc-metadata/index.js +15 -0
- package/lib/warehousing/eth-minter/adapter.d.ts +2 -0
- package/lib/warehousing/eth-minter/adapter.js +119 -0
- package/lib/warehousing/eth-minter/index.d.ts +4 -0
- package/lib/warehousing/eth-minter/index.js +10 -0
- package/lib/warehousing/store/adapter.d.ts +2 -0
- package/lib/warehousing/store/adapter.js +33 -0
- package/lib/warehousing/store/index.d.ts +4 -0
- package/lib/warehousing/store/index.js +10 -0
- package/lib/worker/budgetsms/adapter.d.ts +22 -0
- package/lib/worker/budgetsms/adapter.js +169 -0
- package/lib/worker/budgetsms/index.d.ts +4 -0
- package/lib/worker/budgetsms/index.js +10 -0
- package/lib/worker/bulk-export/adapter.d.ts +3 -0
- package/lib/worker/bulk-export/adapter.js +64 -0
- package/lib/worker/bulk-export/index.d.ts +4 -0
- package/lib/worker/bulk-export/index.js +10 -0
- package/lib/worker/bulk-import/adapter.d.ts +3 -0
- package/lib/worker/bulk-import/adapter.js +65 -0
- package/lib/worker/bulk-import/api.d.ts +9 -0
- package/lib/worker/bulk-import/api.js +52 -0
- package/lib/worker/bulk-import/index.d.ts +4 -0
- package/lib/worker/bulk-import/index.js +18 -0
- package/lib/worker/bulkgate/adapter.d.ts +12 -0
- package/lib/worker/bulkgate/adapter.js +91 -0
- package/lib/worker/bulkgate/index.d.ts +4 -0
- package/lib/worker/bulkgate/index.js +10 -0
- package/lib/worker/email/adapter.d.ts +9 -0
- package/lib/worker/email/adapter.js +150 -0
- package/lib/worker/email/index.d.ts +4 -0
- package/lib/worker/email/index.js +10 -0
- package/lib/worker/enrollment-order-generator/adapter.d.ts +4 -0
- package/lib/worker/enrollment-order-generator/adapter.js +77 -0
- package/lib/worker/enrollment-order-generator/index.d.ts +4 -0
- package/lib/worker/enrollment-order-generator/index.js +13 -0
- package/lib/worker/error-notifications/adapter.d.ts +10 -0
- package/lib/worker/error-notifications/adapter.js +62 -0
- package/lib/worker/error-notifications/index.d.ts +4 -0
- package/lib/worker/error-notifications/index.js +13 -0
- package/lib/worker/export-token/adapter.d.ts +4 -0
- package/lib/worker/export-token/adapter.js +25 -0
- package/lib/worker/export-token/index.d.ts +4 -0
- package/lib/worker/export-token/index.js +13 -0
- package/lib/worker/external/adapter.d.ts +3 -0
- package/lib/worker/external/adapter.js +13 -0
- package/lib/worker/external/index.d.ts +4 -0
- package/lib/worker/external/index.js +10 -0
- package/lib/worker/gc-guests/adapter.d.ts +9 -0
- package/lib/worker/gc-guests/adapter.js +56 -0
- package/lib/worker/gc-guests/index.d.ts +4 -0
- package/lib/worker/gc-guests/index.js +13 -0
- package/lib/worker/heartbeat/adapter.d.ts +8 -0
- package/lib/worker/heartbeat/adapter.js +26 -0
- package/lib/worker/heartbeat/index.d.ts +4 -0
- package/lib/worker/heartbeat/index.js +10 -0
- package/lib/worker/http-request/adapter.d.ts +8 -0
- package/lib/worker/http-request/adapter.js +55 -0
- package/lib/worker/http-request/index.d.ts +4 -0
- package/lib/worker/http-request/index.js +10 -0
- package/lib/worker/invalidate-carts/adapter.d.ts +9 -0
- package/lib/worker/invalidate-carts/adapter.js +52 -0
- package/lib/worker/invalidate-carts/index.d.ts +4 -0
- package/lib/worker/invalidate-carts/index.js +13 -0
- package/lib/worker/message/adapter.d.ts +11 -0
- package/lib/worker/message/adapter.js +42 -0
- package/lib/worker/message/index.d.ts +4 -0
- package/lib/worker/message/index.js +10 -0
- package/lib/worker/push-notification/adapter.d.ts +9 -0
- package/lib/worker/push-notification/adapter.js +87 -0
- package/lib/worker/push-notification/index.d.ts +4 -0
- package/lib/worker/push-notification/index.js +10 -0
- package/lib/worker/twilio/adapter.d.ts +8 -0
- package/lib/worker/twilio/adapter.js +59 -0
- package/lib/worker/twilio/index.d.ts +4 -0
- package/lib/worker/twilio/index.js +10 -0
- package/lib/worker/update-coinbase-rates/adapter.d.ts +4 -0
- package/lib/worker/update-coinbase-rates/adapter.js +59 -0
- package/lib/worker/update-coinbase-rates/index.d.ts +4 -0
- package/lib/worker/update-coinbase-rates/index.js +13 -0
- package/lib/worker/update-ecb-rates/adapter.d.ts +4 -0
- package/lib/worker/update-ecb-rates/adapter.js +94 -0
- package/lib/worker/update-ecb-rates/index.d.ts +4 -0
- package/lib/worker/update-ecb-rates/index.js +13 -0
- package/lib/worker/update-token-ownership/adapter.d.ts +5 -0
- package/lib/worker/update-token-ownership/adapter.js +58 -0
- package/lib/worker/update-token-ownership/index.d.ts +4 -0
- package/lib/worker/update-token-ownership/index.js +13 -0
- package/lib/worker/zombie-killer/adapter.d.ts +15 -0
- package/lib/worker/zombie-killer/adapter.js +113 -0
- package/lib/worker/zombie-killer/index.d.ts +4 -0
- package/lib/worker/zombie-killer/index.js +13 -0
- package/package.json +19 -19
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OrderDiscountAdapter, } from '@unchainedshop/core';
|
|
2
|
+
export const HalfPriceManual = {
|
|
3
|
+
...OrderDiscountAdapter,
|
|
4
|
+
key: 'shop.unchained.discount.half-price-manual',
|
|
5
|
+
label: 'Half Price Manual',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
orderIndex: 10,
|
|
8
|
+
isManualAdditionAllowed: async () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
isManualRemovalAllowed: async () => {
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
actions: async ({ context }) => ({
|
|
15
|
+
...(await OrderDiscountAdapter.actions({ context })),
|
|
16
|
+
isValidForSystemTriggering: async () => {
|
|
17
|
+
return false;
|
|
18
|
+
},
|
|
19
|
+
isValidForCodeTriggering: async ({ code }) => {
|
|
20
|
+
return code === 'HALFPRICE';
|
|
21
|
+
},
|
|
22
|
+
discountForPricingAdapterKey({ pricingAdapterKey }) {
|
|
23
|
+
if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
|
|
24
|
+
return { rate: 0.5 };
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
export default HalfPriceManual;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { HalfPriceManual } from "./adapter.js";
|
|
3
|
+
export const HalfPriceManualPlugin = {
|
|
4
|
+
key: 'shop.unchained.discount.half-price-manual',
|
|
5
|
+
label: 'Half Price Manual Discount Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [HalfPriceManual],
|
|
8
|
+
};
|
|
9
|
+
export default HalfPriceManualPlugin;
|
|
10
|
+
export { HalfPriceManual } from "./adapter.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DeliveryPricingAdapter } from '@unchainedshop/core';
|
|
2
|
+
export const DeliveryFreePrice = {
|
|
3
|
+
...DeliveryPricingAdapter,
|
|
4
|
+
key: 'shop.unchained.pricing.delivery-free',
|
|
5
|
+
label: 'Free Delivery',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
orderIndex: 0,
|
|
8
|
+
isActivatedFor: () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
actions: (params) => {
|
|
12
|
+
const pricingAdapter = DeliveryPricingAdapter.actions(params);
|
|
13
|
+
return {
|
|
14
|
+
...pricingAdapter,
|
|
15
|
+
calculate: async () => {
|
|
16
|
+
pricingAdapter.resultSheet().addFee({
|
|
17
|
+
amount: 0,
|
|
18
|
+
isTaxable: false,
|
|
19
|
+
isNetPrice: false,
|
|
20
|
+
meta: { adapter: DeliveryFreePrice.key },
|
|
21
|
+
});
|
|
22
|
+
return pricingAdapter.calculate();
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export default DeliveryFreePrice;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { DeliveryFreePrice } from "./adapter.js";
|
|
3
|
+
export const DeliveryFreePricePlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.delivery-free',
|
|
5
|
+
label: 'Free Delivery Pricing Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [DeliveryFreePrice],
|
|
8
|
+
};
|
|
9
|
+
export default DeliveryFreePricePlugin;
|
|
10
|
+
export { DeliveryFreePrice } from "./adapter.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PaymentPricingAdapter } from '@unchainedshop/core';
|
|
2
|
+
export const PaymentFreePrice = {
|
|
3
|
+
...PaymentPricingAdapter,
|
|
4
|
+
key: 'shop.unchained.pricing.payment-free',
|
|
5
|
+
label: 'Free Payment',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
orderIndex: 0,
|
|
8
|
+
isActivatedFor: () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
actions: (params) => {
|
|
12
|
+
const pricingAdapter = PaymentPricingAdapter.actions(params);
|
|
13
|
+
return {
|
|
14
|
+
...pricingAdapter,
|
|
15
|
+
calculate: async () => {
|
|
16
|
+
pricingAdapter.resultSheet().addFee({
|
|
17
|
+
amount: 0,
|
|
18
|
+
isNetPrice: false,
|
|
19
|
+
isTaxable: false,
|
|
20
|
+
meta: { adapter: PaymentFreePrice.key },
|
|
21
|
+
});
|
|
22
|
+
return pricingAdapter.calculate();
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export default PaymentFreePrice;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { PaymentFreePrice } from "./adapter.js";
|
|
3
|
+
export const PaymentFreePricePlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.payment-free',
|
|
5
|
+
label: 'Free Payment Pricing Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [PaymentFreePrice],
|
|
8
|
+
};
|
|
9
|
+
export default PaymentFreePricePlugin;
|
|
10
|
+
export { PaymentFreePrice } from "./adapter.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OrderPricingAdapter, DeliveryPricingSheet, } from '@unchainedshop/core';
|
|
2
|
+
export const OrderDelivery = {
|
|
3
|
+
...OrderPricingAdapter,
|
|
4
|
+
key: 'shop.unchained.pricing.order-delivery',
|
|
5
|
+
version: '1.0.0',
|
|
6
|
+
label: 'Add Delivery Fees to Order',
|
|
7
|
+
orderIndex: 10,
|
|
8
|
+
isActivatedFor: () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
actions: (params) => {
|
|
12
|
+
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
13
|
+
const { order, orderDelivery } = params.context;
|
|
14
|
+
return {
|
|
15
|
+
...pricingAdapter,
|
|
16
|
+
calculate: async () => {
|
|
17
|
+
if (!orderDelivery)
|
|
18
|
+
return null;
|
|
19
|
+
const pricing = DeliveryPricingSheet({
|
|
20
|
+
calculation: orderDelivery.calculation,
|
|
21
|
+
currencyCode: order.currencyCode,
|
|
22
|
+
});
|
|
23
|
+
const tax = pricing.taxSum();
|
|
24
|
+
const shipping = pricing.gross();
|
|
25
|
+
pricingAdapter
|
|
26
|
+
.resultSheet()
|
|
27
|
+
.addDelivery({ amount: shipping, taxAmount: tax, meta: { adapter: OrderDelivery.key } });
|
|
28
|
+
return pricingAdapter.calculate();
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export default OrderDelivery;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { OrderDelivery } from "./adapter.js";
|
|
3
|
+
export const OrderDeliveryPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.order-delivery',
|
|
5
|
+
label: 'Order Delivery Pricing Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [OrderDelivery],
|
|
8
|
+
};
|
|
9
|
+
export default OrderDeliveryPlugin;
|
|
10
|
+
export { OrderDelivery } from "./adapter.js";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { OrderPricingRowCategory, OrderPricingAdapter, DeliveryPricingSheet, PaymentPricingSheet, ProductPricingSheet, resolveRatioAndTaxDivisorForPricingSheet, } from '@unchainedshop/core';
|
|
2
|
+
import { calculation as calcUtils } from '@unchainedshop/utils';
|
|
3
|
+
export const OrderDiscount = {
|
|
4
|
+
...OrderPricingAdapter,
|
|
5
|
+
key: 'shop.unchained.pricing.order-discount',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
label: 'Apply Discounts on Total Order Value',
|
|
8
|
+
orderIndex: 40,
|
|
9
|
+
isActivatedFor: () => {
|
|
10
|
+
return true;
|
|
11
|
+
},
|
|
12
|
+
actions: (params) => {
|
|
13
|
+
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
14
|
+
const { order, orderDelivery, orderPositions, orderPayment } = params.context;
|
|
15
|
+
return {
|
|
16
|
+
...pricingAdapter,
|
|
17
|
+
calculate: async () => {
|
|
18
|
+
if (!order)
|
|
19
|
+
return pricingAdapter.calculate();
|
|
20
|
+
const totalAmountOfItems = params.calculationSheet.total({
|
|
21
|
+
category: OrderPricingRowCategory.Items,
|
|
22
|
+
useNetPrice: false,
|
|
23
|
+
}).amount;
|
|
24
|
+
const totalAmountOfPaymentAndDelivery = params.calculationSheet.total({
|
|
25
|
+
category: OrderPricingRowCategory.Payment,
|
|
26
|
+
useNetPrice: false,
|
|
27
|
+
}).amount +
|
|
28
|
+
params.calculationSheet.total({
|
|
29
|
+
category: OrderPricingRowCategory.Delivery,
|
|
30
|
+
useNetPrice: false,
|
|
31
|
+
}).amount;
|
|
32
|
+
const itemShares = orderPositions.map((orderPosition) => resolveRatioAndTaxDivisorForPricingSheet(ProductPricingSheet({
|
|
33
|
+
calculation: orderPosition.calculation,
|
|
34
|
+
currencyCode: order.currencyCode,
|
|
35
|
+
quantity: orderPosition.quantity,
|
|
36
|
+
}), totalAmountOfItems));
|
|
37
|
+
const deliveryShare = resolveRatioAndTaxDivisorForPricingSheet(DeliveryPricingSheet({
|
|
38
|
+
calculation: orderDelivery?.calculation || [],
|
|
39
|
+
currencyCode: order.currencyCode,
|
|
40
|
+
}), totalAmountOfPaymentAndDelivery);
|
|
41
|
+
const paymentShare = resolveRatioAndTaxDivisorForPricingSheet(PaymentPricingSheet({
|
|
42
|
+
calculation: orderPayment?.calculation || [],
|
|
43
|
+
currencyCode: order.currencyCode,
|
|
44
|
+
}), totalAmountOfPaymentAndDelivery);
|
|
45
|
+
let amountLeft = totalAmountOfPaymentAndDelivery + totalAmountOfItems;
|
|
46
|
+
params.discounts.forEach(({ configuration, discountId }) => {
|
|
47
|
+
const leftInDiscountToSplit = calcUtils.calculateAmountToSplit({ ...configuration }, Math.min(totalAmountOfItems, amountLeft));
|
|
48
|
+
const [itemsDiscountAmount, itemsTaxAmount] = calcUtils.applyDiscountToMultipleShares(itemShares, Math.max(0, Math.min(amountLeft, leftInDiscountToSplit)));
|
|
49
|
+
amountLeft -= itemsDiscountAmount;
|
|
50
|
+
const fixedRate = Number(configuration.fixedRate) > 0
|
|
51
|
+
? Math.max(0, configuration.fixedRate - itemsDiscountAmount)
|
|
52
|
+
: undefined;
|
|
53
|
+
const leftInFeesToSplit = calcUtils.calculateAmountToSplit({ ...configuration, fixedRate }, Math.min(totalAmountOfPaymentAndDelivery, amountLeft));
|
|
54
|
+
const [deliveryAndPaymentDiscountAmount, deliveryAndPaymentTaxAmount] = calcUtils.applyDiscountToMultipleShares([deliveryShare, paymentShare], Math.max(0, Math.min(amountLeft, leftInFeesToSplit)));
|
|
55
|
+
amountLeft -= deliveryAndPaymentDiscountAmount;
|
|
56
|
+
const discountAmount = (itemsDiscountAmount + deliveryAndPaymentDiscountAmount) * -1;
|
|
57
|
+
const taxAmount = (itemsTaxAmount + deliveryAndPaymentTaxAmount) * -1;
|
|
58
|
+
if (discountAmount) {
|
|
59
|
+
pricingAdapter.resultSheet().addDiscount({
|
|
60
|
+
amount: discountAmount,
|
|
61
|
+
taxAmount,
|
|
62
|
+
discountId,
|
|
63
|
+
meta: {
|
|
64
|
+
adapter: OrderDiscount.key,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return pricingAdapter.calculate();
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
export default OrderDiscount;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { OrderDiscount } from "./adapter.js";
|
|
3
|
+
export const OrderDiscountPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.order-discount',
|
|
5
|
+
label: 'Order Discount Pricing Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [OrderDiscount],
|
|
8
|
+
};
|
|
9
|
+
export default OrderDiscountPlugin;
|
|
10
|
+
export { OrderDiscount } from "./adapter.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { OrderPricingAdapter, ProductPricingSheet, } from '@unchainedshop/core';
|
|
2
|
+
export const OrderItems = {
|
|
3
|
+
...OrderPricingAdapter,
|
|
4
|
+
key: 'shop.unchained.pricing.order-items',
|
|
5
|
+
version: '1.0.0',
|
|
6
|
+
label: 'Add Total Value Of Goods to Order',
|
|
7
|
+
orderIndex: 0,
|
|
8
|
+
isActivatedFor: () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
actions: (params) => {
|
|
12
|
+
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
13
|
+
const { order, orderPositions } = params.context;
|
|
14
|
+
return {
|
|
15
|
+
...pricingAdapter,
|
|
16
|
+
calculate: async () => {
|
|
17
|
+
const totalAndTaxesOfAllItems = orderPositions.reduce((current, orderPosition) => {
|
|
18
|
+
const pricing = ProductPricingSheet({
|
|
19
|
+
calculation: orderPosition.calculation,
|
|
20
|
+
currencyCode: order.currencyCode,
|
|
21
|
+
quantity: orderPosition.quantity,
|
|
22
|
+
});
|
|
23
|
+
const tax = pricing.taxSum();
|
|
24
|
+
const items = pricing.gross();
|
|
25
|
+
return {
|
|
26
|
+
taxes: current.taxes + tax,
|
|
27
|
+
items: current.items + items,
|
|
28
|
+
};
|
|
29
|
+
}, {
|
|
30
|
+
taxes: 0,
|
|
31
|
+
items: 0,
|
|
32
|
+
});
|
|
33
|
+
pricingAdapter.resultSheet().addItems({
|
|
34
|
+
amount: totalAndTaxesOfAllItems.items,
|
|
35
|
+
taxAmount: totalAndTaxesOfAllItems.taxes,
|
|
36
|
+
meta: { adapter: OrderItems.key },
|
|
37
|
+
});
|
|
38
|
+
return pricingAdapter.calculate();
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export default OrderItems;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { OrderItems } from "./adapter.js";
|
|
3
|
+
export const OrderItemsPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.order-items',
|
|
5
|
+
label: 'Order Items Pricing Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [OrderItems],
|
|
8
|
+
};
|
|
9
|
+
export default OrderItemsPlugin;
|
|
10
|
+
export { OrderItems } from "./adapter.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OrderPricingAdapter, PaymentPricingSheet, } from '@unchainedshop/core';
|
|
2
|
+
export const OrderPayment = {
|
|
3
|
+
...OrderPricingAdapter,
|
|
4
|
+
key: 'shop.unchained.pricing.order-payment',
|
|
5
|
+
version: '1.0.0',
|
|
6
|
+
label: 'Add Payment Fees to Order',
|
|
7
|
+
orderIndex: 10,
|
|
8
|
+
isActivatedFor: () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
actions: (params) => {
|
|
12
|
+
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
13
|
+
const { order, orderPayment } = params.context;
|
|
14
|
+
return {
|
|
15
|
+
...pricingAdapter,
|
|
16
|
+
calculate: async () => {
|
|
17
|
+
if (!orderPayment)
|
|
18
|
+
return null;
|
|
19
|
+
const pricing = PaymentPricingSheet({
|
|
20
|
+
calculation: orderPayment.calculation,
|
|
21
|
+
currencyCode: order.currencyCode,
|
|
22
|
+
});
|
|
23
|
+
const tax = pricing.taxSum();
|
|
24
|
+
const paymentFees = pricing.gross();
|
|
25
|
+
pricingAdapter
|
|
26
|
+
.resultSheet()
|
|
27
|
+
.addPayment({ amount: paymentFees, taxAmount: tax, meta: { adapter: OrderPayment.key } });
|
|
28
|
+
return pricingAdapter.calculate();
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export default OrderPayment;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { OrderPayment } from "./adapter.js";
|
|
3
|
+
export const OrderPaymentPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.order-payment',
|
|
5
|
+
label: 'Order Payment Pricing Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [OrderPayment],
|
|
8
|
+
};
|
|
9
|
+
export default OrderPaymentPlugin;
|
|
10
|
+
export { OrderPayment } from "./adapter.js";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ProductPricingAdapter } from '@unchainedshop/core';
|
|
2
|
+
import { ProductType } from '@unchainedshop/core-products';
|
|
3
|
+
export const ProductPrice = {
|
|
4
|
+
...ProductPricingAdapter,
|
|
5
|
+
key: 'shop.unchained.pricing.product-price',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
label: 'Add Gross Price to Product',
|
|
8
|
+
orderIndex: 0,
|
|
9
|
+
isActivatedFor: () => {
|
|
10
|
+
return true;
|
|
11
|
+
},
|
|
12
|
+
actions: (params) => {
|
|
13
|
+
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
14
|
+
return {
|
|
15
|
+
...pricingAdapter,
|
|
16
|
+
calculate: async () => {
|
|
17
|
+
const { product, countryCode, currencyCode, quantity, modules } = params.context;
|
|
18
|
+
const price = await modules.products.prices.price(product, {
|
|
19
|
+
countryCode,
|
|
20
|
+
currencyCode,
|
|
21
|
+
quantity,
|
|
22
|
+
});
|
|
23
|
+
if (price) {
|
|
24
|
+
const itemTotal = price.amount * quantity;
|
|
25
|
+
pricingAdapter.resultSheet().addItem({
|
|
26
|
+
amount: itemTotal,
|
|
27
|
+
isTaxable: Boolean(price.isTaxable),
|
|
28
|
+
isNetPrice: Boolean(price.isNetPrice),
|
|
29
|
+
meta: { adapter: ProductPrice.key },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else if (product.type === ProductType.BUNDLE_PRODUCT) {
|
|
33
|
+
for (const bundleItem of product.bundleItems || []) {
|
|
34
|
+
const bundledProduct = await modules.products.findProduct({
|
|
35
|
+
productId: bundleItem.productId,
|
|
36
|
+
});
|
|
37
|
+
if (bundledProduct) {
|
|
38
|
+
const bundleItemPrice = await modules.products.prices.price(bundledProduct, {
|
|
39
|
+
countryCode,
|
|
40
|
+
currencyCode,
|
|
41
|
+
quantity: bundleItem.quantity * quantity,
|
|
42
|
+
});
|
|
43
|
+
if (bundleItemPrice) {
|
|
44
|
+
const bundleItemTotal = bundleItemPrice.amount * bundleItem.quantity * quantity;
|
|
45
|
+
pricingAdapter.resultSheet().addItem({
|
|
46
|
+
amount: bundleItemTotal,
|
|
47
|
+
isTaxable: Boolean(bundleItemPrice.isTaxable),
|
|
48
|
+
isNetPrice: Boolean(bundleItemPrice.isNetPrice),
|
|
49
|
+
meta: { adapter: ProductPrice.key },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return pricingAdapter.calculate();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export default ProductPrice;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { ProductPrice } from "./adapter.js";
|
|
3
|
+
export const ProductPricePlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.product-catalog',
|
|
5
|
+
label: 'Product Catalog Price Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [ProductPrice],
|
|
8
|
+
};
|
|
9
|
+
export default ProductPricePlugin;
|
|
10
|
+
export { ProductPrice } from "./adapter.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { calculation as calcUtils } from '@unchainedshop/utils';
|
|
2
|
+
import { ProductPricingAdapter, ProductPricingRowCategory, } from '@unchainedshop/core';
|
|
3
|
+
export const ProductDiscount = {
|
|
4
|
+
...ProductPricingAdapter,
|
|
5
|
+
key: 'shop.unchained.pricing.product-discount',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
label: 'Apply Discounts on Product Price',
|
|
8
|
+
orderIndex: 30,
|
|
9
|
+
isActivatedFor: () => {
|
|
10
|
+
return true;
|
|
11
|
+
},
|
|
12
|
+
actions: (params) => {
|
|
13
|
+
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
14
|
+
const addDiscounts = (discount, total, resolvedConfiguration) => {
|
|
15
|
+
const { discountId } = discount;
|
|
16
|
+
const { isNetPrice = false, taxRate, ...meta } = resolvedConfiguration;
|
|
17
|
+
const amount = calcUtils.applyRate(resolvedConfiguration, total);
|
|
18
|
+
const isTaxable = taxRate === undefined || taxRate === null;
|
|
19
|
+
pricingAdapter.resultSheet().addDiscount({
|
|
20
|
+
amount: amount * -1,
|
|
21
|
+
discountId,
|
|
22
|
+
isNetPrice,
|
|
23
|
+
isTaxable,
|
|
24
|
+
meta: { adapter: ProductDiscount.key, ...meta },
|
|
25
|
+
});
|
|
26
|
+
if (!isTaxable && taxRate) {
|
|
27
|
+
const taxAmount = calcUtils.getTaxAmount(amount, taxRate, isNetPrice);
|
|
28
|
+
pricingAdapter.resultSheet().addTax({
|
|
29
|
+
amount: taxAmount * -1,
|
|
30
|
+
rate: taxRate,
|
|
31
|
+
discountId,
|
|
32
|
+
baseCategory: ProductPricingRowCategory.Discount,
|
|
33
|
+
meta: { adapter: ProductDiscount.key, discountId, ...meta },
|
|
34
|
+
});
|
|
35
|
+
if (!isNetPrice) {
|
|
36
|
+
pricingAdapter.resultSheet().addDiscount({
|
|
37
|
+
amount: taxAmount,
|
|
38
|
+
discountId,
|
|
39
|
+
isNetPrice: false,
|
|
40
|
+
isTaxable: false,
|
|
41
|
+
meta: { adapter: ProductDiscount.key, discountId, ...meta },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
...pricingAdapter,
|
|
48
|
+
calculate: async () => {
|
|
49
|
+
params.discounts.forEach((discount) => {
|
|
50
|
+
if (!discount)
|
|
51
|
+
return;
|
|
52
|
+
const { configuration } = discount;
|
|
53
|
+
const resolvedConfiguration = configuration.customPriceConfigurationResolver
|
|
54
|
+
? configuration.customPriceConfigurationResolver(params.context.product, params.context.quantity, params.context.configuration)
|
|
55
|
+
: configuration;
|
|
56
|
+
if (!resolvedConfiguration)
|
|
57
|
+
return;
|
|
58
|
+
const total = params.calculationSheet.total({
|
|
59
|
+
category: ProductPricingRowCategory.Item,
|
|
60
|
+
useNetPrice: resolvedConfiguration.isNetPrice,
|
|
61
|
+
});
|
|
62
|
+
addDiscounts(discount, total.amount, resolvedConfiguration);
|
|
63
|
+
});
|
|
64
|
+
return pricingAdapter.calculate();
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export default ProductDiscount;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { ProductDiscount } from "./adapter.js";
|
|
3
|
+
export const ProductDiscountPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.product-discount',
|
|
5
|
+
label: 'Product Discount Pricing Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [ProductDiscount],
|
|
8
|
+
};
|
|
9
|
+
export default ProductDiscountPlugin;
|
|
10
|
+
export { ProductDiscount } from "./adapter.js";
|