@zeniai/client-epic-state 5.1.96-betaAK0 → 5.1.97
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/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +4 -6
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +24 -2
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +0 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +1 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.d.ts +1 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +1 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +3 -5
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.d.ts +16 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +26 -3
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +0 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +0 -1
- package/package.json +1 -1
- package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
|
@@ -80,7 +80,7 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
80
80
|
}
|
|
81
81
|
return payload;
|
|
82
82
|
};
|
|
83
|
-
/** `unit` is the item's unit of measure, not a currency; `CURRENCY_CODE` above prices
|
|
83
|
+
/** `unit` is the item's unit of measure, not a currency; `CURRENCY_CODE` above prices Price points. */
|
|
84
84
|
const DEFAULT_CATALOG_ITEM_UNIT = 'USD';
|
|
85
85
|
/**
|
|
86
86
|
* Build the parent catalog-item request body from the form draft. Creates omit
|
package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js
CHANGED
|
@@ -121,7 +121,7 @@ export const initialInvoicingCatalogItemFormLocalData = {
|
|
|
121
121
|
unit: '',
|
|
122
122
|
};
|
|
123
123
|
/**
|
|
124
|
-
* Seed the form draft from a parent catalog item and its embedded
|
|
124
|
+
* Seed the form draft from a parent catalog item and its embedded Price points.
|
|
125
125
|
*/
|
|
126
126
|
export const entityToInvoicingCatalogItemFormLocalData = (item) => {
|
|
127
127
|
if (item == null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toAddressUpdatableInfoPayload } from '../../addressView/addressViewPayload';
|
|
2
|
-
import { billingFrequencyToPeriod, invoicingSubscriptionTodayIso, toInvoicingSubscriptionQuantity, } from './invoicingSubscriptionFormConfig';
|
|
2
|
+
import { billingFrequencyToPeriod, invoicingSubscriptionTodayIso, toInvoicingSubscriptionBillingCycles, toInvoicingSubscriptionQuantity, } from './invoicingSubscriptionFormConfig';
|
|
3
3
|
/**
|
|
4
4
|
* Build the create/update subscription request body from the form draft. The
|
|
5
5
|
* shipping address is sent as an object (captured via the shared Address
|
|
@@ -32,7 +32,7 @@ export const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingA
|
|
|
32
32
|
const poNumber = localData.poNumber.trim();
|
|
33
33
|
const trialEnd = localData.trialEnd.trim();
|
|
34
34
|
const startedAt = localData.startedAt.trim();
|
|
35
|
-
const remainingBillingCycles = localData.remainingBillingCycles
|
|
35
|
+
const remainingBillingCycles = toInvoicingSubscriptionBillingCycles(localData.remainingBillingCycles);
|
|
36
36
|
return {
|
|
37
37
|
auto_collection: localData.autoCollection ? 'on' : 'off',
|
|
38
38
|
billing_period: frequency.period,
|
|
@@ -44,10 +44,8 @@ export const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingA
|
|
|
44
44
|
...(setupFee != null ? { setup_fee: setupFee } : {}),
|
|
45
45
|
...(poNumber !== '' ? { po_number: poNumber } : {}),
|
|
46
46
|
...(trialEnd !== '' ? { trial_end: trialEnd } : {}),
|
|
47
|
-
...(remainingBillingCycles
|
|
48
|
-
? {
|
|
49
|
-
remaining_billing_cycles: toInvoicingSubscriptionQuantity(Number(remainingBillingCycles)),
|
|
50
|
-
}
|
|
47
|
+
...(remainingBillingCycles != null
|
|
48
|
+
? { remaining_billing_cycles: remainingBillingCycles }
|
|
51
49
|
: {}),
|
|
52
50
|
...(localData.couponId !== '' ? { coupon_ids: [localData.couponId] } : {}),
|
|
53
51
|
...(shippingAddress != null
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dateNow } from '../../../zeniDayJS';
|
|
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,8 +45,12 @@ const subscriptionItemQuantities = (subscription, itemType) => {
|
|
|
44
45
|
});
|
|
45
46
|
return quantities;
|
|
46
47
|
};
|
|
47
|
-
/**
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Today as `YYYY-MM-DD`, the default subscription start date. Goes through
|
|
50
|
+
* dayjs (not `toISOString`, which is UTC) so a user in a UTC+ timezone late in
|
|
51
|
+
* their day gets their own calendar date rather than yesterday's.
|
|
52
|
+
*/
|
|
53
|
+
export const invoicingSubscriptionTodayIso = () => dateNow().format('YYYY-MM-DD');
|
|
49
54
|
/**
|
|
50
55
|
* Clamp a subscription-item quantity to the minimum the API accepts. Shared by
|
|
51
56
|
* the plan, add-on and charge items so none of them can bill a 0 or a fraction.
|
|
@@ -54,6 +59,23 @@ export const toInvoicingSubscriptionQuantity = (quantity) => {
|
|
|
54
59
|
const whole = Math.floor(Number(quantity));
|
|
55
60
|
return Number.isFinite(whole) && whole > 0 ? whole : 1;
|
|
56
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Parse the billing-cycles field into what the API should receive, or
|
|
64
|
+
* `undefined` when the field is empty or unparseable (the payload then omits it
|
|
65
|
+
* so the backend applies the plan's own limit).
|
|
66
|
+
*
|
|
67
|
+
* Deliberately NOT `toInvoicingSubscriptionQuantity`: `0` is a real
|
|
68
|
+
* remaining-cycles value on a subscription serving its last paid term, and edit
|
|
69
|
+
* drafts seed it straight off the entity. Clamping it up to `1` would turn a
|
|
70
|
+
* no-op save of a non-renewing subscription into a one-cycle extension.
|
|
71
|
+
*/
|
|
72
|
+
export const toInvoicingSubscriptionBillingCycles = (remainingBillingCycles) => {
|
|
73
|
+
if (remainingBillingCycles.trim() === '') {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const whole = Math.floor(Number(remainingBillingCycles));
|
|
77
|
+
return Number.isFinite(whole) && whole >= 0 ? whole : undefined;
|
|
78
|
+
};
|
|
57
79
|
export const initialInvoicingSubscriptionFormLocalData = {
|
|
58
80
|
addonPriceCodes: [],
|
|
59
81
|
addonQuantities: {},
|
|
@@ -83,7 +83,7 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
83
83
|
}
|
|
84
84
|
return payload;
|
|
85
85
|
};
|
|
86
|
-
/** `unit` is the item's unit of measure, not a currency; `CURRENCY_CODE` above prices
|
|
86
|
+
/** `unit` is the item's unit of measure, not a currency; `CURRENCY_CODE` above prices Price points. */
|
|
87
87
|
const DEFAULT_CATALOG_ITEM_UNIT = 'USD';
|
|
88
88
|
/**
|
|
89
89
|
* Build the parent catalog-item request body from the form draft. Creates omit
|
package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.d.ts
CHANGED
|
@@ -19,6 +19,6 @@ export declare const blankInvoicingCatalogSubFamily: () => InvoicingCatalogItemF
|
|
|
19
19
|
export declare const invoicingProductToCatalogItemFormSubFamily: (product?: InvoicingProduct) => InvoicingCatalogItemFormSubFamily;
|
|
20
20
|
export declare const initialInvoicingCatalogItemFormLocalData: InvoicingCatalogItemFormLocalData;
|
|
21
21
|
/**
|
|
22
|
-
* Seed the form draft from a parent catalog item and its embedded
|
|
22
|
+
* Seed the form draft from a parent catalog item and its embedded Price points.
|
|
23
23
|
*/
|
|
24
24
|
export declare const entityToInvoicingCatalogItemFormLocalData: (item?: InvoicingPlan) => InvoicingCatalogItemFormLocalData;
|
package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js
CHANGED
|
@@ -128,7 +128,7 @@ exports.initialInvoicingCatalogItemFormLocalData = {
|
|
|
128
128
|
unit: '',
|
|
129
129
|
};
|
|
130
130
|
/**
|
|
131
|
-
* Seed the form draft from a parent catalog item and its embedded
|
|
131
|
+
* Seed the form draft from a parent catalog item and its embedded Price points.
|
|
132
132
|
*/
|
|
133
133
|
const entityToInvoicingCatalogItemFormLocalData = (item) => {
|
|
134
134
|
if (item == null) {
|
|
@@ -35,7 +35,7 @@ const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingAddress)
|
|
|
35
35
|
const poNumber = localData.poNumber.trim();
|
|
36
36
|
const trialEnd = localData.trialEnd.trim();
|
|
37
37
|
const startedAt = localData.startedAt.trim();
|
|
38
|
-
const remainingBillingCycles = localData.remainingBillingCycles
|
|
38
|
+
const remainingBillingCycles = (0, invoicingSubscriptionFormConfig_1.toInvoicingSubscriptionBillingCycles)(localData.remainingBillingCycles);
|
|
39
39
|
return {
|
|
40
40
|
auto_collection: localData.autoCollection ? 'on' : 'off',
|
|
41
41
|
billing_period: frequency.period,
|
|
@@ -47,10 +47,8 @@ const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingAddress)
|
|
|
47
47
|
...(setupFee != null ? { setup_fee: setupFee } : {}),
|
|
48
48
|
...(poNumber !== '' ? { po_number: poNumber } : {}),
|
|
49
49
|
...(trialEnd !== '' ? { trial_end: trialEnd } : {}),
|
|
50
|
-
...(remainingBillingCycles
|
|
51
|
-
? {
|
|
52
|
-
remaining_billing_cycles: (0, invoicingSubscriptionFormConfig_1.toInvoicingSubscriptionQuantity)(Number(remainingBillingCycles)),
|
|
53
|
-
}
|
|
50
|
+
...(remainingBillingCycles != null
|
|
51
|
+
? { remaining_billing_cycles: remainingBillingCycles }
|
|
54
52
|
: {}),
|
|
55
53
|
...(localData.couponId !== '' ? { coupon_ids: [localData.couponId] } : {}),
|
|
56
54
|
...(shippingAddress != null
|
package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.d.ts
CHANGED
|
@@ -15,13 +15,28 @@ export declare const billingFrequencyToPeriod: (value: string) => {
|
|
|
15
15
|
};
|
|
16
16
|
/** Map an existing subscription's period/unit back to a billing-frequency value. */
|
|
17
17
|
export declare const periodToBillingFrequency: (period?: number, unit?: string) => string;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Today as `YYYY-MM-DD`, the default subscription start date. Goes through
|
|
20
|
+
* dayjs (not `toISOString`, which is UTC) so a user in a UTC+ timezone late in
|
|
21
|
+
* their day gets their own calendar date rather than yesterday's.
|
|
22
|
+
*/
|
|
19
23
|
export declare const invoicingSubscriptionTodayIso: () => string;
|
|
20
24
|
/**
|
|
21
25
|
* Clamp a subscription-item quantity to the minimum the API accepts. Shared by
|
|
22
26
|
* the plan, add-on and charge items so none of them can bill a 0 or a fraction.
|
|
23
27
|
*/
|
|
24
28
|
export declare const toInvoicingSubscriptionQuantity: (quantity?: number) => number;
|
|
29
|
+
/**
|
|
30
|
+
* Parse the billing-cycles field into what the API should receive, or
|
|
31
|
+
* `undefined` when the field is empty or unparseable (the payload then omits it
|
|
32
|
+
* so the backend applies the plan's own limit).
|
|
33
|
+
*
|
|
34
|
+
* Deliberately NOT `toInvoicingSubscriptionQuantity`: `0` is a real
|
|
35
|
+
* remaining-cycles value on a subscription serving its last paid term, and edit
|
|
36
|
+
* drafts seed it straight off the entity. Clamping it up to `1` would turn a
|
|
37
|
+
* no-op save of a non-renewing subscription into a one-cycle extension.
|
|
38
|
+
*/
|
|
39
|
+
export declare const toInvoicingSubscriptionBillingCycles: (remainingBillingCycles: string) => number | undefined;
|
|
25
40
|
export declare const initialInvoicingSubscriptionFormLocalData: InvoicingSubscriptionFormLocalData;
|
|
26
41
|
/** Seed the form draft from an existing subscription entity (edit mode). */
|
|
27
42
|
export declare const entityToInvoicingSubscriptionFormLocalData: (subscription?: InvoicingSubscription) => InvoicingSubscriptionFormLocalData;
|
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
|
-
exports.entityToInvoicingSubscriptionFormLocalData = exports.initialInvoicingSubscriptionFormLocalData = exports.toInvoicingSubscriptionQuantity = exports.invoicingSubscriptionTodayIso = exports.periodToBillingFrequency = exports.billingFrequencyToPeriod = exports.INVOICING_SUBSCRIPTION_BILLING_FREQUENCY_VALUES = exports.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE = void 0;
|
|
3
|
+
exports.entityToInvoicingSubscriptionFormLocalData = exports.initialInvoicingSubscriptionFormLocalData = exports.toInvoicingSubscriptionBillingCycles = exports.toInvoicingSubscriptionQuantity = exports.invoicingSubscriptionTodayIso = exports.periodToBillingFrequency = exports.billingFrequencyToPeriod = exports.INVOICING_SUBSCRIPTION_BILLING_FREQUENCY_VALUES = exports.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE = void 0;
|
|
4
|
+
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
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,8 +50,12 @@ const subscriptionItemQuantities = (subscription, itemType) => {
|
|
|
49
50
|
});
|
|
50
51
|
return quantities;
|
|
51
52
|
};
|
|
52
|
-
/**
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Today as `YYYY-MM-DD`, the default subscription start date. Goes through
|
|
55
|
+
* dayjs (not `toISOString`, which is UTC) so a user in a UTC+ timezone late in
|
|
56
|
+
* their day gets their own calendar date rather than yesterday's.
|
|
57
|
+
*/
|
|
58
|
+
const invoicingSubscriptionTodayIso = () => (0, zeniDayJS_1.dateNow)().format('YYYY-MM-DD');
|
|
54
59
|
exports.invoicingSubscriptionTodayIso = invoicingSubscriptionTodayIso;
|
|
55
60
|
/**
|
|
56
61
|
* Clamp a subscription-item quantity to the minimum the API accepts. Shared by
|
|
@@ -61,6 +66,24 @@ const toInvoicingSubscriptionQuantity = (quantity) => {
|
|
|
61
66
|
return Number.isFinite(whole) && whole > 0 ? whole : 1;
|
|
62
67
|
};
|
|
63
68
|
exports.toInvoicingSubscriptionQuantity = toInvoicingSubscriptionQuantity;
|
|
69
|
+
/**
|
|
70
|
+
* Parse the billing-cycles field into what the API should receive, or
|
|
71
|
+
* `undefined` when the field is empty or unparseable (the payload then omits it
|
|
72
|
+
* so the backend applies the plan's own limit).
|
|
73
|
+
*
|
|
74
|
+
* Deliberately NOT `toInvoicingSubscriptionQuantity`: `0` is a real
|
|
75
|
+
* remaining-cycles value on a subscription serving its last paid term, and edit
|
|
76
|
+
* drafts seed it straight off the entity. Clamping it up to `1` would turn a
|
|
77
|
+
* no-op save of a non-renewing subscription into a one-cycle extension.
|
|
78
|
+
*/
|
|
79
|
+
const toInvoicingSubscriptionBillingCycles = (remainingBillingCycles) => {
|
|
80
|
+
if (remainingBillingCycles.trim() === '') {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const whole = Math.floor(Number(remainingBillingCycles));
|
|
84
|
+
return Number.isFinite(whole) && whole >= 0 ? whole : undefined;
|
|
85
|
+
};
|
|
86
|
+
exports.toInvoicingSubscriptionBillingCycles = toInvoicingSubscriptionBillingCycles;
|
|
64
87
|
exports.initialInvoicingSubscriptionFormLocalData = {
|
|
65
88
|
addonPriceCodes: [],
|
|
66
89
|
addonQuantities: {},
|
|
@@ -2,7 +2,6 @@ import { FetchState, FetchStateAndError } from '../../../commonStateTypes/common
|
|
|
2
2
|
import { InvoicingNamedOption, InvoicingQboAccountMappingKindOption, InvoicingSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
3
|
import { RootState } from '../../../reducer';
|
|
4
4
|
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
5
|
-
import { InvoicingOnboardingStatus } from '../invoicingConfigView/invoicingConfigViewPayload';
|
|
6
5
|
import { InvoicingBrandingFormLocalData } from './invoicingBrandingFormConfig';
|
|
7
6
|
/**
|
|
8
7
|
* Shared primitive: the raw invoicing settings. Consumed internally by other
|
|
@@ -50,7 +49,6 @@ export interface InvoicingSettingsHubView {
|
|
|
50
49
|
isEnablingInvoicing: boolean;
|
|
51
50
|
isQboConfigured: boolean;
|
|
52
51
|
isStripeConnected: boolean;
|
|
53
|
-
status?: InvoicingOnboardingStatus;
|
|
54
52
|
}
|
|
55
53
|
/**
|
|
56
54
|
* The settings hub's composite of everything it derives from the store: whether
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.97",
|
|
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",
|