@zeniai/client-epic-state 4.20.3-betaRD42 → 4.20.3-betaRD43

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.
@@ -1,13 +1,13 @@
1
1
  import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
2
+ import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
3
  import { updateCompanies } from '../../../../entity/company/companyReducer';
4
4
  import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
5
  import { updateTenantAccountingClassesEnabled } from '../../../../entity/tenant/tenantReducer';
6
6
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
7
7
  import { updateAccountingClassesEnabled, updateAccountingClassesEnabledFailure, updateAccountingClassesEnabledSuccess, } from '../../companyViewReducer';
8
- export const updateAccountingClassesEnabledEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(updateAccountingClassesEnabled.match), mergeMap((action) => {
8
+ export const updateAccountingClassesEnabledEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(updateAccountingClassesEnabled.match), switchMap((action) => {
9
9
  const { companyId, enabled } = action.payload;
10
- const currentTenantId = state$.value.tenantState.currentTenantId;
10
+ const tenantId = Object.values(state$.value.tenantState.tenantsById).find((t) => t.companyId === companyId)?.tenantId;
11
11
  return zeniAPI
12
12
  .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, { is_accounting_classes_enabled: enabled })
13
13
  .pipe(mergeMap((response) => {
@@ -19,10 +19,10 @@ export const updateAccountingClassesEnabledEpic = (actions$, state$, zeniAPI) =>
19
19
  schema: {},
20
20
  }),
21
21
  ];
22
- if (currentTenantId != null) {
22
+ if (tenantId != null) {
23
23
  actions.push(updateTenantAccountingClassesEnabled({
24
24
  enabled,
25
- tenantId: currentTenantId,
25
+ tenantId,
26
26
  }));
27
27
  }
28
28
  actions.push(updateAccountingClassesEnabledSuccess());
@@ -48,7 +48,9 @@ export const updateAccountingClassesEnabledEpic = (actions$, state$, zeniAPI) =>
48
48
  }), catchError((error) => from([
49
49
  updateAccountingClassesEnabledFailure({
50
50
  status: createZeniAPIStatus('Unexpected error', 'Update Accounting Classes Enabled errored out' +
51
- JSON.stringify(error)),
51
+ (error instanceof Error
52
+ ? error.message
53
+ : JSON.stringify(error))),
52
54
  }),
53
55
  openSnackbar({
54
56
  messageSection: 'accounting_classes_enabled_update',
@@ -593,6 +593,9 @@ function updateAllReconciliation(draft, accounts, selectedPeriod, reconciliation
593
593
  ? toReconciliationAccountSource(account.reconciliation_source)
594
594
  : undefined,
595
595
  },
596
+ accountDetectionReason: account?.detection_info != null && account.detection_reason != null
597
+ ? account.detection_reason
598
+ : undefined,
596
599
  };
597
600
  accountReconciliationRecords.accountIDs.push(reconciliation.account_id);
598
601
  });
@@ -674,5 +677,6 @@ const updateReconciliationByAccountIDOnIncludeAccount = (draft, accountId, recon
674
677
  statementUpdateStatus: { fetchState: 'Not-Started', error: undefined },
675
678
  statementParseInProgress: reconciliation.bank_status.code === 'parsing',
676
679
  localData: {},
680
+ accountDetectionReason: undefined,
677
681
  };
678
682
  };
@@ -252,6 +252,8 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
252
252
  .transactionFetchState,
253
253
  accountListState.byReportId.accountList,
254
254
  ]),
255
+ accountDetectionReason: accountReconForMonthYearPeriod.reconciliationByAccountID[accountID]
256
+ .accountDetectionReason,
255
257
  };
256
258
  });
257
259
  const accountReconciliationBySectionID = {