@zeniai/client-epic-state 4.8.13 → 4.8.14

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.
Files changed (34) hide show
  1. package/lib/entity/billPay/billTransaction/billTransactionPayload.d.ts +4 -2
  2. package/lib/entity/billPay/billTransaction/billTransactionPayload.js +24 -3
  3. package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +11 -3
  4. package/lib/entity/billPay/billTransaction/billTransactionState.js +12 -1
  5. package/lib/entity/reimbursement/reimbursementPayload.d.ts +2 -1
  6. package/lib/entity/reimbursement/reimbursementPayload.js +12 -3
  7. package/lib/entity/reimbursement/reimbursementState.d.ts +7 -3
  8. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewPayload.d.ts +2 -0
  9. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewReducer.d.ts +1 -1
  10. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewReducer.js +2 -3
  11. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.d.ts +6 -7
  12. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +21 -26
  13. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewState.d.ts +0 -4
  14. package/lib/view/spendManagement/billPay/billDetailView/epics/fetchBillDetailEpic.d.ts +2 -1
  15. package/lib/view/spendManagement/billPay/billDetailView/epics/fetchBillDetailEpic.js +3 -1
  16. package/lib/view/spendManagement/billPay/billList/billListSelector.js +4 -3
  17. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigPayload.d.ts +10 -8
  18. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigPayload.js +38 -38
  19. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigReducer.js +14 -4
  20. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigState.d.ts +1 -1
  21. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigState.js +2 -2
  22. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +8 -48
  23. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +11 -5
  24. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +69 -50
  25. package/lib/view/spendManagement/billPay/editBillView/editBillViewState.d.ts +2 -1
  26. package/lib/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.d.ts +2 -1
  27. package/lib/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js +13 -7
  28. package/lib/view/spendManagement/billPay/editBillView/epics/initializeBillToLocalStoreEpic.js +6 -9
  29. package/lib/view/spendManagement/billPay/editBillView/epics/parseInvoiceToBillEpic.js +14 -12
  30. package/lib/view/spendManagement/billPay/editBillView/epics/saveBillDetailEpic.js +27 -25
  31. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailSelector.d.ts +5 -0
  32. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailSelector.js +41 -30
  33. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferMoneyEpic.js +4 -4
  34. package/package.json +1 -1
@@ -3,11 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getRecurringBillLocalData = exports.getCurrentPaymentToOption = exports.toPaymentToOption = exports.getPaymentMethodType = exports.getBillPayConfigList = exports.getEditBillDetail = void 0;
6
+ exports.getWithdrawFrom = exports.getRecurringBillLocalData = exports.getCurrentPaymentToOption = exports.toPaymentToOption = exports.getPaymentSection = exports.getWhatForSection = exports.getPaymentMethodType = exports.getBillPayConfigList = exports.getEditBillDetail = void 0;
7
7
  const get_1 = __importDefault(require("lodash/get"));
8
8
  const has_1 = __importDefault(require("lodash/has"));
9
9
  const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
10
- const accountSelector_1 = require("../../../../entity/account/accountSelector");
11
10
  const bankAccountSelector_1 = require("../../../../entity/bankAccount/bankAccountSelector");
12
11
  const paymentAccountSelector_1 = require("../../../../entity/paymentAccount/paymentAccountSelector");
13
12
  const vendorSelector_1 = require("../../../../entity/vendor/vendorSelector");
@@ -27,13 +26,15 @@ const helpers_1 = require("../../helpers");
27
26
  const billPayReviewSelector_1 = require("../billPayReview/billPayReviewSelector");
28
27
  const paymentInstrumentSelector_1 = require("../../../../entity/paymentInstrument/paymentInstrumentSelector");
29
28
  const billPayConfigPayload_1 = require("../billPayConfig/billPayConfigPayload");
