@unchainedshop/plugins 4.8.24 → 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.
Files changed (252) hide show
  1. package/lib/payment/stripe/stripe.js +1 -1
  2. package/lib/pricing/tax/ch-tax-rates.json +1 -1
  3. package/lib/pricing/tax/eraRates.d.ts +3 -2
  4. package/lib/pricing/tax/eraRates.js +34 -8
  5. package/lib/pricing/tax/eu-tax-rates.json +33 -1
  6. package/lib/pricing/tax/eu.js +1 -1
  7. package/lib/pricing/tax/uk-tax-rates.json +1 -1
  8. package/lib/pricing/tax/us-tax-rates.json +63 -3
  9. package/lib/pricing/tax/us.js +1 -1
  10. package/package.json +1 -1
  11. package/lib/delivery/post/adapter.d.ts +0 -2
  12. package/lib/delivery/post/adapter.js +0 -22
  13. package/lib/delivery/post/index.d.ts +0 -4
  14. package/lib/delivery/post/index.js +0 -10
  15. package/lib/delivery/send-message/adapter.d.ts +0 -2
  16. package/lib/delivery/send-message/adapter.js +0 -39
  17. package/lib/delivery/send-message/index.d.ts +0 -4
  18. package/lib/delivery/send-message/index.js +0 -10
  19. package/lib/delivery/stores/adapter.d.ts +0 -2
  20. package/lib/delivery/stores/adapter.js +0 -42
  21. package/lib/delivery/stores/index.d.ts +0 -4
  22. package/lib/delivery/stores/index.js +0 -10
  23. package/lib/enrollments/licensed/adapter.d.ts +0 -6
  24. package/lib/enrollments/licensed/adapter.js +0 -51
  25. package/lib/enrollments/licensed/index.d.ts +0 -4
  26. package/lib/enrollments/licensed/index.js +0 -10
  27. package/lib/files/gridfs/api.d.ts +0 -7
  28. package/lib/files/gridfs/api.js +0 -163
  29. package/lib/files/minio/adapter.d.ts +0 -4
  30. package/lib/files/minio/adapter.js +0 -160
  31. package/lib/files/minio/api.d.ts +0 -2
  32. package/lib/files/minio/api.js +0 -40
  33. package/lib/files/temp-upload/api.d.ts +0 -8
  34. package/lib/files/temp-upload/api.js +0 -48
  35. package/lib/files/temp-upload/index.d.ts +0 -3
  36. package/lib/files/temp-upload/index.js +0 -15
  37. package/lib/filters/local-search/adapter.d.ts +0 -2
  38. package/lib/filters/local-search/adapter.js +0 -56
  39. package/lib/filters/local-search/index.d.ts +0 -4
  40. package/lib/filters/local-search/index.js +0 -10
  41. package/lib/filters/strict-equal/adapter.d.ts +0 -2
  42. package/lib/filters/strict-equal/adapter.js +0 -23
  43. package/lib/filters/strict-equal/index.d.ts +0 -4
  44. package/lib/filters/strict-equal/index.js +0 -10
  45. package/lib/payment/apple-iap/api.d.ts +0 -2
  46. package/lib/payment/apple-iap/api.js +0 -119
  47. package/lib/payment/cryptopay/adapter.d.ts +0 -2
  48. package/lib/payment/cryptopay/adapter.js +0 -157
  49. package/lib/payment/cryptopay/api.d.ts +0 -2
  50. package/lib/payment/cryptopay/api.js +0 -23
  51. package/lib/payment/datatrans-v2/adapter.d.ts +0 -2
  52. package/lib/payment/datatrans-v2/adapter.js +0 -417
  53. package/lib/payment/datatrans-v2/api.d.ts +0 -2
  54. package/lib/payment/datatrans-v2/api.js +0 -108
  55. package/lib/payment/invoice/adapter.d.ts +0 -2
  56. package/lib/payment/invoice/adapter.js +0 -26
  57. package/lib/payment/invoice/index.d.ts +0 -4
  58. package/lib/payment/invoice/index.js +0 -10
  59. package/lib/payment/invoice-prepaid/adapter.d.ts +0 -2
  60. package/lib/payment/invoice-prepaid/adapter.js +0 -29
  61. package/lib/payment/invoice-prepaid/index.d.ts +0 -4
  62. package/lib/payment/invoice-prepaid/index.js +0 -10
  63. package/lib/payment/payrexx/adapter.d.ts +0 -2
  64. package/lib/payment/payrexx/adapter.js +0 -161
  65. package/lib/payment/payrexx/api.d.ts +0 -2
  66. package/lib/payment/payrexx/api.js +0 -97
  67. package/lib/payment/postfinance-checkout/adapter.d.ts +0 -2
  68. package/lib/payment/postfinance-checkout/adapter.js +0 -189
  69. package/lib/payment/postfinance-checkout/webhook.d.ts +0 -2
  70. package/lib/payment/postfinance-checkout/webhook.js +0 -48
  71. package/lib/payment/saferpay/webhook.d.ts +0 -2
  72. package/lib/payment/saferpay/webhook.js +0 -64
  73. package/lib/payment/stripe/adapter.d.ts +0 -2
  74. package/lib/payment/stripe/adapter.js +0 -121
  75. package/lib/payment/stripe/api.d.ts +0 -6
  76. package/lib/payment/stripe/api.js +0 -165
  77. package/lib/pricing/delivery-eu-tax/adapter.d.ts +0 -3
  78. package/lib/pricing/delivery-eu-tax/adapter.js +0 -55
  79. package/lib/pricing/delivery-eu-tax/index.d.ts +0 -4
  80. package/lib/pricing/delivery-eu-tax/index.js +0 -10
  81. package/lib/pricing/delivery-swiss-tax/adapter.d.ts +0 -3
  82. package/lib/pricing/delivery-swiss-tax/adapter.js +0 -43
  83. package/lib/pricing/delivery-swiss-tax/index.d.ts +0 -4
  84. package/lib/pricing/delivery-swiss-tax/index.js +0 -10
  85. package/lib/pricing/delivery-uk-tax/adapter.d.ts +0 -3
  86. package/lib/pricing/delivery-uk-tax/adapter.js +0 -43
  87. package/lib/pricing/delivery-uk-tax/index.d.ts +0 -4
  88. package/lib/pricing/delivery-uk-tax/index.js +0 -10
  89. package/lib/pricing/delivery-us-sales-tax/adapter.d.ts +0 -3
  90. package/lib/pricing/delivery-us-sales-tax/adapter.js +0 -58
  91. package/lib/pricing/delivery-us-sales-tax/index.d.ts +0 -4
  92. package/lib/pricing/delivery-us-sales-tax/index.js +0 -10
  93. package/lib/pricing/discount-100-off/adapter.d.ts +0 -3
  94. package/lib/pricing/discount-100-off/adapter.js +0 -30
  95. package/lib/pricing/discount-100-off/index.d.ts +0 -4
  96. package/lib/pricing/discount-100-off/index.js +0 -10
  97. package/lib/pricing/discount-half-price-manual/adapter.d.ts +0 -3
  98. package/lib/pricing/discount-half-price-manual/adapter.js +0 -30
  99. package/lib/pricing/discount-half-price-manual/index.d.ts +0 -4
  100. package/lib/pricing/discount-half-price-manual/index.js +0 -10
  101. package/lib/pricing/free-delivery/adapter.d.ts +0 -3
  102. package/lib/pricing/free-delivery/adapter.js +0 -27
  103. package/lib/pricing/free-delivery/index.d.ts +0 -4
  104. package/lib/pricing/free-delivery/index.js +0 -10
  105. package/lib/pricing/free-payment/adapter.d.ts +0 -3
  106. package/lib/pricing/free-payment/adapter.js +0 -27
  107. package/lib/pricing/free-payment/index.d.ts +0 -4
  108. package/lib/pricing/free-payment/index.js +0 -10
  109. package/lib/pricing/order-delivery/adapter.d.ts +0 -3
  110. package/lib/pricing/order-delivery/adapter.js +0 -33
  111. package/lib/pricing/order-delivery/index.d.ts +0 -4
  112. package/lib/pricing/order-delivery/index.js +0 -10
  113. package/lib/pricing/order-discount/adapter.d.ts +0 -3
  114. package/lib/pricing/order-discount/adapter.js +0 -74
  115. package/lib/pricing/order-discount/index.d.ts +0 -4
  116. package/lib/pricing/order-discount/index.js +0 -10
  117. package/lib/pricing/order-items/adapter.d.ts +0 -3
  118. package/lib/pricing/order-items/adapter.js +0 -43
  119. package/lib/pricing/order-items/index.d.ts +0 -4
  120. package/lib/pricing/order-items/index.js +0 -10
  121. package/lib/pricing/order-payment/adapter.d.ts +0 -3
  122. package/lib/pricing/order-payment/adapter.js +0 -33
  123. package/lib/pricing/order-payment/index.d.ts +0 -4
  124. package/lib/pricing/order-payment/index.js +0 -10
  125. package/lib/pricing/product-catalog-price/adapter.d.ts +0 -3
  126. package/lib/pricing/product-catalog-price/adapter.js +0 -60
  127. package/lib/pricing/product-catalog-price/index.d.ts +0 -4
  128. package/lib/pricing/product-catalog-price/index.js +0 -10
  129. package/lib/pricing/product-discount/adapter.d.ts +0 -3
  130. package/lib/pricing/product-discount/adapter.js +0 -69
  131. package/lib/pricing/product-discount/index.d.ts +0 -4
  132. package/lib/pricing/product-discount/index.js +0 -10
  133. package/lib/pricing/product-eu-tax/adapter.d.ts +0 -3
  134. package/lib/pricing/product-eu-tax/adapter.js +0 -56
  135. package/lib/pricing/product-eu-tax/index.d.ts +0 -4
  136. package/lib/pricing/product-eu-tax/index.js +0 -10
  137. package/lib/pricing/product-price-rateconversion/adapter.d.ts +0 -3
  138. package/lib/pricing/product-price-rateconversion/adapter.js +0 -53
  139. package/lib/pricing/product-price-rateconversion/index.d.ts +0 -4
  140. package/lib/pricing/product-price-rateconversion/index.js +0 -10
  141. package/lib/pricing/product-quotation-price.d.ts +0 -2
  142. package/lib/pricing/product-quotation-price.js +0 -40
  143. package/lib/pricing/product-swiss-tax/adapter.d.ts +0 -3
  144. package/lib/pricing/product-swiss-tax/adapter.js +0 -57
  145. package/lib/pricing/product-swiss-tax/index.d.ts +0 -4
  146. package/lib/pricing/product-swiss-tax/index.js +0 -10
  147. package/lib/pricing/product-uk-tax/adapter.d.ts +0 -3
  148. package/lib/pricing/product-uk-tax/adapter.js +0 -57
  149. package/lib/pricing/product-uk-tax/index.d.ts +0 -4
  150. package/lib/pricing/product-uk-tax/index.js +0 -10
  151. package/lib/pricing/product-us-sales-tax/adapter.d.ts +0 -3
  152. package/lib/pricing/product-us-sales-tax/adapter.js +0 -52
  153. package/lib/pricing/product-us-sales-tax/index.d.ts +0 -4
  154. package/lib/pricing/product-us-sales-tax/index.js +0 -10
  155. package/lib/quotations/manual/adapter.d.ts +0 -2
  156. package/lib/quotations/manual/adapter.js +0 -24
  157. package/lib/quotations/manual/index.d.ts +0 -4
  158. package/lib/quotations/manual/index.js +0 -10
  159. package/lib/warehousing/erc-metadata/api.d.ts +0 -12
  160. package/lib/warehousing/erc-metadata/api.js +0 -43
  161. package/lib/warehousing/erc-metadata/index.d.ts +0 -3
  162. package/lib/warehousing/erc-metadata/index.js +0 -15
  163. package/lib/warehousing/eth-minter/adapter.d.ts +0 -2
  164. package/lib/warehousing/eth-minter/adapter.js +0 -119
  165. package/lib/warehousing/eth-minter/index.d.ts +0 -4
  166. package/lib/warehousing/eth-minter/index.js +0 -10
  167. package/lib/warehousing/store/adapter.d.ts +0 -2
  168. package/lib/warehousing/store/adapter.js +0 -33
  169. package/lib/warehousing/store/index.d.ts +0 -4
  170. package/lib/warehousing/store/index.js +0 -10
  171. package/lib/worker/budgetsms/adapter.d.ts +0 -22
  172. package/lib/worker/budgetsms/adapter.js +0 -169
  173. package/lib/worker/budgetsms/index.d.ts +0 -4
  174. package/lib/worker/budgetsms/index.js +0 -10
  175. package/lib/worker/bulk-export/adapter.d.ts +0 -3
  176. package/lib/worker/bulk-export/adapter.js +0 -64
  177. package/lib/worker/bulk-export/index.d.ts +0 -4
  178. package/lib/worker/bulk-export/index.js +0 -10
  179. package/lib/worker/bulk-import/adapter.d.ts +0 -3
  180. package/lib/worker/bulk-import/adapter.js +0 -65
  181. package/lib/worker/bulk-import/api.d.ts +0 -9
  182. package/lib/worker/bulk-import/api.js +0 -52
  183. package/lib/worker/bulk-import/index.d.ts +0 -4
  184. package/lib/worker/bulk-import/index.js +0 -18
  185. package/lib/worker/bulkgate/adapter.d.ts +0 -12
  186. package/lib/worker/bulkgate/adapter.js +0 -91
  187. package/lib/worker/bulkgate/index.d.ts +0 -4
  188. package/lib/worker/bulkgate/index.js +0 -10
  189. package/lib/worker/email/adapter.d.ts +0 -9
  190. package/lib/worker/email/adapter.js +0 -150
  191. package/lib/worker/email/index.d.ts +0 -4
  192. package/lib/worker/email/index.js +0 -10
  193. package/lib/worker/enrollment-order-generator/adapter.d.ts +0 -4
  194. package/lib/worker/enrollment-order-generator/adapter.js +0 -77
  195. package/lib/worker/enrollment-order-generator/index.d.ts +0 -4
  196. package/lib/worker/enrollment-order-generator/index.js +0 -13
  197. package/lib/worker/error-notifications/adapter.d.ts +0 -10
  198. package/lib/worker/error-notifications/adapter.js +0 -62
  199. package/lib/worker/error-notifications/index.d.ts +0 -4
  200. package/lib/worker/error-notifications/index.js +0 -13
  201. package/lib/worker/export-token/adapter.d.ts +0 -4
  202. package/lib/worker/export-token/adapter.js +0 -25
  203. package/lib/worker/export-token/index.d.ts +0 -4
  204. package/lib/worker/export-token/index.js +0 -13
  205. package/lib/worker/external/adapter.d.ts +0 -3
  206. package/lib/worker/external/adapter.js +0 -13
  207. package/lib/worker/external/index.d.ts +0 -4
  208. package/lib/worker/external/index.js +0 -10
  209. package/lib/worker/gc-guests/adapter.d.ts +0 -9
  210. package/lib/worker/gc-guests/adapter.js +0 -56
  211. package/lib/worker/gc-guests/index.d.ts +0 -4
  212. package/lib/worker/gc-guests/index.js +0 -13
  213. package/lib/worker/heartbeat/adapter.d.ts +0 -8
  214. package/lib/worker/heartbeat/adapter.js +0 -26
  215. package/lib/worker/heartbeat/index.d.ts +0 -4
  216. package/lib/worker/heartbeat/index.js +0 -10
  217. package/lib/worker/http-request/adapter.d.ts +0 -8
  218. package/lib/worker/http-request/adapter.js +0 -55
  219. package/lib/worker/http-request/index.d.ts +0 -4
  220. package/lib/worker/http-request/index.js +0 -10
  221. package/lib/worker/invalidate-carts/adapter.d.ts +0 -9
  222. package/lib/worker/invalidate-carts/adapter.js +0 -52
  223. package/lib/worker/invalidate-carts/index.d.ts +0 -4
  224. package/lib/worker/invalidate-carts/index.js +0 -13
  225. package/lib/worker/message/adapter.d.ts +0 -11
  226. package/lib/worker/message/adapter.js +0 -42
  227. package/lib/worker/message/index.d.ts +0 -4
  228. package/lib/worker/message/index.js +0 -10
  229. package/lib/worker/push-notification/adapter.d.ts +0 -9
  230. package/lib/worker/push-notification/adapter.js +0 -87
  231. package/lib/worker/push-notification/index.d.ts +0 -4
  232. package/lib/worker/push-notification/index.js +0 -10
  233. package/lib/worker/twilio/adapter.d.ts +0 -8
  234. package/lib/worker/twilio/adapter.js +0 -59
  235. package/lib/worker/twilio/index.d.ts +0 -4
  236. package/lib/worker/twilio/index.js +0 -10
  237. package/lib/worker/update-coinbase-rates/adapter.d.ts +0 -4
  238. package/lib/worker/update-coinbase-rates/adapter.js +0 -59
  239. package/lib/worker/update-coinbase-rates/index.d.ts +0 -4
  240. package/lib/worker/update-coinbase-rates/index.js +0 -13
  241. package/lib/worker/update-ecb-rates/adapter.d.ts +0 -4
  242. package/lib/worker/update-ecb-rates/adapter.js +0 -94
  243. package/lib/worker/update-ecb-rates/index.d.ts +0 -4
  244. package/lib/worker/update-ecb-rates/index.js +0 -13
  245. package/lib/worker/update-token-ownership/adapter.d.ts +0 -5
  246. package/lib/worker/update-token-ownership/adapter.js +0 -58
  247. package/lib/worker/update-token-ownership/index.d.ts +0 -4
  248. package/lib/worker/update-token-ownership/index.js +0 -13
  249. package/lib/worker/zombie-killer/adapter.d.ts +0 -15
  250. package/lib/worker/zombie-killer/adapter.js +0 -113
  251. package/lib/worker/zombie-killer/index.d.ts +0 -4
  252. 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,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const ProductEuTaxPlugin: IPlugin;
