@zeniai/client-epic-state 4.7.74 → 4.7.75

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 (66) hide show
  1. package/lib/commonStateTypes/workingDayHelper.d.ts +9 -5
  2. package/lib/commonStateTypes/workingDayHelper.js +36 -12
  3. package/lib/entity/billPay/billTransaction/billTransactionPayload.d.ts +3 -0
  4. package/lib/entity/billPay/billTransaction/billTransactionPayload.js +2 -2
  5. package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +3 -0
  6. package/lib/entity/billPay/recurringBills/recurringBillsPayload.d.ts +34 -0
  7. package/lib/entity/billPay/recurringBills/recurringBillsPayload.js +44 -0
  8. package/lib/entity/billPay/recurringBills/recurringBillsReducer.d.ts +6 -0
  9. package/lib/entity/billPay/recurringBills/recurringBillsReducer.js +40 -0
  10. package/lib/entity/billPay/recurringBills/recurringBillsState.d.ts +33 -0
  11. package/lib/entity/billPay/recurringBills/recurringBillsState.js +14 -0
  12. package/lib/entity/chargeCard/chargeCard.d.ts +2 -2
  13. package/lib/entity/entityApprovalStatus/entityApprovalStatusPayload.d.ts +1 -0
  14. package/lib/entity/entityApprovalStatus/entityApprovalStatusPayload.js +1 -0
  15. package/lib/entity/entityApprovalStatus/entityApprovalStatusState.d.ts +1 -0
  16. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  17. package/lib/entity/tenant/clearAllEpic.js +2 -0
  18. package/lib/entity/transaction/stateTypes/attachment.js +5 -5
  19. package/lib/index.d.ts +6 -4
  20. package/lib/index.js +10 -4
  21. package/lib/reducer.d.ts +3 -0
  22. package/lib/reducer.js +3 -0
  23. package/lib/view/accountList/accountListReducer.js +2 -1
  24. package/lib/view/accountList/accountListState.d.ts +1 -1
  25. package/lib/view/commonVendorView/vendorView/epics/saveVendorEpic.js +1 -0
  26. package/lib/view/commonVendorView/vendorView/vendorViewSelector.js +2 -2
  27. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewPayload.d.ts +3 -0
  28. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.d.ts +5 -0
  29. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +13 -2
  30. package/lib/view/spendManagement/billPay/billDetailView/epics/cancelAndDeleteBillEpic.d.ts +2 -1
  31. package/lib/view/spendManagement/billPay/billDetailView/epics/cancelAndDeleteBillEpic.js +19 -8
  32. package/lib/view/spendManagement/billPay/billDetailView/epics/deleteBillEpic.d.ts +2 -1
  33. package/lib/view/spendManagement/billPay/billDetailView/epics/deleteBillEpic.js +14 -4
  34. package/lib/view/spendManagement/billPay/billDetailView/epics/fetchBillDetailEpic.d.ts +2 -1
  35. package/lib/view/spendManagement/billPay/billDetailView/epics/fetchBillDetailEpic.js +5 -2
  36. package/lib/view/spendManagement/billPay/billList/billListPayload.d.ts +2 -0
  37. package/lib/view/spendManagement/billPay/billList/billListSelector.d.ts +3 -0
  38. package/lib/view/spendManagement/billPay/billList/billListSelector.js +10 -2
  39. package/lib/view/spendManagement/billPay/billList/fetchBillListPerTabEpic.d.ts +2 -1
  40. package/lib/view/spendManagement/billPay/billList/fetchBillListPerTabEpic.js +3 -1
  41. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.d.ts +4 -0
  42. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +31 -9
  43. package/lib/view/spendManagement/billPay/editBillView/editBillViewPayload.d.ts +4 -0
  44. package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.js +17 -0
  45. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +10 -2
  46. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +59 -14
  47. package/lib/view/spendManagement/billPay/editBillView/editBillViewState.d.ts +28 -0
  48. package/lib/view/spendManagement/billPay/editBillView/editBillViewState.js +1 -0
  49. package/lib/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js +3 -3
  50. package/lib/view/spendManagement/billPay/editBillView/epics/initializeBillToLocalStoreEpic.js +13 -2
  51. package/lib/view/spendManagement/billPay/editBillView/epics/parseInvoiceToBillEpic.js +3 -2
  52. package/lib/view/spendManagement/billPay/editBillView/epics/saveBillDetailEpic.d.ts +11 -24
  53. package/lib/view/spendManagement/billPay/editBillView/epics/saveBillDetailEpic.js +100 -14
  54. package/lib/view/spendManagement/commonHistoryView/commonHistory.d.ts +1 -0
  55. package/lib/view/spendManagement/commonHistoryView/commonHistoryPayload.d.ts +1 -0
  56. package/lib/view/spendManagement/commonHistoryView/commonHistoryPayload.js +9 -5
  57. package/lib/view/spendManagement/helpers.d.ts +11 -1
  58. package/lib/view/spendManagement/helpers.js +134 -1
  59. package/lib/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.d.ts +1 -0
  60. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigPayload.d.ts +1 -0
  61. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigPayload.js +1 -0
  62. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigReducer.js +3 -1
  63. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigSelector.d.ts +1 -0
  64. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigSelector.js +2 -1
  65. package/lib/view/spendManagement/zeniAccounts/zeniAccountsConfig/zeniAccountsConfigState.d.ts +1 -0
  66. package/package.json +5 -4
@@ -2,7 +2,7 @@ import { FetchStateAndError, ID } from '../../../../commonStateTypes/common';
2
2
  import { RootState } from '../../../../reducer';
3
3
  import { SelectorView } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
4
4
  import { Amount } from '../../../../commonStateTypes/amount';
5
- import { BillPayInfo, BillPaymentMethod, BillStageCodeType, InternationalTransferFeeBearerPaymentMethod } from '../../../../entity/billPay/billTransaction/billTransactionState';
5
+ import { BillPayInfo, BillPaymentMethod, BillStageCodeType, BillTransaction, InternationalTransferFeeBearerPaymentMethod } from '../../../../entity/billPay/billTransaction/billTransactionState';
6
6
  import { PaymentAccount } from '../../../../entity/paymentAccount/paymentAccountState';
