@zeniai/client-epic-state 4.19.96-betaJK19 → 4.19.96-betaJK20

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.
@@ -4,7 +4,7 @@ import { ClassesViewParentID } from '../../commonStateTypes/classesView/nestedCl
4
4
  import { ID, UpdateType } from '../../commonStateTypes/common';
5
5
  import { ReportIDPlusForecastID } from '../../commonStateTypes/viewAndReport/viewAndReport';
6
6
  import { AccountPayload } from './accountPayload';
7
- import { AccountBase, AccountState, StatementCloseDay } from './accountState';
7
+ import { AccountBase, AccountKey, AccountState, StatementCloseDay } from './accountState';
8
8
  export declare const initialState: AccountState;
9
9
  export declare const updateAccounts: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: AccountPayload[], reportId: ReportIDPlusForecastID, classesViewParentId?: ClassesViewParentID | undefined, updateType?: UpdateType | undefined], AccountPayload[], "account/updateAccounts", never, {
10
10
  reportId: ReportIDPlusForecastID;
@@ -20,7 +20,10 @@ export declare const updateAccounts: import("@reduxjs/toolkit").ActionCreatorWit
20
20
  accountId: ID;
21
21
  reportId: ReportIDPlusForecastID;
22
22
  statementCloseDay: StatementCloseDay;
23
- }, "account/updateAccountStatementCloseDay">, clearAllAccounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"account/clearAllAccounts">;
23
+ }, "account/updateAccountStatementCloseDay">, changeAccountKey: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
24
+ newKey: AccountKey;
25
+ oldKey: AccountKey;
26
+ }, "account/changeAccountKey">, clearAllAccounts: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"account/clearAllAccounts">;
24
27
  declare const _default: import("redux").Reducer<AccountState>;
25
28
  export default _default;
26
29
  export declare const emptyAccount: AccountBase;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.emptyAccount = exports.clearAllAccounts = exports.updateAccountStatementCloseDay = exports.updateMultipleSubAccountsWithBalances = exports.updateAccounts = exports.initialState = void 0;
7
+ exports.emptyAccount = exports.clearAllAccounts = exports.changeAccountKey = exports.updateAccountStatementCloseDay = exports.updateMultipleSubAccountsWithBalances = exports.updateAccounts = exports.initialState = void 0;
8
8
  const toolkit_1 = require("@reduxjs/toolkit");
9
9
  const assignWith_1 = __importDefault(require("lodash/assignWith"));
10
10
  const balanceChangePayload_1 = require("../../commonPayloadTypes/balanceChangePayload");
@@ -52,12 +52,17 @@ const account = (0, toolkit_1.createSlice)({
52
52
  draft.accountsByKey[key].statementCloseDay =
53
53
  action.payload.statementCloseDay;
54
54
  },
55
+ changeAccountKey(draft, action) {
56
+ const { oldKey, newKey } = action.payload;
57
+ draft.accountsByKey[newKey] = draft.accountsByKey[oldKey];
58
+ delete draft.accountsByKey[oldKey];
59
+ },
55
60
  clearAllAccounts(draft) {
56
61
  draft.accountsByKey = {};
57
62
  },
58
63
  },
59
64
  });
60
- _a = account.actions, exports.updateAccounts = _a.updateAccounts, exports.updateMultipleSubAccountsWithBalances = _a.updateMultipleSubAccountsWithBalances, exports.updateAccountStatementCloseDay = _a.updateAccountStatementCloseDay, exports.clearAllAccounts = _a.clearAllAccounts;
65
+ _a = account.actions, exports.updateAccounts = _a.updateAccounts, exports.updateMultipleSubAccountsWithBalances = _a.updateMultipleSubAccountsWithBalances, exports.updateAccountStatementCloseDay = _a.updateAccountStatementCloseDay, exports.changeAccountKey = _a.changeAccountKey, exports.clearAllAccounts = _a.clearAllAccounts;
61
66
  exports.default = account.reducer;
