@zeniai/client-epic-state 5.1.78 → 5.1.80
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/entity/invoicing/invoicingCommonPayload.d.ts +0 -42
- package/lib/entity/invoicing/invoicingCommonPayload.js +1 -66
- package/lib/entity/tenant/clearAllEpic.d.ts +1 -2
- package/lib/entity/tenant/clearAllEpic.js +0 -2
- package/lib/epic.d.ts +1 -2
- package/lib/epic.js +1 -7
- package/lib/esm/entity/invoicing/invoicingCommonPayload.js +0 -61
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -2
- package/lib/esm/epic.js +1 -7
- package/lib/esm/index.js +1 -5
- package/lib/esm/reducer.js +0 -3
- package/lib/esm/view/dashboard/dashboardSelector.js +10 -14
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +18 -4
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteFormConfig.js +1 -6
- package/lib/esm/view/invoicing/createCreditNote/createCreditNotePayload.js +8 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -4
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +11 -10
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +10 -8
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +2 -2
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js +1 -43
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/invoicingCouponFormConfig.js +44 -0
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +5 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +2 -1
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +1 -7
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +0 -3
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNotePayload.js +11 -4
- package/lib/esm/view/invoicing/recordPayment/recordPaymentFormConfig.js +1 -0
- package/lib/esm/view/invoicing/recordPayment/recordPaymentPayload.js +14 -5
- package/lib/index.d.ts +1 -7
- package/lib/index.js +4 -20
- package/lib/reducer.d.ts +0 -3
- package/lib/reducer.js +0 -3
- package/lib/view/dashboard/dashboardSelector.d.ts +3 -2
- package/lib/view/dashboard/dashboardSelector.js +9 -13
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +17 -3
- package/lib/view/invoicing/createCreditNote/createCreditNoteFormConfig.js +1 -6
- package/lib/view/invoicing/createCreditNote/createCreditNotePayload.js +8 -1
- package/lib/view/invoicing/createCreditNote/createCreditNoteState.d.ts +1 -3
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.d.ts +1 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -4
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +11 -10
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +5 -10
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js +10 -8
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +2 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +3 -3
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +2 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts +2 -9
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js +0 -45
- package/lib/view/invoicing/editInvoicingCouponDetailView/invoicingCouponFormConfig.d.ts +5 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/invoicingCouponFormConfig.js +48 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +5 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +1 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +2 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewPayload.d.ts +1 -4
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +0 -6
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +1 -4
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +0 -3
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewState.d.ts +1 -4
- package/lib/view/invoicing/issueCreditNote/issueCreditNotePayload.js +11 -4
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteState.d.ts +2 -3
- package/lib/view/invoicing/recordPayment/recordPaymentFormConfig.js +1 -0
- package/lib/view/invoicing/recordPayment/recordPaymentPayload.js +14 -5
- package/lib/view/invoicing/recordPayment/recordPaymentState.d.ts +2 -4
- package/package.json +1 -1
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -25
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -15
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboConnectionEpic.js +0 -15
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboSyncHealthEpic.js +0 -15
- package/lib/esm/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.js +0 -1
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +0 -26
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +0 -18
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewPayload.js +0 -47
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewReducer.js +0 -128
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +0 -20
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewState.js +0 -1
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +0 -6
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -29
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +0 -6
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -19
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboConnectionEpic.d.ts +0 -6
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboConnectionEpic.js +0 -19
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboSyncHealthEpic.d.ts +0 -6
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboSyncHealthEpic.js +0 -19
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.d.ts +0 -2
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.js +0 -2
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.d.ts +0 -6
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +0 -30
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.d.ts +0 -6
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +0 -22
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewPayload.d.ts +0 -79
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewPayload.js +0 -52
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewReducer.d.ts +0 -25
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewReducer.js +0 -132
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +0 -21
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +0 -24
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewState.d.ts +0 -14
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewState.js +0 -2
|
@@ -10,16 +10,17 @@ const toProductCode = (value) => value
|
|
|
10
10
|
.toLowerCase()
|
|
11
11
|
.replace(/[^a-z0-9]+/g, '-')
|
|
12
12
|
.replace(/^-|-$/g, '');
|
|
13
|
-
const
|
|
13
|
+
const toAmountValue = (value) => Number(value) || 0;
|
|
14
|
+
const buildAccountingDetail = (localData) => {
|
|
14
15
|
const detail = {};
|
|
15
|
-
if (
|
|
16
|
-
detail.sku =
|
|
16
|
+
if (localData.sku.trim() !== '') {
|
|
17
|
+
detail.sku = localData.sku.trim();
|
|
17
18
|
}
|
|
18
|
-
if (
|
|
19
|
-
detail.accounting_code =
|
|
19
|
+
if (localData.accountingCode.trim() !== '') {
|
|
20
|
+
detail.accounting_code = localData.accountingCode.trim();
|
|
20
21
|
}
|
|
21
|
-
if (
|
|
22
|
-
detail.accounting_category_1 =
|
|
22
|
+
if (localData.accountingCategory.trim() !== '') {
|
|
23
|
+
detail.accounting_category_1 = localData.accountingCategory.trim();
|
|
23
24
|
}
|
|
24
25
|
return Object.keys(detail).length > 0 ? detail : undefined;
|
|
25
26
|
};
|
|
@@ -33,7 +34,7 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
33
34
|
free_quantity: Number(subFamily.freeQuantity) || 0,
|
|
34
35
|
is_taxable: subFamily.isTaxable,
|
|
35
36
|
name,
|
|
36
|
-
price: tiered ? 0 : (subFamily.priceDollars
|
|
37
|
+
price: tiered ? 0 : toAmountValue(subFamily.priceDollars),
|
|
37
38
|
price_code: priceCode,
|
|
38
39
|
pricing_model: subFamily.pricingModel,
|
|
39
40
|
show_description_in_invoices: subFamily.showDescriptionInInvoices,
|
|
@@ -72,12 +73,12 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
|
|
|
72
73
|
payload.tiers = subFamily.tiers.map((tier) => ({
|
|
73
74
|
ending_unit: tier.endingUnit.trim() !== '' ? Number(tier.endingUnit) : undefined,
|
|
74
75
|
package_size: tier.packageSize.trim() !== '' ? Number(tier.packageSize) : undefined,
|
|
75
|
-
price: tier.price
|
|
76
|
+
price: toAmountValue(tier.price),
|
|
76
77
|
pricing_type: tier.pricingType,
|
|
77
78
|
starting_unit: Number(tier.startingUnit) || 1,
|
|
78
79
|
}));
|
|
79
80
|
}
|
|
80
|
-
const accountingDetail = buildAccountingDetail(
|
|
81
|
+
const accountingDetail = buildAccountingDetail(localData);
|
|
81
82
|
if (accountingDetail != null) {
|
|
82
83
|
payload.accounting_detail = accountingDetail;
|
|
83
84
|
}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
1
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
2
|
import { InvoicingCatalogItemKind } from '../invoicingCatalogItemDetailView/invoicingCatalogItemDetailViewState';
|
|
4
3
|
/** A single pricing tier within a sub-family (values kept as raw strings). */
|
|
5
4
|
export interface InvoicingCatalogItemFormTier {
|
|
6
5
|
endingUnit: string;
|
|
7
6
|
packageSize: string;
|
|
7
|
+
price: string;
|
|
8
8
|
pricingType: string;
|
|
9
9
|
startingUnit: string;
|
|
10
|
-
/** Unset until entered, so a blank field is distinguishable from a real 0. */
|
|
11
|
-
price?: Amount;
|
|
12
10
|
}
|
|
13
11
|
/** A sub-family (price point) of a catalog item. */
|
|
14
12
|
export interface InvoicingCatalogItemFormSubFamily {
|
|
15
|
-
/** Accounting integration is per sub-family: the API carries
|
|
16
|
-
* `accounting_detail` on each product, not on the parent item. */
|
|
17
|
-
accountingCategory: string;
|
|
18
|
-
accountingCode: string;
|
|
19
13
|
billingCycles: string;
|
|
20
14
|
description: string;
|
|
21
15
|
freeQuantity: string;
|
|
@@ -26,17 +20,15 @@ export interface InvoicingCatalogItemFormSubFamily {
|
|
|
26
20
|
period: string;
|
|
27
21
|
periodUnit: string;
|
|
28
22
|
priceCode: string;
|
|
23
|
+
priceDollars: string;
|
|
29
24
|
pricingModel: string;
|
|
30
25
|
prorationType: string;
|
|
31
26
|
showDescriptionInInvoices: boolean;
|
|
32
27
|
showDescriptionInQuotes: boolean;
|
|
33
|
-
sku: string;
|
|
34
28
|
tiers: InvoicingCatalogItemFormTier[];
|
|
35
29
|
trialEndAction: string;
|
|
36
30
|
trialPeriod: string;
|
|
37
31
|
trialPeriodUnit: string;
|
|
38
|
-
/** Unset until entered, so a blank field is distinguishable from a real 0. */
|
|
39
|
-
priceDollars?: Amount;
|
|
40
32
|
}
|
|
41
33
|
/**
|
|
42
34
|
* Draft form state for the create/edit catalog item (plan / add-on / one-time
|
|
@@ -45,6 +37,8 @@ export interface InvoicingCatalogItemFormSubFamily {
|
|
|
45
37
|
* every type is persisted as a parent catalog item through `/catalog/plans`.
|
|
46
38
|
*/
|
|
47
39
|
export interface InvoicingCatalogItemFormLocalData {
|
|
40
|
+
accountingCategory: string;
|
|
41
|
+
accountingCode: string;
|
|
48
42
|
applicableItems: string[];
|
|
49
43
|
catalogType: string;
|
|
50
44
|
description: string;
|
|
@@ -52,6 +46,7 @@ export interface InvoicingCatalogItemFormLocalData {
|
|
|
52
46
|
itemApplicability: string;
|
|
53
47
|
name: string;
|
|
54
48
|
productCode: string;
|
|
49
|
+
sku: string;
|
|
55
50
|
subFamilies: InvoicingCatalogItemFormSubFamily[];
|
|
56
51
|
unit: string;
|
|
57
52
|
}
|
package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormConfig.js
CHANGED
|
@@ -48,13 +48,12 @@ exports.isTieredCatalogPricingModel = isTieredCatalogPricingModel;
|
|
|
48
48
|
const blankInvoicingCatalogTier = (startingUnit = '1') => ({
|
|
49
49
|
endingUnit: '',
|
|
50
50
|
packageSize: '',
|
|
51
|
+
price: '',
|
|
51
52
|
pricingType: 'per_unit',
|
|
52
53
|
startingUnit,
|
|
53
54
|
});
|
|
54
55
|
exports.blankInvoicingCatalogTier = blankInvoicingCatalogTier;
|
|
55
56
|
const blankInvoicingCatalogSubFamily = () => ({
|
|
56
|
-
accountingCategory: '',
|
|
57
|
-
accountingCode: '',
|
|
58
57
|
billingCycles: '',
|
|
59
58
|
description: '',
|
|
60
59
|
freeQuantity: '0',
|
|
@@ -64,12 +63,12 @@ const blankInvoicingCatalogSubFamily = () => ({
|
|
|
64
63
|
name: '',
|
|
65
64
|
period: '1',
|
|
66
65
|
periodUnit: 'month',
|
|
66
|
+
priceDollars: '',
|
|
67
67
|
priceCode: '',
|
|
68
68
|
pricingModel: 'flat_fee',
|
|
69
69
|
prorationType: 'site_default',
|
|
70
70
|
showDescriptionInInvoices: true,
|
|
71
71
|
showDescriptionInQuotes: true,
|
|
72
|
-
sku: '',
|
|
73
72
|
tiers: [(0, exports.blankInvoicingCatalogTier)('1')],
|
|
74
73
|
trialEndAction: 'site_default',
|
|
75
74
|
trialPeriod: '',
|
|
@@ -83,10 +82,7 @@ const invoicingProductToCatalogItemFormSubFamily = (product) => {
|
|
|
83
82
|
}
|
|
84
83
|
return {
|
|
85
84
|
...base,
|
|
86
|
-
accountingCategory: product.accountingDetail?.accountingCategory1 ?? '',
|
|
87
|
-
accountingCode: product.accountingDetail?.accountingCode ?? '',
|
|
88
85
|
billingCycles: product.billingCycles != null ? String(product.billingCycles) : '',
|
|
89
|
-
sku: product.accountingDetail?.sku ?? '',
|
|
90
86
|
description: product.description ?? '',
|
|
91
87
|
freeQuantity: product.freeQuantity != null ? String(product.freeQuantity) : '0',
|
|
92
88
|
id: product.id,
|
|
@@ -95,7 +91,7 @@ const invoicingProductToCatalogItemFormSubFamily = (product) => {
|
|
|
95
91
|
name: product.name ?? '',
|
|
96
92
|
period: product.period != null ? String(product.period) : '1',
|
|
97
93
|
periodUnit: product.periodUnit ?? 'month',
|
|
98
|
-
priceDollars: product.price,
|
|
94
|
+
priceDollars: product.price != null ? String(product.price.amount) : '',
|
|
99
95
|
priceCode: product.priceCode ?? '',
|
|
100
96
|
pricingModel: product.pricingModel ?? 'flat_fee',
|
|
101
97
|
prorationType: product.prorationType ?? 'site_default',
|
|
@@ -105,7 +101,7 @@ const invoicingProductToCatalogItemFormSubFamily = (product) => {
|
|
|
105
101
|
? product.tiers.map((tier) => ({
|
|
106
102
|
endingUnit: tier.endingUnit != null ? String(tier.endingUnit) : '',
|
|
107
103
|
packageSize: tier.packageSize != null ? String(tier.packageSize) : '',
|
|
108
|
-
price: tier.price,
|
|
104
|
+
price: String(tier.price.amount),
|
|
109
105
|
pricingType: tier.pricingType ?? 'per_unit',
|
|
110
106
|
startingUnit: String(tier.startingUnit ?? 1),
|
|
111
107
|
}))
|
|
@@ -117,6 +113,8 @@ const invoicingProductToCatalogItemFormSubFamily = (product) => {
|
|
|
117
113
|
};
|
|
118
114
|
exports.invoicingProductToCatalogItemFormSubFamily = invoicingProductToCatalogItemFormSubFamily;
|
|
119
115
|
exports.initialInvoicingCatalogItemFormLocalData = {
|
|
116
|
+
accountingCategory: '',
|
|
117
|
+
accountingCode: '',
|
|
120
118
|
applicableItems: [],
|
|
121
119
|
catalogType: 'plan',
|
|
122
120
|
description: '',
|
|
@@ -124,6 +122,7 @@ exports.initialInvoicingCatalogItemFormLocalData = {
|
|
|
124
122
|
itemApplicability: 'all',
|
|
125
123
|
name: '',
|
|
126
124
|
productCode: '',
|
|
125
|
+
sku: '',
|
|
127
126
|
subFamilies: [(0, exports.blankInvoicingCatalogSubFamily)()],
|
|
128
127
|
unit: '',
|
|
129
128
|
};
|
|
@@ -144,6 +143,8 @@ const entityToInvoicingCatalogItemFormLocalData = (item) => {
|
|
|
144
143
|
? 'addon'
|
|
145
144
|
: 'plan';
|
|
146
145
|
return {
|
|
146
|
+
accountingCategory: plan.subFamilies?.[0]?.accountingDetail?.accountingCategory1 ?? '',
|
|
147
|
+
accountingCode: plan.subFamilies?.[0]?.accountingDetail?.accountingCode ?? '',
|
|
147
148
|
applicableItems: item.applicableItems ?? [],
|
|
148
149
|
catalogType,
|
|
149
150
|
description: item.description ?? '',
|
|
@@ -151,6 +152,7 @@ const entityToInvoicingCatalogItemFormLocalData = (item) => {
|
|
|
151
152
|
itemApplicability: item.itemApplicability ?? 'all',
|
|
152
153
|
name: item.name ?? '',
|
|
153
154
|
productCode: item.productCode ?? '',
|
|
155
|
+
sku: plan.subFamilies?.[0]?.accountingDetail?.sku ?? '',
|
|
154
156
|
subFamilies: plan?.subFamilies != null && plan.subFamilies.length > 0
|
|
155
157
|
? plan.subFamilies.map(exports.invoicingProductToCatalogItemFormSubFamily)
|
|
156
158
|
: [(0, exports.invoicingProductToCatalogItemFormSubFamily)()],
|
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 = localData.discountAmount
|
|
28
|
+
if (localData.discountAmount.trim() !== '') {
|
|
29
|
+
data.discount_amount = Number(localData.discountAmount);
|
|
30
30
|
}
|
|
31
31
|
data.currency_code = 'USD';
|
|
32
32
|
}
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js
CHANGED
|
@@ -3,12 +3,12 @@ var _a;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.resetEditInvoicingCouponDetailView = exports.submitInvoicingCouponFormFailure = exports.submitInvoicingCouponFormSuccess = exports.saveInvoicingCoupon = exports.submitInvoicingCouponForm = exports.updateInvoicingCouponFormDraft = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
const
|
|
6
|
+
const invoicingCouponFormConfig_1 = require("./invoicingCouponFormConfig");
|
|
7
7
|
exports.initialState = {
|
|
8
8
|
fetchState: 'Not-Started',
|
|
9
9
|
error: undefined,
|
|
10
10
|
editDraftById: {},
|
|
11
|
-
newCouponDraft: { ...
|
|
11
|
+
newCouponDraft: { ...invoicingCouponFormConfig_1.initialInvoicingCouponFormLocalData },
|
|
12
12
|
savedCouponId: undefined,
|
|
13
13
|
hasValidState() {
|
|
14
14
|
return this.fetchState === 'Completed';
|
|
@@ -61,7 +61,7 @@ const editInvoicingCouponDetailView = (0, toolkit_1.createSlice)({
|
|
|
61
61
|
draft.error = undefined;
|
|
62
62
|
draft.savedCouponId = undefined;
|
|
63
63
|
draft.editDraftById = {};
|
|
64
|
-
draft.newCouponDraft = { ...
|
|
64
|
+
draft.newCouponDraft = { ...invoicingCouponFormConfig_1.initialInvoicingCouponFormLocalData };
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
});
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getInvoicingCouponFormView = exports.getEditInvoicingCouponDetailViewState = void 0;
|
|
4
4
|
const couponConstants_1 = require("../../../entity/invoicing/coupon/couponConstants");
|
|
5
5
|
const couponSelector_1 = require("../../../entity/invoicing/coupon/couponSelector");
|
|
6
|
-
const
|
|
6
|
+
const invoicingCouponFormConfig_1 = require("./invoicingCouponFormConfig");
|
|
7
7
|
/**
|
|
8
8
|
* Bundled view for the discount create/edit form: the save fetch state/error,
|
|
9
9
|
* the id of the coupon last saved, and — when a `couponId` is passed (edit
|
|
@@ -33,7 +33,7 @@ const getInvoicingCouponFormView = (state, couponId) => {
|
|
|
33
33
|
const { editDraftById, newCouponDraft } = state.editInvoicingCouponDetailViewState;
|
|
34
34
|
const localData = couponId != null
|
|
35
35
|
? (editDraftById[couponId] ??
|
|
36
|
-
(0,
|
|
36
|
+
(0, invoicingCouponFormConfig_1.entityToInvoicingCouponFormLocalData)(base.coupon))
|
|
37
37
|
: newCouponDraft;
|
|
38
38
|
return {
|
|
39
39
|
...base,
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
1
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
|
-
import { InvoicingCoupon } from '../../../entity/invoicing/coupon/couponState';
|
|
4
2
|
/**
|
|
5
3
|
* Draft form state for the create/edit discount-coupon form. Held in CES so the
|
|
6
4
|
* form flows its data from here (mirrors the customer form pattern). Dates are
|
|
7
|
-
* stored as ISO `YYYY-MM-DD` strings;
|
|
8
|
-
* the coupon entity); remaining quantities as raw strings.
|
|
5
|
+
* stored as ISO `YYYY-MM-DD` strings; amounts/quantities as raw strings.
|
|
9
6
|
*/
|
|
10
7
|
export interface InvoicingCouponFormLocalData {
|
|
11
8
|
applyOn: string;
|
|
12
9
|
couponCode: string;
|
|
13
10
|
couponId: string;
|
|
11
|
+
discountAmount: string;
|
|
14
12
|
discountPercentage: string;
|
|
15
13
|
discountQuantity: string;
|
|
16
14
|
discountType: string;
|
|
@@ -23,14 +21,9 @@ export interface InvoicingCouponFormLocalData {
|
|
|
23
21
|
periodUnit: string;
|
|
24
22
|
validFrom: string;
|
|
25
23
|
validTill: string;
|
|
26
|
-
/** Unset until the user enters one, so an explicit 0 stays distinguishable. */
|
|
27
|
-
discountAmount?: Amount;
|
|
28
24
|
}
|
|
29
25
|
export interface EditInvoicingCouponDetailViewState extends FetchedState {
|
|
30
26
|
editDraftById: Record<ID, InvoicingCouponFormLocalData>;
|
|
31
27
|
newCouponDraft: InvoicingCouponFormLocalData;
|
|
32
28
|
savedCouponId?: ID;
|
|
33
29
|
}
|
|
34
|
-
export declare const initialInvoicingCouponFormLocalData: InvoicingCouponFormLocalData;
|
|
35
|
-
/** Seed the form draft from an existing coupon entity (edit mode). */
|
|
36
|
-
export declare const entityToInvoicingCouponFormLocalData: (coupon?: InvoicingCoupon) => InvoicingCouponFormLocalData;
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js
CHANGED
|
@@ -1,47 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.entityToInvoicingCouponFormLocalData = exports.initialInvoicingCouponFormLocalData = void 0;
|
|
4
|
-
exports.initialInvoicingCouponFormLocalData = {
|
|
5
|
-
applyOn: 'invoice_amount',
|
|
6
|
-
couponCode: '',
|
|
7
|
-
couponId: '',
|
|
8
|
-
discountPercentage: '',
|
|
9
|
-
discountQuantity: '',
|
|
10
|
-
discountType: 'percentage',
|
|
11
|
-
durationType: 'one_time',
|
|
12
|
-
invoiceName: '',
|
|
13
|
-
invoiceNotes: '',
|
|
14
|
-
maxRedemptions: '',
|
|
15
|
-
name: '',
|
|
16
|
-
period: '',
|
|
17
|
-
periodUnit: 'month',
|
|
18
|
-
validFrom: '',
|
|
19
|
-
validTill: '',
|
|
20
|
-
};
|
|
21
|
-
/** Seed the form draft from an existing coupon entity (edit mode). */
|
|
22
|
-
const entityToInvoicingCouponFormLocalData = (coupon) => {
|
|
23
|
-
if (coupon == null) {
|
|
24
|
-
return { ...exports.initialInvoicingCouponFormLocalData };
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
applyOn: coupon.applyOn ?? 'invoice_amount',
|
|
28
|
-
couponCode: coupon.couponCode ?? '',
|
|
29
|
-
couponId: coupon.id ?? '',
|
|
30
|
-
discountAmount: coupon.discountAmount,
|
|
31
|
-
discountPercentage: coupon.discountPercentage != null
|
|
32
|
-
? String(coupon.discountPercentage)
|
|
33
|
-
: '',
|
|
34
|
-
discountQuantity: coupon.discountQuantity != null ? String(coupon.discountQuantity) : '',
|
|
35
|
-
discountType: coupon.discountType ?? 'percentage',
|
|
36
|
-
durationType: coupon.durationType ?? 'one_time',
|
|
37
|
-
invoiceName: coupon.invoiceName ?? '',
|
|
38
|
-
invoiceNotes: coupon.invoiceNotes ?? '',
|
|
39
|
-
maxRedemptions: coupon.maxRedemptions != null ? String(coupon.maxRedemptions) : '',
|
|
40
|
-
name: coupon.name ?? '',
|
|
41
|
-
period: coupon.period != null ? String(coupon.period) : '',
|
|
42
|
-
periodUnit: coupon.periodUnit ?? 'month',
|
|
43
|
-
validFrom: coupon.validFrom != null ? coupon.validFrom.format('YYYY-MM-DD') : '',
|
|
44
|
-
validTill: coupon.validTill != null ? coupon.validTill.format('YYYY-MM-DD') : '',
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
exports.entityToInvoicingCouponFormLocalData = entityToInvoicingCouponFormLocalData;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InvoicingCoupon } from '../../../entity/invoicing/coupon/couponState';
|
|
2
|
+
import { InvoicingCouponFormLocalData } from './editInvoicingCouponDetailViewState';
|
|
3
|
+
export declare const initialInvoicingCouponFormLocalData: InvoicingCouponFormLocalData;
|
|
4
|
+
/** Seed the form draft from an existing coupon entity (edit mode). */
|
|
5
|
+
export declare const entityToInvoicingCouponFormLocalData: (coupon?: InvoicingCoupon) => InvoicingCouponFormLocalData;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entityToInvoicingCouponFormLocalData = exports.initialInvoicingCouponFormLocalData = void 0;
|
|
4
|
+
exports.initialInvoicingCouponFormLocalData = {
|
|
5
|
+
applyOn: 'invoice_amount',
|
|
6
|
+
couponCode: '',
|
|
7
|
+
couponId: '',
|
|
8
|
+
discountAmount: '',
|
|
9
|
+
discountPercentage: '',
|
|
10
|
+
discountQuantity: '',
|
|
11
|
+
discountType: 'percentage',
|
|
12
|
+
durationType: 'one_time',
|
|
13
|
+
invoiceName: '',
|
|
14
|
+
invoiceNotes: '',
|
|
15
|
+
maxRedemptions: '',
|
|
16
|
+
name: '',
|
|
17
|
+
period: '',
|
|
18
|
+
periodUnit: 'month',
|
|
19
|
+
validFrom: '',
|
|
20
|
+
validTill: '',
|
|
21
|
+
};
|
|
22
|
+
/** Seed the form draft from an existing coupon entity (edit mode). */
|
|
23
|
+
const entityToInvoicingCouponFormLocalData = (coupon) => {
|
|
24
|
+
if (coupon == null) {
|
|
25
|
+
return { ...exports.initialInvoicingCouponFormLocalData };
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
applyOn: coupon.applyOn ?? 'invoice_amount',
|
|
29
|
+
couponCode: coupon.couponCode ?? '',
|
|
30
|
+
couponId: coupon.id ?? '',
|
|
31
|
+
discountAmount: coupon.discountAmount != null ? String(coupon.discountAmount.amount) : '',
|
|
32
|
+
discountPercentage: coupon.discountPercentage != null
|
|
33
|
+
? String(coupon.discountPercentage)
|
|
34
|
+
: '',
|
|
35
|
+
discountQuantity: coupon.discountQuantity != null ? String(coupon.discountQuantity) : '',
|
|
36
|
+
discountType: coupon.discountType ?? 'percentage',
|
|
37
|
+
durationType: coupon.durationType ?? 'one_time',
|
|
38
|
+
invoiceName: coupon.invoiceName ?? '',
|
|
39
|
+
invoiceNotes: coupon.invoiceNotes ?? '',
|
|
40
|
+
maxRedemptions: coupon.maxRedemptions != null ? String(coupon.maxRedemptions) : '',
|
|
41
|
+
name: coupon.name ?? '',
|
|
42
|
+
period: coupon.period != null ? String(coupon.period) : '',
|
|
43
|
+
periodUnit: coupon.periodUnit ?? 'month',
|
|
44
|
+
validFrom: coupon.validFrom != null ? coupon.validFrom.format('YYYY-MM-DD') : '',
|
|
45
|
+
validTill: coupon.validTill != null ? coupon.validTill.format('YYYY-MM-DD') : '',
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.entityToInvoicingCouponFormLocalData = entityToInvoicingCouponFormLocalData;
|
|
@@ -27,7 +27,8 @@ const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingAddress)
|
|
|
27
27
|
quantity: 1,
|
|
28
28
|
})),
|
|
29
29
|
];
|
|
30
|
-
const setupFee = localData.setupFee
|
|
30
|
+
const setupFee = localData.setupFee.trim();
|
|
31
|
+
const parsedSetupFee = Number.parseFloat(setupFee);
|
|
31
32
|
const poNumber = localData.poNumber.trim();
|
|
32
33
|
const trialEnd = localData.trialEnd.trim();
|
|
33
34
|
return {
|
|
@@ -37,7 +38,9 @@ const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingAddress)
|
|
|
37
38
|
currency_code: localData.preferredCurrencyCode,
|
|
38
39
|
customer_id: localData.customerId,
|
|
39
40
|
subscription_items: items,
|
|
40
|
-
...(setupFee
|
|
41
|
+
...(setupFee !== '' && !Number.isNaN(parsedSetupFee)
|
|
42
|
+
? { setup_fee: parsedSetupFee }
|
|
43
|
+
: {}),
|
|
41
44
|
...(poNumber !== '' ? { po_number: poNumber } : {}),
|
|
42
45
|
...(trialEnd !== '' ? { trial_end: trialEnd } : {}),
|
|
43
46
|
...(localData.couponId !== '' ? { coupon_ids: [localData.couponId] } : {}),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
1
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
2
|
/**
|
|
4
3
|
* Draft form state for the create/edit subscription form. Held in CES so the
|
|
@@ -18,9 +17,8 @@ export interface InvoicingSubscriptionFormLocalData {
|
|
|
18
17
|
planQuantity: number;
|
|
19
18
|
poNumber: string;
|
|
20
19
|
preferredCurrencyCode: string;
|
|
20
|
+
setupFee: string;
|
|
21
21
|
trialEnd: string;
|
|
22
|
-
/** Unset until the user enters one, so an explicit 0 stays distinguishable. */
|
|
23
|
-
setupFee?: Amount;
|
|
24
22
|
}
|
|
25
23
|
export interface EditInvoicingSubscriptionDetailViewState extends FetchedState {
|
|
26
24
|
editDraftById: Record<ID, InvoicingSubscriptionFormLocalData>;
|
package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js
CHANGED
|
@@ -49,6 +49,7 @@ exports.initialInvoicingSubscriptionFormLocalData = {
|
|
|
49
49
|
planQuantity: 1,
|
|
50
50
|
poNumber: '',
|
|
51
51
|
preferredCurrencyCode: 'USD',
|
|
52
|
+
setupFee: '',
|
|
52
53
|
trialEnd: '',
|
|
53
54
|
};
|
|
54
55
|
/** Seed the form draft from an existing subscription entity (edit mode). */
|
|
@@ -70,7 +71,7 @@ const entityToInvoicingSubscriptionFormLocalData = (subscription) => {
|
|
|
70
71
|
planQuantity: planItem?.quantity ?? 1,
|
|
71
72
|
poNumber: subscription.poNumber ?? '',
|
|
72
73
|
preferredCurrencyCode: subscription.currencyCode ?? 'USD',
|
|
73
|
-
setupFee:
|
|
74
|
+
setupFee: '',
|
|
74
75
|
trialEnd: subscription.trialEnd != null
|
|
75
76
|
? subscription.trialEnd.format('YYYY-MM-DD')
|
|
76
77
|
: '',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuditLogEntityRouteOptionWire, AuditLogListSortFieldOptionWire, AuditLogSourceLabelOptionWire, InvoicingCatalogLifecycleActionOptionWire, InvoicingDunningActionOption, InvoicingNamedOptionWire,
|
|
1
|
+
import { AuditLogEntityRouteOptionWire, AuditLogListSortFieldOptionWire, AuditLogSourceLabelOptionWire, InvoicingCatalogLifecycleActionOptionWire, InvoicingDunningActionOption, InvoicingNamedOptionWire, InvoicingSubscriptionEditFieldOptionWire, InvoicingSubscriptionLifecycleActionOptionWire } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
2
2
|
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
3
3
|
/**
|
|
4
4
|
* Wire payload of the invoicing config API (GET/PUT `/1.0/config`). Follows
|
|
@@ -27,9 +27,6 @@ export interface InvoicingConfigPayload {
|
|
|
27
27
|
invoicing_tos_acceptance_user_agent?: string | null;
|
|
28
28
|
invoicing_tos_acceptance_user_id?: string | null;
|
|
29
29
|
is_invoicing_settings_seeded?: boolean;
|
|
30
|
-
qbo_account_mapping_kind_options?: InvoicingQboAccountMappingKindOptionWire[];
|
|
31
|
-
qbo_customer_matching_options?: InvoicingNamedOptionWire[];
|
|
32
|
-
qbo_sync_status_options?: InvoicingNamedOptionWire[];
|
|
33
30
|
updated_at?: string | null;
|
|
34
31
|
}
|
|
35
32
|
export type InvoicingConfigResponse = ZeniAPIResponse<InvoicingConfigPayload>;
|
|
@@ -2,7 +2,7 @@ import { ZeniAPIStatus } from '../../../responsePayload';
|
|
|
2
2
|
import { InvoicingConfigPayload } from './invoicingConfigViewPayload';
|
|
3
3
|
import { InvoicingConfigViewState } from './invoicingConfigViewState';
|
|
4
4
|
export declare const initialState: InvoicingConfigViewState;
|
|
5
|
-
export declare function mapInvoicingConfigPayloadToState(payload: InvoicingConfigPayload): Pick<InvoicingConfigViewState, 'auditLogEntityRouteOptions' | 'auditLogListSortFieldOptions' | 'auditLogSourceLabels' | 'dunningScheduleActionOptions' | 'subscriptionLifecycleActionOptions' | 'subscriptionCommercialEditAllowedFromStatuses' | 'subscriptionMetadataEditAllowedFromStatuses' | 'subscriptionEditFieldOptions' | 'subscriptionCancelTimingOptions' | 'subscriptionChangeOptionOptions' | 'catalogItemLifecycleActionOptions' | 'catalogProductLifecycleActionOptions' | 'discountLifecycleActionOptions' | '
|
|
5
|
+
export declare function mapInvoicingConfigPayloadToState(payload: InvoicingConfigPayload): Pick<InvoicingConfigViewState, 'auditLogEntityRouteOptions' | 'auditLogListSortFieldOptions' | 'auditLogSourceLabels' | 'dunningScheduleActionOptions' | 'subscriptionLifecycleActionOptions' | 'subscriptionCommercialEditAllowedFromStatuses' | 'subscriptionMetadataEditAllowedFromStatuses' | 'subscriptionEditFieldOptions' | 'subscriptionCancelTimingOptions' | 'subscriptionChangeOptionOptions' | 'catalogItemLifecycleActionOptions' | 'catalogProductLifecycleActionOptions' | 'discountLifecycleActionOptions' | 'isInvoicingEnabled' | 'isInvoicingTosAccepted' | 'invoicingTosAcceptanceIp' | 'invoicingTosAcceptanceTime' | 'invoicingTosAcceptanceUserAgent' | 'invoicingTosAcceptanceUserId' | 'isInvoicingSettingsSeeded'>;
|
|
6
6
|
export declare const fetchInvoicingConfig: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload?: {
|
|
7
7
|
cacheOverride?: boolean;
|
|
8
8
|
} | undefined], {
|
|
@@ -23,9 +23,6 @@ exports.initialState = {
|
|
|
23
23
|
catalogItemLifecycleActionOptions: [],
|
|
24
24
|
catalogProductLifecycleActionOptions: [],
|
|
25
25
|
discountLifecycleActionOptions: [],
|
|
26
|
-
qboAccountMappingKindOptions: [],
|
|
27
|
-
qboCustomerMatchingOptions: [],
|
|
28
|
-
qboSyncStatusOptions: [],
|
|
29
26
|
isInvoicingEnabled: undefined,
|
|
30
27
|
isInvoicingTosAccepted: undefined,
|
|
31
28
|
invoicingTosAcceptanceIp: undefined,
|
|
@@ -61,9 +58,6 @@ function mapInvoicingConfigPayloadToState(payload) {
|
|
|
61
58
|
catalogItemLifecycleActionOptions: (payload.catalog_item_lifecycle_action_options ?? []).map((option) => (0, invoicingCommonPayload_1.toInvoicingCatalogItemLifecycleActionOption)(option)),
|
|
62
59
|
catalogProductLifecycleActionOptions: (payload.catalog_product_lifecycle_action_options ?? []).map((option) => (0, invoicingCommonPayload_1.toInvoicingCatalogProductLifecycleActionOption)(option)),
|
|
63
60
|
discountLifecycleActionOptions: (payload.discount_lifecycle_action_options ?? []).map((option) => (0, invoicingCommonPayload_1.toInvoicingDiscountLifecycleActionOption)(option)),
|
|
64
|
-
qboAccountMappingKindOptions: (payload.qbo_account_mapping_kind_options ?? []).map(invoicingCommonPayload_1.toInvoicingQboAccountMappingKindOption),
|
|
65
|
-
qboCustomerMatchingOptions: (payload.qbo_customer_matching_options ?? []).map(invoicingCommonPayload_1.toInvoicingNamedOption),
|
|
66
|
-
qboSyncStatusOptions: (payload.qbo_sync_status_options ?? []).map(invoicingCommonPayload_1.toInvoicingNamedOption),
|
|
67
61
|
isInvoicingEnabled: payload.is_invoicing_enabled,
|
|
68
62
|
isInvoicingTosAccepted: payload.is_invoicing_tos_accepted,
|
|
69
63
|
invoicingTosAcceptanceIp: payload.invoicing_tos_acceptance_ip ?? undefined,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FetchState, FetchStateAndError } from '../../../commonStateTypes/common';
|
|
2
2
|
import { InvoicingDunningActionOption } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
|
-
import type { AuditLogEntityRouteOption, AuditLogListSortFieldOption, AuditLogSourceLabelOption, InvoicingCatalogItemLifecycleAction, InvoicingCatalogLifecycleActionOption, InvoicingCatalogProductLifecycleAction, InvoicingDiscountLifecycleActionOption, InvoicingNamedOption,
|
|
3
|
+
import type { AuditLogEntityRouteOption, AuditLogListSortFieldOption, AuditLogSourceLabelOption, InvoicingCatalogItemLifecycleAction, InvoicingCatalogLifecycleActionOption, InvoicingCatalogProductLifecycleAction, InvoicingDiscountLifecycleActionOption, InvoicingNamedOption, InvoicingSubscriptionEditFieldOption, InvoicingSubscriptionLifecycleActionOption } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
4
4
|
import { RootState } from '../../../reducer';
|
|
5
5
|
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
6
6
|
import { InvoicingOnboardingStatus } from './invoicingConfigViewPayload';
|
|
@@ -15,9 +15,6 @@ export interface InvoicingConfigView {
|
|
|
15
15
|
dunningScheduleActionOptions: InvoicingDunningActionOption[];
|
|
16
16
|
enableState: FetchStateAndError;
|
|
17
17
|
fetchState: FetchState;
|
|
18
|
-
qboAccountMappingKindOptions: InvoicingQboAccountMappingKindOption[];
|
|
19
|
-
qboCustomerMatchingOptions: InvoicingNamedOption[];
|
|
20
|
-
qboSyncStatusOptions: InvoicingNamedOption[];
|
|
21
18
|
subscriptionCancelTimingOptions: InvoicingNamedOption[];
|
|
22
19
|
subscriptionChangeOptionOptions: InvoicingNamedOption[];
|
|
23
20
|
subscriptionCommercialEditAllowedFromStatuses: string[];
|
|
@@ -26,9 +26,6 @@ const getInvoicingConfigView = (state) => {
|
|
|
26
26
|
catalogItemLifecycleActionOptions: configState.catalogItemLifecycleActionOptions,
|
|
27
27
|
catalogProductLifecycleActionOptions: configState.catalogProductLifecycleActionOptions,
|
|
28
28
|
discountLifecycleActionOptions: configState.discountLifecycleActionOptions,
|
|
29
|
-
qboAccountMappingKindOptions: configState.qboAccountMappingKindOptions,
|
|
30
|
-
qboCustomerMatchingOptions: configState.qboCustomerMatchingOptions,
|
|
31
|
-
qboSyncStatusOptions: configState.qboSyncStatusOptions,
|
|
32
29
|
error: configState.error,
|
|
33
30
|
fetchState: configState.fetchState,
|
|
34
31
|
isInvoicingEnabled: configState.isInvoicingEnabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FetchStateAndError, FetchedState } from '../../../commonStateTypes/common';
|
|
2
|
-
import type { AuditLogEntityRouteOption, AuditLogListSortFieldOption, AuditLogSourceLabelOption, InvoicingCatalogItemLifecycleAction, InvoicingCatalogLifecycleActionOption, InvoicingCatalogProductLifecycleAction, InvoicingDiscountLifecycleActionOption, InvoicingNamedOption,
|
|
2
|
+
import type { AuditLogEntityRouteOption, AuditLogListSortFieldOption, AuditLogSourceLabelOption, InvoicingCatalogItemLifecycleAction, InvoicingCatalogLifecycleActionOption, InvoicingCatalogProductLifecycleAction, InvoicingDiscountLifecycleActionOption, InvoicingNamedOption, InvoicingSubscriptionEditFieldOption, InvoicingSubscriptionLifecycleActionOption } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
3
|
import { InvoicingDunningActionOption } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
4
4
|
export interface InvoicingConfigViewState extends FetchedState {
|
|
5
5
|
acceptTermsFetchState: FetchStateAndError;
|
|
@@ -11,9 +11,6 @@ export interface InvoicingConfigViewState extends FetchedState {
|
|
|
11
11
|
discountLifecycleActionOptions: InvoicingDiscountLifecycleActionOption[];
|
|
12
12
|
dunningScheduleActionOptions: InvoicingDunningActionOption[];
|
|
13
13
|
enableFetchState: FetchStateAndError;
|
|
14
|
-
qboAccountMappingKindOptions: InvoicingQboAccountMappingKindOption[];
|
|
15
|
-
qboCustomerMatchingOptions: InvoicingNamedOption[];
|
|
16
|
-
qboSyncStatusOptions: InvoicingNamedOption[];
|
|
17
14
|
subscriptionCancelTimingOptions: InvoicingNamedOption[];
|
|
18
15
|
subscriptionChangeOptionOptions: InvoicingNamedOption[];
|
|
19
16
|
subscriptionCommercialEditAllowedFromStatuses: string[];
|
|
@@ -1,11 +1,18 @@
|
|
|
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
|
+
};
|
|
4
11
|
const computeIssueCreditNoteTotal = (lineItems) => lineItems
|
|
5
12
|
.filter((lineItem) => lineItem.selected)
|
|
6
13
|
.reduce((total, lineItem) => {
|
|
7
14
|
const quantity = Number.parseFloat(lineItem.quantity);
|
|
8
|
-
const unitAmount = lineItem.unitAmount
|
|
15
|
+
const unitAmount = dollarsFromAmountString(lineItem.unitAmount);
|
|
9
16
|
if (Number.isNaN(quantity) || quantity <= 0 || unitAmount <= 0) {
|
|
10
17
|
return total;
|
|
11
18
|
}
|
|
@@ -17,7 +24,7 @@ const localDataToIssueCreditNotePayload = (localData) => {
|
|
|
17
24
|
.filter((lineItem) => lineItem.selected)
|
|
18
25
|
.map((lineItem) => {
|
|
19
26
|
const quantity = Math.round(Number.parseFloat(lineItem.quantity));
|
|
20
|
-
const unitAmount = lineItem.unitAmount
|
|
27
|
+
const unitAmount = dollarsFromAmountString(lineItem.unitAmount);
|
|
21
28
|
return {
|
|
22
29
|
description: lineItem.description,
|
|
23
30
|
quantity,
|
|
@@ -41,10 +48,10 @@ const initializeIssueCreditNoteDraftFromInvoice = (invoice) => ({
|
|
|
41
48
|
description: lineItem.description,
|
|
42
49
|
id: lineItem.id,
|
|
43
50
|
maxQuantity: lineItem.quantity,
|
|
44
|
-
maxUnitAmount: lineItem.unitAmount,
|
|
51
|
+
maxUnitAmount: lineItem.unitAmount.amount,
|
|
45
52
|
quantity: String(lineItem.quantity),
|
|
46
53
|
selected: true,
|
|
47
|
-
unitAmount: lineItem.unitAmount,
|
|
54
|
+
unitAmount: lineItem.unitAmount.amount.toFixed(2),
|
|
48
55
|
})),
|
|
49
56
|
});
|
|
50
57
|
exports.initializeIssueCreditNoteDraftFromInvoice = initializeIssueCreditNoteDraftFromInvoice;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
1
|
import { FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
2
|
export interface IssueCreditNoteLineItemDraft {
|
|
4
3
|
description: string;
|
|
5
4
|
maxQuantity: number;
|
|
6
|
-
maxUnitAmount:
|
|
5
|
+
maxUnitAmount: number;
|
|
7
6
|
quantity: string;
|
|
8
7
|
selected: boolean;
|
|
9
|
-
unitAmount:
|
|
8
|
+
unitAmount: string;
|
|
10
9
|
id?: string;
|
|
11
10
|
}
|
|
12
11
|
export interface IssueCreditNoteFormLocalData {
|