7
7
  import { Attachment } from '../../../../entity/transaction/stateTypes/attachment';
8
8
  import { TransactionWithAccountAndClassLine } from '../../../../entity/transaction/stateTypes/transactionLine';
@@ -11,7 +11,7 @@ import { ZeniDate } from '../../../../zeniDayJS';
11
11
  import { AccountListSelectorView } from '../../../accountList/accountListSelector';
12
12
  import { ClassListSelectorView } from '../../../classList/classListSelector';
13
13
  import { PreviousBillsSelectorView } from '../previousBills/previousBillsSelector';
14
- import { AddBillAutoFields, WhatForSection, PaymentModeType, PaymentMode } from './editBillViewState';
14
+ import { AddBillAutoFields, WhatForSection, PaymentModeType, PaymentMode, RecurringBillConfigLocalData, RecurringBillInstance } from './editBillViewState';
15
15
  import { BillActivity } from '../billDetailView/billDetailViewSelector';
16
16
  import { BillPaySetupApproverView } from '../billPaySetupApproverView/billPaySetupApproverViewSelectorTypes';
17
17
  import { User } from '../../../../entity/user/userState';
@@ -25,6 +25,7 @@ import { RecommendationByLineId } from '../../../../entity/transaction/stateType
25
25
  import { VendorDetailLocalData } from '../../../commonVendorView/vendorView/vendorViewState';
26
26
  import { AccountBase, RecommendedAccountBase } from '../../../../entity/account/accountState';
27
27
  import { ClassBase, RecommendedClassBase } from '../../../../entity/class/classState';
28
+ import { RecurringBillState } from '../../../../entity/billPay/recurringBills/recurringBillsState';
28
29
  export declare type PaymentToOption = {
29
30
  id: ID;
30
31
  type: PaymentModeType;
@@ -98,6 +99,9 @@ export interface EditBillDetailSelectorView extends SelectorView {
98
99
  recommendationByLineID?: RecommendationByLineId;
99
100
  vendorDetailLocalData?: VendorDetailLocalData;
100
101
  recommendedVendor?: Vendor;
102
+ isRecurring: boolean;
103
+ recurringConfig?: RecurringBillConfigLocalData;
104
+ recurringBillInstances?: RecurringBillInstance[];
101
105
  }
102
106
  export interface EditBillInitialDetails {
103
107
  vendor?: Vendor;
@@ -120,3 +124,7 @@ export interface PaymentDetailsSectionView {
120
124
  internationalTransferFeeBearerPaymentMethod?: InternationalTransferFeeBearerPaymentMethod;
121
125
  conversionRate?: number;
122
126
  }
127
+ export declare const getRecurringBillLocalData: (recurringBillState: RecurringBillState, transaction: BillTransaction) => {
128
+ recurringBillInstancesLocalData: RecurringBillInstance[];
129
+ recurringConfigLocalData?: RecurringBillConfigLocalData | undefined;
130
+ };
@@ -3,7 +3,7 @@ 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.getCurrentPaymentToOption = exports.toPaymentToOption = exports.getPaymentMethodType = exports.getBillPayConfigList = exports.getEditBillDetail = void 0;
6
+ exports.getRecurringBillLocalData = exports.getCurrentPaymentToOption = exports.toPaymentToOption = 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");
@@ -28,8 +28,8 @@ const billPayReviewSelector_1 = require("../billPayReview/billPayReviewSelector"
28
28
  const paymentInstrumentSelector_1 = require("../../../../entity/paymentInstrument/paymentInstrumentSelector");
29
29
  const billPayConfigPayload_1 = require("../billPayConfig/billPayConfigPayload");
30
30
  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;
32
- const { accountListState, accountState, bankAccountState, billDetailViewState, setupViewState, billTransactionState, billPayConfigState, classListState, classState, editBillDetailViewState, paymentAccountState, vendorState, tenantState, companyState, userState, commonHistoryState, contactState, paymentInstrumentState, } = state;
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
33
  let transaction = null;
34
34
  let recommendations = {};
35
35
  if (billId != null) {
@@ -85,10 +85,13 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
85
85
  paymentDetailsSection: getPaymentSection(state, withdrawFromList, {}),
86
86
  totalAmount: sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.billDetailLocalData.totalAmount,
87
87
  };
88
- const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
88
+ const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'billPayAccountList');
89
89
  let billPayInfo = undefined;
90
90
  let toAccountVendorEmail = undefined;
91
91
  let isCollectToAccountInfoFromVendorContact = false;
92
+ let isRecurring = false;
93
+ let recurringConfig;
94
+ let recurringBillInstances;
92
95
  if (billId != null) {
93
96
  const transaction = (0, get_1.default)(billTransactionState.transactionById, billId, undefined);
94
97
  isDeleted = (_f = transaction === null || transaction === void 0 ? void 0 : transaction.isDeleted) !== null && _f !== void 0 ? _f : false;
@@ -147,17 +150,24 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
147
150
  if (billViewState != null) {
148
151
  fetchState = (0, reduceFetchState_1.reduceFetchState)([
149
152
  billViewState,
150
- accountListState.byReportId.accountList,
153
+ accountListState.byReportId.billPayAccountList,
151
154
  classListState,
152
155
  ]).fetchState;
153
156
  deleteStatus = billViewState.deleteStatus;
154
157
  billActivities = (0, billDetailViewSelector_1.getBillActivities)(state, billId, billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.stage.code);
155
158
  }
156
159
  }
160
+ //recurringBill Details
161
+ isRecurring = (_r = transaction === null || transaction === void 0 ? void 0 : transaction.isRecurring) !== null && _r !== void 0 ? _r : false;
162
+ if (isRecurring && transaction != null) {
163
+ const { recurringConfigLocalData, recurringBillInstancesLocalData } = (0, exports.getRecurringBillLocalData)(recurringBillState, transaction);
164
+ recurringConfig = recurringConfigLocalData;
165
+ recurringBillInstances = recurringBillInstancesLocalData;
166
+ }
157
167
  }
158
168
  else {
159
169
  fetchState = (0, reduceFetchState_1.reduceFetchState)([
160
- accountListState.byReportId['accountList'],
170
+ accountListState.byReportId.billPayAccountList,
161
171
  classListState,
162
172
  ]).fetchState;
163
173
  }
@@ -177,9 +187,9 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
177
187
  ? (0, vendorSelector_1.getVendorByVendorId)(vendorState, updatedRecord.vendor.id)
178
188
  : undefined;
179
189
  file = updatedRecord.file != null ? updatedRecord.file : undefined;
180
- const bankAccInBill = (0, bankAccountSelector_1.getBankAccountByBankAccountId)(bankAccountState, (_s = (_r = updatedRecord.paymentDetailsSection) === null || _r === void 0 ? void 0 : _r.paymentTo) !== null && _s !== void 0 ? _s : '');
181
- const vendorBankAccounts = (0, bankAccountSelector_1.getBankAccountsByBankAccountIds)(bankAccountState, (_t = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.bankAccountIds) !== null && _t !== void 0 ? _t : []);
182
- const vendorPaymentInstruments = (0, paymentInstrumentSelector_1.getPaymentInstrumentsByIds)(paymentInstrumentState, (_u = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.paymentInstrumentIds) !== null && _u !== void 0 ? _u : []);
190
+ const bankAccInBill = (0, bankAccountSelector_1.getBankAccountByBankAccountId)(bankAccountState, (_t = (_s = updatedRecord.paymentDetailsSection) === null || _s === void 0 ? void 0 : _s.paymentTo) !== null && _t !== void 0 ? _t : '');
191
+ const vendorBankAccounts = (0, bankAccountSelector_1.getBankAccountsByBankAccountIds)(bankAccountState, (_u = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.bankAccountIds) !== null && _u !== void 0 ? _u : []);
192
+ const vendorPaymentInstruments = (0, paymentInstrumentSelector_1.getPaymentInstrumentsByIds)(paymentInstrumentState, (_v = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.paymentInstrumentIds) !== null && _v !== void 0 ? _v : []);
183
193
  const isBankAccInBillExistInVendor = bankAccInBill != null
184
194
  ? vendorBankAccounts
185
195
  .map((bankAc) => bankAc.bankAccountId)
@@ -229,6 +239,10 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
229
239
  (recommendedVendor === null || recommendedVendor === void 0 ? void 0 : recommendedVendor.vendorCurrencyCode) != null) {
230
240
  whatForSection.currencyCode = recommendedVendor.vendorCurrencyCode;
231
241
  }
