@zeniai/client-epic-state 4.13.32 → 4.13.34

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.
@@ -10,13 +10,10 @@ const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedules
10
10
  const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
11
11
  const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.fetchJeSchedules.match), (0, operators_1.switchMap)((action) => {
12
12
  const state = state$.value;
13
- const {
14
- // expenseAutomationJESchedulesViewState: {fetchState},
15
- expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
13
+ const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
16
14
  const { period } = action.payload;
17
15
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
18
16
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
19
- // if (fetchState !== 'Not-Started') {
20
17
  const queryParam = {
21
18
  start_date: (0, timePeriod_1.toString)(period.start),
22
19
  end_date: (0, timePeriod_1.toString)(period.end),
@@ -52,8 +49,5 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
52
49
  JSON.stringify(error)),
53
50
  selectedPeriod,
54
51
  }))));
55
- // } else {
56
- // return from([] as ActionType[]);
57
- // }
58
52
  }));
59
53
  exports.fetchJeSchedulesEpic = fetchJeSchedulesEpic;
@@ -47,7 +47,12 @@ const expenseAutomationView = (0, toolkit_1.createSlice)({
47
47
  },
48
48
  initializeSelectedPeriodForTenants(draft, action) {
49
49
  const { selectedPeriodByTenantId } = action.payload;
50
- draft.selectedPeriodByTenantId = selectedPeriodByTenantId;
50
+ const tenantIds = Object.keys(selectedPeriodByTenantId);
51
+ tenantIds.forEach((tenantId) => {
52
+ var _a;
53
+ draft.selectedPeriodByTenantId[tenantId] =
54
+ (_a = draft.selectedPeriodByTenantId[tenantId]) !== null && _a !== void 0 ? _a : selectedPeriodByTenantId[tenantId];
55
+ });
51
56
  },
52
57
  updateCurrentSelectedPeriod: {
53
58
  reducer(draft, action) {
@@ -14,15 +14,19 @@ const markAsCompleteScheduleDetailEpic = (actions$, state$, zeniAPI) => actions$
14
14
  const { scheduleType, jeScheduleKey } = action.payload;
15
15
  const actions = [];
16
16
  const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
17
+ const scheduleDetailId = jeScheduleTransactionState.jeScheduleId;
17
18
  const vendorName = jeScheduleTransactionState.vendor.name;
18
- const scheduleDetailsUpdated = state.scheduleDetailState.newScheduleState[scheduleType];
19
+ const scheduleDetailsUpdated = scheduleDetailId != null
20
+ ? state.scheduleDetailState.editScheduleStateByDetailId[scheduleType][scheduleDetailId]
21
+ : state.scheduleDetailState.newScheduleState[scheduleType];
19
22
  const payload = Object.assign({}, (0, scheduleDetailPayload_1.prepareScheduleDetailPayload)(state, scheduleDetailsUpdated, jeScheduleKey, scheduleType, false, true));
20
23
  const queryParam = {
21
24
  je_schedule_type: scheduleType,
22
25
  };
23
- return zeniAPI
24
- .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
25
- .pipe((0, operators_1.mergeMap)((response) => {
26
+ const markAsCompleteApi = scheduleDetailId != null
27
+ ? zeniAPI.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${scheduleDetailId}?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
28
+ : zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload);
29
+ return markAsCompleteApi.pipe((0, operators_1.mergeMap)((response) => {
26
30
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
27
31
  actions.push((0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries, 'replace'), (0, scheduleDetailReducer_1.markAsCompleteScheduleDetailSuccessOrFailure)('Completed'), (0, snackbarReducer_1.openSnackbar)({
28
32
  messageSection: 'mark_as_complete_schedule',
@@ -127,7 +127,7 @@ const mapJEScheduleTransactionToPayload = (jeScheduleTransactionState, vendorSta
127
127
  vendor_id: (_a = selectedVendor === null || selectedVendor === void 0 ? void 0 : selectedVendor.id) !== null && _a !== void 0 ? _a : '',
128
128
  vendor_name: (_b = selectedVendor === null || selectedVendor === void 0 ? void 0 : selectedVendor.name) !== null && _b !== void 0 ? _b : '',
129
129
  };
130
- const payload = Object.assign(Object.assign({ status: updatedStatus, vendor: (selectedVendor === null || selectedVendor === void 0 ? void 0 : selectedVendor.id) !== ''
130
+ const payload = Object.assign(Object.assign({ status: updatedStatus, vendor: Boolean(selectedVendor) && Boolean(selectedVendor === null || selectedVendor === void 0 ? void 0 : selectedVendor.id) === true
131
131
  ? updatedVendor
132
132
  : (0, exports.mapVendorToVendorPayload)(vendorDetails), currency_code: currencyCode, currency_symbol: currencySymbol, period: selectedMonths !== null && selectedMonths !== void 0 ? selectedMonths : null, je_schedule_type: jeScheduleType, posting_date: postingDate, je_schedule_id: status.code === 'marked_as_completed' ? jeScheduleId : undefined, balance: getBalanceAmountAsOfToday({
133
133
  isMarkAsComplete,
@@ -177,7 +177,7 @@ const mapFixedAssetJEScheduleTransactionToPayload = (jeScheduleTransactionState,
177
177
  vendor_id: (_a = selectedVendor === null || selectedVendor === void 0 ? void 0 : selectedVendor.id) !== null && _a !== void 0 ? _a : '',
178
178
  vendor_name: (_b = selectedVendor === null || selectedVendor === void 0 ? void 0 : selectedVendor.name) !== null && _b !== void 0 ? _b : '',
179
179
  };
180
- const payload = Object.assign(Object.assign({ status: updatedStatus, vendor: (selectedVendor === null || selectedVendor === void 0 ? void 0 : selectedVendor.id) !== ''
180
+ const payload = Object.assign(Object.assign({ status: updatedStatus, vendor: Boolean(selectedVendor) && Boolean(selectedVendor === null || selectedVendor === void 0 ? void 0 : selectedVendor.id) === true
181
181
  ? updatedVendor
182
182
  : (0, exports.mapVendorToVendorPayload)(vendorDetails), currency_code: currencyCode, currency_symbol: currencySymbol, period: selectedMonths !== null && selectedMonths !== void 0 ? selectedMonths : null, je_schedule_type: 'fixed_assets', posting_date: postingDate, je_schedule_id: status.code === 'marked_as_completed' ? jeScheduleId : undefined, balance: getBalanceAmountAsOfToday({
183
183
  isMarkAsComplete,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.13.32",
3
+ "version": "4.13.34",
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",