@zeniai/client-epic-state 4.9.79 → 4.9.81
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.
|
@@ -20,18 +20,17 @@ const billDetailViewState_1 = require("../../billDetailView/billDetailViewState"
|
|
|
20
20
|
const billPayConfigState_1 = require("../../billPayConfig/billPayConfigState");
|
|
21
21
|
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
22
22
|
const billPayConfigPayload_1 = require("../../billPayConfig/billPayConfigPayload");
|
|
23
|
-
const vendorSelector_1 = require("../../../../../entity/vendor/vendorSelector");
|
|
24
23
|
const recurringBillsPayload_1 = require("../../../../../entity/billPay/recurringBills/recurringBillsPayload");
|
|
25
24
|
const workingDayHelper_1 = require("../../../../../commonStateTypes/workingDayHelper");
|
|
26
25
|
const helpers_1 = require("../../../helpers");
|
|
27
26
|
const saveBillDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(editBillViewReducer_1.saveBillDetail.match), (0, operators_1.mergeMap)((action) => {
|
|
28
27
|
const state = state$.value;
|
|
29
|
-
const { billStageCode, billId
|
|
28
|
+
const { billStageCode, billId } = action.payload;
|
|
30
29
|
const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(billId !== null && billId !== void 0 ? billId : '');
|
|
31
30
|
const billDetail = billId != null
|
|
32
31
|
? state.editBillDetailViewState.editBillStateById[key]
|
|
33
32
|
: state.editBillDetailViewState.newBillState;
|
|
34
|
-
const payload = prepareSaveBillPayload(state.accountState, state.billTransactionState, state.paymentAccountState, state.
|
|
33
|
+
const payload = prepareSaveBillPayload(state.accountState, state.billTransactionState, state.paymentAccountState, state.recurringBillState, billDetail, billStageCode);
|
|
35
34
|
const isRecurringBill = billDetail.billDetailLocalData.isRecurring;
|
|
36
35
|
const saveBillBaseURL = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bills/transactions`;
|
|
37
36
|
const saveBillApi = billId != null
|
|
@@ -83,79 +82,68 @@ const getSaveBillApiURL = (saveBillBaseURL, isRecurring, billId, billTransaction
|
|
|
83
82
|
return isRecurring ? `${saveBillBaseURL}/recurring` : `${saveBillBaseURL}`;
|
|
84
83
|
}
|
|
85
84
|
};
|
|
86
|
-
function prepareSaveBillPayload(accountState, billTransactionState, paymentAccountState,
|
|
87
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22;
|
|
85
|
+
function prepareSaveBillPayload(accountState, billTransactionState, paymentAccountState, recurringBillState, billDetail, billStageCode) {
|
|
86
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
|
|
88
87
|
const billId = billDetail.billId;
|
|
89
88
|
let detail;
|
|
90
89
|
const withdrawFromAccount = (_a = billDetail.billDetailLocalData.paymentDetailsSection) === null || _a === void 0 ? void 0 : _a.withdrawFrom;
|
|
91
90
|
// In case if withdraw from account is a payment account we need a connected zeni account id
|
|
92
91
|
const zeniAccountId = (_c = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, (_b = withdrawFromAccount === null || withdrawFromAccount === void 0 ? void 0 : withdrawFromAccount.id) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.zeniAccountId;
|
|
93
|
-
const recommendedVendor = billDetail.billDetailLocalData.recommendedVendorId != null
|
|
94
|
-
? (0, vendorSelector_1.getVendorByVendorId)(vendorState, billDetail.billDetailLocalData.recommendedVendorId)
|
|
95
|
-
: undefined;
|
|
96
|
-
const isRecommendedVendor = isVendorRecommendationEnabled &&
|
|
97
|
-
recommendedVendor != null &&
|
|
98
|
-
billDetail.addBillAutoFields.tentativeVendorName != null;
|
|
99
92
|
const isRecurring = Boolean(billDetail.billDetailLocalData.isRecurring) === true;
|
|
100
93
|
const payload = {
|
|
101
|
-
vendor_id:
|
|
102
|
-
|
|
103
|
-
: (_d = billDetail.billDetailLocalData.vendor) === null || _d === void 0 ? void 0 : _d.qboId,
|
|
104
|
-
vendor_name: isRecommendedVendor
|
|
105
|
-
? recommendedVendor.name
|
|
106
|
-
: (_e = billDetail.billDetailLocalData.vendor) === null || _e === void 0 ? void 0 : _e.name,
|
|
94
|
+
vendor_id: (_e = (_d = billDetail.billDetailLocalData.vendor) === null || _d === void 0 ? void 0 : _d.qboId) !== null && _e !== void 0 ? _e : '',
|
|
95
|
+
vendor_name: (_g = (_f = billDetail.billDetailLocalData.vendor) === null || _f === void 0 ? void 0 : _f.name) !== null && _g !== void 0 ? _g : '',
|
|
107
96
|
//pass candidate_vendor_name only when we are not adding vendor(recommended or actual) to the bill
|
|
108
|
-
candidate_vendor_name:
|
|
109
|
-
((_f = billDetail.billDetailLocalData.vendor) === null || _f === void 0 ? void 0 : _f.qboId) != null
|
|
97
|
+
candidate_vendor_name: ((_h = billDetail.billDetailLocalData.vendor) === null || _h === void 0 ? void 0 : _h.qboId) != null
|
|
110
98
|
? undefined
|
|
111
|
-
: (
|
|
99
|
+
: (_j = billDetail.addBillAutoFields.tentativeVendorName) !== null && _j !== void 0 ? _j : billDetail.billDetailLocalData.candidateVendorname,
|
|
112
100
|
ocr_parsed_vendor_term: Boolean(billDetail.addBillAutoFields.tentativeVendorName) === true
|
|
113
101
|
? billDetail.addBillAutoFields.tentativeVendorName
|
|
114
102
|
: null,
|
|
115
103
|
transaction_type: 'bill',
|
|
116
104
|
bill_pay_provider: 'zeni',
|
|
117
105
|
account_id: zeniAccountId != null
|
|
118
|
-
? (
|
|
106
|
+
? (_k = (0, accountSelector_1.getAccountBase)(accountState, zeniAccountId, 'bill_pay')) === null || _k === void 0 ? void 0 : _k.qboId
|
|
119
107
|
: '',
|
|
120
|
-
file_id: (
|
|
121
|
-
transaction_date: (
|
|
122
|
-
due_date: (
|
|
123
|
-
total_amount: (
|
|
108
|
+
file_id: (_l = billDetail.billDetailLocalData.file) === null || _l === void 0 ? void 0 : _l.fileId,
|
|
109
|
+
transaction_date: (_p = (_o = (_m = billDetail.billDetailLocalData.whatForSection) === null || _m === void 0 ? void 0 : _m.invoiceDate) === null || _o === void 0 ? void 0 : _o.format('YYYY-MM-DD')) !== null && _p !== void 0 ? _p : (0, zeniDayJS_1.dateNow)().format('YYYY-MM-DD'),
|
|
110
|
+
due_date: (_s = (_r = (_q = billDetail.billDetailLocalData.whatForSection) === null || _q === void 0 ? void 0 : _q.billDueDate) === null || _r === void 0 ? void 0 : _r.format('YYYY-MM-DD')) !== null && _s !== void 0 ? _s : null,
|
|
111
|
+
total_amount: (_u = (_t = billDetail.billDetailLocalData.totalAmount) === null || _t === void 0 ? void 0 : _t.amount) !== null && _u !== void 0 ? _u : 0,
|
|
124
112
|
bill_pay_info: {
|
|
125
113
|
stage: {
|
|
126
114
|
code: billStageCode,
|
|
127
115
|
},
|
|
128
|
-
payment_date: (
|
|
116
|
+
payment_date: (_x = (_w = (_v = billDetail.billDetailLocalData.paymentDetailsSection) === null || _v === void 0 ? void 0 : _v.paymentDate) === null || _w === void 0 ? void 0 : _w.format('YYYY-MM-DD')) !== null && _x !== void 0 ? _x : null,
|
|
129
117
|
from_account: {
|
|
130
|
-
account_id: (
|
|
131
|
-
account_type: (
|
|
118
|
+
account_id: (_0 = (_z = (_y = billDetail.billDetailLocalData.paymentDetailsSection) === null || _y === void 0 ? void 0 : _y.withdrawFrom) === null || _z === void 0 ? void 0 : _z.id) !== null && _0 !== void 0 ? _0 : '',
|
|
119
|
+
account_type: (_3 = (0, helpers_1.accountTypeSubConfigCodeToAccType)((_2 = (_1 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _1 === void 0 ? void 0 : _1.withdrawFrom) === null || _2 === void 0 ? void 0 : _2.accType)) !== null && _3 !== void 0 ? _3 : '',
|
|
132
120
|
},
|
|
133
|
-
to_account: Object.assign({}, (((
|
|
121
|
+
to_account: Object.assign({}, (((_5 = (_4 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _4 === void 0 ? void 0 : _4.paymentType) === null || _5 === void 0 ? void 0 : _5.method.includes('international')) === true
|
|
134
122
|
? {
|
|
135
123
|
payment_instrument_id: Boolean(billDetail.billDetailLocalData
|
|
136
124
|
.isCollectToAccountInfoFromVendorContact) === false
|
|
137
|
-
? (
|
|
125
|
+
? (_7 = (_6 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _6 === void 0 ? void 0 : _6.paymentTo) !== null && _7 !== void 0 ? _7 : null
|
|
138
126
|
: null,
|
|
139
127
|
}
|
|
140
128
|
: {
|
|
141
129
|
account_id: Boolean(billDetail.billDetailLocalData
|
|
142
130
|
.isCollectToAccountInfoFromVendorContact) === false
|
|
143
|
-
? (
|
|
131
|
+
? (_9 = (_8 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _8 === void 0 ? void 0 : _8.paymentTo) !== null && _9 !== void 0 ? _9 : null
|
|
144
132
|
: null,
|
|
145
133
|
})),
|
|
146
|
-
to_account_vendor_email: (
|
|
134
|
+
to_account_vendor_email: (_10 = billDetail.billDetailLocalData.toAccountVendorEmail) !== null && _10 !== void 0 ? _10 : null,
|
|
147
135
|
is_collect_to_account_info_from_vendor_contact: billDetail.billDetailLocalData.isCollectToAccountInfoFromVendorContact,
|
|
148
136
|
is_cancelled: false,
|
|
149
|
-
bill_payment_method_type: getBillPaymentMethodTypePayload((
|
|
150
|
-
international_transfer_fee_bearer_payment_method: ((
|
|
151
|
-
((
|
|
152
|
-
? (
|
|
153
|
-
.internationalTransferFeeBearerPaymentMethod) !== null &&
|
|
137
|
+
bill_payment_method_type: getBillPaymentMethodTypePayload((_11 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _11 === void 0 ? void 0 : _11.paymentType),
|
|
138
|
+
international_transfer_fee_bearer_payment_method: ((_13 = (_12 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _12 === void 0 ? void 0 : _12.paymentType) === null || _13 === void 0 ? void 0 : _13.method.includes('international')) === true &&
|
|
139
|
+
((_14 = billDetail.billDetailLocalData.vendor) === null || _14 === void 0 ? void 0 : _14.vendorCurrencyCode) === 'USD'
|
|
140
|
+
? (_15 = billDetail.billDetailLocalData.paymentDetailsSection
|
|
141
|
+
.internationalTransferFeeBearerPaymentMethod) !== null && _15 !== void 0 ? _15 : 'swift_our' //default value for international method and USD currency
|
|
154
142
|
: null,
|
|
155
143
|
},
|
|
156
|
-
document_id: (
|
|
157
|
-
transaction_memo: (
|
|
158
|
-
currency_code: (
|
|
144
|
+
document_id: (_16 = billDetail.billDetailLocalData.whatForSection) === null || _16 === void 0 ? void 0 : _16.invoiceNumber,
|
|
145
|
+
transaction_memo: (_17 = billDetail.billDetailLocalData.whatForSection) === null || _17 === void 0 ? void 0 : _17.memo,
|
|
146
|
+
currency_code: (_19 = (_18 = billDetail.billDetailLocalData.whatForSection) === null || _18 === void 0 ? void 0 : _18.currencyCode) !== null && _19 !== void 0 ? _19 : 'USD',
|
|
159
147
|
lines: Object.keys(billDetail.billDetailLocalData.updatesByLineId).map((lineId) => {
|
|
160
148
|
const line = billDetail.billDetailLocalData.updatesByLineId[lineId];
|
|
161
149
|
const lineAsTransactionLinePayload = (0, editBillViewPayload_1.fromLineLocalDataToTransactionLinePayload)(line);
|
|
@@ -163,12 +151,12 @@ function prepareSaveBillPayload(accountState, billTransactionState, paymentAccou
|
|
|
163
151
|
}),
|
|
164
152
|
};
|
|
165
153
|
if (!isRecurring) {
|
|
166
|
-
payload.vendor_name = (
|
|
154
|
+
payload.vendor_name = (_21 = (_20 = billDetail.billDetailLocalData.vendor) === null || _20 === void 0 ? void 0 : _20.name) !== null && _21 !== void 0 ? _21 : '';
|
|
167
155
|
}
|
|
168
156
|
if (billId != null) {
|
|
169
157
|
detail = (0, get_1.default)(billTransactionState.transactionById, billId, undefined);
|
|
170
|
-
payload.sync_token = (
|
|
171
|
-
payload.update_time = (
|
|
158
|
+
payload.sync_token = (_22 = detail === null || detail === void 0 ? void 0 : detail.syncToken) !== null && _22 !== void 0 ? _22 : null;
|
|
159
|
+
payload.update_time = (_23 = detail === null || detail === void 0 ? void 0 : detail.updateTime.format('YYYY-MM-DD')) !== null && _23 !== void 0 ? _23 : null;
|
|
172
160
|
//required by platform to clear old recurring details
|
|
173
161
|
if ((detail === null || detail === void 0 ? void 0 : detail.isRecurring) === true &&
|
|
174
162
|
Boolean(billDetail.billDetailLocalData.isRecurring) === false) {
|
|
@@ -179,7 +167,7 @@ function prepareSaveBillPayload(accountState, billTransactionState, paymentAccou
|
|
|
179
167
|
payload.are_approvals_serialized = true;
|
|
180
168
|
}
|
|
181
169
|
if (billStageCode === 'pending_approval' &&
|
|
182
|
-
((
|
|
170
|
+
((_24 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _24 === void 0 ? void 0 : _24.conversionRate) != null) {
|
|
183
171
|
// required by platform
|
|
184
172
|
payload.exchange_rate =
|
|
185
173
|
1 / billDetail.billDetailLocalData.paymentDetailsSection.conversionRate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.81",
|
|
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
|
"types": "lib/index.d.ts",
|