242
+ isRecurring = (_w = sourceBillDetail.billDetailLocalData.isRecurring) !== null && _w !== void 0 ? _w : false;
243
+ recurringConfig = sourceBillDetail.billDetailLocalData.recurringConfig;
244
+ recurringBillInstances =
245
+ sourceBillDetail.billDetailLocalData.recurringBillInstances;
232
246
  //add paymentToOption on initial bill load for collect from email
233
247
  if (isCollectToAccountInfoFromVendorContact &&
234
248
  toAccountVendorEmail != null &&
@@ -245,7 +259,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
245
259
  }
246
260
  const vendorContactSaveStatus = editBillDetailViewState.updateVendorContactState;
247
261
  const lineDetailSection = {};
248
- const lineDetailSectionUpdatesByLineId = (_w = (_v = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.billDetailLocalData) === null || _v === void 0 ? void 0 : _v.updatesByLineId) !== null && _w !== void 0 ? _w : {};
262
+ 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 : {};
249
263
  const classList = (0, classListSelector_1.getClassList)(classState, classListState);
250
264
  if (accountList.fetchState === 'Completed') {
251
265
  Object.keys(lineDetailSectionUpdatesByLineId).forEach((lineId) => {
@@ -263,16 +277,16 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
263
277
  });
264
278
  }
265
279
  const billHistory = (0, commonHistorySelector_1.getActivityHistory)(commonHistoryState, billId !== null && billId !== void 0 ? billId : '', 'bill_pay');
266
- const accountsHeirarchyList = (0, accountListSelector_1.getNestedAccountListHeirarchy)(accountListState, 'accountList');
280
+ const accountsHeirarchyList = (0, accountListSelector_1.getNestedAccountListHeirarchy)(accountListState, 'billPayAccountList');
267
281
  const classHeirarchyList = (0, classListSelector_1.getNestedClassListHeirarchy)(classListState);
268
282
  const duplicateBills = (0, billPayReviewSelector_1.getDuplicateBills)(state, billId);
269
283
  return {
270
284
  recommendedVendor,
271
285
  duplicateBills,
272
286
  fetchState: fetchState,
273
- saveStatus: (_x = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.saveStatus) !== null && _x !== void 0 ? _x : undefined,
274
- error: (_z = (_y = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.fetchStatus) === null || _y === void 0 ? void 0 : _y.error) !== null && _z !== void 0 ? _z : undefined,
275
- uploadStatus: (_0 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.uploadFetchState) !== null && _0 !== void 0 ? _0 : undefined,
287
+ saveStatus: (_z = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.saveStatus) !== null && _z !== void 0 ? _z : undefined,
288
+ 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,
289
+ uploadStatus: (_2 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.uploadFetchState) !== null && _2 !== void 0 ? _2 : undefined,
276
290
  version: 0,
277
291
  createdBy,
278
292
  createTime,
@@ -308,6 +322,9 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
308
322
  classHeirarchyList,
309
323
  latestApprovedDate: (0, helpers_1.getLatestApprovalDate)(billActivities),
310
324
  recommendationByLineID: recommendations,
325
+ isRecurring,
326
+ recurringBillInstances,
327
+ recurringConfig,
311
328
  };
312
329
  };
313
330
  exports.getEditBillDetail = getEditBillDetail;
