@nextblock-cms/ecom 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_virtual/_rolldown/runtime.cjs.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs.js +1 -1
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs.js +1 -1
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs.js +1 -1
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs.js +1 -1
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs.js +1 -1
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs.js +1 -1
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs.js +1 -1
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs.js +1 -1
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs.js +1 -1
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs.js +1 -1
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs.js +1 -1
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs.js +1 -1
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs.js +1 -1
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs.js +1 -1
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs.js +1 -1
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs.js +1 -1
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs.js +1 -1
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs.js +1 -1
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs.js +1 -1
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs.js +1 -1
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs.js +3 -3
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs.js +1 -1
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs.js +25 -25
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs.js +1 -1
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs.js +1 -1
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs.js +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs.js +3 -3
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs.js +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs.js +1 -1
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs.js +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
- package/lib/pages/cms/products/actions.cjs.js +4 -4
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs.js +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs.js +1 -1
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs.js +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs.js +1 -1
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs.js +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs.js +1 -1
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs.js +4 -4
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs.js +1 -1
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs.js +1 -5
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs.js +1 -1
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs.js +1 -1
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs.js +1 -1
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs.js +1 -1
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs.js +1 -1
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs.js +2 -2
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs.js +2 -2
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs.js +1 -1
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs.js +1 -1
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs.js +1 -1
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs.js +1 -1
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs.js +1 -1
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs.js +1 -1
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs.js +1 -1
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs.js +1 -1
- package/lib/zod-config.es.js +5 -6
- package/package.json +16 -16
- package/server.cjs.js +1 -1
- package/server.es.js +56 -211
|
@@ -1,116 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { normalizeCustomerAddress as e } from "./customer.es.js";
|
|
2
|
+
import { createClient as t } from "@nextblock-cms/db/server";
|
|
3
|
+
//#region libs/ecommerce/src/lib/customer-addresses.ts
|
|
4
|
+
function n(e) {
|
|
5
|
+
return e?.trim() || null;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
function r(t) {
|
|
8
|
+
return t ? e({
|
|
9
|
+
company_name: t.company_name,
|
|
10
|
+
recipient_name: t.recipient_name,
|
|
11
|
+
line1: t.line1,
|
|
12
|
+
line2: t.line2,
|
|
13
|
+
city: t.city,
|
|
14
|
+
state: t.state,
|
|
15
|
+
postal_code: t.postal_code,
|
|
16
|
+
country_code: t.country_code
|
|
17
|
+
}) : null;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
(t) => t.address_type === n && t.is_default
|
|
22
|
-
) ?? e?.find((t) => t.address_type === n) ?? null;
|
|
19
|
+
function i(e, t) {
|
|
20
|
+
return e?.find((e) => e.address_type === t && e.is_default) ?? e?.find((e) => e.address_type === t) ?? null;
|
|
23
21
|
}
|
|
24
|
-
async function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (c.length) {
|
|
61
|
-
const { error: s } = await e.from("user_addresses").delete().in("id", c);
|
|
62
|
-
if (s)
|
|
63
|
-
throw new Error(s.message);
|
|
64
|
-
}
|
|
22
|
+
async function a(t, n, r, i) {
|
|
23
|
+
let a = e(i), { data: o, error: s } = await t.from("user_addresses").select("*").eq("user_id", n).eq("address_type", r).order("is_default", { ascending: !1 }).order("updated_at", { ascending: !1 });
|
|
24
|
+
if (s) throw Error(s.message);
|
|
25
|
+
let c = o?.[0] ?? null, l = (o ?? []).slice(1).map((e) => e.id);
|
|
26
|
+
if (!a) {
|
|
27
|
+
if (o?.length) {
|
|
28
|
+
let e = o.map((e) => e.id), { error: n } = await t.from("user_addresses").delete().in("id", e);
|
|
29
|
+
if (n) throw Error(n.message);
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let u = {
|
|
34
|
+
user_id: n,
|
|
35
|
+
address_type: r,
|
|
36
|
+
is_default: !0,
|
|
37
|
+
company_name: a.company_name ?? null,
|
|
38
|
+
recipient_name: a.recipient_name ?? null,
|
|
39
|
+
line1: a.line1 ?? null,
|
|
40
|
+
line2: a.line2 ?? null,
|
|
41
|
+
city: a.city ?? null,
|
|
42
|
+
state: a.state ?? null,
|
|
43
|
+
postal_code: a.postal_code ?? null,
|
|
44
|
+
country_code: a.country_code ?? null,
|
|
45
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
46
|
+
};
|
|
47
|
+
if (c) {
|
|
48
|
+
let { error: e } = await t.from("user_addresses").update(u).eq("id", c.id);
|
|
49
|
+
if (e) throw Error(e.message);
|
|
50
|
+
} else {
|
|
51
|
+
let { error: e } = await t.from("user_addresses").insert(u);
|
|
52
|
+
if (e) throw Error(e.message);
|
|
53
|
+
}
|
|
54
|
+
if (l.length) {
|
|
55
|
+
let { error: e } = await t.from("user_addresses").delete().in("id", l);
|
|
56
|
+
if (e) throw Error(e.message);
|
|
57
|
+
}
|
|
65
58
|
}
|
|
66
|
-
async function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
billingAddress: o,
|
|
75
|
-
shippingAddress: a
|
|
76
|
-
};
|
|
59
|
+
async function o(e, n) {
|
|
60
|
+
let { data: a, error: o } = await (n ?? t()).from("user_addresses").select("*").eq("user_id", e).in("address_type", ["billing", "shipping"]).order("is_default", { ascending: !1 }).order("updated_at", { ascending: !1 });
|
|
61
|
+
if (o) throw Error(o.message);
|
|
62
|
+
return {
|
|
63
|
+
billingAddress: r(i(a ?? [], "billing")),
|
|
64
|
+
shippingAddress: r(i(a ?? [], "shipping"))
|
|
65
|
+
};
|
|
77
66
|
}
|
|
78
|
-
async function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
n,
|
|
82
|
-
e.userId,
|
|
83
|
-
"billing",
|
|
84
|
-
e.billingAddress ?? null
|
|
85
|
-
), await g(
|
|
86
|
-
n,
|
|
87
|
-
e.userId,
|
|
88
|
-
"shipping",
|
|
89
|
-
e.shippingAddress ?? null
|
|
90
|
-
);
|
|
67
|
+
async function s(e) {
|
|
68
|
+
let n = e.client ?? t();
|
|
69
|
+
await a(n, e.userId, "billing", e.billingAddress ?? null), await a(n, e.userId, "shipping", e.shippingAddress ?? null);
|
|
91
70
|
}
|
|
92
|
-
async function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
phone: d,
|
|
107
|
-
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
108
|
-
}).eq("id", e.userId);
|
|
109
|
-
if (c)
|
|
110
|
-
throw new Error(c.message);
|
|
71
|
+
async function c(e) {
|
|
72
|
+
let r = e.client ?? t(), i = n(e.fullName), a = n(e.phone);
|
|
73
|
+
if (!i && !a) return;
|
|
74
|
+
let { data: o, error: s } = await r.from("profiles").select("full_name, phone").eq("id", e.userId).maybeSingle();
|
|
75
|
+
if (s) throw Error(s.message);
|
|
76
|
+
if (!o) return;
|
|
77
|
+
let c = n(o.full_name) || i, l = n(o.phone) || a;
|
|
78
|
+
if (n(o.full_name) === c && n(o.phone) === l) return;
|
|
79
|
+
let { error: u } = await r.from("profiles").update({
|
|
80
|
+
full_name: c,
|
|
81
|
+
phone: l,
|
|
82
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
83
|
+
}).eq("id", e.userId);
|
|
84
|
+
if (u) throw Error(u.message);
|
|
111
85
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
A as getDefaultUserAddresses,
|
|
115
|
-
D as upsertDefaultUserAddresses
|
|
116
|
-
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { c as fillMissingUserProfileCheckoutDetails, o as getDefaultUserAddresses, s as upsertDefaultUserAddresses };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./invoice-server.cjs.js"),t=require("./freemius-license.cjs.js");let n=require("@nextblock-cms/db/server");var r=[`pending`];function i(e){return e??(0,n.createClient)()}async function a(e){let{data:{user:t},error:n}=await e.auth.getUser();if(n||!t)throw Error(`Unauthorized`);return t}async function o(e){let t=i(e),n=await a(t),{data:o,error:s}=await t.from(`orders`).select(`id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total`).eq(`user_id`,n.id).not(`status`,`in`,`(${r.join(`,`)})`).order(`created_at`,{ascending:!1});if(s)throw Error(s.message);return o??[]}async function s(e,t){let n=i(t),o=await a(n),{data:s,error:c}=await n.from(`orders`).select(`id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total`).eq(`id`,e).eq(`user_id`,o.id).not(`status`,`in`,`(${r.join(`,`)})`).maybeSingle();if(c)throw Error(c.message);return s??null}async function c(n,r){let a=i(r),o=await s(n,a);return o?{order:o,invoice:o.invoice_number?await e.getInvoicePresentationData(n,a):null,license:o.provider===`freemius`?await t.getFreemiusOrderLicense({orderId:n,client:a}):null}:null}exports.getCurrentCustomerOrder=s,exports.getCurrentCustomerOrderInvoice=c,exports.getCurrentCustomerOrders=o;
|
|
@@ -1,48 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { getInvoicePresentationData as e } from "./invoice-server.es.js";
|
|
2
|
+
import { getFreemiusOrderLicense as t } from "./freemius-license.es.js";
|
|
3
|
+
import { createClient as n } from "@nextblock-cms/db/server";
|
|
4
|
+
//#region libs/ecommerce/src/lib/customer-orders.ts
|
|
5
|
+
var r = ["pending"];
|
|
6
|
+
function i(e) {
|
|
7
|
+
return e ?? n();
|
|
7
8
|
}
|
|
8
|
-
async function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} = await t.auth.getUser();
|
|
13
|
-
if (e || !r)
|
|
14
|
-
throw new Error("Unauthorized");
|
|
15
|
-
return r;
|
|
9
|
+
async function a(e) {
|
|
10
|
+
let { data: { user: t }, error: n } = await e.auth.getUser();
|
|
11
|
+
if (n || !t) throw Error("Unauthorized");
|
|
12
|
+
return t;
|
|
16
13
|
}
|
|
17
|
-
async function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (a)
|
|
22
|
-
throw new Error(a.message);
|
|
23
|
-
return n ?? [];
|
|
14
|
+
async function o(e) {
|
|
15
|
+
let t = i(e), n = await a(t), { data: o, error: s } = await t.from("orders").select("id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total").eq("user_id", n.id).not("status", "in", `(${r.join(",")})`).order("created_at", { ascending: !1 });
|
|
16
|
+
if (s) throw Error(s.message);
|
|
17
|
+
return o ?? [];
|
|
24
18
|
}
|
|
25
|
-
async function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (i)
|
|
30
|
-
throw new Error(i.message);
|
|
31
|
-
return a ?? null;
|
|
19
|
+
async function s(e, t) {
|
|
20
|
+
let n = i(t), o = await a(n), { data: s, error: c } = await n.from("orders").select("id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total").eq("id", e).eq("user_id", o.id).not("status", "in", `(${r.join(",")})`).maybeSingle();
|
|
21
|
+
if (c) throw Error(c.message);
|
|
22
|
+
return s ?? null;
|
|
32
23
|
}
|
|
33
|
-
async function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
async function c(n, r) {
|
|
25
|
+
let a = i(r), o = await s(n, a);
|
|
26
|
+
return o ? {
|
|
27
|
+
order: o,
|
|
28
|
+
invoice: o.invoice_number ? await e(n, a) : null,
|
|
29
|
+
license: o.provider === "freemius" ? await t({
|
|
30
|
+
orderId: n,
|
|
31
|
+
client: a
|
|
32
|
+
}) : null
|
|
33
|
+
} : null;
|
|
43
34
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
w as getCurrentCustomerOrderInvoice,
|
|
47
|
-
g as getCurrentCustomerOrders
|
|
48
|
-
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { s as getCurrentCustomerOrder, c as getCurrentCustomerOrderInvoice, o as getCurrentCustomerOrders };
|
package/lib/customer.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./countries.cjs.js"),t=require("./states.cjs.js");var n=()=>({company_name:``,recipient_name:``,line1:``,line2:``,city:``,state:``,postal_code:``,country_code:`CA`});function r(e){return e?.trim()||null}function i(n){if(!n)return null;let i={company_name:r(n.company_name),recipient_name:r(n.recipient_name),line1:r(n.line1),line2:r(n.line2),city:r(n.city),postal_code:r(n.postal_code),country_code:e.normalizeCountryCode(n.country_code)};return i.state=t.normalizeSubdivisionCode(i.country_code,r(n.state)),Object.values(i).some(Boolean)?i:null}function a(e){let n=i(e);return n?!!(n.recipient_name&&n.line1&&n.city&&n.postal_code&&n.country_code&&(!t.countryUsesStructuredStates(n.country_code)||n.state)):!1}function o(e){let t=i(e.billing),n=i(e.shipping),a=r(e.email)?.toLowerCase()??null,o=r(e.phone);return{email:a,name:r(e.name)??t?.recipient_name??n?.recipient_name??null,phone:o,billing:t,shipping:n}}function s(e,t){let n=i(e),r=i(t);return JSON.stringify(n)===JSON.stringify(r)}exports.addressesMatch=s,exports.emptyCustomerAddress=n,exports.isCustomerAddressComplete=a,exports.normalizeCustomerAddress=i,exports.normalizeOrderCustomerDetails=o;
|
package/lib/customer.es.js
CHANGED
|
@@ -1,58 +1,49 @@
|
|
|
1
|
-
import { normalizeCountryCode as
|
|
2
|
-
import { countryUsesStructuredStates as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { normalizeCountryCode as e } from "./countries.es.js";
|
|
2
|
+
import { countryUsesStructuredStates as t, normalizeSubdivisionCode as n } from "./states.es.js";
|
|
3
|
+
//#region libs/ecommerce/src/lib/customer.ts
|
|
4
|
+
var r = () => ({
|
|
5
|
+
company_name: "",
|
|
6
|
+
recipient_name: "",
|
|
7
|
+
line1: "",
|
|
8
|
+
line2: "",
|
|
9
|
+
city: "",
|
|
10
|
+
state: "",
|
|
11
|
+
postal_code: "",
|
|
12
|
+
country_code: "CA"
|
|
12
13
|
});
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
return e || null;
|
|
14
|
+
function i(e) {
|
|
15
|
+
return e?.trim() || null;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return e.state = s(
|
|
30
|
-
e.country_code,
|
|
31
|
-
o(n.state)
|
|
32
|
-
), Object.values(e).some(Boolean) ? e : null;
|
|
17
|
+
function a(t) {
|
|
18
|
+
if (!t) return null;
|
|
19
|
+
let r = {
|
|
20
|
+
company_name: i(t.company_name),
|
|
21
|
+
recipient_name: i(t.recipient_name),
|
|
22
|
+
line1: i(t.line1),
|
|
23
|
+
line2: i(t.line2),
|
|
24
|
+
city: i(t.city),
|
|
25
|
+
postal_code: i(t.postal_code),
|
|
26
|
+
country_code: e(t.country_code)
|
|
27
|
+
};
|
|
28
|
+
return r.state = n(r.country_code, i(t.state)), Object.values(r).some(Boolean) ? r : null;
|
|
33
29
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
function o(e) {
|
|
31
|
+
let n = a(e);
|
|
32
|
+
return n ? !!(n.recipient_name && n.line1 && n.city && n.postal_code && n.country_code && (!t(n.country_code) || n.state)) : !1;
|
|
37
33
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
function s(e) {
|
|
35
|
+
let t = a(e.billing), n = a(e.shipping), r = i(e.email)?.toLowerCase() ?? null, o = i(e.phone);
|
|
36
|
+
return {
|
|
37
|
+
email: r,
|
|
38
|
+
name: i(e.name) ?? t?.recipient_name ?? n?.recipient_name ?? null,
|
|
39
|
+
phone: o,
|
|
40
|
+
billing: t,
|
|
41
|
+
shipping: n
|
|
42
|
+
};
|
|
47
43
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
function c(e, t) {
|
|
45
|
+
let n = a(e), r = a(t);
|
|
46
|
+
return JSON.stringify(n) === JSON.stringify(r);
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
y as emptyCustomerAddress,
|
|
55
|
-
_ as isCustomerAddressComplete,
|
|
56
|
-
i as normalizeCustomerAddress,
|
|
57
|
-
d as normalizeOrderCustomerDetails
|
|
58
|
-
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { c as addressesMatch, r as emptyCustomerAddress, o as isCustomerAddressComplete, a as normalizeCustomerAddress, s as normalizeOrderCustomerDetails };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs.js");let t=require("papaparse");t=e.__toESM(t,1);function n(e,n){let r=t.default.unparse(e),i=new Blob([r],{type:`text/csv;charset=utf-8;`}),a=document.createElement(`a`);if(a.download!==void 0){let e=URL.createObjectURL(i);a.setAttribute(`href`,e),a.setAttribute(`download`,n),a.style.visibility=`hidden`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}}function r(e){return e.map(e=>({"Order ID":e.id,Date:new Date(e.created_at).toLocaleDateString(),"Customer Name":e.customer?.full_name||e.customer_details?.name||`Guest`,"Customer Email":e.customer?.email||e.customer_details?.email||`N/A`,Subtotal:(e.subtotal/100).toFixed(2),"Tax Amount":(e.tax_total/100).toFixed(2),"Shipping Amount":(e.shipping_total/100).toFixed(2),Total:(e.total/100).toFixed(2),Currency:e.currency.toUpperCase(),"Payment Status":e.status,"Fulfillment Status":e.status===`shipped`?`Shipped`:e.status===`paid`?`Paid`:e.status===`trial`?`Trial`:`Pending`,"Payment Gateway":e.provider===`freemius`?`Freemius`:`Stripe`}))}function i(e){return e.filter(e=>e.status===`paid`).map(e=>{let t=e.customer_details?.shipping||e.customer_details?.billing,n=t?.country_code||`N/A`,r=t?.state||`N/A`,i=e.tax_details?.lines?.[0]?.rate?.display_name||`N/A`,a=e.tax_details?.lines?.[0]?.rate?.percentage||0;return{Date:e.paid_at?new Date(e.paid_at).toLocaleDateString():new Date(e.created_at).toLocaleDateString(),"Order ID":e.id,Destination:`${r}, ${n}`,"Tax Rate Applied":`${a}% (${i})`,"Total Taxable Amount":(e.subtotal/100).toFixed(2),"Tax Collected":(e.tax_total/100).toFixed(2),Currency:e.currency.toUpperCase()}})}function a(e){let t={};return e.filter(e=>e.status===`paid`).forEach(e=>{let n=e.currency.toUpperCase();t[n]||(t[n]={volume:0,subtotal:0,tax:0}),t[n].volume+=e.total,t[n].subtotal+=e.subtotal,t[n].tax+=e.tax_total}),Object.entries(t).map(([e,t])=>({Currency:e,"Total Transaction Volume":(t.volume/100).toFixed(2),"Total Subtotal":(t.subtotal/100).toFixed(2),"Total Tax Collected":(t.tax/100).toFixed(2)}))}exports.generateCSV=n,exports.mapGeneralSalesLedger=r,exports.mapMultiCurrencyRevenue=a,exports.mapTaxLiabilitySummary=i;
|
package/lib/export-helpers.es.js
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import e from "papaparse";
|
|
2
|
+
//#region libs/ecommerce/src/lib/export-helpers.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = e.unparse(t), i = new Blob([r], { type: "text/csv;charset=utf-8;" }), a = document.createElement("a");
|
|
5
|
+
if (a.download !== void 0) {
|
|
6
|
+
let e = URL.createObjectURL(i);
|
|
7
|
+
a.setAttribute("href", e), a.setAttribute("download", n), a.style.visibility = "hidden", document.body.appendChild(a), a.click(), document.body.removeChild(a);
|
|
8
|
+
}
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
function n(e) {
|
|
11
|
+
return e.map((e) => ({
|
|
12
|
+
"Order ID": e.id,
|
|
13
|
+
Date: new Date(e.created_at).toLocaleDateString(),
|
|
14
|
+
"Customer Name": e.customer?.full_name || e.customer_details?.name || "Guest",
|
|
15
|
+
"Customer Email": e.customer?.email || e.customer_details?.email || "N/A",
|
|
16
|
+
Subtotal: (e.subtotal / 100).toFixed(2),
|
|
17
|
+
"Tax Amount": (e.tax_total / 100).toFixed(2),
|
|
18
|
+
"Shipping Amount": (e.shipping_total / 100).toFixed(2),
|
|
19
|
+
Total: (e.total / 100).toFixed(2),
|
|
20
|
+
Currency: e.currency.toUpperCase(),
|
|
21
|
+
"Payment Status": e.status,
|
|
22
|
+
"Fulfillment Status": e.status === "shipped" ? "Shipped" : e.status === "paid" ? "Paid" : e.status === "trial" ? "Trial" : "Pending",
|
|
23
|
+
"Payment Gateway": e.provider === "freemius" ? "Freemius" : "Stripe"
|
|
24
|
+
}));
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
function r(e) {
|
|
27
|
+
return e.filter((e) => e.status === "paid").map((e) => {
|
|
28
|
+
let t = e.customer_details?.shipping || e.customer_details?.billing, n = t?.country_code || "N/A", r = t?.state || "N/A", i = e.tax_details?.lines?.[0]?.rate?.display_name || "N/A", a = e.tax_details?.lines?.[0]?.rate?.percentage || 0;
|
|
29
|
+
return {
|
|
30
|
+
Date: e.paid_at ? new Date(e.paid_at).toLocaleDateString() : new Date(e.created_at).toLocaleDateString(),
|
|
31
|
+
"Order ID": e.id,
|
|
32
|
+
Destination: `${r}, ${n}`,
|
|
33
|
+
"Tax Rate Applied": `${a}% (${i})`,
|
|
34
|
+
"Total Taxable Amount": (e.subtotal / 100).toFixed(2),
|
|
35
|
+
"Tax Collected": (e.tax_total / 100).toFixed(2),
|
|
36
|
+
Currency: e.currency.toUpperCase()
|
|
37
|
+
};
|
|
38
|
+
});
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
function i(e) {
|
|
41
|
+
let t = {};
|
|
42
|
+
return e.filter((e) => e.status === "paid").forEach((e) => {
|
|
43
|
+
let n = e.currency.toUpperCase();
|
|
44
|
+
t[n] || (t[n] = {
|
|
45
|
+
volume: 0,
|
|
46
|
+
subtotal: 0,
|
|
47
|
+
tax: 0
|
|
48
|
+
}), t[n].volume += e.total, t[n].subtotal += e.subtotal, t[n].tax += e.tax_total;
|
|
49
|
+
}), Object.entries(t).map(([e, t]) => ({
|
|
50
|
+
Currency: e,
|
|
51
|
+
"Total Transaction Volume": (t.volume / 100).toFixed(2),
|
|
52
|
+
"Total Subtotal": (t.subtotal / 100).toFixed(2),
|
|
53
|
+
"Total Tax Collected": (t.tax / 100).toFixed(2)
|
|
54
|
+
}));
|
|
50
55
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
m as mapGeneralSalesLedger,
|
|
54
|
-
x as mapMultiCurrencyRevenue,
|
|
55
|
-
p as mapTaxLiabilitySummary
|
|
56
|
-
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { t as generateCSV, n as mapGeneralSalesLedger, i as mapMultiCurrencyRevenue, r as mapTaxLiabilitySummary };
|
package/lib/factory.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./providers/freemius.cjs.js"),t=require("./providers/stripe.cjs.js");function n(n){switch(n){case`freemius`:return new e.FreemiusProvider;default:return new t.StripeProvider}}exports.getPaymentProvider=n;
|
package/lib/factory.es.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { FreemiusProvider as e } from "./providers/freemius.es.js";
|
|
2
|
+
import { StripeProvider as t } from "./providers/stripe.es.js";
|
|
3
|
+
//#region libs/ecommerce/src/lib/factory.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
switch (n) {
|
|
6
|
+
case "freemius": return new e();
|
|
7
|
+
default: return new t();
|
|
8
|
+
}
|
|
5
9
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { n as getPaymentProvider };
|