@zeniai/client-epic-state 4.8.26 → 4.8.27

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.
@@ -11,8 +11,8 @@ const initializeScheduleDetailLocalDataEpic = (actions$, state$) => actions$.pip
11
11
  const { scheduleDetailState } = state;
12
12
  const actions = [];
13
13
  const { selectedJeScheduleDetailId, selectedJEScheduleKey } = action.payload;
14
- const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleKey)(selectedJEScheduleKey, state);
15
14
  if (selectedJeScheduleDetailId != null) {
15
+ const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleKey)(selectedJEScheduleKey, state);
16
16
  const scheduledJournalEntry = jeScheduleTransactionState.scheduledJournalEntry;
17
17
  if (selectedJEScheduleKey != null) {
18
18
  actions.push((0, scheduleDetailReducer_1.updateScheduleDetailsLocalData)({
@@ -22,10 +22,8 @@ const initializeScheduleDetailLocalDataEpic = (actions$, state$) => actions$.pip
22
22
  }
23
23
  }
24
24
  else {
25
- // Initialize the start posting date with the start month of transaction
26
- const transactionStartMonth = jeScheduleTransactionState.baseTransaction.date.endOf('month');
27
25
  actions.push((0, scheduleDetailReducer_1.updateScheduleDetailsLocalData)({
28
- localData: Object.assign(Object.assign({}, scheduleDetailState.newScheduleState), { selectedDate: transactionStartMonth }),
26
+ localData: scheduleDetailState.newScheduleState,
29
27
  selectedJeScheduleDetailId: undefined,
30
28
  }));
31
29
  }
@@ -12,6 +12,7 @@ const scheduleListReducer_1 = require("./scheduleListReducer");
12
12
  const scheduleListTypes_1 = require("./scheduleListTypes");
13
13
  const amount_1 = require("../../../commonStateTypes/amount");
14
14
  const scheduleListHelper_1 = require("./scheduleListHelper");
15
+ const scheduleListHelper_2 = require("./scheduleListHelper");
15
16
  const accountSelector_1 = require("../../../entity/account/accountSelector");
16
17
  const sortedJETransactionsView = (jeTransactions, sortKey, sortOrder) => {
17
18
  return (0, orderBy_1.default)(jeTransactions, (jeTransaction) => {
@@ -70,7 +71,7 @@ const getScheduleListReport = (state) => {
70
71
  const allScheduleAccounts = (0, accountListSelector_1.getAccountList)(accountState, accountListState, (0, scheduleListHelper_1.getAccountListKeyForSchedulesTab)(scheduleListState.currentTab));
71
72
  let allNestedAccounts = (0, accountListSelector_1.getNestedAccountListHeirarchy)(accountListState, (0, scheduleListHelper_1.getAccountListKeyForSchedulesTab)(scheduleListState.currentTab));
72
73
  let allAccounts = allScheduleAccounts.accounts;
73
- const scheduleListCurrentTabAccountTypes = (0, scheduleListHelper_1.getAccountsTypesForScheduleList)(scheduleListState.currentTab).allowedAccountList;
74
+ const scheduleListCurrentTabAccountTypes = (0, scheduleListHelper_2.getAccountsTypesForScheduleList)(scheduleListState.currentTab).allowedAccountList;
74
75
  const scheduleListCurrentTabAccountIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, scheduleListCurrentTabAccountTypes);
75
76
  if (scheduleListState.currentTab === 'prepaid_expenses') {
76
77
  const filteredList = (0, accountListSelector_1.getFilteredNestedAndAccountListsForLabel)(accountState, accountListState, (0, scheduleListHelper_1.getAccountListKeyForSchedulesTab)(scheduleListState.currentTab), 'prepaid_expenses');
@@ -53,7 +53,8 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, billId)
53
53
  let contactDetails = [];
54
54
  const primaryPaymentAccount = (0, paymentAccountSelector_1.getPaymentAccountsByPaymentAccountIds)(paymentAccountState, (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountType) ===
55
55
  'paymentAccount' &&
56
- (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountId) != null
56
+ (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountId) != null &&
57
+ (transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.fromAccount.billAccountId.length) > 0
57
58
  ? /*
58
59
  for extsing transaction since we are not calling payment accounts
59
60
  we need to pick payment ids from billPayInfo object
@@ -125,18 +125,8 @@ const getTotalPayments = (startDate, endDate, frequency, currentInstance) => {
125
125
  pastPayments = currentInstance.instance - 1;
126
126
  }
127
127
  let totalPayments = 0;
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
- }
128
+ const offSetValue = getRecurringFrequencyInDays(frequency);
129
+ totalPayments = endDate.diff(currentStartDate, 'day') / offSetValue;
140
130
  return Math.floor(totalPayments + pastPayments) + 1; //+1 to include startDate
141
131
  };
142
132
  exports.getTotalPayments = getTotalPayments;
@@ -148,40 +138,17 @@ const getEndDate = (startDate, frequency, totalPayments, currentInstance) => {
148
138
  currentStartDate = currentInstance.vendorReceiveDate;
149
139
  currentTotalPayments = totalPayments - currentInstance.instance + 1;
150
140
  }
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
- }
141
+ const offSetValue = getRecurringFrequencyInDays(frequency);
142
+ endDate = currentStartDate.add(offSetValue * (currentTotalPayments - 1), 'day');
163
143
  return endDate;
164
144
  };
165
145
  exports.getEndDate = getEndDate;
166
146
  function getRecurringBillInstances(startDate, frequency, totalPayments, currentInstance, billAmount) {
167
147
  const updatedInstances = [];
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);
148
+ const offSetValue = getRecurringFrequencyInDays(frequency);
181
149
  for (let i = 0; i < totalPayments; i++) {
182
- updatedInstances.push(Object.assign({ instance: currentInstance + i, isDeleted: false, amount: billAmount }, checkIfHolidayAndGetNextDate(startDate.add(i * offSetValue, offSetUnit))));
150
+ updatedInstances.push(Object.assign({ instance: currentInstance + i, isDeleted: false, amount: billAmount }, checkIfHolidayAndGetNextDate(startDate.add(i * offSetValue, 'day'))));
183
151
  }
184
- ;
185
152
  return updatedInstances;
186
153
  }
187
154
  function getRecurringFrequencyInDays(frequency) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.8.26",
3
+ "version": "4.8.27",
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",