@@ -459,3 +476,31 @@ function getCurrentPaymentToOption(state, id) {
459
476
  return selectedOption != null ? toPaymentToOption(selectedOption) : undefined;
460
477
  }
461
478
  exports.getCurrentPaymentToOption = getCurrentPaymentToOption;
479
+ const getRecurringBillLocalData = (recurringBillState, transaction) => {
480
+ let recurringConfigLocalData = undefined;
481
+ let recurringBillInstancesLocalData = [];
482
+ let recurringBillDetail = undefined;
483
+ if (transaction.recurringBillConfigId != null) {
484
+ recurringBillDetail = (0, get_1.default)(recurringBillState.recurringBillDetailByConfigId, transaction.recurringBillConfigId, undefined);
485
+ }
486
+ if (recurringBillDetail != null) {
487
+ const { recurringBillInstances: currentRecurringBillInstances, recurringBillConfig, } = recurringBillDetail;
488
+ recurringBillInstancesLocalData = [...currentRecurringBillInstances]
489
+ .map((recurringBill) => ({
490
+ instance: recurringBill.instance,
491
+ amount: recurringBill.amount,
492
+ stage: recurringBill.stage,
493
+ paymentDate: recurringBill.paymentDate,
494
+ vendorReceiveDate: recurringBill.vendorReceiveDate,
495
+ vendorReceiveDateNotes: recurringBill.vendorReceiveDateNotes,
496
+ readonly: transaction.recurringBillInstance != null
497
+ ? recurringBill.instance < transaction.recurringBillInstance
498
+ : false,
499
+ transactionId: recurringBill.transactionId,
500
+ }))
501
+ .sort((a, b) => a.instance - b.instance);
502
+ recurringConfigLocalData = Object.assign(Object.assign({}, recurringBillConfig), { currentInstance: transaction.recurringBillInstance });
503
+ }
504
+ return { recurringConfigLocalData, recurringBillInstancesLocalData };
505
+ };
506
+ exports.getRecurringBillLocalData = getRecurringBillLocalData;
@@ -11,6 +11,8 @@ import { InternationalTransferFeeBearerPaymentMethod } from '../../../../entity/
11
11
  import { PaymentInstrument } from '../../../../entity/paymentInstrument/paymentInstrument';
12
12
  import { BankAccount } from '../../../../entity/bankAccount/bankAccount';
13
13
  import { Contact } from '../../../../entity/billPay/contact/contact';