29
+ const transferDetailSelector_1 = require("../../zeniAccounts/transferDetail/transferDetailSelector");
30
+ const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
31
+ const depositAccountSelector_1 = require("../../../../entity/depositAccount/depositAccountSelector");
30
32
  const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId) => {
31
- 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;
32
- const { accountListState, accountState, bankAccountState, billDetailViewState, setupViewState, billTransactionState, billPayConfigState, classListState, classState, editBillDetailViewState, paymentAccountState, vendorState, tenantState, companyState, userState, commonHistoryState, contactState, paymentInstrumentState, recurringBillState, } = state;
33
- let transaction = null;
33
+ 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;
34
+ const { accountListState, accountState, bankAccountState, billDetailViewState, setupViewState, billTransactionState, billPayConfigState, classListState, classState, editBillDetailViewState, paymentAccountState, vendorState, tenantState, companyState, userState, commonHistoryState, contactState, paymentInstrumentState, recurringBillState, depositAccountListState, depositAccountState, } = state;
35
+ const transaction = (0, get_1.default)(billTransactionState.transactionById, billId !== null && billId !== void 0 ? billId : '', undefined);
34
36
  let recommendations = {};
35
37
  if (billId != null) {
36
- transaction = billTransactionState.transactionById[billId];
37
38
  recommendations = (transaction === null || transaction === void 0 ? void 0 : transaction.recommendations) || {};
38
39
  }
39
40
  const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(billId !== null && billId !== void 0 ? billId : '');
@@ -50,7 +51,15 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
50
51
  let bankAccountList = [];
51
52
  let paymentInstrumentList = [];
52
53
  let contactDetails = [];
53
- const withdrawFromList = (0, paymentAccountSelector_1.getPaymentAccountsByPaymentAccountIds)(paymentAccountState, setupViewState.accountDetails.paymentAccountIds);
54
+ const primaryPaymentAccount = (0, paymentAccountSelector_1.getPaymentAccountsByPaymentAccountIds)(paymentAccountState, (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountId) != null
55
+ ? /*
56
+ for extsing transaction since we are not calling payment accounts
57
+ we need to pick payment ids from billPayInfo object
58
+ */
59
+ [transaction.billPayInfo.fromAccount.billAccountId]
60
+ : setupViewState.accountDetails.paymentAccountIds);
61
+ const allDepositAccounts = (0, depositAccountListSelector_1.getAllDepostAccounts)(depositAccountState, depositAccountListState).depositAccounts;
62
+ const withdrawFromList = (0, transferDetailSelector_1.getTransferMoneyParties)(allDepositAccounts, primaryPaymentAccount);
54
63
  let previousBills = {
55
64
  bills: [],
56
65
  fetchState: 'Not-Started',
@@ -94,7 +103,6 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
94
103
  let recurringConfig;
95
104
  let recurringBillInstances;
96
105
  if (billId != null) {
97
- const transaction = (0, get_1.default)(billTransactionState.transactionById, billId, undefined);
98
106
  isDeleted = (_f = transaction === null || transaction === void 0 ? void 0 : transaction.isDeleted) !== null && _f !== void 0 ? _f : false;
99
107
  createdBy = (0, userSelector_1.getUserByUserId)(userState, (_g = transaction === null || transaction === void 0 ? void 0 : transaction.createdBy) !== null && _g !== void 0 ? _g : '');
100
108
  createTime = transaction === null || transaction === void 0 ? void 0 : transaction.createTime;
@@ -114,23 +122,18 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
114
122
  if (accountList.fetchState === 'Completed') {
115
123
  (_m = transaction === null || transaction === void 0 ? void 0 : transaction.lines) === null || _m === void 0 ? void 0 : _m.forEach((line) => {
116
124
  var _a;
117
- updatesByLineId[line.id] = Object.assign({}, line, {
118
- account: (_a = accountList.accounts.find((account) => {
125
+ updatesByLineId[line.id] = Object.assign(Object.assign({}, line), { account: (_a = accountList.accounts.find((account) => {
119
126
  var _a;
120
127
  return account.accountId ===
121
128
  ((_a = line.account) === null || _a === void 0 ? void 0 : _a.accountId);
122
- })) !== null && _a !== void 0 ? _a : line.account,
123
- });
129
+ })) !== null && _a !== void 0 ? _a : line.account });
124
130
  });
125
131
  }
126
132
  const initialPaymentDetailsSection = {
127
- paymentType: (0, exports.getPaymentMethodType)(billPayConfigState, billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.billPaymentMethodType, billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.internationalTransferFeeBearerPaymentMethod),
133
+ paymentType: (0, exports.getPaymentMethodType)(billPayConfigState, (_o = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.fromAccount.billAccountType) !== null && _o !== void 0 ? _o : 'depositAccount', billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.billPaymentMethodType, billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.internationalTransferFeeBearerPaymentMethod),
128
134
  paymentDate: billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.paymentDate,
129
- withdrawFrom: ((_o = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.fromAccount.billAccountId) === null || _o === void 0 ? void 0 : _o.length) != null &&
130
- (billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.fromAccount.billAccountId.length) > 0
131
- ? billPayInfo.fromAccount.billAccountId
132
- : undefined,
133
- paymentTo: ((_p = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.toAccount.billAccountId) === null || _p === void 0 ? void 0 : _p.length) != null &&
135
+ withdrawFrom: (0, exports.getWithdrawFrom)(paymentAccountState, depositAccountState, (_p = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.fromAccount.billAccountId) !== null && _p !== void 0 ? _p : '', (_q = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.fromAccount.billAccountType) !== null && _q !== void 0 ? _q : ''),
136
+ paymentTo: ((_r = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.toAccount.billAccountId) === null || _r === void 0 ? void 0 : _r.length) != null &&
134
137
  (billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.toAccount.billAccountId.length) > 0
135
138
  ? billPayInfo.toAccount.billAccountId
136
139
  : undefined,
@@ -147,7 +150,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
147
150
  if (sourceBillDetail != null) {
148
151
  const billViewState = billDetailViewState.billDetailById[key];
149
152
  isCancelled = sourceBillDetail.billDetailLocalData.isCancelled;
150
- billStage = (_q = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.stage.code) !== null && _q !== void 0 ? _q : 'draft';
153
+ billStage = (_s = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.stage.code) !== null && _s !== void 0 ? _s : 'draft';
151
154
  if (billViewState != null) {
152
155
  fetchState = (0, reduceFetchState_1.reduceFetchState)([
153
156
  billViewState,
@@ -159,7 +162,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
159
162
  }
160
163
  }
161
164
  //recurringBill Details
162
- isRecurring = (_r = transaction === null || transaction === void 0 ? void 0 : transaction.isRecurring) !== null && _r !== void 0 ? _r : false;
165
+ isRecurring = (_t = transaction === null || transaction === void 0 ? void 0 : transaction.isRecurring) !== null && _t !== void 0 ? _t : false;
163
166
  if (isRecurring && transaction != null) {
164
167
  const { recurringConfigLocalData, recurringBillInstancesLocalData } = (0, exports.getRecurringBillLocalData)(recurringBillState, transaction);
165
168
  recurringConfig = recurringConfigLocalData;
@@ -188,10 +191,10 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
188
191
  updatedRecord.vendor != null
189
192
  ? (0, vendorSelector_1.getVendorByVendorId)(vendorState, updatedRecord.vendor.id)
190
193
  : undefined;
191
- file = updatedRecord.file != null ? updatedRecord.file : undefined;
192
- const bankAccInBill = (0, bankAccountSelector_1.getBankAccountByBankAccountId)(bankAccountState, (_t = (_s = updatedRecord.paymentDetailsSection) === null || _s === void 0 ? void 0 : _s.paymentTo) !== null && _t !== void 0 ? _t : '');
193
- const vendorBankAccounts = (0, bankAccountSelector_1.getBankAccountsByBankAccountIds)(bankAccountState, (_u = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.bankAccountIds) !== null && _u !== void 0 ? _u : []);
194
- const vendorPaymentInstruments = (0, paymentInstrumentSelector_1.getPaymentInstrumentsByIds)(paymentInstrumentState, (_v = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.paymentInstrumentIds) !== null && _v !== void 0 ? _v : []);
194
+ file = updatedRecord.file;
195
+ const bankAccInBill = (0, bankAccountSelector_1.getBankAccountByBankAccountId)(bankAccountState, (_v = (_u = updatedRecord.paymentDetailsSection) === null || _u === void 0 ? void 0 : _u.paymentTo) !== null && _v !== void 0 ? _v : '');
196
+ const vendorBankAccounts = (0, bankAccountSelector_1.getBankAccountsByBankAccountIds)(bankAccountState, (_w = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.bankAccountIds) !== null && _w !== void 0 ? _w : []);
197
+ const vendorPaymentInstruments = (0, paymentInstrumentSelector_1.getPaymentInstrumentsByIds)(paymentInstrumentState, (_x = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.paymentInstrumentIds) !== null && _x !== void 0 ? _x : []);
195
198
  const isBankAccInBillExistInVendor = bankAccInBill != null
196
199
  ? vendorBankAccounts
197
200
  .map((bankAc) => bankAc.bankAccountId)
@@ -241,7 +244,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
241
244
  (recommendedVendor === null || recommendedVendor === void 0 ? void 0 : recommendedVendor.vendorCurrencyCode) != null) {
242
245
  whatForSection.currencyCode = recommendedVendor.vendorCurrencyCode;
243
246
  }
244
- isRecurring = (_w = sourceBillDetail.billDetailLocalData.isRecurring) !== null && _w !== void 0 ? _w : false;
247
+ isRecurring = (_y = sourceBillDetail.billDetailLocalData.isRecurring) !== null && _y !== void 0 ? _y : false;
245
248
  recurringConfig = sourceBillDetail.billDetailLocalData.recurringConfig;
246
249
  recurringBillInstances =
247
250
  sourceBillDetail.billDetailLocalData.recurringBillInstances;
@@ -261,7 +264,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
261
264
  }
262
265
  const vendorContactSaveStatus = editBillDetailViewState.updateVendorContactState;
263
266
  const lineDetailSection = {};
264
- const lineDetailSectionUpdatesByLineId = (_y = (_x = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.billDetailLocalData) === null || _x === void 0 ? void 0 : _x.updatesByLineId) !== null && _y !== void 0 ? _y : {};
267
+ const lineDetailSectionUpdatesByLineId = (_0 = (_z = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.billDetailLocalData) === null || _z === void 0 ? void 0 : _z.updatesByLineId) !== null && _0 !== void 0 ? _0 : {};
265
268
  const classList = (0, classListSelector_1.getClassList)(classState, classListState);
266
269
  if (accountList.fetchState === 'Completed') {
267
270
  Object.keys(lineDetailSectionUpdatesByLineId).forEach((lineId) => {
@@ -287,9 +290,9 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
287
290
  lastRecommendedVendorName,
288
291
  duplicateBills,
289
292
  fetchState: fetchState,
290
- saveStatus: (_z = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.saveStatus) !== null && _z !== void 0 ? _z : undefined,
291
- error: (_1 = (_0 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.fetchStatus) === null || _0 === void 0 ? void 0 : _0.error) !== null && _1 !== void 0 ? _1 : undefined,
292
- uploadStatus: (_2 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.uploadFetchState) !== null && _2 !== void 0 ? _2 : undefined,
293
+ saveStatus: (_1 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.saveStatus) !== null && _1 !== void 0 ? _1 : undefined,
294
+ error: (_3 = (_2 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.fetchStatus) === null || _2 === void 0 ? void 0 : _2.error) !== null && _3 !== void 0 ? _3 : undefined,
295
+ uploadStatus: (_4 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.uploadFetchState) !== null && _4 !== void 0 ? _4 : undefined,
293
296
  version: 0,
294
297
  createdBy,
295
298
  createTime,
@@ -336,22 +339,30 @@ const getBillPayConfigList = (billPayConfigState) => {
336
339
  billPayConfigState_1.BILL_PAYMENT_METHOD_CODE.forEach((code) => {
337
340
  switch (code) {
338
341
  case 'ach': {
339
- billPayConfigState_1.PAYMENT_ACH_SUB_CODES.forEach((subCode) => billPayConfigKeys.push((0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigPayload_1.getPaymentAchSubConfigCodeKey)(subCode))));
342
+ billPayConfigState_1.PAYMENT_ACH_SUB_CODES.forEach((subCode) => billPayConfigState_1.ACCOUNT_TYPE_CODES.forEach((accType) => {
343
+ billPayConfigKeys.push((0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigPayload_1.getPaymentAchSubConfigCodeKey)(subCode), (0, billPayConfigPayload_1.getAccountTypeSubConfigCodeKey)(accType)));
344
+ }));
340
345
  break;
341
346
  }
342
347
  case 'wire': {
343
348
  billPayConfigState_1.BILL_PAYMENT_WIRE_SUB_CODES.forEach((subCode) => {
344
349
  if (subCode === 'us-domestic') {
345
- billPayConfigKeys.push((0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigPayload_1.getBillPaymentWireSubConfigCodeKey)(subCode)));
350
+ billPayConfigState_1.ACCOUNT_TYPE_CODES.forEach((accType) => {
351
+ billPayConfigKeys.push((0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigPayload_1.getBillPaymentWireSubConfigCodeKey)(subCode), (0, billPayConfigPayload_1.getAccountTypeSubConfigCodeKey)(accType)));
352
+ });
346
353
  }
347
354
  else {
348
355
  billPayConfigState_1.INTERNATIONAL_CODES.forEach((internationalCode) => {
349
356
  if (internationalCode === 'usd-to-local-currency') {
350
- billPayConfigKeys.push((0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigPayload_1.getBillPaymentWireSubConfigCodeKey)(subCode), (0, billPayConfigPayload_1.getInternationalWireMethodCodeKey)(internationalCode)));
357
+ billPayConfigState_1.ACCOUNT_TYPE_CODES.forEach((accType) => {
358
+ billPayConfigKeys.push((0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigPayload_1.getBillPaymentWireSubConfigCodeKey)(subCode), (0, billPayConfigPayload_1.getAccountTypeSubConfigCodeKey)(accType), (0, billPayConfigPayload_1.getInternationalWireMethodCodeKey)(internationalCode)));
359
+ });
351
360
  }
352
361
  else {
353
362
  billPayConfigState_1.INTERNATIONAL_SUB_CODES.forEach((internationalSubCode) => {
354
- billPayConfigKeys.push((0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigPayload_1.getBillPaymentWireSubConfigCodeKey)(subCode), (0, billPayConfigPayload_1.getInternationalWireMethodCodeKey)(internationalCode), (0, billPayConfigPayload_1.getInternationalSubConfigCodeKey)(internationalSubCode)));
363
+ billPayConfigState_1.ACCOUNT_TYPE_CODES.forEach((accType) => {
364
+ billPayConfigKeys.push((0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigPayload_1.getBillPaymentWireSubConfigCodeKey)(subCode), (0, billPayConfigPayload_1.getAccountTypeSubConfigCodeKey)(accType), (0, billPayConfigPayload_1.getInternationalWireMethodCodeKey)(internationalCode), (0, billPayConfigPayload_1.getInternationalSubConfigCodeKey)(internationalSubCode)));
365
+ });
355
366
  });
356
367
  }
357
368
  });
@@ -364,7 +375,7 @@ const getBillPayConfigList = (billPayConfigState) => {
364
375
  return (0, billPayConfigSelector_1.getBillPayConfigByKeys)(billPayConfigState, billPayConfigKeys);
365
376
  };
366
377
  exports.getBillPayConfigList = getBillPayConfigList;
367
- const getPaymentMethodType = (billPayConfigState, paymentMethod, internationalTransferFeeBearerPaymentMethod) => {
378
+ const getPaymentMethodType = (billPayConfigState, accType, paymentMethod, internationalTransferFeeBearerPaymentMethod) => {
368
379
  if (paymentMethod == null) {
369
380
  return undefined;
370
381
  }
@@ -373,7 +384,7 @@ const getPaymentMethodType = (billPayConfigState, paymentMethod, internationalTr
373
384
  return undefined;
374
385
  }
375
386
  const { internationalCode, internationalSubCode } = (0, billPayConfigSelector_1.getInternationalMethodCode)(subCode, internationalTransferFeeBearerPaymentMethod);
376
- const key = (0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigState_1.toBillPaymentSubConfigCodeKeyType)((0, billPayConfigPayload_1.getBillPaymentSubConfigCodeKey)(subCode)), internationalCode != null
387
+ const key = (0, billPayConfigState_1.getBillPayConfigMethodKey)(code, (0, billPayConfigState_1.toBillPaymentSubConfigCodeKeyType)((0, billPayConfigPayload_1.getBillPaymentSubConfigCodeKey)(subCode)), accType, internationalCode != null
377
388
  ? (0, billPayConfigPayload_1.getInternationalWireMethodCodeKey)(internationalCode)
378
389
  : undefined, internationalSubCode != null
379
390
  ? (0, billPayConfigPayload_1.getInternationalSubConfigCodeKey)(internationalSubCode)
@@ -397,27 +408,20 @@ function getWhatForSection(updatedWhatForSection) {
397
408
  currencyCode: (_e = updatedWhatForSection === null || updatedWhatForSection === void 0 ? void 0 : updatedWhatForSection.currencyCode) !== null && _e !== void 0 ? _e : 'USD',
398
409
  };
399
410
  }
411
+ exports.getWhatForSection = getWhatForSection;
400
412
  function getPaymentSection(state, withdrawFromList, updatedPaymentSection) {
401
- var _a, _b, _c;
402
- const { accountState, paymentAccountState } = state;
413
+ var _a, _b;
403
414
  const withdrawFrom = (updatedPaymentSection === null || updatedPaymentSection === void 0 ? void 0 : updatedPaymentSection.withdrawFrom) != null
404
- ? (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, updatedPaymentSection.withdrawFrom)
405
- : withdrawFromList.length > 0
415
+ ? updatedPaymentSection === null || updatedPaymentSection === void 0 ? void 0 : updatedPaymentSection.withdrawFrom
416
+ : withdrawFromList.length === 1
406
417
  ? withdrawFromList[0]
407
418
  : undefined;
408
- const withdrawFromAccountingName = (withdrawFrom === null || withdrawFrom === void 0 ? void 0 : withdrawFrom.zeniAccountId) != null &&
409
- (withdrawFrom === null || withdrawFrom === void 0 ? void 0 : withdrawFrom.zeniAccountId.length) > 0
410
- ? (_a = (0, accountSelector_1.getAccountBase)(accountState, withdrawFrom === null || withdrawFrom === void 0 ? void 0 : withdrawFrom.zeniAccountId, 'bill_pay')) === null || _a === void 0 ? void 0 : _a.accountName
411
- : '';
412
- const isSinglePaymentTypeOption = state.billPayConfigState.fetchState === 'Completed' &&
413
- (0, exports.getBillPayConfigList)(state.billPayConfigState).length === 1;
419
+ const withdrawFromAccountingName = undefined;
414
420
  return {
415
- paymentType: isSinglePaymentTypeOption
416
- ? (0, exports.getBillPayConfigList)(state.billPayConfigState)[0]
417
- : (_b = updatedPaymentSection.paymentType) !== null && _b !== void 0 ? _b : undefined,
418
- paymentDate: (_c = updatedPaymentSection === null || updatedPaymentSection === void 0 ? void 0 : updatedPaymentSection.paymentDate) !== null && _c !== void 0 ? _c : undefined,
421
+ paymentType: (_a = updatedPaymentSection.paymentType) !== null && _a !== void 0 ? _a : undefined,
422
+ paymentDate: (_b = updatedPaymentSection === null || updatedPaymentSection === void 0 ? void 0 : updatedPaymentSection.paymentDate) !== null && _b !== void 0 ? _b : undefined,
419
423
  withdrawFrom: withdrawFrom,
420
- withdrawFromAccountingName: withdrawFromAccountingName,
424
+ withdrawFromAccountingName,
421
425
  paymentTo: updatedPaymentSection.paymentTo != null
422
426
  ? getCurrentPaymentToOption(state, updatedPaymentSection.paymentTo)
423
427
  : undefined,
@@ -425,6 +429,7 @@ function getPaymentSection(state, withdrawFromList, updatedPaymentSection) {
425
429
  conversionRate: updatedPaymentSection.conversionRate,
426
430
  };
427
431
  }
432
+ exports.getPaymentSection = getPaymentSection;
428
433
  function toPaymentToOption(paymentMode) {
429
434
  const paymentToOption = {
430
435
  id: '',
@@ -513,3 +518,17 @@ const getRecurringBillLocalData = (recurringBillState, transaction) => {
513
518
  return { recurringConfigLocalData, recurringBillInstancesLocalData };
514
519
  };
515
520
  exports.getRecurringBillLocalData = getRecurringBillLocalData;
521
+ const getWithdrawFrom = (paymentAccountState, depositAccountState, fromAccountId, fromAccountType) => {
522
+ const withdrawFromAsDepositAcc = (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, fromAccountId);
523
+ const withdrawFromAsPaymentAcc = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, fromAccountId);
524
+ if (fromAccountType === 'depositAccount' &&
525
+ withdrawFromAsDepositAcc != null) {
526
+ return (0, transferDetailSelector_1.mapDepositAccToTransferMoneyParty)(withdrawFromAsDepositAcc);
527
+ }
528
+ if (fromAccountType === 'paymentAccount' &&
529
+ withdrawFromAsPaymentAcc != null) {
530
+ return (0, transferDetailSelector_1.mapPaymentAccToTransferMoneyParty)(withdrawFromAsPaymentAcc);
531
+ }
532
+ return undefined;
533
+ };
534
+ exports.getWithdrawFrom = getWithdrawFrom;
@@ -13,6 +13,7 @@ import { BankAccount } from '../../../../entity/bankAccount/bankAccount';
13
13
  import { Contact } from '../../../../entity/billPay/contact/contact';
14
14
  import { RecurringBillFrequency, RecurringBillPaymentStatus, RecurringBillStatus } from '../../../../entity/billPay/recurringBills/recurringBillsState';
15
15
  import { BillStage } from '../../../../entity/billPay/billTransaction/billTransactionState';
16
+ import { TransferMoneyParty } from '../../zeniAccounts/transferDetail/transferDetailState';
16
17
  export interface EditBillDetail {
17
18
  fetchStatus: FetchStateAndError;
18
19
  saveStatus: FetchStateAndError;
@@ -73,7 +74,7 @@ export interface PaymentDetailsSection {
73
74
  internationalTransferFeeBearerPaymentMethod?: InternationalTransferFeeBearerPaymentMethod;
74
75
  paymentType?: BillPayConfig;
75
76
  paymentDate?: ZeniDate;
76
- withdrawFrom?: ID;
77
+ withdrawFrom?: TransferMoneyParty;
77
78
  paymentTo?: ID;
78
79
  conversionRate?: number;
79
80
  }
@@ -9,5 +9,6 @@ import { fetchBillPaySetupApproverView } from '../../billPaySetupApproverView/bi
9
9
  import { fetchOwnerList } from '../../../../ownerList/ownerListReducer';
10
10
  import { fetchVendorTypeList } from '../../../../vendorTypeList/vendorTypeListReducer';
11
11
  import { fetchBillPayConfig } from '../../billPayConfig/billPayConfigReducer';
12
- export declare type ActionType = ReturnType<typeof fetchEditBillDetailPage> | ReturnType<typeof fetchClassList> | ReturnType<typeof fetchVendorTypeList> | ReturnType<typeof fetchAccountList> | ReturnType<typeof getPaymentAccounts> | ReturnType<typeof fetchBillPayConfig> | ReturnType<typeof updateShowAutofill> | ReturnType<typeof fetchBillPaySetupApproverView> | ReturnType<typeof fetchOwnerList>;
12
+ import { fetchDepositAccountList } from '../../../zeniAccounts/depositAccountList/depositAccountListReducer';
13
+ export declare type ActionType = ReturnType<typeof fetchEditBillDetailPage> | ReturnType<typeof fetchClassList> | ReturnType<typeof fetchVendorTypeList> | ReturnType<typeof fetchAccountList> | ReturnType<typeof getPaymentAccounts> | ReturnType<typeof fetchDepositAccountList> | ReturnType<typeof fetchBillPayConfig> | ReturnType<typeof updateShowAutofill> | ReturnType<typeof fetchBillPaySetupApproverView> | ReturnType<typeof fetchOwnerList>;
13
14
  export declare const fetchEditBillDetailPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -11,6 +11,7 @@ const billPaySetupApproverViewReducer_1 = require("../../billPaySetupApproverVie
11
11
  const ownerListReducer_1 = require("../../../../ownerList/ownerListReducer");
12
12
  const vendorTypeListReducer_1 = require("../../../../vendorTypeList/vendorTypeListReducer");
13
13
  const billPayConfigReducer_1 = require("../../billPayConfig/billPayConfigReducer");
14
+ const depositAccountListReducer_1 = require("../../../zeniAccounts/depositAccountList/depositAccountListReducer");
14
15
  const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editBillViewReducer_1.fetchEditBillDetailPage.match), (0, operators_1.mergeMap)((action) => {
15
16
  const { cacheOverride, billId, isShowDeletedBillsEnabled } = action.payload;
16
17
  const billDetailActions = [];
@@ -21,13 +22,14 @@ const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe((0, oper
21
22
  billDetailActions.push((0, vendorTypeListReducer_1.fetchVendorTypeList)());
22
23
  billDetailActions.push((0, ownerListReducer_1.fetchOwnerList)());
23
24
  billDetailActions.push((0, billPayConfigReducer_1.fetchBillPayConfig)());
25
+ billDetailActions.push((0, depositAccountListReducer_1.fetchDepositAccountList)());
26
+ billDetailActions.push((0, setupViewReducer_1.getPaymentAccounts)('bill_pay'));
24
27
  if (billId != null) {
25
28
  billDetailActions.push((0, editBillViewReducer_1.fetchBillAndInitializeLocalStore)(billId, true, isShowDeletedBillsEnabled));
26
29
  }
27
30
  else {
28
31
  billDetailActions.push((0, editBillViewReducer_1.updateShowAutofill)(true));
29
32
  billDetailActions.push((0, billPaySetupApproverViewReducer_1.fetchBillPaySetupApproverView)(true));
30
- billDetailActions.push((0, setupViewReducer_1.getPaymentAccounts)('bill_pay'));
31
33
  }
32
34
  }
33
35
  else {
@@ -54,6 +56,16 @@ const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe((0, oper
54
56
  billPayConfigFetchState !== 'In-Progress') {
55
57
  billDetailActions.push((0, billPayConfigReducer_1.fetchBillPayConfig)());
56
58
  }
59
+ const depositAccounts = state.depositAccountListState;
60
+ if (depositAccounts.fetchState !== 'In-Progress' &&
61
+ depositAccounts.fetchState !== 'Completed') {
62
+ billDetailActions.push((0, depositAccountListReducer_1.fetchDepositAccountList)());
63
+ }
64
+ const paymentAccount = state.setupViewState.accountDetails;
65
+ if (paymentAccount.fetchStatus.fetchState !== 'In-Progress' &&
66
+ paymentAccount.fetchStatus.fetchState !== 'Completed') {
67
+ billDetailActions.push((0, setupViewReducer_1.getPaymentAccounts)('bill_pay'));
68
+ }
57
69
  if (billId != null) {
58
70
  billDetailActions.push((0, editBillViewReducer_1.fetchBillAndInitializeLocalStore)(billId, false, isShowDeletedBillsEnabled));
59
71
  }
@@ -63,12 +75,6 @@ const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe((0, oper
63
75
  if (approvalViewFetchState !== 'In-Progress') {
64
76
  billDetailActions.push((0, billPaySetupApproverViewReducer_1.fetchBillPaySetupApproverView)(true));
65
77
  }
66
- const paymentAccount = state.setupViewState.accountDetails;
67
- if (billId == null &&
68
- paymentAccount.fetchStatus.fetchState !== 'In-Progress' &&
69
- paymentAccount.fetchStatus.fetchState !== 'Completed') {
70
- billDetailActions.push((0, setupViewReducer_1.getPaymentAccounts)('bill_pay'));
71
- }
72
78
  }
73
79
  }
74
80
  return (0, rxjs_1.concat)((0, rxjs_1.from)(billDetailActions));
@@ -90,14 +90,14 @@ const getLineRecommendationsLocalData = (lineId, line, recommendations, accountL
90
90
  };
91
91
  exports.getLineRecommendationsLocalData = getLineRecommendationsLocalData;
92
92
  const initializeBillToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editBillViewReducer_1.initializeBillToLocalStore.match), (0, operators_1.mergeMap)((action) => {
93
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
93
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
94
94
  const { billId } = action.payload;
95
95
  const state = state$.value;
96
96
  const detailKey = (0, billDetailViewState_1.getBillTransactionDetailKey)(billId);
97
97
  const editBillState = (0, get_1.default)(state.editBillDetailViewState.editBillStateById, detailKey, undefined);
98
98
  const billDetail = (0, get_1.default)(state.billDetailViewState.billDetailById, detailKey, undefined);
99
99
  const transaction = (0, get_1.default)(state.billTransactionState.transactionById, billId, undefined);
100
- const { accountListState, accountState, classListState, classState, recurringBillState, } = state;
100
+ const { accountListState, accountState, classListState, classState, recurringBillState, depositAccountState, paymentAccountState, } = state;
101
101
  const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'billPayAccountList');
102
102
  const classList = (0, classListSelector_1.getClassList)(classState, classListState);
103
103
  const recommendations = transaction === null || transaction === void 0 ? void 0 : transaction.recommendations;
@@ -150,12 +150,9 @@ const initializeBillToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, o
150
150
  ? (0, zeniDayJS_1.dateNow)().isSameOrBefore(payNowCutOffTime)
151
151
  : false;
152
152
  const paymentDetailsSection = {
153
- paymentType: (0, editBillViewSelector_1.getPaymentMethodType)(state.billPayConfigState, transaction.billPayInfo.billPaymentMethodType, transaction.billPayInfo.internationalTransferFeeBearerPaymentMethod),
154
- paymentDate: (_h = transaction.billPayInfo.paymentDate) !== null && _h !== void 0 ? _h : (0, zeniDayJS_1.date)((0, workingDayHelper_1.getNextNthWorkingDay)((0, zeniDayJS_1.dateNow)().toDate(), [0, 6], isPayNowEnabled ? 0 : 1).toISOString()),
155
- withdrawFrom: transaction.billPayInfo.fromAccount.billAccountId != null &&
156
- transaction.billPayInfo.fromAccount.billAccountId.length > 0
157
- ? transaction.billPayInfo.fromAccount.billAccountId
158
- : undefined,
153
+ paymentType: (0, editBillViewSelector_1.getPaymentMethodType)(state.billPayConfigState, (_h = transaction.billPayInfo.fromAccount.billAccountType) !== null && _h !== void 0 ? _h : 'depositAccount', transaction.billPayInfo.billPaymentMethodType, transaction.billPayInfo.internationalTransferFeeBearerPaymentMethod),
154
+ paymentDate: (_j = transaction.billPayInfo.paymentDate) !== null && _j !== void 0 ? _j : (0, zeniDayJS_1.date)((0, workingDayHelper_1.getNextNthWorkingDay)((0, zeniDayJS_1.dateNow)().toDate(), [0, 6], isPayNowEnabled ? 0 : 1).toISOString()),
155
+ withdrawFrom: (0, editBillViewSelector_1.getWithdrawFrom)(paymentAccountState, depositAccountState, (_k = transaction.billPayInfo.fromAccount.billAccountId) !== null && _k !== void 0 ? _k : '', (_l = transaction.billPayInfo.fromAccount.billAccountType) !== null && _l !== void 0 ? _l : ''),
159
156
  paymentTo: transaction.billPayInfo.toAccount.billAccountId != null &&
160
157
  transaction.billPayInfo.toAccount.billAccountId.length > 0
161
158
  ? transaction.billPayInfo.toAccount.billAccountId
@@ -164,7 +161,7 @@ const initializeBillToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, o
164
161
  };
165
162
  const totalAmount = transaction.amount;
166
163
  const isCancelled = transaction.billPayInfo.isCancelled;
167
- const file = (_j = transaction.attachments) === null || _j === void 0 ? void 0 : _j[0];
164
+ const file = (_m = transaction.attachments) === null || _m === void 0 ? void 0 : _m[0];
168
165
  const candidateVendorname = transaction.candidateVendorName;
169
166
  const toAccountVendorEmail = transaction.billPayInfo.toAccountVendorEmail;
170
167
  const isCollectToAccountInfoFromVendorContact = transaction.billPayInfo.isCollectToAccountInfoFromVendorContact;
@@ -19,6 +19,7 @@ const vendorSelector_1 = require("../../../../../entity/vendor/vendorSelector");
19
19
  const billPayReviewReducer_1 = require("../../billPayReview/billPayReviewReducer");
20
20
  const classPayload_1 = require("../../../../../entity/class/classPayload");
21
21
  const accountPayload_1 = require("../../../../../entity/account/accountPayload");
22
+ const editBillViewSelector_1 = require("../editBillViewSelector");
22
23
  const classListSelector_1 = require("../../../../classList/classListSelector");
23
24
  const accountListSelector_1 = require("../../../../accountList/accountListSelector");
24
25
  const initializeBillToLocalStoreEpic_1 = require("./initializeBillToLocalStoreEpic");
@@ -120,7 +121,7 @@ const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators
120
121
  }));
121
122
  exports.parseInvoiceToBillEpic = parseInvoiceToBillEpic;
122
123
  const toBillDetailLocalData = (state, billPayload, vendor, recommendedVendorId) => {
123
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
124
+ 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;
124
125
  const currency = {
125
126
  currencyCode: (_a = billPayload.currency_code) !== null && _a !== void 0 ? _a : '',
126
127
  currencySymbol: (_b = billPayload.currency_symbol) !== null && _b !== void 0 ? _b : '', //api not returning symbol
@@ -182,6 +183,7 @@ const toBillDetailLocalData = (state, billPayload, vendor, recommendedVendorId)
182
183
  const isPayNowEnabled = payNowCutOffTime != null
183
184
  ? (0, zeniDayJS_1.dateNow)().isSameOrBefore(payNowCutOffTime)
184
185
  : false;
186
+ const fromAccountType = (0, billPayConfigPayload_1.getAccountTypeSubConfigCodeKey)((0, billPayConfigState_1.toAccType)((_m = (_l = billPayload.bill_pay_info) === null || _l === void 0 ? void 0 : _l.from_account.account_type) !== null && _m !== void 0 ? _m : ''));
185
187
  return {
186
188
  recommendedVendorId,
187
189
  lastRecommendedVendorName: recommendedVendorId != null ? vendor === null || vendor === void 0 ? void 0 : vendor.name : undefined,
@@ -202,30 +204,30 @@ const toBillDetailLocalData = (state, billPayload, vendor, recommendedVendorId)
202
204
  paymentDetailsSection: {
203
205
  paymentTo: vendor != null ? vendor.bankAccountIds[0] : undefined,
204
206
  paymentType: paymentMethodCode != null && paymentMethodSubCode != null
205
- ? (0, billPayConfigSelector_1.getBillPayConfigByKey)(state.billPayConfigState, (0, billPayConfigState_1.getBillPayConfigMethodKey)((0, billPayConfigState_1.toBillPaymentMethodCodeType)(paymentMethodCode), (0, billPayConfigState_1.toBillPaymentSubConfigCodeKeyType)((0, billPayConfigPayload_1.getBillPaymentSubConfigCodeKey)((0, billPayConfigState_1.toBillPaymentSubConfigCodeType)(paymentMethodSubCode))), internationalCode != null
207
+ ? (0, billPayConfigSelector_1.getBillPayConfigByKey)(state.billPayConfigState, (0, billPayConfigState_1.getBillPayConfigMethodKey)((0, billPayConfigState_1.toBillPaymentMethodCodeType)(paymentMethodCode), (0, billPayConfigState_1.toBillPaymentSubConfigCodeKeyType)((0, billPayConfigPayload_1.getBillPaymentSubConfigCodeKey)((0, billPayConfigState_1.toBillPaymentSubConfigCodeType)(paymentMethodSubCode))), fromAccountType, internationalCode != null
206
208
  ? (0, billPayConfigPayload_1.getInternationalWireMethodCodeKey)(internationalCode)
207
209
  : undefined, internationalSubCode != null
208
210
  ? (0, billPayConfigPayload_1.getInternationalSubConfigCodeKey)(internationalSubCode)
209
211
  : undefined))
210
212
  : undefined,
211
- paymentDate: ((_l = billPayload.bill_pay_info) === null || _l === void 0 ? void 0 : _l.payment_date) != null
212
- ? (0, zeniDayJS_1.date)((_m = billPayload.bill_pay_info) === null || _m === void 0 ? void 0 : _m.payment_date)
213
+ paymentDate: ((_o = billPayload.bill_pay_info) === null || _o === void 0 ? void 0 : _o.payment_date) != null
214
+ ? (0, zeniDayJS_1.date)((_p = billPayload.bill_pay_info) === null || _p === void 0 ? void 0 : _p.payment_date)
213
215
  : (0, zeniDayJS_1.date)((0, workingDayHelper_1.getNextNthWorkingDay)((0, zeniDayJS_1.dateNow)().toDate(), [0, 6], isPayNowEnabled ? 0 : 1).toISOString()),
214
- withdrawFrom: (_p = (_o = billPayload.bill_pay_info) === null || _o === void 0 ? void 0 : _o.from_account.account_id) !== null && _p !== void 0 ? _p : undefined,
215
- internationalTransferFeeBearerPaymentMethod: ((_q = billPayload.bill_pay_info) === null || _q === void 0 ? void 0 : _q.international_transfer_fee_bearer_payment_method) != null
216
- ? (0, billTransactionState_1.toInternationalTransferFeeBearerPaymentMethod)((_r = billPayload.bill_pay_info) === null || _r === void 0 ? void 0 : _r.international_transfer_fee_bearer_payment_method)
216
+ withdrawFrom: (0, editBillViewSelector_1.getWithdrawFrom)(state.paymentAccountState, state.depositAccountState, (_r = (_q = billPayload.bill_pay_info) === null || _q === void 0 ? void 0 : _q.from_account.account_id) !== null && _r !== void 0 ? _r : '', (_t = (_s = billPayload.bill_pay_info) === null || _s === void 0 ? void 0 : _s.from_account.account_type) !== null && _t !== void 0 ? _t : ''),
217
+ internationalTransferFeeBearerPaymentMethod: ((_u = billPayload.bill_pay_info) === null || _u === void 0 ? void 0 : _u.international_transfer_fee_bearer_payment_method) != null
218
+ ? (0, billTransactionState_1.toInternationalTransferFeeBearerPaymentMethod)((_v = billPayload.bill_pay_info) === null || _v === void 0 ? void 0 : _v.international_transfer_fee_bearer_payment_method)
217
219
  : undefined,
218
220
  },
219
221
  totalAmount: billPayload.amount != null
220
222
  ? (0, amount_1.toAmountWC)(billPayload.amount, {
221
- currencyCode: (_s = billPayload.currency_code) !== null && _s !== void 0 ? _s : 'USD',
222
- currencySymbol: (_t = billPayload.currency_symbol) !== null && _t !== void 0 ? _t : '$',
223
+ currencyCode: (_w = billPayload.currency_code) !== null && _w !== void 0 ? _w : 'USD',
224
+ currencySymbol: (_x = billPayload.currency_symbol) !== null && _x !== void 0 ? _x : '$',
223
225
  })
224
226
  : undefined,
225
227
  isCancelled: false,
226
- toAccountVendorEmail: (_v = (_u = billPayload.bill_pay_info) === null || _u === void 0 ? void 0 : _u.to_account_vendor_email) !== null && _v !== void 0 ? _v : undefined,
227
- isCollectToAccountInfoFromVendorContact: (_x = (_w = billPayload.bill_pay_info) === null || _w === void 0 ? void 0 : _w.is_collect_to_account_info_from_vendor_contact) !== null && _x !== void 0 ? _x : false,
228
- isRecurring: (_y = billPayload.is_recurring) !== null && _y !== void 0 ? _y : false,
228
+ toAccountVendorEmail: (_z = (_y = billPayload.bill_pay_info) === null || _y === void 0 ? void 0 : _y.to_account_vendor_email) !== null && _z !== void 0 ? _z : undefined,
229
+ isCollectToAccountInfoFromVendorContact: (_1 = (_0 = billPayload.bill_pay_info) === null || _0 === void 0 ? void 0 : _0.is_collect_to_account_info_from_vendor_contact) !== null && _1 !== void 0 ? _1 : false,
230
+ isRecurring: (_2 = billPayload.is_recurring) !== null && _2 !== void 0 ? _2 : false,
229
231
  };
230
232
  };
231
233
  exports.toBillDetailLocalData = toBillDetailLocalData;
@@ -31,7 +31,7 @@ const saveBillDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, oper
31
31
  const billDetail = billId != null
32
32
  ? state.editBillDetailViewState.editBillStateById[key]
33
33
  : state.editBillDetailViewState.newBillState;
34
- const payload = prepareSaveBillPayload(state.accountState, state.billTransactionState, state.paymentAccountState, state.setupViewState, state.vendorState, state.recurringBillState, billDetail, billStageCode, isVendorRecommendationEnabled, isLocalCurrencyEnabled);
34
+ const payload = prepareSaveBillPayload(state.accountState, state.billTransactionState, state.paymentAccountState, state.vendorState, state.recurringBillState, billDetail, billStageCode, isVendorRecommendationEnabled, isLocalCurrencyEnabled);
35
35
  const isRecurringBill = billDetail.billDetailLocalData.isRecurring;
36
36
  const saveBillBaseURL = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bills/transactions`;
37
37
  const saveBillApi = billId != null
@@ -82,12 +82,13 @@ const getSaveBillApiURL = (saveBillBaseURL, isRecurring, billId) => {
82
82
  return isRecurring ? `${saveBillBaseURL}/recurring` : `${saveBillBaseURL}`;
83
83
  }
84
84
  };
85
- function prepareSaveBillPayload(accountState, billTransactionState, paymentAccountState, setupViewState, vendorState, recurringBillState, billDetail, billStageCode, isVendorRecommendationEnabled, isLocalCurrencyEnabled) {
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;
85
+ function prepareSaveBillPayload(accountState, billTransactionState, paymentAccountState, vendorState, recurringBillState, billDetail, billStageCode, isVendorRecommendationEnabled, isLocalCurrencyEnabled) {
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;
87
87
  const billId = billDetail.billId;
88
88
  let detail;
89
- const withdrawFromList = (0, paymentAccountSelector_1.getPaymentAccountsByPaymentAccountIds)(paymentAccountState, setupViewState.accountDetails.paymentAccountIds);
90
- const withdrawFromAccount = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, (_c = (_b = (_a = billDetail.billDetailLocalData.paymentDetailsSection) === null || _a === void 0 ? void 0 : _a.withdrawFrom) !== null && _b !== void 0 ? _b : withdrawFromList === null || withdrawFromList === void 0 ? void 0 : withdrawFromList[0].paymentAccountId) !== null && _c !== void 0 ? _c : '');
89
+ const withdrawFromAccount = (_a = billDetail.billDetailLocalData.paymentDetailsSection) === null || _a === void 0 ? void 0 : _a.withdrawFrom;
90
+ // In case if withdraw from account is a payment account we need a connected zeni account id
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;
91
92
  const recommendedVendor = billDetail.billDetailLocalData.recommendedVendorId != null
92
93
  ? (0, vendorSelector_1.getVendorByVendorId)(vendorState, billDetail.billDetailLocalData.recommendedVendorId)
93
94
  : undefined;
@@ -107,8 +108,8 @@ function prepareSaveBillPayload(accountState, billTransactionState, paymentAccou
107
108
  : (_f = billDetail.addBillAutoFields.tentativeVendorName) !== null && _f !== void 0 ? _f : billDetail.billDetailLocalData.candidateVendorname,
108
109
  transaction_type: 'bill',
109
110
  bill_pay_provider: 'zeni',
110
- account_id: withdrawFromAccount != null
111
- ? (_g = (0, accountSelector_1.getAccountBase)(accountState, withdrawFromAccount.zeniAccountId, 'bill_pay')) === null || _g === void 0 ? void 0 : _g.qboId
111
+ account_id: zeniAccountId != null
112
+ ? (_g = (0, accountSelector_1.getAccountBase)(accountState, zeniAccountId, 'bill_pay')) === null || _g === void 0 ? void 0 : _g.qboId
112
113
  : '',
113
114
  file_id: (_h = billDetail.billDetailLocalData.file) === null || _h === void 0 ? void 0 : _h.fileId,
114
115
  transaction_date: (_l = (_k = (_j = billDetail.billDetailLocalData.whatForSection) === null || _j === void 0 ? void 0 : _j.invoiceDate) === null || _k === void 0 ? void 0 : _k.format('YYYY-MM-DD')) !== null && _l !== void 0 ? _l : (0, zeniDayJS_1.dateNow)().format('YYYY-MM-DD'),
@@ -120,35 +121,36 @@ function prepareSaveBillPayload(accountState, billTransactionState, paymentAccou
120
121
  },
121
122
  payment_date: (_u = (_t = (_s = billDetail.billDetailLocalData.paymentDetailsSection) === null || _s === void 0 ? void 0 : _s.paymentDate) === null || _t === void 0 ? void 0 : _t.format('YYYY-MM-DD')) !== null && _u !== void 0 ? _u : null,
122
123
  from_account: {
123
- account_id: (_x = (_w = (_v = billDetail.billDetailLocalData.paymentDetailsSection) === null || _v === void 0 ? void 0 : _v.withdrawFrom) !== null && _w !== void 0 ? _w : withdrawFromList === null || withdrawFromList === void 0 ? void 0 : withdrawFromList[0].paymentAccountId) !== null && _x !== void 0 ? _x : '',
124
+ account_id: (_x = (_w = (_v = billDetail.billDetailLocalData.paymentDetailsSection) === null || _v === void 0 ? void 0 : _v.withdrawFrom) === null || _w === void 0 ? void 0 : _w.id) !== null && _x !== void 0 ? _x : '',
125
+ account_type: (_0 = (0, helpers_1.accountTypeSubConfigCodeToAccType)((_z = (_y = billDetail.billDetailLocalData.paymentDetailsSection) === null || _y === void 0 ? void 0 : _y.withdrawFrom) === null || _z === void 0 ? void 0 : _z.accType)) !== null && _0 !== void 0 ? _0 : '',
124
126
  },
125
127
  to_account: Object.assign({}, (isLocalCurrencyEnabled === true &&
126
- ((_z = (_y = billDetail.billDetailLocalData.paymentDetailsSection) === null || _y === void 0 ? void 0 : _y.paymentType) === null || _z === void 0 ? void 0 : _z.method.includes('international')) === true
128
+ ((_2 = (_1 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _1 === void 0 ? void 0 : _1.paymentType) === null || _2 === void 0 ? void 0 : _2.method.includes('international')) === true
127
129
  ? {
128
130
  payment_instrument_id: Boolean(billDetail.billDetailLocalData
129
131
  .isCollectToAccountInfoFromVendorContact) === false
130
- ? (_1 = (_0 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _0 === void 0 ? void 0 : _0.paymentTo) !== null && _1 !== void 0 ? _1 : null
132
+ ? (_4 = (_3 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _3 === void 0 ? void 0 : _3.paymentTo) !== null && _4 !== void 0 ? _4 : null
131
133
  : null,
132
134
  }
133
135
  : {
134
136
  account_id: Boolean(billDetail.billDetailLocalData
135
137
  .isCollectToAccountInfoFromVendorContact) === false
136
- ? (_3 = (_2 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _2 === void 0 ? void 0 : _2.paymentTo) !== null && _3 !== void 0 ? _3 : null
138
+ ? (_6 = (_5 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _5 === void 0 ? void 0 : _5.paymentTo) !== null && _6 !== void 0 ? _6 : null
137
139
  : null,
138
140
  })),
139
- to_account_vendor_email: (_4 = billDetail.billDetailLocalData.toAccountVendorEmail) !== null && _4 !== void 0 ? _4 : null,
141
+ to_account_vendor_email: (_7 = billDetail.billDetailLocalData.toAccountVendorEmail) !== null && _7 !== void 0 ? _7 : null,
140
142
  is_collect_to_account_info_from_vendor_contact: billDetail.billDetailLocalData.isCollectToAccountInfoFromVendorContact,
141
143
  is_cancelled: false,
142
- bill_payment_method_type: getBillPaymentMethodTypePayload((_5 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _5 === void 0 ? void 0 : _5.paymentType),
143
- international_transfer_fee_bearer_payment_method: ((_7 = (_6 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _6 === void 0 ? void 0 : _6.paymentType) === null || _7 === void 0 ? void 0 : _7.method.includes('international')) === true &&
144
- ((_8 = billDetail.billDetailLocalData.vendor) === null || _8 === void 0 ? void 0 : _8.vendorCurrencyCode) === 'USD'
145
- ? (_9 = billDetail.billDetailLocalData.paymentDetailsSection
146
- .internationalTransferFeeBearerPaymentMethod) !== null && _9 !== void 0 ? _9 : 'swift_our' //default value for international method and USD currency
144
+ bill_payment_method_type: getBillPaymentMethodTypePayload((_8 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _8 === void 0 ? void 0 : _8.paymentType),
145
+ international_transfer_fee_bearer_payment_method: ((_10 = (_9 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _9 === void 0 ? void 0 : _9.paymentType) === null || _10 === void 0 ? void 0 : _10.method.includes('international')) === true &&
146
+ ((_11 = billDetail.billDetailLocalData.vendor) === null || _11 === void 0 ? void 0 : _11.vendorCurrencyCode) === 'USD'
147
+ ? (_12 = billDetail.billDetailLocalData.paymentDetailsSection
148
+ .internationalTransferFeeBearerPaymentMethod) !== null && _12 !== void 0 ? _12 : 'swift_our' //default value for international method and USD currency
147
149
  : null,
148
150
  },
149
- document_id: (_10 = billDetail.billDetailLocalData.whatForSection) === null || _10 === void 0 ? void 0 : _10.invoiceNumber,
150
- transaction_memo: (_11 = billDetail.billDetailLocalData.whatForSection) === null || _11 === void 0 ? void 0 : _11.memo,
151
- currency_code: (_13 = (_12 = billDetail.billDetailLocalData.whatForSection) === null || _12 === void 0 ? void 0 : _12.currencyCode) !== null && _13 !== void 0 ? _13 : 'USD',
151
+ document_id: (_13 = billDetail.billDetailLocalData.whatForSection) === null || _13 === void 0 ? void 0 : _13.invoiceNumber,
152
+ transaction_memo: (_14 = billDetail.billDetailLocalData.whatForSection) === null || _14 === void 0 ? void 0 : _14.memo,
153
+ currency_code: (_16 = (_15 = billDetail.billDetailLocalData.whatForSection) === null || _15 === void 0 ? void 0 : _15.currencyCode) !== null && _16 !== void 0 ? _16 : 'USD',
152
154
  lines: Object.keys(billDetail.billDetailLocalData.updatesByLineId).map((lineId) => {
153
155
  const line = billDetail.billDetailLocalData.updatesByLineId[lineId];
154
156
  const lineAsTransactionLinePayload = (0, editBillViewPayload_1.fromLineLocalDataToTransactionLinePayload)(line);
@@ -156,18 +158,18 @@ function prepareSaveBillPayload(accountState, billTransactionState, paymentAccou
156
158
  }),
157
159
  };
158
160
  if (!isRecurring) {
159
- payload.vendor_name = (_15 = (_14 = billDetail.billDetailLocalData.vendor) === null || _14 === void 0 ? void 0 : _14.name) !== null && _15 !== void 0 ? _15 : '';
161
+ payload.vendor_name = (_18 = (_17 = billDetail.billDetailLocalData.vendor) === null || _17 === void 0 ? void 0 : _17.name) !== null && _18 !== void 0 ? _18 : '';
160
162
  }
161
163
  if (billId != null) {
162
164
  detail = (0, get_1.default)(billTransactionState.transactionById, billId, undefined);
163
- payload.sync_token = (_16 = detail === null || detail === void 0 ? void 0 : detail.syncToken) !== null && _16 !== void 0 ? _16 : null;
164
- payload.update_time = (_17 = detail === null || detail === void 0 ? void 0 : detail.updateTime.format('YYYY-MM-DD')) !== null && _17 !== void 0 ? _17 : null;
165
+ payload.sync_token = (_19 = detail === null || detail === void 0 ? void 0 : detail.syncToken) !== null && _19 !== void 0 ? _19 : null;
166
+ payload.update_time = (_20 = detail === null || detail === void 0 ? void 0 : detail.updateTime.format('YYYY-MM-DD')) !== null && _20 !== void 0 ? _20 : null;
165
167
  }
166
168
  else {
167
169
  payload.are_approvals_serialized = true;
168
170
  }
169
171
  if (billStageCode === 'pending_approval' &&
170
- ((_18 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _18 === void 0 ? void 0 : _18.conversionRate) != null) {
172
+ ((_21 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _21 === void 0 ? void 0 : _21.conversionRate) != null) {
171
173
  // required by platform
172
174
  payload.exchange_rate =
173
175
  1 / billDetail.billDetailLocalData.paymentDetailsSection.conversionRate;
@@ -229,7 +231,7 @@ const getBillPaymentMethodTypePayload = (paymentType) => {
229
231
  code: Boolean(code) === true
230
232
  ? (0, billPayConfigState_1.toBillPaymentMethodCodeType)(code)
231
233
  : null,
232
- name: (_a = paymentType === null || paymentType === void 0 ? void 0 : paymentType.method) !== null && _a !== void 0 ? _a : '',
234
+ name: (_a = paymentType === null || paymentType === void 0 ? void 0 : paymentType.method.replace(/(_depositAccount|_paymentAccount)/g, '')) !== null && _a !== void 0 ? _a : '',
233
235
  sub_code: Boolean(subCode) === true
234
236
  ? (0, billPayConfigPayload_1.getSubCodePayload)((0, billPayConfigState_1.toBillPaymentSubConfigCodeKeyType)(subCode))
235
237
  : null,