@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,56 @@
|
|
|
1
|
+
import { ProductPricingAdapter, ProductPricingRowCategory, } from '@unchainedshop/core';
|
|
2
|
+
import { resolveEuTaxCategoryFromDeliveryProvider, resolveEuTaxCategoryFromProduct, resolveEuTaxRate, } from "../tax/eu.js";
|
|
3
|
+
import resolveDeliveryLocation from "../utils/resolveDeliveryLocation.js";
|
|
4
|
+
import { applyTaxRateToTaxableRows } from "../tax/applyTaxRateToTaxableRows.js";
|
|
5
|
+
export const ProductEuTax = {
|
|
6
|
+
...ProductPricingAdapter,
|
|
7
|
+
key: 'shop.unchained.pricing.product-eu-tax',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
label: 'Apply EU VAT on Product',
|
|
10
|
+
orderIndex: 80,
|
|
11
|
+
isActivatedFor: () => {
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
actions: (params) => {
|
|
15
|
+
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
16
|
+
const { context } = params;
|
|
17
|
+
return {
|
|
18
|
+
...pricingAdapter,
|
|
19
|
+
calculate: async () => {
|
|
20
|
+
const orderDelivery = context.order?.deliveryId
|
|
21
|
+
? await context.modules.orders.deliveries.findDelivery({
|
|
22
|
+
orderDeliveryId: context.order?.deliveryId,
|
|
23
|
+
})
|
|
24
|
+
: null;
|
|
25
|
+
const { countryCode } = resolveDeliveryLocation({ ...context, orderDelivery });
|
|
26
|
+
let category = resolveEuTaxCategoryFromProduct(context.product);
|
|
27
|
+
if (!category) {
|
|
28
|
+
const provider = orderDelivery?.deliveryProviderId
|
|
29
|
+
? await context.modules.delivery.findProvider({
|
|
30
|
+
deliveryProviderId: orderDelivery?.deliveryProviderId,
|
|
31
|
+
})
|
|
32
|
+
: null;
|
|
33
|
+
if (provider)
|
|
34
|
+
category = resolveEuTaxCategoryFromDeliveryProvider(provider);
|
|
35
|
+
}
|
|
36
|
+
const taxRate = resolveEuTaxRate({
|
|
37
|
+
countryCode,
|
|
38
|
+
category,
|
|
39
|
+
referenceDate: context.order?.ordered,
|
|
40
|
+
});
|
|
41
|
+
if (taxRate === null)
|
|
42
|
+
return pricingAdapter.calculate();
|
|
43
|
+
ProductPricingAdapter.log(`ProductEuTax -> Tax Multiplicator: ${taxRate}`);
|
|
44
|
+
applyTaxRateToTaxableRows({
|
|
45
|
+
calculationSheet: params.calculationSheet,
|
|
46
|
+
resultSheet: pricingAdapter.resultSheet(),
|
|
47
|
+
taxRate,
|
|
48
|
+
baseCategory: ProductPricingRowCategory.Item,
|
|
49
|
+
adapterKey: ProductEuTax.key,
|
|
50
|
+
});
|
|
51
|
+
return pricingAdapter.calculate();
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export default ProductEuTax;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { ProductEuTax } from "./adapter.js";
|
|
3
|
+
export const ProductEuTaxPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.product-eu-tax',
|
|
5
|
+
label: 'Product EU Tax Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [ProductEuTax],
|
|
8
|
+
};
|
|
9
|
+
export default ProductEuTaxPlugin;
|
|
10
|
+
export { ProductEuTax } from "./adapter.js";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ProductPricingAdapter } from '@unchainedshop/core';
|
|
2
|
+
export const ProductPriceRateConversion = {
|
|
3
|
+
...ProductPricingAdapter,
|
|
4
|
+
key: 'shop.unchained.pricing.rate-conversion',
|
|
5
|
+
version: '1.0.0',
|
|
6
|
+
label: 'Generic rate conversion plugin that converts between rates if entry in DB exists.',
|
|
7
|
+
orderIndex: 10,
|
|
8
|
+
isActivatedFor: () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
actions: (params) => {
|
|
12
|
+
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
13
|
+
const { modules } = params.context;
|
|
14
|
+
return {
|
|
15
|
+
...pricingAdapter,
|
|
16
|
+
calculate: async () => {
|
|
17
|
+
const { product, countryCode, quantity, currencyCode: targetCurrency } = params.context;
|
|
18
|
+
const { calculation = [] } = params.calculationSheet;
|
|
19
|
+
if (calculation?.length) {
|
|
20
|
+
return pricingAdapter.calculate();
|
|
21
|
+
}
|
|
22
|
+
const productPrice = await modules.products.prices.price(product, {
|
|
23
|
+
countryCode,
|
|
24
|
+
quantity,
|
|
25
|
+
});
|
|
26
|
+
if (!productPrice) {
|
|
27
|
+
return pricingAdapter.calculate();
|
|
28
|
+
}
|
|
29
|
+
const fromCurrencyObj = await modules.currencies.findCurrency({
|
|
30
|
+
isoCode: productPrice.currencyCode,
|
|
31
|
+
});
|
|
32
|
+
const targetCurrencyObj = await modules.currencies.findCurrency({
|
|
33
|
+
isoCode: targetCurrency,
|
|
34
|
+
});
|
|
35
|
+
if (!targetCurrencyObj?.isActive || !fromCurrencyObj?.isActive)
|
|
36
|
+
return pricingAdapter.calculate();
|
|
37
|
+
const rateData = await modules.products.prices.rates.getRate(fromCurrencyObj, targetCurrencyObj);
|
|
38
|
+
if (rateData && rateData.rate > 0) {
|
|
39
|
+
const convertedAmount = Math.round(productPrice.amount * rateData.rate);
|
|
40
|
+
pricingAdapter.resultSheet().resetCalculation(params.calculationSheet);
|
|
41
|
+
pricingAdapter.resultSheet().addItem({
|
|
42
|
+
amount: convertedAmount * quantity,
|
|
43
|
+
isTaxable: Boolean(productPrice?.isTaxable),
|
|
44
|
+
isNetPrice: Boolean(productPrice?.isNetPrice),
|
|
45
|
+
meta: { adapter: ProductPriceRateConversion.key, rate: rateData.rate },
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return pricingAdapter.calculate();
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
export default ProductPriceRateConversion;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { ProductPriceRateConversion } from "./adapter.js";
|
|
3
|
+
export const ProductPriceRateConversionPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.rate-conversion',
|
|
5
|
+
label: 'Product Price Rate Conversion Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [ProductPriceRateConversion],
|
|
8
|
+
};
|
|
9
|
+
export default ProductPriceRateConversionPlugin;
|
|
10
|
+
export { ProductPriceRateConversion } from "./adapter.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ProductPricingDirector, ProductPricingAdapter, } from '@unchainedshop/core';
|
|
2
|
+
export const ProductQuotationPrice = {
|
|
3
|
+
...ProductPricingAdapter,
|
|
4
|
+
key: 'shop.unchained.pricing.quotation-price',
|
|
5
|
+
version: '1.0.0',
|
|
6
|
+
label: 'Apply negotiated quotation price',
|
|
7
|
+
orderIndex: 20,
|
|
8
|
+
isActivatedFor: (context) => {
|
|
9
|
+
return Boolean(context.quotationId);
|
|
10
|
+
},
|
|
11
|
+
actions: (params) => {
|
|
12
|
+
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
13
|
+
return {
|
|
14
|
+
...pricingAdapter,
|
|
15
|
+
calculate: async () => {
|
|
16
|
+
const { quotationId, currencyCode, quantity, modules } = params.context;
|
|
17
|
+
const quotation = await modules.quotations.findQuotation({ quotationId: quotationId });
|
|
18
|
+
const isApplicable = quotation &&
|
|
19
|
+
quotation.price != null &&
|
|
20
|
+
quotation.currencyCode === currencyCode &&
|
|
21
|
+
(modules.quotations.isProposalValid(quotation) ||
|
|
22
|
+
modules.quotations.normalizedStatus(quotation) === 'FULFILLED');
|
|
23
|
+
if (isApplicable) {
|
|
24
|
+
const negotiatedTotal = Math.round(quotation.price) * quantity;
|
|
25
|
+
const correction = negotiatedTotal - params.calculationSheet.sum();
|
|
26
|
+
if (correction !== 0) {
|
|
27
|
+
pricingAdapter.resultSheet().addItem({
|
|
28
|
+
amount: correction,
|
|
29
|
+
isTaxable: false,
|
|
30
|
+
isNetPrice: false,
|
|
31
|
+
meta: { adapter: ProductQuotationPrice.key, quotationId: quotation._id },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return pricingAdapter.calculate();
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
ProductPricingDirector.registerAdapter(ProductQuotationPrice);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ProductPricingAdapter, ProductPricingRowCategory, } from '@unchainedshop/core';
|
|
2
|
+
import { resolveTaxCategoryFromDeliveryProvider, resolveTaxCategoryFromProduct, SwissTaxCategories, } from "../tax/ch.js";
|
|
3
|
+
import isDeliveryAddressInCountry from "../utils/isDeliveryAddressInCountry.js";
|
|
4
|
+
import { applyTaxRateToTaxableRows } from "../tax/applyTaxRateToTaxableRows.js";
|
|
5
|
+
export const ProductSwissTax = {
|
|
6
|
+
...ProductPricingAdapter,
|
|
7
|
+
key: 'shop.unchained.pricing.product-swiss-tax',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
label: 'Apply Swiss Tax on Product',
|
|
10
|
+
orderIndex: 80,
|
|
11
|
+
isActivatedFor: () => {
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
actions: (params) => {
|
|
15
|
+
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
16
|
+
const { context } = params;
|
|
17
|
+
return {
|
|
18
|
+
...pricingAdapter,
|
|
19
|
+
calculate: async () => {
|
|
20
|
+
const orderDelivery = context.order?.deliveryId
|
|
21
|
+
? await context.modules.orders.deliveries.findDelivery({
|
|
22
|
+
orderDeliveryId: context.order?.deliveryId,
|
|
23
|
+
})
|
|
24
|
+
: null;
|
|
25
|
+
if (!isDeliveryAddressInCountry({
|
|
26
|
+
...context,
|
|
27
|
+
orderDelivery,
|
|
28
|
+
}, ['CH', 'LI'])) {
|
|
29
|
+
return pricingAdapter.calculate();
|
|
30
|
+
}
|
|
31
|
+
let taxCategory = resolveTaxCategoryFromProduct(context.product);
|
|
32
|
+
if (!taxCategory) {
|
|
33
|
+
const provider = orderDelivery?.deliveryProviderId
|
|
34
|
+
? await context.modules.delivery.findProvider({
|
|
35
|
+
deliveryProviderId: orderDelivery?.deliveryProviderId,
|
|
36
|
+
})
|
|
37
|
+
: null;
|
|
38
|
+
if (provider)
|
|
39
|
+
taxCategory = resolveTaxCategoryFromDeliveryProvider(provider);
|
|
40
|
+
}
|
|
41
|
+
if (!taxCategory)
|
|
42
|
+
taxCategory = SwissTaxCategories.DEFAULT;
|
|
43
|
+
const taxRate = taxCategory.rate(context.order?.ordered);
|
|
44
|
+
ProductPricingAdapter.log(`ProductSwissTax -> Tax Multiplicator: ${taxRate}`);
|
|
45
|
+
applyTaxRateToTaxableRows({
|
|
46
|
+
calculationSheet: params.calculationSheet,
|
|
47
|
+
resultSheet: pricingAdapter.resultSheet(),
|
|
48
|
+
taxRate,
|
|
49
|
+
baseCategory: ProductPricingRowCategory.Item,
|
|
50
|
+
adapterKey: ProductSwissTax.key,
|
|
51
|
+
});
|
|
52
|
+
return pricingAdapter.calculate();
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
export default ProductSwissTax;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { ProductSwissTax } from "./adapter.js";
|
|
3
|
+
export const ProductSwissTaxPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.product-swiss-tax',
|
|
5
|
+
label: 'Product Swiss Tax Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [ProductSwissTax],
|
|
8
|
+
};
|
|
9
|
+
export default ProductSwissTaxPlugin;
|
|
10
|
+
export { ProductSwissTax } from "./adapter.js";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ProductPricingAdapter, ProductPricingRowCategory, } from '@unchainedshop/core';
|
|
2
|
+
import { resolveUkTaxCategoryFromDeliveryProvider, resolveUkTaxCategoryFromProduct, UkTaxCategories, UK_VAT_COUNTRY_CODES, } from "../tax/uk.js";
|
|
3
|
+
import isDeliveryAddressInCountry from "../utils/isDeliveryAddressInCountry.js";
|
|
4
|
+
import { applyTaxRateToTaxableRows } from "../tax/applyTaxRateToTaxableRows.js";
|
|
5
|
+
export const ProductUkTax = {
|
|
6
|
+
...ProductPricingAdapter,
|
|
7
|
+
key: 'shop.unchained.pricing.product-uk-tax',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
label: 'Apply UK VAT on Product',
|
|
10
|
+
orderIndex: 80,
|
|
11
|
+
isActivatedFor: () => {
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
actions: (params) => {
|
|
15
|
+
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
16
|
+
const { context } = params;
|
|
17
|
+
return {
|
|
18
|
+
...pricingAdapter,
|
|
19
|
+
calculate: async () => {
|
|
20
|
+
const orderDelivery = context.order?.deliveryId
|
|
21
|
+
? await context.modules.orders.deliveries.findDelivery({
|
|
22
|
+
orderDeliveryId: context.order?.deliveryId,
|
|
23
|
+
})
|
|
24
|
+
: null;
|
|
25
|
+
if (!isDeliveryAddressInCountry({
|
|
26
|
+
...context,
|
|
27
|
+
orderDelivery,
|
|
28
|
+
}, UK_VAT_COUNTRY_CODES)) {
|
|
29
|
+
return pricingAdapter.calculate();
|
|
30
|
+
}
|
|
31
|
+
let taxCategory = resolveUkTaxCategoryFromProduct(context.product);
|
|
32
|
+
if (!taxCategory) {
|
|
33
|
+
const provider = orderDelivery?.deliveryProviderId
|
|
34
|
+
? await context.modules.delivery.findProvider({
|
|
35
|
+
deliveryProviderId: orderDelivery?.deliveryProviderId,
|
|
36
|
+
})
|
|
37
|
+
: null;
|
|
38
|
+
if (provider)
|
|
39
|
+
taxCategory = resolveUkTaxCategoryFromDeliveryProvider(provider);
|
|
40
|
+
}
|
|
41
|
+
if (!taxCategory)
|
|
42
|
+
taxCategory = UkTaxCategories.STANDARD;
|
|
43
|
+
const taxRate = taxCategory.rate(context.order?.ordered);
|
|
44
|
+
ProductPricingAdapter.log(`ProductUkTax -> Tax Multiplicator: ${taxRate}`);
|
|
45
|
+
applyTaxRateToTaxableRows({
|
|
46
|
+
calculationSheet: params.calculationSheet,
|
|
47
|
+
resultSheet: pricingAdapter.resultSheet(),
|
|
48
|
+
taxRate,
|
|
49
|
+
baseCategory: ProductPricingRowCategory.Item,
|
|
50
|
+
adapterKey: ProductUkTax.key,
|
|
51
|
+
});
|
|
52
|
+
return pricingAdapter.calculate();
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
export default ProductUkTax;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { ProductUkTax } from "./adapter.js";
|
|
3
|
+
export const ProductUkTaxPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.product-uk-tax',
|
|
5
|
+
label: 'Product UK Tax Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [ProductUkTax],
|
|
8
|
+
};
|
|
9
|
+
export default ProductUkTaxPlugin;
|
|
10
|
+
export { ProductUkTax } from "./adapter.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ProductPricingAdapter, ProductPricingRowCategory, } from '@unchainedshop/core';
|
|
2
|
+
import { US_COUNTRY_CODE, isProductExemptFromUsSalesTax, resolveUsSalesTaxRate } from "../tax/us.js";
|
|
3
|
+
import resolveDeliveryLocation from "../utils/resolveDeliveryLocation.js";
|
|
4
|
+
import { applyTaxRateToTaxableRows } from "../tax/applyTaxRateToTaxableRows.js";
|
|
5
|
+
export const ProductUsSalesTax = {
|
|
6
|
+
...ProductPricingAdapter,
|
|
7
|
+
key: 'shop.unchained.pricing.product-us-sales-tax',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
label: 'Apply US State Sales Tax on Product',
|
|
10
|
+
orderIndex: 80,
|
|
11
|
+
isActivatedFor: () => {
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
actions: (params) => {
|
|
15
|
+
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
16
|
+
const { context } = params;
|
|
17
|
+
return {
|
|
18
|
+
...pricingAdapter,
|
|
19
|
+
calculate: async () => {
|
|
20
|
+
if (isProductExemptFromUsSalesTax(context.product)) {
|
|
21
|
+
return pricingAdapter.calculate();
|
|
22
|
+
}
|
|
23
|
+
const orderDelivery = context.order?.deliveryId
|
|
24
|
+
? await context.modules.orders.deliveries.findDelivery({
|
|
25
|
+
orderDeliveryId: context.order?.deliveryId,
|
|
26
|
+
})
|
|
27
|
+
: null;
|
|
28
|
+
const { countryCode, regionCode } = resolveDeliveryLocation({ ...context, orderDelivery });
|
|
29
|
+
if (countryCode !== US_COUNTRY_CODE)
|
|
30
|
+
return pricingAdapter.calculate();
|
|
31
|
+
const taxRate = resolveUsSalesTaxRate({
|
|
32
|
+
regionCode,
|
|
33
|
+
referenceDate: context.order?.ordered,
|
|
34
|
+
});
|
|
35
|
+
if (taxRate === null) {
|
|
36
|
+
ProductPricingAdapter.log(`ProductUsSalesTax -> unknown state '${regionCode}', no sales tax applied`);
|
|
37
|
+
return pricingAdapter.calculate();
|
|
38
|
+
}
|
|
39
|
+
ProductPricingAdapter.log(`ProductUsSalesTax -> Tax Multiplicator: ${taxRate}`);
|
|
40
|
+
applyTaxRateToTaxableRows({
|
|
41
|
+
calculationSheet: params.calculationSheet,
|
|
42
|
+
resultSheet: pricingAdapter.resultSheet(),
|
|
43
|
+
taxRate,
|
|
44
|
+
baseCategory: ProductPricingRowCategory.Item,
|
|
45
|
+
adapterKey: ProductUsSalesTax.key,
|
|
46
|
+
});
|
|
47
|
+
return pricingAdapter.calculate();
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export default ProductUsSalesTax;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { ProductUsSalesTax } from "./adapter.js";
|
|
3
|
+
export const ProductUsSalesTaxPlugin = {
|
|
4
|
+
key: 'shop.unchained.pricing.product-us-sales-tax',
|
|
5
|
+
label: 'Product US Sales Tax Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [ProductUsSalesTax],
|
|
8
|
+
};
|
|
9
|
+
export default ProductUsSalesTaxPlugin;
|
|
10
|
+
export { ProductUsSalesTax } from "./adapter.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QuotationAdapter } from '@unchainedshop/core';
|
|
2
|
+
export const ManualOffering = {
|
|
3
|
+
...QuotationAdapter,
|
|
4
|
+
key: 'shop.unchained.quotations.manual',
|
|
5
|
+
version: '1.0.0',
|
|
6
|
+
label: 'Manual Offerings',
|
|
7
|
+
orderIndex: 0,
|
|
8
|
+
isActivatedFor: () => true,
|
|
9
|
+
actions: (params) => {
|
|
10
|
+
return {
|
|
11
|
+
...QuotationAdapter.actions(params),
|
|
12
|
+
quote: async () => {
|
|
13
|
+
const { quotation } = params;
|
|
14
|
+
const price = Number(quotation?.context?.price);
|
|
15
|
+
return {
|
|
16
|
+
expires: quotation?.context?.expires
|
|
17
|
+
? new Date(quotation.context.expires)
|
|
18
|
+
: new Date(new Date().getTime() + 3600 * 1000),
|
|
19
|
+
price: Number.isFinite(price) && price > 0 ? Math.round(price) : undefined,
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { ManualOffering } from "./adapter.js";
|
|
3
|
+
export const ManualOfferingPlugin = {
|
|
4
|
+
key: 'shop.unchained.quotations.manual',
|
|
5
|
+
label: 'Manual Offering Quotation Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [ManualOffering],
|
|
8
|
+
};
|
|
9
|
+
export default ManualOfferingPlugin;
|
|
10
|
+
export { ManualOffering } from "./adapter.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UnchainedCore } from '@unchainedshop/core';
|
|
2
|
+
export declare function ercMetadataHandler(request: Request, context: UnchainedCore & {
|
|
3
|
+
params: Record<string, string>;
|
|
4
|
+
locale?: Intl.Locale;
|
|
5
|
+
loaders?: {
|
|
6
|
+
productLoader: {
|
|
7
|
+
load: (params: {
|
|
8
|
+
productId: string;
|
|
9
|
+
}) => Promise<any>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}): Promise<Response>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import { ProductContractStandard } from '@unchainedshop/core-products';
|
|
3
|
+
import { systemLocale } from '@unchainedshop/utils';
|
|
4
|
+
const logger = createLogger('unchained:erc-metadata');
|
|
5
|
+
export async function ercMetadataHandler(request, context) {
|
|
6
|
+
try {
|
|
7
|
+
const { ROOT_URL = 'http://localhost:4010' } = process.env;
|
|
8
|
+
const { services, modules, locale, loaders, params } = context;
|
|
9
|
+
const url = new URL(request.url, ROOT_URL);
|
|
10
|
+
if (!url.pathname.toLowerCase().endsWith('.json')) {
|
|
11
|
+
throw new Error('Invalid ERC Metadata URI');
|
|
12
|
+
}
|
|
13
|
+
const { productId, localeOrTokenFilename, tokenFileName } = params;
|
|
14
|
+
const product = loaders
|
|
15
|
+
? await loaders.productLoader.load({ productId })
|
|
16
|
+
: await modules.products.findProduct({ productId });
|
|
17
|
+
const tokenSelector = {
|
|
18
|
+
contractAddress: product?.tokenization?.contractAddress,
|
|
19
|
+
};
|
|
20
|
+
if (product?.tokenization?.contractStandard !== ProductContractStandard.ERC721) {
|
|
21
|
+
tokenSelector.tokenSerialNumber = (tokenFileName || localeOrTokenFilename)
|
|
22
|
+
.toLowerCase()
|
|
23
|
+
.replace('.json', '');
|
|
24
|
+
}
|
|
25
|
+
const [token] = await modules.warehousing.findTokens(tokenSelector);
|
|
26
|
+
const resolvedLocale = tokenFileName
|
|
27
|
+
? new Intl.Locale(localeOrTokenFilename)
|
|
28
|
+
: locale || systemLocale;
|
|
29
|
+
const ercMetadata = await services.warehousing.ercMetadata({
|
|
30
|
+
product,
|
|
31
|
+
token,
|
|
32
|
+
locale: resolvedLocale,
|
|
33
|
+
});
|
|
34
|
+
if (!ercMetadata) {
|
|
35
|
+
return new Response(null, { status: 404 });
|
|
36
|
+
}
|
|
37
|
+
return Response.json(ercMetadata, { status: 200 });
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
logger.error(e);
|
|
41
|
+
return Response.json({ name: e.name, code: e.code, message: e.message }, { status: 503 });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ercMetadataHandler } from "./api.js";
|
|
2
|
+
const { ERC_METADATA_API_PATH = '/erc-metadata' } = process.env;
|
|
3
|
+
export const ERCMetadataPlugin = {
|
|
4
|
+
key: 'shop.unchained.warehousing.erc-metadata',
|
|
5
|
+
label: 'ERC Metadata Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
routes: [
|
|
8
|
+
{
|
|
9
|
+
path: `${ERC_METADATA_API_PATH}/:productId/:localeOrTokenFilename{/:tokenFileName}`,
|
|
10
|
+
method: 'GET',
|
|
11
|
+
handler: ercMetadataHandler,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
export default ERCMetadataPlugin;
|