@zeniai/client-epic-state 5.1.77-betaAK0 → 5.1.77-betaAK1
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/esm/view/invoicing/createCreditNote/createCreditNoteFormConfig.js +8 -1
- package/lib/esm/view/invoicing/createCreditNote/createCreditNotePayload.js +1 -8
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -5
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +2 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +5 -4
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +2 -2
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js +3 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +3 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +4 -2
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboConnectionEpic.js +2 -2
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboSyncHealthEpic.js +2 -2
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +3 -3
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNotePayload.js +4 -11
- package/lib/esm/view/invoicing/recordPayment/recordPaymentFormConfig.js +2 -1
- package/lib/esm/view/invoicing/recordPayment/recordPaymentPayload.js +5 -14
- package/lib/view/invoicing/createCreditNote/createCreditNoteFormConfig.js +8 -1
- package/lib/view/invoicing/createCreditNote/createCreditNotePayload.js +1 -8
- package/lib/view/invoicing/createCreditNote/createCreditNoteState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -5
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +2 -3
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +3 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +5 -4
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +2 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts +4 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js +3 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +3 -4
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +4 -2
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboConnectionEpic.js +2 -2
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboSyncHealthEpic.js +2 -2
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +3 -3
- package/lib/view/invoicing/issueCreditNote/issueCreditNotePayload.js +4 -11
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteState.d.ts +3 -2
- package/lib/view/invoicing/recordPayment/recordPaymentFormConfig.js +2 -1
- package/lib/view/invoicing/recordPayment/recordPaymentPayload.js +5 -14
- package/lib/view/invoicing/recordPayment/recordPaymentState.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
1
2
|
export const initialCreateCreditNoteFormLocalData = () => ({
|
|
2
3
|
customerId: '',
|
|
3
|
-
lineItems: [
|
|
4
|
+
lineItems: [
|
|
5
|
+
{
|
|
6
|
+
description: '',
|
|
7
|
+
quantity: '1',
|
|
8
|
+
unitAmount: toAmount(0, 'USD', '$'),
|
|
9
|
+
},
|
|
10
|
+
],
|
|
4
11
|
reasonCode: '',
|
|
5
12
|
referenceInvoiceId: '',
|
|
6
13
|
});
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
const dollarsFromAmountString = (value) => {
|
|
2
|
-
const parsed = Number.parseFloat(value);
|
|
3
|
-
if (Number.isNaN(parsed)) {
|
|
4
|
-
return 0;
|
|
5
|
-
}
|
|
6
|
-
return parsed;
|
|
7
|
-
};
|
|
8
1
|
export const localDataToCreateCreditNotePayload = (localData) => {
|
|
9
2
|
const lineItems = localData.lineItems
|
|
10
3
|
.map((lineItem) => {
|
|
11
4
|
const quantity = Math.round(Number.parseFloat(lineItem.quantity));
|
|
12
|
-
const unitAmount =
|
|
5
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
13
6
|
return {
|
|
14
7
|
description: lineItem.description.trim(),
|
|
15
8
|
quantity,
|
package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { invoicingProductToCatalogItemFormSubFamily, isTieredCatalogPricingModel, } from './invoicingCatalogItemFormConfig';
|
|
2
3
|
const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
|
|
3
4
|
const trimOrNull = (value) => value.trim() !== '' ? value.trim() : null;
|
|
@@ -31,7 +32,7 @@ const tierToPayload = (tier) => ({
|
|
|
31
32
|
package_size: hasValue(tier.packageSize)
|
|
32
33
|
? Number(tier.packageSize)
|
|
33
34
|
: undefined,
|
|
34
|
-
price:
|
|
35
|
+
price: tier.price.amount,
|
|
35
36
|
pricing_type: tier.pricingType,
|
|
36
37
|
starting_unit: Number(tier.startingUnit) || 1,
|
|
37
38
|
});
|
|
@@ -45,7 +46,7 @@ const subFamilyToProductUpdate = (subFamily, itemType) => {
|
|
|
45
46
|
is_taxable: subFamily.isTaxable,
|
|
46
47
|
period: hasValue(subFamily.period) ? Number(subFamily.period) : null,
|
|
47
48
|
period_unit: hasValue(subFamily.period) ? subFamily.periodUnit : null,
|
|
48
|
-
price: tiered ? 0 :
|
|
49
|
+
price: tiered ? 0 : subFamily.priceDollars.amount,
|
|
49
50
|
pricing_model: subFamily.pricingModel,
|
|
50
51
|
show_description_in_quotes: subFamily.showDescriptionInQuotes,
|
|
51
52
|
tiers: tiered ? subFamily.tiers.map(tierToPayload) : [],
|
|
@@ -112,7 +113,6 @@ export const catalogDetailEditValuesToSavePayload = (values, itemType = 'plan',
|
|
|
112
113
|
productUpdates,
|
|
113
114
|
};
|
|
114
115
|
};
|
|
115
|
-
const toAmountValue = (value) => Number(value) || 0;
|
|
116
116
|
/** Build POST /catalog/products body for Create sub-family. */
|
|
117
117
|
export const createSubFamilyFormToPayload = (itemId, itemType, values) => {
|
|
118
118
|
const name = values.name.trim();
|
|
@@ -123,7 +123,7 @@ export const createSubFamilyFormToPayload = (itemId, itemType, values) => {
|
|
|
123
123
|
is_taxable: true,
|
|
124
124
|
item_id: itemId,
|
|
125
125
|
name,
|
|
126
|
-
price:
|
|
126
|
+
price: values.priceDollars.amount,
|
|
127
127
|
price_code: priceCode,
|
|
128
128
|
pricing_model: values.pricingModel || 'flat_fee',
|
|
129
129
|
show_description_in_invoices: true,
|
|
@@ -162,7 +162,7 @@ export const productToCreateSubFamilyFormValues = (product) => ({
|
|
|
162
162
|
period: product?.period != null ? String(product.period) : '1',
|
|
163
163
|
periodUnit: product?.periodUnit ?? 'month',
|
|
164
164
|
priceCode: '',
|
|
165
|
-
priceDollars: product?.price
|
|
165
|
+
priceDollars: product?.price ?? toAmount(0, 'USD', '$'),
|
|
166
166
|
pricingModel: product?.pricingModel ?? 'flat_fee',
|
|
167
167
|
prorationType: product?.prorationType ?? 'site_default',
|
|
168
168
|
trialEndAction: product?.trialEndAction ?? 'site_default',
|
|
@@ -7,7 +7,6 @@ const toProductCode = (value) => value
|
|
|
7
7
|
.toLowerCase()
|
|
8
8
|
.replace(/[^a-z0-9]+/g, '-')
|
|
9
9
|
.replace(/^-|-$/g, '');
|
|
10
|
-
const toAmountValue = (value) => Number(value) || 0;
|
|
11
10
|
const buildAccountingDetail = (localData) => {
|
|
12
11
|
const detail = {};
|
|
13
12
|
if (localData.sku.trim() !== '') {
|
|
@@ -31,7 +30,7 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
31
30
|
free_quantity: Number(subFamily.freeQuantity) || 0,
|
|
32
31
|
is_taxable: subFamily.isTaxable,
|
|
33
32
|
name,
|
|
34
|
-
price: tiered ? 0 :
|
|
33
|
+
price: tiered ? 0 : subFamily.priceDollars.amount,
|
|
35
34
|
price_code: priceCode,
|
|
36
35
|
pricing_model: subFamily.pricingModel,
|
|
37
36
|
show_description_in_invoices: subFamily.showDescriptionInInvoices,
|
|
@@ -70,7 +69,7 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
70
69
|
payload.tiers = subFamily.tiers.map((tier) => ({
|
|
71
70
|
ending_unit: tier.endingUnit.trim() !== '' ? Number(tier.endingUnit) : undefined,
|
|
72
71
|
package_size: tier.packageSize.trim() !== '' ? Number(tier.packageSize) : undefined,
|
|
73
|
-
price:
|
|
72
|
+
price: tier.price.amount,
|
|
74
73
|
pricing_type: tier.pricingType,
|
|
75
74
|
starting_unit: Number(tier.startingUnit) || 1,
|
|
76
75
|
}));
|
package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
1
2
|
/**
|
|
2
3
|
* Canonical value sets for the catalog item form. CES owns the values;
|
|
3
4
|
* web-components maps each value to a localized label.
|
|
@@ -44,7 +45,7 @@ export const isTieredCatalogPricingModel = (model) => ['tiered', 'volume', 'stai
|
|
|
44
45
|
export const blankInvoicingCatalogTier = (startingUnit = '1') => ({
|
|
45
46
|
endingUnit: '',
|
|
46
47
|
packageSize: '',
|
|
47
|
-
price: '',
|
|
48
|
+
price: toAmount(0, 'USD', '$'),
|
|
48
49
|
pricingType: 'per_unit',
|
|
49
50
|
startingUnit,
|
|
50
51
|
});
|
|
@@ -58,7 +59,7 @@ export const blankInvoicingCatalogSubFamily = () => ({
|
|
|
58
59
|
name: '',
|
|
59
60
|
period: '1',
|
|
60
61
|
periodUnit: 'month',
|
|
61
|
-
priceDollars: '',
|
|
62
|
+
priceDollars: toAmount(0, 'USD', '$'),
|
|
62
63
|
priceCode: '',
|
|
63
64
|
pricingModel: 'flat_fee',
|
|
64
65
|
prorationType: 'site_default',
|
|
@@ -85,7 +86,7 @@ export const invoicingProductToCatalogItemFormSubFamily = (product) => {
|
|
|
85
86
|
name: product.name ?? '',
|
|
86
87
|
period: product.period != null ? String(product.period) : '1',
|
|
87
88
|
periodUnit: product.periodUnit ?? 'month',
|
|
88
|
-
priceDollars: product.price
|
|
89
|
+
priceDollars: product.price ?? toAmount(0, 'USD', '$'),
|
|
89
90
|
priceCode: product.priceCode ?? '',
|
|
90
91
|
pricingModel: product.pricingModel ?? 'flat_fee',
|
|
91
92
|
prorationType: product.prorationType ?? 'site_default',
|
|
@@ -95,7 +96,7 @@ export const invoicingProductToCatalogItemFormSubFamily = (product) => {
|
|
|
95
96
|
? product.tiers.map((tier) => ({
|
|
96
97
|
endingUnit: tier.endingUnit != null ? String(tier.endingUnit) : '',
|
|
97
98
|
packageSize: tier.packageSize != null ? String(tier.packageSize) : '',
|
|
98
|
-
price:
|
|
99
|
+
price: tier.price,
|
|
99
100
|
pricingType: tier.pricingType ?? 'per_unit',
|
|
100
101
|
startingUnit: String(tier.startingUnit ?? 1),
|
|
101
102
|
}))
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js
CHANGED
|
@@ -22,8 +22,8 @@ export const localDataToSaveInvoicingCouponPayload = (localData, isCreate) => {
|
|
|
22
22
|
data.discount_percentage = Number(localData.discountPercentage);
|
|
23
23
|
}
|
|
24
24
|
if (localData.discountType === 'fixed_amount') {
|
|
25
|
-
if (localData.discountAmount.
|
|
26
|
-
data.discount_amount =
|
|
25
|
+
if (localData.discountAmount.amount !== 0) {
|
|
26
|
+
data.discount_amount = localData.discountAmount.amount;
|
|
27
27
|
}
|
|
28
28
|
data.currency_code = 'USD';
|
|
29
29
|
}
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
1
2
|
export const initialInvoicingCouponFormLocalData = {
|
|
2
3
|
applyOn: 'invoice_amount',
|
|
3
4
|
couponCode: '',
|
|
4
5
|
couponId: '',
|
|
5
|
-
discountAmount: '',
|
|
6
|
+
discountAmount: toAmount(0, 'USD', '$'),
|
|
6
7
|
discountPercentage: '',
|
|
7
8
|
discountQuantity: '',
|
|
8
9
|
discountType: 'percentage',
|
|
@@ -25,7 +26,7 @@ export const entityToInvoicingCouponFormLocalData = (coupon) => {
|
|
|
25
26
|
applyOn: coupon.applyOn ?? 'invoice_amount',
|
|
26
27
|
couponCode: coupon.couponCode ?? '',
|
|
27
28
|
couponId: coupon.id ?? '',
|
|
28
|
-
discountAmount: coupon.discountAmount
|
|
29
|
+
discountAmount: coupon.discountAmount ?? toAmount(0, 'USD', '$'),
|
|
29
30
|
discountPercentage: coupon.discountPercentage != null
|
|
30
31
|
? String(coupon.discountPercentage)
|
|
31
32
|
: '',
|
|
@@ -24,8 +24,7 @@ export const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingA
|
|
|
24
24
|
quantity: 1,
|
|
25
25
|
})),
|
|
26
26
|
];
|
|
27
|
-
const setupFee = localData.setupFee.
|
|
28
|
-
const parsedSetupFee = Number.parseFloat(setupFee);
|
|
27
|
+
const setupFee = localData.setupFee.amount;
|
|
29
28
|
const poNumber = localData.poNumber.trim();
|
|
30
29
|
const trialEnd = localData.trialEnd.trim();
|
|
31
30
|
return {
|
|
@@ -35,8 +34,8 @@ export const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingA
|
|
|
35
34
|
currency_code: localData.preferredCurrencyCode,
|
|
36
35
|
customer_id: localData.customerId,
|
|
37
36
|
subscription_items: items,
|
|
38
|
-
...(setupFee
|
|
39
|
-
? { setup_fee:
|
|
37
|
+
...(Number.isFinite(setupFee) && setupFee !== 0
|
|
38
|
+
? { setup_fee: setupFee }
|
|
40
39
|
: {}),
|
|
41
40
|
...(poNumber !== '' ? { po_number: poNumber } : {}),
|
|
42
41
|
...(trialEnd !== '' ? { trial_end: trialEnd } : {}),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
1
2
|
/** `AddressType` key used when the subscription form opens the shared Address screen. */
|
|
2
3
|
export const INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE = 'invoicing_subscription_shipping_address';
|
|
3
4
|
/**
|
|
@@ -44,7 +45,7 @@ export const initialInvoicingSubscriptionFormLocalData = {
|
|
|
44
45
|
planQuantity: 1,
|
|
45
46
|
poNumber: '',
|
|
46
47
|
preferredCurrencyCode: 'USD',
|
|
47
|
-
setupFee: '',
|
|
48
|
+
setupFee: toAmount(0, 'USD', '$'),
|
|
48
49
|
trialEnd: '',
|
|
49
50
|
};
|
|
50
51
|
/** Seed the form draft from an existing subscription entity (edit mode). */
|
|
@@ -66,7 +67,8 @@ export const entityToInvoicingSubscriptionFormLocalData = (subscription) => {
|
|
|
66
67
|
planQuantity: planItem?.quantity ?? 1,
|
|
67
68
|
poNumber: subscription.poNumber ?? '',
|
|
68
69
|
preferredCurrencyCode: subscription.currencyCode ?? 'USD',
|
|
69
|
-
setupFee:
|
|
70
|
+
setupFee: subscription.setupFee ??
|
|
71
|
+
toAmount(0, subscription.currencyCode ?? 'USD', '$'),
|
|
70
72
|
trialEnd: subscription.trialEnd != null
|
|
71
73
|
? subscription.trialEnd.format('YYYY-MM-DD')
|
|
72
74
|
: '',
|
|
@@ -6,8 +6,8 @@ import { fetchInvoicingQboConnection, updateInvoicingQboConnection, updateInvoic
|
|
|
6
6
|
export const fetchInvoicingQboConnectionEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchInvoicingQboConnection.match), switchMap(() => {
|
|
7
7
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/connection`;
|
|
8
8
|
return zeniAPI.getJSON(apiUrl).pipe(switchMap((response) => {
|
|
9
|
-
if (isSuccessResponse(response)
|
|
10
|
-
return of(updateInvoicingQboConnection(mapInvoicingQboConnection(response.data)));
|
|
9
|
+
if (isSuccessResponse(response)) {
|
|
10
|
+
return of(updateInvoicingQboConnection(mapInvoicingQboConnection(response.data ?? { connected: false })));
|
|
11
11
|
}
|
|
12
12
|
return of(updateInvoicingQboConnectionFailure(response.status));
|
|
13
13
|
}), catchError((error) => of(updateInvoicingQboConnectionFailure(createZeniAPIStatus('Unexpected Error', 'Fetch QBO connection REST API call errored out ' +
|
|
@@ -6,8 +6,8 @@ import { fetchInvoicingQboSyncHealth, updateInvoicingQboSyncHealth, updateInvoic
|
|
|
6
6
|
export const fetchInvoicingQboSyncHealthEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchInvoicingQboSyncHealth.match), switchMap(() => {
|
|
7
7
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/sync-health`;
|
|
8
8
|
return zeniAPI.getJSON(apiUrl).pipe(switchMap((response) => {
|
|
9
|
-
if (isSuccessResponse(response)
|
|
10
|
-
return of(updateInvoicingQboSyncHealth(mapInvoicingQboSyncHealth(response.data)));
|
|
9
|
+
if (isSuccessResponse(response)) {
|
|
10
|
+
return of(updateInvoicingQboSyncHealth(mapInvoicingQboSyncHealth(response.data ?? {})));
|
|
11
11
|
}
|
|
12
12
|
return of(updateInvoicingQboSyncHealthFailure(response.status));
|
|
13
13
|
}), catchError((error) => of(updateInvoicingQboSyncHealthFailure(createZeniAPIStatus('Unexpected Error', 'Fetch QBO sync health REST API call errored out ' +
|
|
@@ -8,10 +8,10 @@ export const retryInvoicingQboSyncTaskEpic = (actions$, _state$, zeniAPI) => act
|
|
|
8
8
|
return zeniAPI
|
|
9
9
|
.postAndGetJSON(apiUrl, {})
|
|
10
10
|
.pipe(switchMap((response) => {
|
|
11
|
-
if (isSuccessResponse(response)
|
|
11
|
+
if (isSuccessResponse(response)) {
|
|
12
12
|
return of(retryInvoicingQboSyncTaskSuccess({
|
|
13
|
-
status: response.data
|
|
14
|
-
taskId: response.data
|
|
13
|
+
status: response.data?.status ?? '',
|
|
14
|
+
taskId: response.data?.task_id ?? taskId,
|
|
15
15
|
}), fetchInvoicingQboSyncHealth());
|
|
16
16
|
}
|
|
17
17
|
return of(retryInvoicingQboSyncTaskFailure({
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
const dollarsFromAmountString = (value) => {
|
|
2
|
-
const parsed = Number.parseFloat(value);
|
|
3
|
-
if (Number.isNaN(parsed)) {
|
|
4
|
-
return 0;
|
|
5
|
-
}
|
|
6
|
-
return parsed;
|
|
7
|
-
};
|
|
8
1
|
export const computeIssueCreditNoteTotal = (lineItems) => lineItems
|
|
9
2
|
.filter((lineItem) => lineItem.selected)
|
|
10
3
|
.reduce((total, lineItem) => {
|
|
11
4
|
const quantity = Number.parseFloat(lineItem.quantity);
|
|
12
|
-
const unitAmount =
|
|
5
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
13
6
|
if (Number.isNaN(quantity) || quantity <= 0 || unitAmount <= 0) {
|
|
14
7
|
return total;
|
|
15
8
|
}
|
|
@@ -20,7 +13,7 @@ export const localDataToIssueCreditNotePayload = (localData) => {
|
|
|
20
13
|
.filter((lineItem) => lineItem.selected)
|
|
21
14
|
.map((lineItem) => {
|
|
22
15
|
const quantity = Math.round(Number.parseFloat(lineItem.quantity));
|
|
23
|
-
const unitAmount =
|
|
16
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
24
17
|
return {
|
|
25
18
|
description: lineItem.description,
|
|
26
19
|
quantity,
|
|
@@ -43,9 +36,9 @@ export const initializeIssueCreditNoteDraftFromInvoice = (invoice) => ({
|
|
|
43
36
|
description: lineItem.description,
|
|
44
37
|
id: lineItem.id,
|
|
45
38
|
maxQuantity: lineItem.quantity,
|
|
46
|
-
maxUnitAmount: lineItem.unitAmount
|
|
39
|
+
maxUnitAmount: lineItem.unitAmount,
|
|
47
40
|
quantity: String(lineItem.quantity),
|
|
48
41
|
selected: true,
|
|
49
|
-
unitAmount: lineItem.unitAmount
|
|
42
|
+
unitAmount: lineItem.unitAmount,
|
|
50
43
|
})),
|
|
51
44
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
1
2
|
/**
|
|
2
3
|
* Canonical value sets for the Record Payment form. CES owns the values;
|
|
3
4
|
* web-components maps each value to a localized label.
|
|
@@ -25,7 +26,7 @@ export const INVOICING_PAYMENT_GATEWAY_VALUES = [
|
|
|
25
26
|
'other',
|
|
26
27
|
];
|
|
27
28
|
export const initialRecordPaymentFormLocalData = {
|
|
28
|
-
amount: '',
|
|
29
|
+
amount: toAmount(0, 'USD', '$'),
|
|
29
30
|
comment: '',
|
|
30
31
|
customerId: '',
|
|
31
32
|
date: '',
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
+
import { toAmount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { dateNow } from '../../../zeniDayJS';
|
|
2
3
|
import { initialRecordPaymentFormLocalData } from './recordPaymentFormConfig';
|
|
3
4
|
const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
|
|
4
|
-
const
|
|
5
|
-
const parsed = Number.parseFloat(value);
|
|
6
|
-
if (Number.isNaN(parsed)) {
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
return parsed;
|
|
10
|
-
};
|
|
11
|
-
const amountDueDollarsFromInvoice = (invoice) => {
|
|
12
|
-
const amountDue = invoice.amountDue?.amount ?? 0;
|
|
13
|
-
return amountDue.toFixed(2);
|
|
14
|
-
};
|
|
5
|
+
const amountDueFromInvoice = (invoice) => invoice.amountDue ?? toAmount(0, 'USD', '$');
|
|
15
6
|
/**
|
|
16
7
|
* Build the invoice-scoped Record Payment body from the form draft. Amount stays
|
|
17
8
|
* in dollars for the invoice endpoint.
|
|
@@ -21,7 +12,7 @@ export const localDataToInvoiceRecordPaymentBody = (localData) => {
|
|
|
21
12
|
const date = localData.date.trim();
|
|
22
13
|
const referenceNumber = trimOrUndefined(localData.referenceNumber);
|
|
23
14
|
return {
|
|
24
|
-
amount:
|
|
15
|
+
amount: localData.amount.amount,
|
|
25
16
|
payment_method: localData.paymentMethod,
|
|
26
17
|
...(gateway != null ? { gateway } : {}),
|
|
27
18
|
...(date !== '' ? { date } : {}),
|
|
@@ -34,7 +25,7 @@ export const localDataToInvoiceRecordPaymentBody = (localData) => {
|
|
|
34
25
|
* and the linked invoice into `linked_invoices`. Currency is locked to USD.
|
|
35
26
|
*/
|
|
36
27
|
export const localDataToRecordPaymentPayload = (localData) => {
|
|
37
|
-
const amount =
|
|
28
|
+
const amount = localData.amount.amount;
|
|
38
29
|
const gateway = trimOrUndefined(localData.gateway);
|
|
39
30
|
const date = localData.date.trim();
|
|
40
31
|
const transactionId = trimOrUndefined(localData.transactionId);
|
|
@@ -60,7 +51,7 @@ export const localDataToRecordPaymentPayload = (localData) => {
|
|
|
60
51
|
};
|
|
61
52
|
export const initializeRecordPaymentDraftFromInvoice = (invoice) => ({
|
|
62
53
|
...initialRecordPaymentFormLocalData,
|
|
63
|
-
amount:
|
|
54
|
+
amount: amountDueFromInvoice(invoice),
|
|
64
55
|
customerId: invoice.customerID,
|
|
65
56
|
date: dateNow().format('YYYY-MM-DD'),
|
|
66
57
|
invoiceToLink: invoice.id,
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initialCreateCreditNoteFormLocalData = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
4
5
|
const initialCreateCreditNoteFormLocalData = () => ({
|
|
5
6
|
customerId: '',
|
|
6
|
-
lineItems: [
|
|
7
|
+
lineItems: [
|
|
8
|
+
{
|
|
9
|
+
description: '',
|
|
10
|
+
quantity: '1',
|
|
11
|
+
unitAmount: (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
7
14
|
reasonCode: '',
|
|
8
15
|
referenceInvoiceId: '',
|
|
9
16
|
});
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.localDataToCreateCreditNotePayload = void 0;
|
|
4
|
-
const dollarsFromAmountString = (value) => {
|
|
5
|
-
const parsed = Number.parseFloat(value);
|
|
6
|
-
if (Number.isNaN(parsed)) {
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
return parsed;
|
|
10
|
-
};
|
|
11
4
|
const localDataToCreateCreditNotePayload = (localData) => {
|
|
12
5
|
const lineItems = localData.lineItems
|
|
13
6
|
.map((lineItem) => {
|
|
14
7
|
const quantity = Math.round(Number.parseFloat(lineItem.quantity));
|
|
15
|
-
const unitAmount =
|
|
8
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
16
9
|
return {
|
|
17
10
|
description: lineItem.description.trim(),
|
|
18
11
|
quantity,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
3
|
export interface CreateCreditNoteLineItemDraft {
|
|
3
4
|
description: string;
|
|
4
5
|
quantity: string;
|
|
5
|
-
unitAmount:
|
|
6
|
+
unitAmount: Amount;
|
|
6
7
|
}
|
|
7
8
|
export interface CreateCreditNoteFormLocalData {
|
|
8
9
|
customerId: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import type { InvoicingPlan } from '../../../entity/invoicing/plan/planState';
|
|
2
3
|
import type { InvoicingProduct } from '../../../entity/invoicing/product/productState';
|
|
3
4
|
import type { InvoicingCatalogItemFormSubFamily } from './editInvoicingCatalogItemDetailViewState';
|
|
@@ -39,7 +40,7 @@ export interface CreateSubFamilyFormValues {
|
|
|
39
40
|
period: string;
|
|
40
41
|
periodUnit: string;
|
|
41
42
|
priceCode: string;
|
|
42
|
-
priceDollars:
|
|
43
|
+
priceDollars: Amount;
|
|
43
44
|
pricingModel: string;
|
|
44
45
|
prorationType: string;
|
|
45
46
|
trialEndAction: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.productToCreateSubFamilyFormValues = exports.createSubFamilyFormToPayload = exports.catalogDetailEditValuesToSavePayload = exports.planToCatalogDetailEditValues = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
4
5
|
const invoicingCatalogItemFormConfig_1 = require("./invoicingCatalogItemFormConfig");
|
|
5
6
|
const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
|
|
6
7
|
const trimOrNull = (value) => value.trim() !== '' ? value.trim() : null;
|
|
@@ -35,7 +36,7 @@ const tierToPayload = (tier) => ({
|
|
|
35
36
|
package_size: hasValue(tier.packageSize)
|
|
36
37
|
? Number(tier.packageSize)
|
|
37
38
|
: undefined,
|
|
38
|
-
price:
|
|
39
|
+
price: tier.price.amount,
|
|
39
40
|
pricing_type: tier.pricingType,
|
|
40
41
|
starting_unit: Number(tier.startingUnit) || 1,
|
|
41
42
|
});
|
|
@@ -49,7 +50,7 @@ const subFamilyToProductUpdate = (subFamily, itemType) => {
|
|
|
49
50
|
is_taxable: subFamily.isTaxable,
|
|
50
51
|
period: hasValue(subFamily.period) ? Number(subFamily.period) : null,
|
|
51
52
|
period_unit: hasValue(subFamily.period) ? subFamily.periodUnit : null,
|
|
52
|
-
price: tiered ? 0 :
|
|
53
|
+
price: tiered ? 0 : subFamily.priceDollars.amount,
|
|
53
54
|
pricing_model: subFamily.pricingModel,
|
|
54
55
|
show_description_in_quotes: subFamily.showDescriptionInQuotes,
|
|
55
56
|
tiers: tiered ? subFamily.tiers.map(tierToPayload) : [],
|
|
@@ -117,7 +118,6 @@ const catalogDetailEditValuesToSavePayload = (values, itemType = 'plan', origina
|
|
|
117
118
|
};
|
|
118
119
|
};
|
|
119
120
|
exports.catalogDetailEditValuesToSavePayload = catalogDetailEditValuesToSavePayload;
|
|
120
|
-
const toAmountValue = (value) => Number(value) || 0;
|
|
121
121
|
/** Build POST /catalog/products body for Create sub-family. */
|
|
122
122
|
const createSubFamilyFormToPayload = (itemId, itemType, values) => {
|
|
123
123
|
const name = values.name.trim();
|
|
@@ -128,7 +128,7 @@ const createSubFamilyFormToPayload = (itemId, itemType, values) => {
|
|
|
128
128
|
is_taxable: true,
|
|
129
129
|
item_id: itemId,
|
|
130
130
|
name,
|
|
131
|
-
price:
|
|
131
|
+
price: values.priceDollars.amount,
|
|
132
132
|
price_code: priceCode,
|
|
133
133
|
pricing_model: values.pricingModel || 'flat_fee',
|
|
134
134
|
show_description_in_invoices: true,
|
|
@@ -168,7 +168,7 @@ const productToCreateSubFamilyFormValues = (product) => ({
|
|
|
168
168
|
period: product?.period != null ? String(product.period) : '1',
|
|
169
169
|
periodUnit: product?.periodUnit ?? 'month',
|
|
170
170
|
priceCode: '',
|
|
171
|
-
priceDollars: product?.price
|
|
171
|
+
priceDollars: product?.price ?? (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
172
172
|
pricingModel: product?.pricingModel ?? 'flat_fee',
|
|
173
173
|
prorationType: product?.prorationType ?? 'site_default',
|
|
174
174
|
trialEndAction: product?.trialEndAction ?? 'site_default',
|
|
@@ -10,7 +10,6 @@ const toProductCode = (value) => value
|
|
|
10
10
|
.toLowerCase()
|
|
11
11
|
.replace(/[^a-z0-9]+/g, '-')
|
|
12
12
|
.replace(/^-|-$/g, '');
|
|
13
|
-
const toAmountValue = (value) => Number(value) || 0;
|
|
14
13
|
const buildAccountingDetail = (localData) => {
|
|
15
14
|
const detail = {};
|
|
16
15
|
if (localData.sku.trim() !== '') {
|
|
@@ -34,7 +33,7 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
34
33
|
free_quantity: Number(subFamily.freeQuantity) || 0,
|
|
35
34
|
is_taxable: subFamily.isTaxable,
|
|
36
35
|
name,
|
|
37
|
-
price: tiered ? 0 :
|
|
36
|
+
price: tiered ? 0 : subFamily.priceDollars.amount,
|
|
38
37
|
price_code: priceCode,
|
|
39
38
|
pricing_model: subFamily.pricingModel,
|
|
40
39
|
show_description_in_invoices: subFamily.showDescriptionInInvoices,
|
|
@@ -73,7 +72,7 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
73
72
|
payload.tiers = subFamily.tiers.map((tier) => ({
|
|
74
73
|
ending_unit: tier.endingUnit.trim() !== '' ? Number(tier.endingUnit) : undefined,
|
|
75
74
|
package_size: tier.packageSize.trim() !== '' ? Number(tier.packageSize) : undefined,
|
|
76
|
-
price:
|
|
75
|
+
price: tier.price.amount,
|
|
77
76
|
pricing_type: tier.pricingType,
|
|
78
77
|
starting_unit: Number(tier.startingUnit) || 1,
|
|
79
78
|
}));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
3
|
import { InvoicingCatalogItemKind } from '../invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewState';
|
|
3
4
|
/** A single pricing tier within a sub-family (values kept as raw strings). */
|
|
4
5
|
export interface InvoicingCatalogItemFormTier {
|
|
5
6
|
endingUnit: string;
|
|
6
7
|
packageSize: string;
|
|
7
|
-
price:
|
|
8
|
+
price: Amount;
|
|
8
9
|
pricingType: string;
|
|
9
10
|
startingUnit: string;
|
|
10
11
|
}
|
|
@@ -20,7 +21,7 @@ export interface InvoicingCatalogItemFormSubFamily {
|
|
|
20
21
|
period: string;
|
|
21
22
|
periodUnit: string;
|
|
22
23
|
priceCode: string;
|
|
23
|
-
priceDollars:
|
|
24
|
+
priceDollars: Amount;
|
|
24
25
|
pricingModel: string;
|
|
25
26
|
prorationType: string;
|
|
26
27
|
showDescriptionInInvoices: boolean;
|
package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.entityToInvoicingCatalogItemFormLocalData = exports.initialInvoicingCatalogItemFormLocalData = exports.invoicingProductToCatalogItemFormSubFamily = exports.blankInvoicingCatalogSubFamily = exports.blankInvoicingCatalogTier = exports.isTieredCatalogPricingModel = exports.INVOICING_CATALOG_APPLICABILITY_VALUES = exports.INVOICING_CATALOG_PRORATION_VALUES = exports.INVOICING_CATALOG_TRIAL_END_ACTION_VALUES = exports.INVOICING_CATALOG_TRIAL_UNIT_VALUES = exports.INVOICING_CATALOG_TIER_TYPE_VALUES = exports.INVOICING_CATALOG_PRICING_MODEL_VALUES = exports.INVOICING_CATALOG_PERIOD_UNIT_VALUES = exports.INVOICING_CATALOG_TYPE_VALUES = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
4
5
|
/**
|
|
5
6
|
* Canonical value sets for the catalog item form. CES owns the values;
|
|
6
7
|
* web-components maps each value to a localized label.
|
|
@@ -48,7 +49,7 @@ exports.isTieredCatalogPricingModel = isTieredCatalogPricingModel;
|
|
|
48
49
|
const blankInvoicingCatalogTier = (startingUnit = '1') => ({
|
|
49
50
|
endingUnit: '',
|
|
50
51
|
packageSize: '',
|
|
51
|
-
price: '',
|
|
52
|
+
price: (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
52
53
|
pricingType: 'per_unit',
|
|
53
54
|
startingUnit,
|
|
54
55
|
});
|
|
@@ -63,7 +64,7 @@ const blankInvoicingCatalogSubFamily = () => ({
|
|
|
63
64
|
name: '',
|
|
64
65
|
period: '1',
|
|
65
66
|
periodUnit: 'month',
|
|
66
|
-
priceDollars: '',
|
|
67
|
+
priceDollars: (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
67
68
|
priceCode: '',
|
|
68
69
|
pricingModel: 'flat_fee',
|
|
69
70
|
prorationType: 'site_default',
|
|
@@ -91,7 +92,7 @@ const invoicingProductToCatalogItemFormSubFamily = (product) => {
|
|
|
91
92
|
name: product.name ?? '',
|
|
92
93
|
period: product.period != null ? String(product.period) : '1',
|
|
93
94
|
periodUnit: product.periodUnit ?? 'month',
|
|
94
|
-
priceDollars: product.price
|
|
95
|
+
priceDollars: product.price ?? (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
95
96
|
priceCode: product.priceCode ?? '',
|
|
96
97
|
pricingModel: product.pricingModel ?? 'flat_fee',
|
|
97
98
|
prorationType: product.prorationType ?? 'site_default',
|
|
@@ -101,7 +102,7 @@ const invoicingProductToCatalogItemFormSubFamily = (product) => {
|
|
|
101
102
|
? product.tiers.map((tier) => ({
|
|
102
103
|
endingUnit: tier.endingUnit != null ? String(tier.endingUnit) : '',
|
|
103
104
|
packageSize: tier.packageSize != null ? String(tier.packageSize) : '',
|
|
104
|
-
price:
|
|
105
|
+
price: tier.price,
|
|
105
106
|
pricingType: tier.pricingType ?? 'per_unit',
|
|
106
107
|
startingUnit: String(tier.startingUnit ?? 1),
|
|
107
108
|
}))
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js
CHANGED
|
@@ -25,8 +25,8 @@ const localDataToSaveInvoicingCouponPayload = (localData, isCreate) => {
|
|
|
25
25
|
data.discount_percentage = Number(localData.discountPercentage);
|
|
26
26
|
}
|
|
27
27
|
if (localData.discountType === 'fixed_amount') {
|
|
28
|
-
if (localData.discountAmount.
|
|
29
|
-
data.discount_amount =
|
|
28
|
+
if (localData.discountAmount.amount !== 0) {
|
|
29
|
+
data.discount_amount = localData.discountAmount.amount;
|
|
30
30
|
}
|
|
31
31
|
data.currency_code = 'USD';
|
|
32
32
|
}
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
3
|
import { InvoicingCoupon } from '../../../entity/invoicing/coupon/couponState';
|
|
3
4
|
/**
|
|
4
5
|
* Draft form state for the create/edit discount-coupon form. Held in CES so the
|
|
5
6
|
* form flows its data from here (mirrors the customer form pattern). Dates are
|
|
6
|
-
* stored as ISO `YYYY-MM-DD` strings;
|
|
7
|
+
* stored as ISO `YYYY-MM-DD` strings; the discount amount as an `Amount` (as on
|
|
8
|
+
* the coupon entity); remaining quantities as raw strings.
|
|
7
9
|
*/
|
|
8
10
|
export interface InvoicingCouponFormLocalData {
|
|
9
11
|
applyOn: string;
|
|
10
12
|
couponCode: string;
|
|
11
13
|
couponId: string;
|
|
12
|
-
discountAmount:
|
|
14
|
+
discountAmount: Amount;
|
|
13
15
|
discountPercentage: string;
|
|
14
16
|
discountQuantity: string;
|
|
15
17
|
discountType: string;
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.entityToInvoicingCouponFormLocalData = exports.initialInvoicingCouponFormLocalData = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
4
5
|
exports.initialInvoicingCouponFormLocalData = {
|
|
5
6
|
applyOn: 'invoice_amount',
|
|
6
7
|
couponCode: '',
|
|
7
8
|
couponId: '',
|
|
8
|
-
discountAmount: '',
|
|
9
|
+
discountAmount: (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
9
10
|
discountPercentage: '',
|
|
10
11
|
discountQuantity: '',
|
|
11
12
|
discountType: 'percentage',
|
|
@@ -28,7 +29,7 @@ const entityToInvoicingCouponFormLocalData = (coupon) => {
|
|
|
28
29
|
applyOn: coupon.applyOn ?? 'invoice_amount',
|
|
29
30
|
couponCode: coupon.couponCode ?? '',
|
|
30
31
|
couponId: coupon.id ?? '',
|
|
31
|
-
discountAmount: coupon.discountAmount
|
|
32
|
+
discountAmount: coupon.discountAmount ?? (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
32
33
|
discountPercentage: coupon.discountPercentage != null
|
|
33
34
|
? String(coupon.discountPercentage)
|
|
34
35
|
: '',
|
|
@@ -27,8 +27,7 @@ const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingAddress)
|
|
|
27
27
|
quantity: 1,
|
|
28
28
|
})),
|
|
29
29
|
];
|
|
30
|
-
const setupFee = localData.setupFee.
|
|
31
|
-
const parsedSetupFee = Number.parseFloat(setupFee);
|
|
30
|
+
const setupFee = localData.setupFee.amount;
|
|
32
31
|
const poNumber = localData.poNumber.trim();
|
|
33
32
|
const trialEnd = localData.trialEnd.trim();
|
|
34
33
|
return {
|
|
@@ -38,8 +37,8 @@ const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingAddress)
|
|
|
38
37
|
currency_code: localData.preferredCurrencyCode,
|
|
39
38
|
customer_id: localData.customerId,
|
|
40
39
|
subscription_items: items,
|
|
41
|
-
...(setupFee
|
|
42
|
-
? { setup_fee:
|
|
40
|
+
...(Number.isFinite(setupFee) && setupFee !== 0
|
|
41
|
+
? { setup_fee: setupFee }
|
|
43
42
|
: {}),
|
|
44
43
|
...(poNumber !== '' ? { po_number: poNumber } : {}),
|
|
45
44
|
...(trialEnd !== '' ? { trial_end: trialEnd } : {}),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
3
|
/**
|
|
3
4
|
* Draft form state for the create/edit subscription form. Held in CES so the
|
|
@@ -17,7 +18,7 @@ export interface InvoicingSubscriptionFormLocalData {
|
|
|
17
18
|
planQuantity: number;
|
|
18
19
|
poNumber: string;
|
|
19
20
|
preferredCurrencyCode: string;
|
|
20
|
-
setupFee:
|
|
21
|
+
setupFee: Amount;
|
|
21
22
|
trialEnd: string;
|
|
22
23
|
}
|
|
23
24
|
export interface EditInvoicingSubscriptionDetailViewState extends FetchedState {
|
package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.entityToInvoicingSubscriptionFormLocalData = exports.initialInvoicingSubscriptionFormLocalData = exports.periodToBillingFrequency = exports.billingFrequencyToPeriod = exports.INVOICING_SUBSCRIPTION_BILLING_FREQUENCY_VALUES = exports.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
4
5
|
/** `AddressType` key used when the subscription form opens the shared Address screen. */
|
|
5
6
|
exports.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE = 'invoicing_subscription_shipping_address';
|
|
6
7
|
/**
|
|
@@ -49,7 +50,7 @@ exports.initialInvoicingSubscriptionFormLocalData = {
|
|
|
49
50
|
planQuantity: 1,
|
|
50
51
|
poNumber: '',
|
|
51
52
|
preferredCurrencyCode: 'USD',
|
|
52
|
-
setupFee: '',
|
|
53
|
+
setupFee: (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
53
54
|
trialEnd: '',
|
|
54
55
|
};
|
|
55
56
|
/** Seed the form draft from an existing subscription entity (edit mode). */
|
|
@@ -71,7 +72,8 @@ const entityToInvoicingSubscriptionFormLocalData = (subscription) => {
|
|
|
71
72
|
planQuantity: planItem?.quantity ?? 1,
|
|
72
73
|
poNumber: subscription.poNumber ?? '',
|
|
73
74
|
preferredCurrencyCode: subscription.currencyCode ?? 'USD',
|
|
74
|
-
setupFee:
|
|
75
|
+
setupFee: subscription.setupFee ??
|
|
76
|
+
(0, amount_1.toAmount)(0, subscription.currencyCode ?? 'USD', '$'),
|
|
75
77
|
trialEnd: subscription.trialEnd != null
|
|
76
78
|
? subscription.trialEnd.format('YYYY-MM-DD')
|
|
77
79
|
: '',
|
|
@@ -9,8 +9,8 @@ const invoicingQboViewReducer_1 = require("../invoicingQboViewReducer");
|
|
|
9
9
|
const fetchInvoicingQboConnectionEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoicingQboViewReducer_1.fetchInvoicingQboConnection.match), (0, operators_1.switchMap)(() => {
|
|
10
10
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/connection`;
|
|
11
11
|
return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
|
|
12
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)
|
|
13
|
-
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboConnection)((0, invoicingQboViewPayload_1.mapInvoicingQboConnection)(response.data)));
|
|
12
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
13
|
+
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboConnection)((0, invoicingQboViewPayload_1.mapInvoicingQboConnection)(response.data ?? { connected: false })));
|
|
14
14
|
}
|
|
15
15
|
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboConnectionFailure)(response.status));
|
|
16
16
|
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboConnectionFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch QBO connection REST API call errored out ' +
|
|
@@ -9,8 +9,8 @@ const invoicingQboViewReducer_1 = require("../invoicingQboViewReducer");
|
|
|
9
9
|
const fetchInvoicingQboSyncHealthEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoicingQboViewReducer_1.fetchInvoicingQboSyncHealth.match), (0, operators_1.switchMap)(() => {
|
|
10
10
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/sync-health`;
|
|
11
11
|
return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
|
|
12
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)
|
|
13
|
-
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboSyncHealth)((0, invoicingQboViewPayload_1.mapInvoicingQboSyncHealth)(response.data)));
|
|
12
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
13
|
+
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboSyncHealth)((0, invoicingQboViewPayload_1.mapInvoicingQboSyncHealth)(response.data ?? {})));
|
|
14
14
|
}
|
|
15
15
|
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboSyncHealthFailure)(response.status));
|
|
16
16
|
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, invoicingQboViewReducer_1.updateInvoicingQboSyncHealthFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch QBO sync health REST API call errored out ' +
|
|
@@ -11,10 +11,10 @@ const retryInvoicingQboSyncTaskEpic = (actions$, _state$, zeniAPI) => actions$.p
|
|
|
11
11
|
return zeniAPI
|
|
12
12
|
.postAndGetJSON(apiUrl, {})
|
|
13
13
|
.pipe((0, operators_1.switchMap)((response) => {
|
|
14
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)
|
|
14
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
15
15
|
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.retryInvoicingQboSyncTaskSuccess)({
|
|
16
|
-
status: response.data
|
|
17
|
-
taskId: response.data
|
|
16
|
+
status: response.data?.status ?? '',
|
|
17
|
+
taskId: response.data?.task_id ?? taskId,
|
|
18
18
|
}), (0, invoicingQboViewReducer_1.fetchInvoicingQboSyncHealth)());
|
|
19
19
|
}
|
|
20
20
|
return (0, rxjs_1.of)((0, invoicingQboViewReducer_1.retryInvoicingQboSyncTaskFailure)({
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initializeIssueCreditNoteDraftFromInvoice = exports.localDataToIssueCreditNotePayload = exports.computeIssueCreditNoteTotal = void 0;
|
|
4
|
-
const dollarsFromAmountString = (value) => {
|
|
5
|
-
const parsed = Number.parseFloat(value);
|
|
6
|
-
if (Number.isNaN(parsed)) {
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
return parsed;
|
|
10
|
-
};
|
|
11
4
|
const computeIssueCreditNoteTotal = (lineItems) => lineItems
|
|
12
5
|
.filter((lineItem) => lineItem.selected)
|
|
13
6
|
.reduce((total, lineItem) => {
|
|
14
7
|
const quantity = Number.parseFloat(lineItem.quantity);
|
|
15
|
-
const unitAmount =
|
|
8
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
16
9
|
if (Number.isNaN(quantity) || quantity <= 0 || unitAmount <= 0) {
|
|
17
10
|
return total;
|
|
18
11
|
}
|
|
@@ -24,7 +17,7 @@ const localDataToIssueCreditNotePayload = (localData) => {
|
|
|
24
17
|
.filter((lineItem) => lineItem.selected)
|
|
25
18
|
.map((lineItem) => {
|
|
26
19
|
const quantity = Math.round(Number.parseFloat(lineItem.quantity));
|
|
27
|
-
const unitAmount =
|
|
20
|
+
const unitAmount = lineItem.unitAmount.amount;
|
|
28
21
|
return {
|
|
29
22
|
description: lineItem.description,
|
|
30
23
|
quantity,
|
|
@@ -48,10 +41,10 @@ const initializeIssueCreditNoteDraftFromInvoice = (invoice) => ({
|
|
|
48
41
|
description: lineItem.description,
|
|
49
42
|
id: lineItem.id,
|
|
50
43
|
maxQuantity: lineItem.quantity,
|
|
51
|
-
maxUnitAmount: lineItem.unitAmount
|
|
44
|
+
maxUnitAmount: lineItem.unitAmount,
|
|
52
45
|
quantity: String(lineItem.quantity),
|
|
53
46
|
selected: true,
|
|
54
|
-
unitAmount: lineItem.unitAmount
|
|
47
|
+
unitAmount: lineItem.unitAmount,
|
|
55
48
|
})),
|
|
56
49
|
});
|
|
57
50
|
exports.initializeIssueCreditNoteDraftFromInvoice = initializeIssueCreditNoteDraftFromInvoice;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
3
|
export interface IssueCreditNoteLineItemDraft {
|
|
3
4
|
description: string;
|
|
4
5
|
maxQuantity: number;
|
|
5
|
-
maxUnitAmount:
|
|
6
|
+
maxUnitAmount: Amount;
|
|
6
7
|
quantity: string;
|
|
7
8
|
selected: boolean;
|
|
8
|
-
unitAmount:
|
|
9
|
+
unitAmount: Amount;
|
|
9
10
|
id?: string;
|
|
10
11
|
}
|
|
11
12
|
export interface IssueCreditNoteFormLocalData {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initialRecordPaymentFormLocalData = exports.INVOICING_PAYMENT_GATEWAY_VALUES = exports.INVOICING_PAYMENT_METHOD_VALUES = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
4
5
|
/**
|
|
5
6
|
* Canonical value sets for the Record Payment form. CES owns the values;
|
|
6
7
|
* web-components maps each value to a localized label.
|
|
@@ -28,7 +29,7 @@ exports.INVOICING_PAYMENT_GATEWAY_VALUES = [
|
|
|
28
29
|
'other',
|
|
29
30
|
];
|
|
30
31
|
exports.initialRecordPaymentFormLocalData = {
|
|
31
|
-
amount: '',
|
|
32
|
+
amount: (0, amount_1.toAmount)(0, 'USD', '$'),
|
|
32
33
|
comment: '',
|
|
33
34
|
customerId: '',
|
|
34
35
|
date: '',
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initializeRecordPaymentDraftFromInvoice = exports.localDataToRecordPaymentPayload = exports.localDataToInvoiceRecordPaymentBody = void 0;
|
|
4
|
+
const amount_1 = require("../../../commonStateTypes/amount");
|
|
4
5
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
5
6
|
const recordPaymentFormConfig_1 = require("./recordPaymentFormConfig");
|
|
6
7
|
const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
|
|
7
|
-
const
|
|
8
|
-
const parsed = Number.parseFloat(value);
|
|
9
|
-
if (Number.isNaN(parsed)) {
|
|
10
|
-
return 0;
|
|
11
|
-
}
|
|
12
|
-
return parsed;
|
|
13
|
-
};
|
|
14
|
-
const amountDueDollarsFromInvoice = (invoice) => {
|
|
15
|
-
const amountDue = invoice.amountDue?.amount ?? 0;
|
|
16
|
-
return amountDue.toFixed(2);
|
|
17
|
-
};
|
|
8
|
+
const amountDueFromInvoice = (invoice) => invoice.amountDue ?? (0, amount_1.toAmount)(0, 'USD', '$');
|
|
18
9
|
/**
|
|
19
10
|
* Build the invoice-scoped Record Payment body from the form draft. Amount stays
|
|
20
11
|
* in dollars for the invoice endpoint.
|
|
@@ -24,7 +15,7 @@ const localDataToInvoiceRecordPaymentBody = (localData) => {
|
|
|
24
15
|
const date = localData.date.trim();
|
|
25
16
|
const referenceNumber = trimOrUndefined(localData.referenceNumber);
|
|
26
17
|
return {
|
|
27
|
-
amount:
|
|
18
|
+
amount: localData.amount.amount,
|
|
28
19
|
payment_method: localData.paymentMethod,
|
|
29
20
|
...(gateway != null ? { gateway } : {}),
|
|
30
21
|
...(date !== '' ? { date } : {}),
|
|
@@ -38,7 +29,7 @@ exports.localDataToInvoiceRecordPaymentBody = localDataToInvoiceRecordPaymentBod
|
|
|
38
29
|
* and the linked invoice into `linked_invoices`. Currency is locked to USD.
|
|
39
30
|
*/
|
|
40
31
|
const localDataToRecordPaymentPayload = (localData) => {
|
|
41
|
-
const amount =
|
|
32
|
+
const amount = localData.amount.amount;
|
|
42
33
|
const gateway = trimOrUndefined(localData.gateway);
|
|
43
34
|
const date = localData.date.trim();
|
|
44
35
|
const transactionId = trimOrUndefined(localData.transactionId);
|
|
@@ -65,7 +56,7 @@ const localDataToRecordPaymentPayload = (localData) => {
|
|
|
65
56
|
exports.localDataToRecordPaymentPayload = localDataToRecordPaymentPayload;
|
|
66
57
|
const initializeRecordPaymentDraftFromInvoice = (invoice) => ({
|
|
67
58
|
...recordPaymentFormConfig_1.initialRecordPaymentFormLocalData,
|
|
68
|
-
amount:
|
|
59
|
+
amount: amountDueFromInvoice(invoice),
|
|
69
60
|
customerId: invoice.customerID,
|
|
70
61
|
date: (0, zeniDayJS_1.dateNow)().format('YYYY-MM-DD'),
|
|
71
62
|
invoiceToLink: invoice.id,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
1
2
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
3
|
/**
|
|
3
4
|
* Draft form state for the Record Payment form. Held in CES so the form flows
|
|
4
5
|
* its data from here (mirrors the customer form pattern). Record payment is
|
|
5
6
|
* create-only, so there is a single draft (no per-id edit tree). The date is an
|
|
6
|
-
* ISO `YYYY-MM-DD` string; amount
|
|
7
|
+
* ISO `YYYY-MM-DD` string; the amount as an `Amount` (as on the invoice entity).
|
|
7
8
|
*/
|
|
8
9
|
export interface RecordPaymentFormLocalData {
|
|
9
|
-
amount:
|
|
10
|
+
amount: Amount;
|
|
10
11
|
comment: string;
|
|
11
12
|
customerId: string;
|
|
12
13
|
date: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.77-
|
|
3
|
+
"version": "5.1.77-betaAK1",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|