@unchainedshop/plugins 4.8.25 → 4.8.26
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/pricing/tax/ch-tax-rates.json +1 -1
- package/lib/pricing/tax/eraRates.d.ts +3 -2
- package/lib/pricing/tax/eraRates.js +34 -8
- package/lib/pricing/tax/eu-tax-rates.json +33 -1
- package/lib/pricing/tax/eu.js +1 -1
- package/lib/pricing/tax/uk-tax-rates.json +1 -1
- package/lib/pricing/tax/us-tax-rates.json +63 -3
- package/lib/pricing/tax/us.js +1 -1
- package/package.json +1 -1
- package/lib/delivery/post/adapter.d.ts +0 -2
- package/lib/delivery/post/adapter.js +0 -22
- package/lib/delivery/post/index.d.ts +0 -4
- package/lib/delivery/post/index.js +0 -10
- package/lib/delivery/send-message/adapter.d.ts +0 -2
- package/lib/delivery/send-message/adapter.js +0 -39
- package/lib/delivery/send-message/index.d.ts +0 -4
- package/lib/delivery/send-message/index.js +0 -10
- package/lib/delivery/stores/adapter.d.ts +0 -2
- package/lib/delivery/stores/adapter.js +0 -42
- package/lib/delivery/stores/index.d.ts +0 -4
- package/lib/delivery/stores/index.js +0 -10
- package/lib/enrollments/licensed/adapter.d.ts +0 -6
- package/lib/enrollments/licensed/adapter.js +0 -51
- package/lib/enrollments/licensed/index.d.ts +0 -4
- package/lib/enrollments/licensed/index.js +0 -10
- package/lib/files/gridfs/api.d.ts +0 -7
- package/lib/files/gridfs/api.js +0 -163
- package/lib/files/minio/adapter.d.ts +0 -4
- package/lib/files/minio/adapter.js +0 -160
- package/lib/files/minio/api.d.ts +0 -2
- package/lib/files/minio/api.js +0 -40
- package/lib/files/temp-upload/api.d.ts +0 -8
- package/lib/files/temp-upload/api.js +0 -48
- package/lib/files/temp-upload/index.d.ts +0 -3
- package/lib/files/temp-upload/index.js +0 -15
- package/lib/filters/local-search/adapter.d.ts +0 -2
- package/lib/filters/local-search/adapter.js +0 -56
- package/lib/filters/local-search/index.d.ts +0 -4
- package/lib/filters/local-search/index.js +0 -10
- package/lib/filters/strict-equal/adapter.d.ts +0 -2
- package/lib/filters/strict-equal/adapter.js +0 -23
- package/lib/filters/strict-equal/index.d.ts +0 -4
- package/lib/filters/strict-equal/index.js +0 -10
- package/lib/payment/apple-iap/api.d.ts +0 -2
- package/lib/payment/apple-iap/api.js +0 -119
- package/lib/payment/cryptopay/adapter.d.ts +0 -2
- package/lib/payment/cryptopay/adapter.js +0 -157
- package/lib/payment/cryptopay/api.d.ts +0 -2
- package/lib/payment/cryptopay/api.js +0 -23
- package/lib/payment/datatrans-v2/adapter.d.ts +0 -2
- package/lib/payment/datatrans-v2/adapter.js +0 -417
- package/lib/payment/datatrans-v2/api.d.ts +0 -2
- package/lib/payment/datatrans-v2/api.js +0 -108
- package/lib/payment/invoice/adapter.d.ts +0 -2
- package/lib/payment/invoice/adapter.js +0 -26
- package/lib/payment/invoice/index.d.ts +0 -4
- package/lib/payment/invoice/index.js +0 -10
- package/lib/payment/invoice-prepaid/adapter.d.ts +0 -2
- package/lib/payment/invoice-prepaid/adapter.js +0 -29
- package/lib/payment/invoice-prepaid/index.d.ts +0 -4
- package/lib/payment/invoice-prepaid/index.js +0 -10
- package/lib/payment/payrexx/adapter.d.ts +0 -2
- package/lib/payment/payrexx/adapter.js +0 -161
- package/lib/payment/payrexx/api.d.ts +0 -2
- package/lib/payment/payrexx/api.js +0 -97
- package/lib/payment/postfinance-checkout/adapter.d.ts +0 -2
- package/lib/payment/postfinance-checkout/adapter.js +0 -189
- package/lib/payment/postfinance-checkout/webhook.d.ts +0 -2
- package/lib/payment/postfinance-checkout/webhook.js +0 -48
- package/lib/payment/saferpay/webhook.d.ts +0 -2
- package/lib/payment/saferpay/webhook.js +0 -64
- package/lib/payment/stripe/adapter.d.ts +0 -2
- package/lib/payment/stripe/adapter.js +0 -121
- package/lib/payment/stripe/api.d.ts +0 -6
- package/lib/payment/stripe/api.js +0 -165
- package/lib/pricing/delivery-eu-tax/adapter.d.ts +0 -3
- package/lib/pricing/delivery-eu-tax/adapter.js +0 -55
- package/lib/pricing/delivery-eu-tax/index.d.ts +0 -4
- package/lib/pricing/delivery-eu-tax/index.js +0 -10
- package/lib/pricing/delivery-swiss-tax/adapter.d.ts +0 -3
- package/lib/pricing/delivery-swiss-tax/adapter.js +0 -43
- package/lib/pricing/delivery-swiss-tax/index.d.ts +0 -4
- package/lib/pricing/delivery-swiss-tax/index.js +0 -10
- package/lib/pricing/delivery-uk-tax/adapter.d.ts +0 -3
- package/lib/pricing/delivery-uk-tax/adapter.js +0 -43
- package/lib/pricing/delivery-uk-tax/index.d.ts +0 -4
- package/lib/pricing/delivery-uk-tax/index.js +0 -10
- package/lib/pricing/delivery-us-sales-tax/adapter.d.ts +0 -3
- package/lib/pricing/delivery-us-sales-tax/adapter.js +0 -58
- package/lib/pricing/delivery-us-sales-tax/index.d.ts +0 -4
- package/lib/pricing/delivery-us-sales-tax/index.js +0 -10
- package/lib/pricing/discount-100-off/adapter.d.ts +0 -3
- package/lib/pricing/discount-100-off/adapter.js +0 -30
- package/lib/pricing/discount-100-off/index.d.ts +0 -4
- package/lib/pricing/discount-100-off/index.js +0 -10
- package/lib/pricing/discount-half-price-manual/adapter.d.ts +0 -3
- package/lib/pricing/discount-half-price-manual/adapter.js +0 -30
- package/lib/pricing/discount-half-price-manual/index.d.ts +0 -4
- package/lib/pricing/discount-half-price-manual/index.js +0 -10
- package/lib/pricing/free-delivery/adapter.d.ts +0 -3
- package/lib/pricing/free-delivery/adapter.js +0 -27
- package/lib/pricing/free-delivery/index.d.ts +0 -4
- package/lib/pricing/free-delivery/index.js +0 -10
- package/lib/pricing/free-payment/adapter.d.ts +0 -3
- package/lib/pricing/free-payment/adapter.js +0 -27
- package/lib/pricing/free-payment/index.d.ts +0 -4
- package/lib/pricing/free-payment/index.js +0 -10
- package/lib/pricing/order-delivery/adapter.d.ts +0 -3
- package/lib/pricing/order-delivery/adapter.js +0 -33
- package/lib/pricing/order-delivery/index.d.ts +0 -4
- package/lib/pricing/order-delivery/index.js +0 -10
- package/lib/pricing/order-discount/adapter.d.ts +0 -3
- package/lib/pricing/order-discount/adapter.js +0 -74
- package/lib/pricing/order-discount/index.d.ts +0 -4
- package/lib/pricing/order-discount/index.js +0 -10
- package/lib/pricing/order-items/adapter.d.ts +0 -3
- package/lib/pricing/order-items/adapter.js +0 -43
- package/lib/pricing/order-items/index.d.ts +0 -4
- package/lib/pricing/order-items/index.js +0 -10
- package/lib/pricing/order-payment/adapter.d.ts +0 -3
- package/lib/pricing/order-payment/adapter.js +0 -33
- package/lib/pricing/order-payment/index.d.ts +0 -4
- package/lib/pricing/order-payment/index.js +0 -10
- package/lib/pricing/product-catalog-price/adapter.d.ts +0 -3
- package/lib/pricing/product-catalog-price/adapter.js +0 -60
- package/lib/pricing/product-catalog-price/index.d.ts +0 -4
- package/lib/pricing/product-catalog-price/index.js +0 -10
- package/lib/pricing/product-discount/adapter.d.ts +0 -3
- package/lib/pricing/product-discount/adapter.js +0 -69
- package/lib/pricing/product-discount/index.d.ts +0 -4
- package/lib/pricing/product-discount/index.js +0 -10
- package/lib/pricing/product-eu-tax/adapter.d.ts +0 -3
- package/lib/pricing/product-eu-tax/adapter.js +0 -56
- package/lib/pricing/product-eu-tax/index.d.ts +0 -4
- package/lib/pricing/product-eu-tax/index.js +0 -10
- package/lib/pricing/product-price-rateconversion/adapter.d.ts +0 -3
- package/lib/pricing/product-price-rateconversion/adapter.js +0 -53
- package/lib/pricing/product-price-rateconversion/index.d.ts +0 -4
- package/lib/pricing/product-price-rateconversion/index.js +0 -10
- package/lib/pricing/product-quotation-price.d.ts +0 -2
- package/lib/pricing/product-quotation-price.js +0 -40
- package/lib/pricing/product-swiss-tax/adapter.d.ts +0 -3
- package/lib/pricing/product-swiss-tax/adapter.js +0 -57
- package/lib/pricing/product-swiss-tax/index.d.ts +0 -4
- package/lib/pricing/product-swiss-tax/index.js +0 -10
- package/lib/pricing/product-uk-tax/adapter.d.ts +0 -3
- package/lib/pricing/product-uk-tax/adapter.js +0 -57
- package/lib/pricing/product-uk-tax/index.d.ts +0 -4
- package/lib/pricing/product-uk-tax/index.js +0 -10
- package/lib/pricing/product-us-sales-tax/adapter.d.ts +0 -3
- package/lib/pricing/product-us-sales-tax/adapter.js +0 -52
- package/lib/pricing/product-us-sales-tax/index.d.ts +0 -4
- package/lib/pricing/product-us-sales-tax/index.js +0 -10
- package/lib/quotations/manual/adapter.d.ts +0 -2
- package/lib/quotations/manual/adapter.js +0 -24
- package/lib/quotations/manual/index.d.ts +0 -4
- package/lib/quotations/manual/index.js +0 -10
- package/lib/warehousing/erc-metadata/api.d.ts +0 -12
- package/lib/warehousing/erc-metadata/api.js +0 -43
- package/lib/warehousing/erc-metadata/index.d.ts +0 -3
- package/lib/warehousing/erc-metadata/index.js +0 -15
- package/lib/warehousing/eth-minter/adapter.d.ts +0 -2
- package/lib/warehousing/eth-minter/adapter.js +0 -119
- package/lib/warehousing/eth-minter/index.d.ts +0 -4
- package/lib/warehousing/eth-minter/index.js +0 -10
- package/lib/warehousing/store/adapter.d.ts +0 -2
- package/lib/warehousing/store/adapter.js +0 -33
- package/lib/warehousing/store/index.d.ts +0 -4
- package/lib/warehousing/store/index.js +0 -10
- package/lib/worker/budgetsms/adapter.d.ts +0 -22
- package/lib/worker/budgetsms/adapter.js +0 -169
- package/lib/worker/budgetsms/index.d.ts +0 -4
- package/lib/worker/budgetsms/index.js +0 -10
- package/lib/worker/bulk-export/adapter.d.ts +0 -3
- package/lib/worker/bulk-export/adapter.js +0 -64
- package/lib/worker/bulk-export/index.d.ts +0 -4
- package/lib/worker/bulk-export/index.js +0 -10
- package/lib/worker/bulk-import/adapter.d.ts +0 -3
- package/lib/worker/bulk-import/adapter.js +0 -65
- package/lib/worker/bulk-import/api.d.ts +0 -9
- package/lib/worker/bulk-import/api.js +0 -52
- package/lib/worker/bulk-import/index.d.ts +0 -4
- package/lib/worker/bulk-import/index.js +0 -18
- package/lib/worker/bulkgate/adapter.d.ts +0 -12
- package/lib/worker/bulkgate/adapter.js +0 -91
- package/lib/worker/bulkgate/index.d.ts +0 -4
- package/lib/worker/bulkgate/index.js +0 -10
- package/lib/worker/email/adapter.d.ts +0 -9
- package/lib/worker/email/adapter.js +0 -150
- package/lib/worker/email/index.d.ts +0 -4
- package/lib/worker/email/index.js +0 -10
- package/lib/worker/enrollment-order-generator/adapter.d.ts +0 -4
- package/lib/worker/enrollment-order-generator/adapter.js +0 -77
- package/lib/worker/enrollment-order-generator/index.d.ts +0 -4
- package/lib/worker/enrollment-order-generator/index.js +0 -13
- package/lib/worker/error-notifications/adapter.d.ts +0 -10
- package/lib/worker/error-notifications/adapter.js +0 -62
- package/lib/worker/error-notifications/index.d.ts +0 -4
- package/lib/worker/error-notifications/index.js +0 -13
- package/lib/worker/export-token/adapter.d.ts +0 -4
- package/lib/worker/export-token/adapter.js +0 -25
- package/lib/worker/export-token/index.d.ts +0 -4
- package/lib/worker/export-token/index.js +0 -13
- package/lib/worker/external/adapter.d.ts +0 -3
- package/lib/worker/external/adapter.js +0 -13
- package/lib/worker/external/index.d.ts +0 -4
- package/lib/worker/external/index.js +0 -10
- package/lib/worker/gc-guests/adapter.d.ts +0 -9
- package/lib/worker/gc-guests/adapter.js +0 -56
- package/lib/worker/gc-guests/index.d.ts +0 -4
- package/lib/worker/gc-guests/index.js +0 -13
- package/lib/worker/heartbeat/adapter.d.ts +0 -8
- package/lib/worker/heartbeat/adapter.js +0 -26
- package/lib/worker/heartbeat/index.d.ts +0 -4
- package/lib/worker/heartbeat/index.js +0 -10
- package/lib/worker/http-request/adapter.d.ts +0 -8
- package/lib/worker/http-request/adapter.js +0 -55
- package/lib/worker/http-request/index.d.ts +0 -4
- package/lib/worker/http-request/index.js +0 -10
- package/lib/worker/invalidate-carts/adapter.d.ts +0 -9
- package/lib/worker/invalidate-carts/adapter.js +0 -52
- package/lib/worker/invalidate-carts/index.d.ts +0 -4
- package/lib/worker/invalidate-carts/index.js +0 -13
- package/lib/worker/message/adapter.d.ts +0 -11
- package/lib/worker/message/adapter.js +0 -42
- package/lib/worker/message/index.d.ts +0 -4
- package/lib/worker/message/index.js +0 -10
- package/lib/worker/push-notification/adapter.d.ts +0 -9
- package/lib/worker/push-notification/adapter.js +0 -87
- package/lib/worker/push-notification/index.d.ts +0 -4
- package/lib/worker/push-notification/index.js +0 -10
- package/lib/worker/twilio/adapter.d.ts +0 -8
- package/lib/worker/twilio/adapter.js +0 -59
- package/lib/worker/twilio/index.d.ts +0 -4
- package/lib/worker/twilio/index.js +0 -10
- package/lib/worker/update-coinbase-rates/adapter.d.ts +0 -4
- package/lib/worker/update-coinbase-rates/adapter.js +0 -59
- package/lib/worker/update-coinbase-rates/index.d.ts +0 -4
- package/lib/worker/update-coinbase-rates/index.js +0 -13
- package/lib/worker/update-ecb-rates/adapter.d.ts +0 -4
- package/lib/worker/update-ecb-rates/adapter.js +0 -94
- package/lib/worker/update-ecb-rates/index.d.ts +0 -4
- package/lib/worker/update-ecb-rates/index.js +0 -13
- package/lib/worker/update-token-ownership/adapter.d.ts +0 -5
- package/lib/worker/update-token-ownership/adapter.js +0 -58
- package/lib/worker/update-token-ownership/index.d.ts +0 -4
- package/lib/worker/update-token-ownership/index.js +0 -13
- package/lib/worker/zombie-killer/adapter.d.ts +0 -15
- package/lib/worker/zombie-killer/adapter.js +0 -113
- package/lib/worker/zombie-killer/index.d.ts +0 -4
- package/lib/worker/zombie-killer/index.js +0 -13
|
@@ -1,56 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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";
|
|
@@ -1,53 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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";
|
|
@@ -1,40 +0,0 @@
|
|
|
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);
|
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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";
|
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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";
|
|
@@ -1,52 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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";
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
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";
|
|
@@ -1,12 +0,0 @@
|
|
|
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>;
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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;
|