14
+ import { RecurringBillFrequency } from '../../../../entity/billPay/recurringBills/recurringBillsState';
15
+ import { BillStage } from '../../../../entity/billPay/billTransaction/billTransactionState';
14
16
  export interface EditBillDetail {
15
17
  fetchStatus: FetchStateAndError;
16
18
  saveStatus: FetchStateAndError;
@@ -28,6 +30,16 @@ export interface EditBillDetailViewState {
28
30
  editBillStateById: Record<BillTransactionDetailKey, EditBillDetail>;
29
31
  updateVendorContactState: FetchStateAndError;
30
32
  }
33
+ export interface RecurringBillInstance {
34
+ instance: number;
35
+ vendorReceiveDate: ZeniDate;
36
+ vendorReceiveDateNotes: string;
37
+ amount?: number;
38
+ stage?: BillStage;
39
+ readonly?: boolean;
40
+ paymentDate?: ZeniDate;
41
+ transactionId?: ID;
42
+ }
31
43
  export interface BillDetailLocalData {
32
44
  vendor?: Vendor;
33
45
  candidateVendorname?: string;
@@ -42,6 +54,9 @@ export interface BillDetailLocalData {
42
54
  isCollectToAccountInfoFromVendorContact: boolean;
43
55
  currencyConversionState?: FetchStateAndError;
44
56
  recommendedVendorId?: ID;
57
+ isRecurring: boolean;
58
+ recurringConfig?: RecurringBillConfigLocalData;
59
+ recurringBillInstances?: RecurringBillInstance[];
45
60
  }
46
61
  export interface WhatForSection {
47
62
  invoiceNumber?: string;
@@ -73,3 +88,16 @@ export declare const PAYMENT_MODE_TYPE: readonly ["BankAccount", "Contact", "Pay
73
88
  export declare const toPaymentModeType: (v: string) => "BankAccount" | "Contact" | "PaymentInstrument";
74
89
  export declare type PaymentModeType = ReturnType<typeof toPaymentModeType>;
75
90
  export declare type PaymentMode = BankAccount | PaymentInstrument | Contact;
91
+ export declare type EditRecurringBillType = 'current' | 'all';
92
+ export interface RecurringBillConfigLocalData {
93
+ isApprovalRequired: boolean;
94
+ frequency?: RecurringBillFrequency;
95
+ totalPaymentCycles: number;
96
+ id?: ID;
97
+ startDate?: ZeniDate;
98
+ endDate?: ZeniDate;
99
+ currentInstance?: number;
100
+ endDateSelectorOptionType?: 'date' | 'payments';
101
+ isActive: boolean;
102
+ updateRecurringBills?: EditRecurringBillType;
103
+ }
@@ -35,6 +35,7 @@ exports.initialBillDetail = {
35
35
  isCancelled: false,
36
36
  toAccountVendorEmail: undefined,
37
37
  isCollectToAccountInfoFromVendorContact: false,
38
+ isRecurring: false,
38
39
  },
39
40
  showSkipAutofill: true,
40
41
  addBillAutoFields: {
@@ -16,7 +16,7 @@ const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe((0, oper
16
16
  const billDetailActions = [];
17
17
  const state = state$.value;
18
18
  if (cacheOverride == true) {
19
- billDetailActions.push((0, accountListReducer_1.fetchAccountList)('accountList', true));
19
+ billDetailActions.push((0, accountListReducer_1.fetchAccountList)('billPayAccountList', true, true, true));
20
20
  billDetailActions.push((0, classListReducer_1.fetchClassList)());
21
21
  billDetailActions.push((0, vendorTypeListReducer_1.fetchVendorTypeList)());
22
22
  billDetailActions.push((0, ownerListReducer_1.fetchOwnerList)());
@@ -35,10 +35,10 @@ const fetchEditBillDetailPageEpic = (actions$, state$) => actions$.pipe((0, oper
35
35
  state.ownerListState.hasValidState() === false) {
36
36
  billDetailActions.push((0, ownerListReducer_1.fetchOwnerList)());
37
37
  }
38
- const accountList = state.accountListState.byReportId.accountList;
38
+ const accountList = state.accountListState.byReportId['billPayAccountList'];
39
39
  if (accountList.hasValidState() === false &&
40
40
  accountList.fetchState !== 'In-Progress') {
41
- billDetailActions.push((0, accountListReducer_1.fetchAccountList)('accountList', true));
41
+ billDetailActions.push((0, accountListReducer_1.fetchAccountList)('billPayAccountList', true, true, true));
42
42
  }
43
43
  const classList = state.classListState;
44
44
  if (classList.hasValidState() === false &&
@@ -94,8 +94,8 @@ const initializeBillToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, o
94
94
  const editBillState = (0, get_1.default)(state.editBillDetailViewState.editBillStateById, detailKey, undefined);
95
95
  const billDetail = (0, get_1.default)(state.billDetailViewState.billDetailById, detailKey, undefined);
96
96
  const transaction = (0, get_1.default)(state.billTransactionState.transactionById, billId, undefined);
97
- const { accountListState, accountState, classListState, classState } = state;
98
- const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
97
+ const { accountListState, accountState, classListState, classState, recurringBillState, } = state;
98
+ const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'billPayAccountList');
99
99
  const classList = (0, classListSelector_1.getClassList)(classState, classListState);
100
100
  const recommendations = transaction === null || transaction === void 0 ? void 0 : transaction.recommendations;
101
101
  /* check vendor info is present in local store or not.
@@ -155,6 +155,14 @@ const initializeBillToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, o
155
155
  const candidateVendorname = transaction.candidateVendorName;
156
156
  const toAccountVendorEmail = transaction.billPayInfo.toAccountVendorEmail;
157
157
  const isCollectToAccountInfoFromVendorContact = transaction.billPayInfo.isCollectToAccountInfoFromVendorContact;
158
+ const isRecurring = transaction.isRecurring;
159
+ let recurringConfig;
160
+ let recurringBillInstances = undefined;
161
+ if (isRecurring) {
162
+ const { recurringConfigLocalData, recurringBillInstancesLocalData } = (0, editBillViewSelector_1.getRecurringBillLocalData)(recurringBillState, transaction);
163
+ recurringConfig = recurringConfigLocalData;
164
+ recurringBillInstances = recurringBillInstancesLocalData;
165
+ }
158
166
  const billDetailLocalData = {
159
167
  vendor,
160
168
  whatForSection,
@@ -166,6 +174,9 @@ const initializeBillToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, o
166
174
  candidateVendorname,
167
175
  toAccountVendorEmail,
168
176
  isCollectToAccountInfoFromVendorContact,
177
+ isRecurring,
178
+ recurringConfig,
179
+ recurringBillInstances,
169
180
  };
170
181
  const actions = [
171
182
  (0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({ billDetailLocalData, billId }),
@@ -118,7 +118,7 @@ const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators
118
118
  }));
119
119
  exports.parseInvoiceToBillEpic = parseInvoiceToBillEpic;
120
120
  const toBillDetailLocalData = (state, billPayload, vendor, recommendedVendorId) => {
121
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
121
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
122
122
  const currency = {
123
123
  currencyCode: (_a = billPayload.currency_code) !== null && _a !== void 0 ? _a : '',
124
124
  currencySymbol: (_b = billPayload.currency_symbol) !== null && _b !== void 0 ? _b : '', //api not returning symbol
@@ -147,7 +147,7 @@ const toBillDetailLocalData = (state, billPayload, vendor, recommendedVendorId)
147
147
  const lineState = (0, transactionLinePayload_1.toTransactionWithAccountAndClassLine)(line, currency);
148
148
  const { accountListState, accountState, classListState, classState } = state;
149
149
  const classList = (0, classListSelector_1.getClassList)(classState, classListState);
150
- const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
150
+ const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'billPayAccountList');
151
151
  const lineWithRecommendations = (0, initializeBillToLocalStoreEpic_1.getLineRecommendationsLocalData)(line.line_id, lineState, recommendations, accountList, classList, vendor);
152
152
  linesById[line.line_id] = Object.assign(Object.assign({}, lineWithRecommendations), { account: ((_b = lineWithRecommendations.account) === null || _b === void 0 ? void 0 : _b.accountId) === '' &&
153
153
  vendorCategory != null
@@ -212,6 +212,7 @@ const toBillDetailLocalData = (state, billPayload, vendor, recommendedVendorId)
212
212
  isCancelled: false,
213
213
  toAccountVendorEmail: (_t = (_s = billPayload.bill_pay_info) === null || _s === void 0 ? void 0 : _s.to_account_vendor_email) !== null && _t !== void 0 ? _t : undefined,
214
214
  isCollectToAccountInfoFromVendorContact: (_v = (_u = billPayload.bill_pay_info) === null || _u === void 0 ? void 0 : _u.is_collect_to_account_info_from_vendor_contact) !== null && _v !== void 0 ? _v : false,
215
+ isRecurring: (_w = billPayload.is_recurring) !== null && _w !== void 0 ? _w : false,
215
216
  };
216
217
  };
217
218
  exports.toBillDetailLocalData = toBillDetailLocalData;
@@ -3,28 +3,15 @@ import { ZeniAPI } from '../../../../../zeniAPI';
3
3
  import { RootState } from '../../../../../reducer';
4
4
  import { saveBillDetail, saveBillSuccessOrFailure } from '../editBillViewReducer';
5
5
  import { updateBillTransaction } from '../../../../../entity/billPay/billTransaction/billTransactionReducer';
6
+ import { RecurringBillInstance } from '../editBillViewState';
7
+ import { updateRecurringBillConfigs, updateRecurringBills } from '../../../../../entity/billPay/recurringBills/recurringBillsReducer';
6
8
  import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
7
- export declare type ActionType = ReturnType<typeof saveBillDetail> | ReturnType<typeof updateBillTransaction> | ReturnType<typeof openSnackbar> | ReturnType<typeof saveBillSuccessOrFailure>;
8
- export declare const saveBillDetailEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
9
- payload: import("../../../../../entity/billPay/billTransaction/billTransactionPayload").BillTransactionPayload;
10
- type: string;
11
- } | {
12
- payload: {
13
- messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_monthEndEmailSent" | "cockpit_monthEndEmailSave" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "zeni_account_accept_term" | "update_vendor" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "charge_card_setup" | "charge_card_accept_term";
14
- messageText: "failed" | "success";
15
- type: import("../../../../..").SnackbarMessageType;
16
- showStatusIcon?: boolean | undefined;
17
- variables?: {
18
- variableName: string;
19
- variableValue: string;
20
- }[] | undefined;
21
- };
22
- type: string;
23
- } | {
24
- payload: {
25
- fetchState: import("../../../../..").FetchState;
26
- billId: string | undefined;
27
- error: import("../../../../../responsePayload").ZeniAPIStatus<Record<string, unknown>> | undefined;
28
- };
29
- type: string;
30
- }>;
9
+ export declare type ActionType = ReturnType<typeof saveBillDetail> | ReturnType<typeof updateBillTransaction> | ReturnType<typeof openSnackbar> | ReturnType<typeof saveBillSuccessOrFailure> | ReturnType<typeof updateRecurringBillConfigs> | ReturnType<typeof updateRecurringBills>;
10
+ export declare const saveBillDetailEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
11
+ export interface RecurringBillInstancePayload {
12
+ instance: number;
13
+ payment_date: string;
14
+ vendor_receive_date: string;
15
+ vendor_receive_date_notes: string;
16
+ }
17
+ export declare const toRecurringBillInstancePayload: (recurringBillInstance: RecurringBillInstance, maxPaymentProcessingDays: number) => RecurringBillInstancePayload;
@@ -3,7 +3,7 @@ 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.saveBillDetailEpic = void 0;
6
+ exports.toRecurringBillInstancePayload = exports.saveBillDetailEpic = void 0;
7
7
  const rxjs_1 = require("rxjs");
8
8
  const operators_1 = require("rxjs/operators");
9
9
  const get_1 = __importDefault(require("lodash/get"));
@@ -15,11 +15,15 @@ const editBillViewPayload_1 = require("../editBillViewPayload");
15
15
  const transactionLinePayload_1 = require("../../../../../entity/transaction/payloadTypes/transactionLinePayload");
16
16
  const accountSelector_1 = require("../../../../../entity/account/accountSelector");
17
17
  const paymentAccountSelector_1 = require("../../../../../entity/paymentAccount/paymentAccountSelector");
18
+ const recurringBillsReducer_1 = require("../../../../../entity/billPay/recurringBills/recurringBillsReducer");
18
19
  const billDetailViewState_1 = require("../../billDetailView/billDetailViewState");
19
20
  const billPayConfigState_1 = require("../../billPayConfig/billPayConfigState");
20
21
  const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
21
22
  const billPayConfigPayload_1 = require("../../billPayConfig/billPayConfigPayload");
22
23
  const vendorSelector_1 = require("../../../../../entity/vendor/vendorSelector");
24
+ const recurringBillsPayload_1 = require("../../../../../entity/billPay/recurringBills/recurringBillsPayload");
25
+ const workingDayHelper_1 = require("../../../../../commonStateTypes/workingDayHelper");
26
+ const helpers_1 = require("../../../helpers");
23
27
  const saveBillDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(editBillViewReducer_1.saveBillDetail.match), (0, operators_1.mergeMap)((action) => {
24
28
  const state = state$.value;
25
29
  const { billStageCode, billId, isLocalCurrencyEnabled, isVendorRecommendationEnabled, } = action.payload;
@@ -27,21 +31,30 @@ const saveBillDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, oper
27
31
  const billDetail = billId != null
28
32
  ? state.editBillDetailViewState.editBillStateById[key]
29
33
  : state.editBillDetailViewState.newBillState;
30
- const payload = prepareSaveBillPayload(state.accountState, state.billTransactionState, state.paymentAccountState, state.setupViewState, state.vendorState, billDetail, billStageCode, isVendorRecommendationEnabled, isLocalCurrencyEnabled);
31
- const saveVendorApi = billId != null
32
- ? zeniAPI.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bills/transactions/${action.payload.billId}`, payload)
33
- : zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bills/transactions`, payload);
34
- return saveVendorApi.pipe((0, operators_1.mergeMap)((response) => {
35
- var _a, _b;
34
+ const payload = prepareSaveBillPayload(state.accountState, state.billTransactionState, state.paymentAccountState, state.setupViewState, state.vendorState, state.recurringBillState, billDetail, billStageCode, isVendorRecommendationEnabled, isLocalCurrencyEnabled);
35
+ const isRecurringBill = billDetail.billDetailLocalData.isRecurring;
36
+ const saveBillBaseURL = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bills/transactions`;
37
+ const saveBillApi = billId != null
38
+ ? zeniAPI.putAndGetJSON(getSaveBillApiURL(saveBillBaseURL, isRecurringBill, billId), payload)
39
+ : zeniAPI.postAndGetJSON(getSaveBillApiURL(saveBillBaseURL, isRecurringBill), payload);
40
+ return saveBillApi.pipe((0, operators_1.mergeMap)((response) => {
41
+ var _a, _b, _c, _d;
36
42
  if ((0, responsePayload_1.isSuccessResponse)(response) &&
37
43
  ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.transactions[0]) === null || _b === void 0 ? void 0 : _b.transaction_id) != null) {
38
- return (0, rxjs_1.of)((0, billTransactionReducer_1.updateBillTransaction)(response.data.transactions[0]), (0, editBillViewReducer_1.saveBillSuccessOrFailure)('Completed', action.payload.billId), (0, snackbarReducer_1.openSnackbar)({
44
+ const actions = [
45
+ (0, billTransactionReducer_1.updateBillTransaction)(response.data.transactions[0]),
46
+ ];
47
+ if (isRecurringBill) {
48
+ actions.push((0, recurringBillsReducer_1.updateRecurringBillConfigs)((_c = response.data.recurring_bill_configs) !== null && _c !== void 0 ? _c : []), (0, recurringBillsReducer_1.updateRecurringBills)((_d = response.data.recurring_bill_instances) !== null && _d !== void 0 ? _d : []));
49
+ }
50
+ actions.push((0, editBillViewReducer_1.saveBillSuccessOrFailure)('Completed', action.payload.billId), (0, snackbarReducer_1.openSnackbar)({
39
51
  messageSection: billStageCode === 'pending_approval'
40
52
  ? 'bill_pay_sent_for_approval'
41
53
  : 'bill_pay_updated',
42
54
  messageText: 'success',
43
55
  type: 'success',
44
56
  }));
57
+ return (0, rxjs_1.from)(actions);
45
58
  }
46
59
  else {
47
60
  return (0, rxjs_1.of)((0, editBillViewReducer_1.saveBillSuccessOrFailure)('Error', action.payload.billId, response.status), (0, snackbarReducer_1.openSnackbar)({
@@ -59,9 +72,20 @@ const saveBillDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, oper
59
72
  }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, editBillViewReducer_1.saveBillSuccessOrFailure)('Error', action.payload.billId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `REST API call errored out ${JSON.stringify(error)}`)))));
60
73
  }));
61
74
  exports.saveBillDetailEpic = saveBillDetailEpic;
62
- function prepareSaveBillPayload(accountState, billTransactionState, paymentAccountState, setupViewState, vendorState, billDetail, billStageCode, isVendorRecommendationEnabled, isLocalCurrencyEnabled) {
63
- 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;
75
+ const getSaveBillApiURL = (saveBillBaseURL, isRecurring, billId) => {
76
+ if (billId != null) {
77
+ return isRecurring
78
+ ? `${saveBillBaseURL}/${billId}/recurring`
79
+ : `${saveBillBaseURL}/${billId}`;
80
+ }
81
+ else {
82
+ return isRecurring ? `${saveBillBaseURL}/recurring` : `${saveBillBaseURL}`;
83
+ }
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, _19, _20, _21;
64
87
  const billId = billDetail.billId;
88
+ let detail;
65
89
  const withdrawFromList = (0, paymentAccountSelector_1.getPaymentAccountsByPaymentAccountIds)(paymentAccountState, setupViewState.accountDetails.paymentAccountIds);
66
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 : '');
67
91
  const recommendedVendor = billDetail.billDetailLocalData.recommendedVendorId != null
@@ -70,6 +94,7 @@ function prepareSaveBillPayload(accountState, billTransactionState, paymentAccou
70
94
  const isRecommendedVendor = isVendorRecommendationEnabled &&
71
95
  recommendedVendor != null &&
72
96
  billDetail.addBillAutoFields.tentativeVendorName != null;
97
+ const isRecurring = Boolean(billDetail.billDetailLocalData.isRecurring) === true;
73
98
  const payload = {
74
99
  vendor_id: isRecommendedVendor
75
100
  ? recommendedVendor.qboId
@@ -130,20 +155,71 @@ function prepareSaveBillPayload(accountState, billTransactionState, paymentAccou
130
155
  return (0, transactionLinePayload_1.toAccountAndClassLinePayload)(lineAsTransactionLinePayload);
131
156
  }),
132
157
  };
158
+ if (!isRecurring) {
159
+ payload.vendor_name = (_15 = (_14 = billDetail.billDetailLocalData.vendor) === null || _14 === void 0 ? void 0 : _14.name) !== null && _15 !== void 0 ? _15 : '';
160
+ }
133
161
  if (billId != null) {
134
- const detail = (0, get_1.default)(billTransactionState.transactionById, billId, undefined);
135
- payload.sync_token = (_14 = detail === null || detail === void 0 ? void 0 : detail.syncToken) !== null && _14 !== void 0 ? _14 : null;
136
- payload.update_time = (_15 = detail === null || detail === void 0 ? void 0 : detail.updateTime.format('YYYY-MM-DD')) !== null && _15 !== void 0 ? _15 : null;
162
+ 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;
137
165
  }
138
166
  else {
139
167
  payload.are_approvals_serialized = true;
140
168
  }
141
169
  if (billStageCode === 'pending_approval' &&
142
- ((_16 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _16 === void 0 ? void 0 : _16.conversionRate) != null) {
170
+ ((_18 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _18 === void 0 ? void 0 : _18.conversionRate) != null) {
143
171
  // required by platform
144
172
  payload.exchange_rate =
145
173
  1 / billDetail.billDetailLocalData.paymentDetailsSection.conversionRate;
146
174
  }
175
+ if (Boolean(billDetail.billDetailLocalData.isRecurring) === true) {
176
+ payload.is_recurring = true;
177
+ const recurringConfig = billDetail.billDetailLocalData.recurringConfig;
178
+ const recurringBillInstances = billDetail.billDetailLocalData.recurringBillInstances;
179
+ if (recurringConfig != null) {
180
+ payload.recurring_bill_config = (0, recurringBillsPayload_1.toRecurringConfigPayload)(recurringConfig);
181
+ }
182
+ if ((recurringConfig === null || recurringConfig === void 0 ? void 0 : recurringConfig.id) != null) {
183
+ const originalRecurringDetail = (0, get_1.default)(recurringBillState.recurringBillDetailByConfigId, recurringConfig.id);
184
+ const isConfigChangedForExistingBill = (0, helpers_1.isRecurringConfigChanged)(recurringConfig, originalRecurringDetail.recurringBillConfig, true);
185
+ payload.is_update_recurring_bill_config = isConfigChangedForExistingBill;
186
+ payload.is_update_future_recurring_bills =
187
+ recurringConfig.updateRecurringBills === 'all';
188
+ payload.is_update_current_bill =
189
+ recurringConfig.updateRecurringBills === 'all' ||
190
+ ((_20 = (_19 = billDetail.billDetailLocalData.paymentDetailsSection) === null || _19 === void 0 ? void 0 : _19.paymentDate) === null || _20 === void 0 ? void 0 : _20.toString()) !==
191
+ ((_21 = detail === null || detail === void 0 ? void 0 : detail.billPayInfo.paymentDate) === null || _21 === void 0 ? void 0 : _21.toString())
192
+ ? true
193
+ : recurringConfig.updateRecurringBills === 'current';
194
+ if ((isConfigChangedForExistingBill ||
195
+ recurringConfig.updateRecurringBills === 'all') &&
196
+ payload.recurring_bill_config != null) {
197
+ payload.recurring_bill_config.sync_token =
198
+ originalRecurringDetail.recurringBillConfig.syncToken;
199
+ }
200
+ if (recurringBillInstances != null) {
201
+ const futureRecurringBills = recurringBillInstances
202
+ .filter((instance) => Boolean(instance.readonly) === false)
203
+ .slice(1)
204
+ .map((instance) => {
205
+ var _a, _b, _c, _d;
206
+ return (0, exports.toRecurringBillInstancePayload)(instance, (_d = (_c = (_b = (_a = billDetail.billDetailLocalData.paymentDetailsSection) === null || _a === void 0 ? void 0 : _a.paymentType) === null || _b === void 0 ? void 0 : _b.maxPeriod) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : workingDayHelper_1.PAYMENT_BUSINESS_DAYS);
207
+ });
208
+ payload.future_recurring_bill_instances = futureRecurringBills;
209
+ if (payload.recurring_bill_config != null) {
210
+ payload.recurring_bill_config.future_total_payment_cycles =
211
+ futureRecurringBills === null || futureRecurringBills === void 0 ? void 0 : futureRecurringBills.length;
212
+ delete payload.recurring_bill_config.total_payment_cycles;
213
+ }
214
+ }
215
+ }
216
+ else {
217
+ payload.recurring_bill_instances = recurringBillInstances === null || recurringBillInstances === void 0 ? void 0 : recurringBillInstances.map((instance) => {
218
+ var _a, _b, _c, _d;
219
+ return (0, exports.toRecurringBillInstancePayload)(instance, (_d = (_c = (_b = (_a = billDetail.billDetailLocalData.paymentDetailsSection) === null || _a === void 0 ? void 0 : _a.paymentType) === null || _b === void 0 ? void 0 : _b.maxPeriod) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : workingDayHelper_1.PAYMENT_BUSINESS_DAYS);
220
+ });
221
+ }
222
+ }
147
223
  return payload;
148
224
  }
149
225
  const getBillPaymentMethodTypePayload = (paymentType) => {
@@ -160,3 +236,13 @@ const getBillPaymentMethodTypePayload = (paymentType) => {
160
236
  : null,
161
237
  };
162
238
  };
239
+ const toRecurringBillInstancePayload = (recurringBillInstance, maxPaymentProcessingDays) => {
240
+ const calculatedPaymentDate = (0, helpers_1.getPaymentDateFromVendorReceiveDate)(recurringBillInstance.vendorReceiveDate, maxPaymentProcessingDays);
241
+ return {
242
+ instance: recurringBillInstance.instance,
243
+ payment_date: calculatedPaymentDate.format('YYYY-MM-DD'),
244
+ vendor_receive_date: recurringBillInstance.vendorReceiveDate.format('YYYY-MM-DD'),
245
+ vendor_receive_date_notes: recurringBillInstance.vendorReceiveDateNotes,
246
+ };
247
+ };
248
+ exports.toRecurringBillInstancePayload = toRecurringBillInstancePayload;
@@ -9,6 +9,7 @@ export interface CommonHistoryView extends FetchedState {
9
9
  export declare const initialCommonHistory: CommonHistoryView;
10
10
  export interface HistoricEvent {
11
11
  eventText: string[];
12
+ eventSubText: string[];
12
13
  timestamp?: ZeniDate;
13
14
  updates: HistoricEventUpdate[];
14
15
  }
@@ -5,6 +5,7 @@ export interface HistoryPayload {
5
5
  }
6
6
  export interface HistoricEventPayload {
7
7
  event_text: string[];
8
+ event_sub_text?: string[] | null;
8
9
  timestamp?: string | null;
9
10
  updates: HistoricEventUpdatePayload[];
10
11
  metadata: HistoricEventMetaDataPayload;
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toHistoricEventUpdate = exports.toHistoricEvent = void 0;
4
4
  const zeniDayJS_1 = require("../../../zeniDayJS");
5
5
  const commonHistory_1 = require("./commonHistory");
6
- const toHistoricEvent = (payload) => ({
7
- eventText: payload.event_text,
8
- timestamp: payload.timestamp != null ? (0, zeniDayJS_1.dateLocal)(payload.timestamp) : undefined,
9
- updates: payload.updates.map((eventUpdatePayload) => (0, exports.toHistoricEventUpdate)(eventUpdatePayload)),
10
- });
6
+ const toHistoricEvent = (payload) => {
7
+ var _a;
8
+ return ({
9
+ eventText: payload.event_text,
10
+ eventSubText: (_a = payload.event_sub_text) !== null && _a !== void 0 ? _a : [],
11
+ timestamp: payload.timestamp != null ? (0, zeniDayJS_1.dateLocal)(payload.timestamp) : undefined,
12
+ updates: payload.updates.map((eventUpdatePayload) => (0, exports.toHistoricEventUpdate)(eventUpdatePayload)),
13
+ });
14
+ };
11
15
  exports.toHistoricEvent = toHistoricEvent;
12
16
  const toHistoricEventUpdate = (payload) => ({
13
17
  title: payload.title,