3
- export default ProductEuTaxPlugin;
4
- export { ProductEuTax } from './adapter.ts';
@@ -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,3 +0,0 @@
1
- import { type IProductPricingAdapter } from '@unchainedshop/core';
2
- export declare const ProductPriceRateConversion: IProductPricingAdapter;
3
- export default ProductPriceRateConversion;
@@ -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,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const ProductPriceRateConversionPlugin: IPlugin;
3
- export default ProductPriceRateConversionPlugin;
4
- export { ProductPriceRateConversion } from './adapter.ts';
@@ -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,2 +0,0 @@
1
- import { type IProductPricingAdapter } from '@unchainedshop/core';
2
- export declare const ProductQuotationPrice: IProductPricingAdapter;
@@ -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,3 +0,0 @@
1
- import { type IProductPricingAdapter } from '@unchainedshop/core';
2
- export declare const ProductSwissTax: IProductPricingAdapter;
3
- export default ProductSwissTax;
@@ -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,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const ProductSwissTaxPlugin: IPlugin;
3
- export default ProductSwissTaxPlugin;
4
- export { ProductSwissTax } from './adapter.ts';
@@ -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,3 +0,0 @@
1
- import { type IProductPricingAdapter } from '@unchainedshop/core';
2
- export declare const ProductUkTax: IProductPricingAdapter;
3
- export default ProductUkTax;
@@ -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,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const ProductUkTaxPlugin: IPlugin;
3
- export default ProductUkTaxPlugin;
4
- export { ProductUkTax } from './adapter.ts';
@@ -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,3 +0,0 @@
1
- import { type IProductPricingAdapter } from '@unchainedshop/core';
2
- export declare const ProductUsSalesTax: IProductPricingAdapter;
3
- export default ProductUsSalesTax;
@@ -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,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const ProductUsSalesTaxPlugin: IPlugin;
3
- export default ProductUsSalesTaxPlugin;
4
- export { ProductUsSalesTax } from './adapter.ts';
@@ -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,2 +0,0 @@
1
- import { type IQuotationAdapter } from '@unchainedshop/core';
2
- export declare const ManualOffering: IQuotationAdapter;
@@ -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,4 +0,0 @@
1
- import { type IPlugin } from '@unchainedshop/core';
2
- export declare const ManualOfferingPlugin: IPlugin;
3
- export default ManualOfferingPlugin;
4
- export { ManualOffering } from './adapter.ts';
@@ -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,3 +0,0 @@
1
- import type { IPlugin } from '@unchainedshop/core';
2
- export declare const ERCMetadataPlugin: IPlugin;
3
- export default ERCMetadataPlugin;
@@ -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;
@@ -1,2 +0,0 @@
1
- import { type IWarehousingAdapter } from '@unchainedshop/core';
2
- export declare const ETHMinter: IWarehousingAdapter;