@zeniai/client-epic-state 4.8.22 → 4.8.24

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.
@@ -51,14 +51,23 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
51
51
  let bankAccountList = [];
52
52
  let paymentInstrumentList = [];
53
53
  let contactDetails = [];
54
- const primaryPaymentAccount = (0, paymentAccountSelector_1.getPaymentAccountsByPaymentAccountIds)(paymentAccountState, (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountId) != null
54
+ const primaryPaymentAccount = (0, paymentAccountSelector_1.getPaymentAccountsByPaymentAccountIds)(paymentAccountState, (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountType) ===
55
+ 'paymentAccount' &&
56
+ (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountId) != null
55
57
  ? /*
56
58
  for extsing transaction since we are not calling payment accounts
57
59
  we need to pick payment ids from billPayInfo object
58
60
  */
59
61
  [transaction.billPayInfo.fromAccount.billAccountId]
60
62
  : setupViewState.accountDetails.paymentAccountIds);
63
+ const fromDepositAccount = (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountType) === 'depositAccount' &&
64
+ (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountId) != null
65
+ ? (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountId)
66
+ : undefined;
61
67
  const allDepositAccounts = (0, depositAccountListSelector_1.getAllDepostAccounts)(depositAccountState, depositAccountListState).depositAccounts;
68
+ if (allDepositAccounts.length === 0 && fromDepositAccount != null) {
69
+ allDepositAccounts.push(fromDepositAccount);
70
+ }
62
71
  const withdrawFromList = (0, transferDetailSelector_1.getTransferMoneyParties)(allDepositAccounts, primaryPaymentAccount);
63
72
  let previousBills = {
64
73
  bills: [],
@@ -125,8 +125,18 @@ const getTotalPayments = (startDate, endDate, frequency, currentInstance) => {
125
125
  pastPayments = currentInstance.instance - 1;
126
126
  }
127
127
  let totalPayments = 0;
128
- const offSetValue = getRecurringFrequencyInDays(frequency);
129
- totalPayments = endDate.diff(currentStartDate, 'day') / offSetValue;
128
+ switch (frequency) {
129
+ case 'weekly':
130
+ case 'biweekly':
131
+ totalPayments = endDate.diff(currentStartDate, 'day') / getRecurringFrequencyInDays(frequency);
132
+ break;
133
+ case 'monthly':
134
+ totalPayments = endDate.diff(currentStartDate, 'month');
135
+ break;
136
+ case 'quarterly':
137
+ totalPayments = endDate.diff(currentStartDate, 'quarter');
138
+ break;
139
+ }
130
140
  return Math.floor(totalPayments + pastPayments) + 1; //+1 to include startDate
131
141
  };
132
142
  exports.getTotalPayments = getTotalPayments;
@@ -138,17 +148,40 @@ const getEndDate = (startDate, frequency, totalPayments, currentInstance) => {
138
148
  currentStartDate = currentInstance.vendorReceiveDate;
139
149
  currentTotalPayments = totalPayments - currentInstance.instance + 1;
140
150
  }
141
- const offSetValue = getRecurringFrequencyInDays(frequency);
142
- endDate = currentStartDate.add(offSetValue * (currentTotalPayments - 1), 'day');
151
+ switch (frequency) {
152
+ case 'weekly':
153
+ case 'biweekly':
154
+ endDate = currentStartDate.add(getRecurringFrequencyInDays(frequency) * (currentTotalPayments - 1), 'day');
155
+ break;
156
+ case 'monthly':
157
+ endDate = currentStartDate.add(currentTotalPayments - 1, 'month');
158
+ break;
159
+ case 'quarterly':
160
+ endDate = currentStartDate.add(currentTotalPayments - 1, 'quarter');
161
+ break;
162
+ }
143
163
  return endDate;
144
164
  };
145
165
  exports.getEndDate = getEndDate;
146
166
  function getRecurringBillInstances(startDate, frequency, totalPayments, currentInstance, billAmount) {
147
167
  const updatedInstances = [];
148
- const offSetValue = getRecurringFrequencyInDays(frequency);
168
+ const getRecurringFrequencyWithOffset = (frequency) => {
169
+ switch (frequency) {
170
+ case 'weekly':
171
+ return { offSetValue: getRecurringFrequencyInDays(frequency), offSetUnit: 'day' };
172
+ case 'biweekly':
173
+ return { offSetValue: getRecurringFrequencyInDays(frequency), offSetUnit: 'day' };
174
+ case 'monthly':
175
+ return { offSetValue: 1, offSetUnit: 'month' };
176
+ case 'quarterly':
177
+ return { offSetValue: 1, offSetUnit: 'quarter' };
178
+ }
179
+ };
180
+ const { offSetValue, offSetUnit } = getRecurringFrequencyWithOffset(frequency);
149
181
  for (let i = 0; i < totalPayments; i++) {
150
- updatedInstances.push(Object.assign({ instance: currentInstance + i, isDeleted: false, amount: billAmount }, checkIfHolidayAndGetNextDate(startDate.add(i * offSetValue, 'day'))));
182
+ updatedInstances.push(Object.assign({ instance: currentInstance + i, isDeleted: false, amount: billAmount }, checkIfHolidayAndGetNextDate(startDate.add(i * offSetValue, offSetUnit))));
151
183
  }
184
+ ;
152
185
  return updatedInstances;
153
186
  }
154
187
  function getRecurringFrequencyInDays(frequency) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.8.22",
3
+ "version": "4.8.24",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",