62
67
  /**
63
68
  * Helper functions.
@@ -45,12 +45,17 @@ const account = createSlice({
45
45
  draft.accountsByKey[key].statementCloseDay =
46
46
  action.payload.statementCloseDay;
47
47
  },
48
+ changeAccountKey(draft, action) {
49
+ const { oldKey, newKey } = action.payload;
50
+ draft.accountsByKey[newKey] = draft.accountsByKey[oldKey];
51
+ delete draft.accountsByKey[oldKey];
52
+ },
48
53
  clearAllAccounts(draft) {
49
54
  draft.accountsByKey = {};
50
55
  },
51
56
  },
52
57
  });
53
- export const { updateAccounts, updateMultipleSubAccountsWithBalances, updateAccountStatementCloseDay, clearAllAccounts, } = account.actions;
58
+ export const { updateAccounts, updateMultipleSubAccountsWithBalances, updateAccountStatementCloseDay, changeAccountKey, clearAllAccounts, } = account.actions;
54
59
  export default account.reducer;
55
60
  /**
56
61
  * Helper functions.
@@ -1,5 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { changeAccountKey } from '../../../../entity/account/accountReducer';
4
+ import { getAccountKey } from '../../../../entity/account/accountState';
3
5
  import { getAccountReconByAccountIdAndSelectedPeriod } from '../../../../entity/accountRecon/accountReconSelector';
4
6
  import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
7
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
@@ -21,9 +23,14 @@ export const excludeAccountFromReconciliationEpic = (actions$, state$, zeniAPI)
21
23
  .postAndGetJSON(apiUrl, payload)
22
24
  .pipe(mergeMap((response) => {
23
25
  if (isSuccessResponse(response)) {
26
+ const newAccountKey = getAccountKey('excluded_account_reconciliation', accountId);
27
+ const oldAccountKey = getAccountKey('account_reconciliation', accountId);
24
28
  return of(excludeAccountFromReconciliationSuccess({
25
29
  account: response.data?.excluded_account ?? undefined,
26
30
  selectedPeriod,
31
+ }), changeAccountKey({
32
+ oldKey: oldAccountKey,
33
+ newKey: newAccountKey,
27
34
  }));
28
35
  }
29
36
  else {
@@ -1,6 +1,8 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { convertToPeriod } from '../../../../commonStateTypes/timePeriod';
4
+ import { changeAccountKey } from '../../../../entity/account/accountReducer';
5
+ import { getAccountKey } from '../../../../entity/account/accountState';
4
6
  import { updateAccountRecon } from '../../../../entity/accountRecon/accountReconReducer';
5
7
  import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
6
8
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
@@ -21,9 +23,14 @@ export const includeAccountInReconciliationEpic = (actions$, state$, zeniAPI) =>
21
23
  .pipe(mergeMap((response) => {
22
24
  if (isSuccessResponse(response) && response.data != null) {
23
25
  const reconciliation = response.data.reconciliation;
26
+ const oldAccountKey = getAccountKey('excluded_account_reconciliation', reconciliation.account_id);
27
+ const newAccountKey = getAccountKey('account_reconciliation', reconciliation.account_id);
24
28
  return of(updateAccountRecon(selectedPeriod, [reconciliation]), includeAccountInReconciliationSuccess({
25
29
  reconciliation,
26
30
  selectedPeriod,
31
+ }), changeAccountKey({
32
+ oldKey: oldAccountKey,
33
+ newKey: newAccountKey,
27
34
  }));
28
35
  }
29
36
  else {
@@ -1,7 +1,8 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
+ import { changeAccountKey } from '../../../../entity/account/accountReducer';
3
4
  import { RootState } from '../../../../reducer';
4
5
  import { ZeniAPI } from '../../../../zeniAPI';
5
6
  import { excludeAccountFromReconciliation, excludeAccountFromReconciliationFailure, excludeAccountFromReconciliationSuccess } from '../../reducers/reconciliationViewReducer';
6
- export type ActionType = ReturnType<typeof excludeAccountFromReconciliation> | ReturnType<typeof excludeAccountFromReconciliationSuccess> | ReturnType<typeof excludeAccountFromReconciliationFailure>;
7
+ export type ActionType = ReturnType<typeof excludeAccountFromReconciliation> | ReturnType<typeof changeAccountKey> | ReturnType<typeof excludeAccountFromReconciliationSuccess> | ReturnType<typeof excludeAccountFromReconciliationFailure>;
7
8
  export declare const excludeAccountFromReconciliationEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.excludeAccountFromReconciliationEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
+ const accountReducer_1 = require("../../../../entity/account/accountReducer");
7
+ const accountState_1 = require("../../../../entity/account/accountState");
6
8
  const accountReconSelector_1 = require("../../../../entity/accountRecon/accountReconSelector");
7
9
  const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
10
  const responsePayload_1 = require("../../../../responsePayload");
@@ -24,9 +26,14 @@ const excludeAccountFromReconciliationEpic = (actions$, state$, zeniAPI) => acti
24
26
  .postAndGetJSON(apiUrl, payload)
25
27
  .pipe((0, operators_1.mergeMap)((response) => {
26
28
  if ((0, responsePayload_1.isSuccessResponse)(response)) {
29
+ const newAccountKey = (0, accountState_1.getAccountKey)('excluded_account_reconciliation', accountId);
30
+ const oldAccountKey = (0, accountState_1.getAccountKey)('account_reconciliation', accountId);
27
31
  return (0, rxjs_1.of)((0, reconciliationViewReducer_1.excludeAccountFromReconciliationSuccess)({
28
32
  account: response.data?.excluded_account ?? undefined,
29
33
  selectedPeriod,
34
+ }), (0, accountReducer_1.changeAccountKey)({
35
+ oldKey: oldAccountKey,
36
+ newKey: newAccountKey,
30
37
  }));
31
38
  }
32
39
  else {
@@ -1,8 +1,9 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
+ import { changeAccountKey } from '../../../../entity/account/accountReducer';
3
4
  import { updateAccountRecon } from '../../../../entity/accountRecon/accountReconReducer';
4
5
  import { RootState } from '../../../../reducer';
5
6
  import { ZeniAPI } from '../../../../zeniAPI';
6
7
  import { includeAccountInReconciliation, includeAccountInReconciliationFailure, includeAccountInReconciliationSuccess } from '../../reducers/reconciliationViewReducer';
7
- export type ActionType = ReturnType<typeof includeAccountInReconciliation> | ReturnType<typeof includeAccountInReconciliationSuccess> | ReturnType<typeof includeAccountInReconciliationFailure> | ReturnType<typeof updateAccountRecon>;
8
+ export type ActionType = ReturnType<typeof includeAccountInReconciliation> | ReturnType<typeof includeAccountInReconciliationSuccess> | ReturnType<typeof includeAccountInReconciliationFailure> | ReturnType<typeof changeAccountKey> | ReturnType<typeof updateAccountRecon>;
8
9
  export declare const includeAccountInReconciliationEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -4,6 +4,8 @@ exports.includeAccountInReconciliationEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
7
+ const accountReducer_1 = require("../../../../entity/account/accountReducer");
8
+ const accountState_1 = require("../../../../entity/account/accountState");
7
9
  const accountReconReducer_1 = require("../../../../entity/accountRecon/accountReconReducer");
8
10
  const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
9
11
  const responsePayload_1 = require("../../../../responsePayload");
@@ -24,9 +26,14 @@ const includeAccountInReconciliationEpic = (actions$, state$, zeniAPI) => action
24
26
  .pipe((0, operators_1.mergeMap)((response) => {
25
27
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
26
28
  const reconciliation = response.data.reconciliation;
29
+ const oldAccountKey = (0, accountState_1.getAccountKey)('excluded_account_reconciliation', reconciliation.account_id);
30
+ const newAccountKey = (0, accountState_1.getAccountKey)('account_reconciliation', reconciliation.account_id);
27
31
  return (0, rxjs_1.of)((0, accountReconReducer_1.updateAccountRecon)(selectedPeriod, [reconciliation]), (0, reconciliationViewReducer_1.includeAccountInReconciliationSuccess)({
28
32
  reconciliation,
29
33
  selectedPeriod,
34
+ }), (0, accountReducer_1.changeAccountKey)({
35
+ oldKey: oldAccountKey,
36
+ newKey: newAccountKey,
30
37
  }));
31
38
  }
32
39
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.96-betaJK19",
3
+ "version": "4.19.96-betaJK20",
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
  "module": "lib/esm/index.js",