@zeniai/client-epic-state 4.19.96-betaJK15 → 4.19.96-betaJK17

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.
@@ -6,6 +6,7 @@ import { ID } from '../../commonStateTypes/common';
6
6
  import { EntityOrder } from '../../commonStateTypes/selectorTypes/selectorTypes';
7
7
  import { ReportIDPlusForecastID } from '../../commonStateTypes/viewAndReport/viewAndReport';
8
8
  import { Account, AccountBase, AccountState, AccountType } from './accountState';
9
+ export declare const getAccountByAccountId: (accountState: AccountState, accountId: ID) => Account | undefined;
9
10
  export declare const getAccountBase: (accountState: AccountState, accountId: ID, reportId: ReportIDPlusForecastID) => AccountBase | undefined;
10
11
  export declare function getAccount(accountState: AccountState, id: {
11
12
  accountId: ID;
@@ -3,13 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getAccountIdsForLabels = exports.getAccountIdsForTypes = exports.getAccountsByType = exports.getAccountsOrdered = exports.getAccountBase = void 0;
6
+ exports.getAccountIdsForLabels = exports.getAccountIdsForTypes = exports.getAccountsByType = exports.getAccountsOrdered = exports.getAccountBase = exports.getAccountByAccountId = void 0;
7
7
  exports.getAccount = getAccount;
8
8
  exports.getAccountWithBalance = getAccountWithBalance;
9
9
  const flatMap_1 = __importDefault(require("lodash/flatMap"));
10
10
  const coaBalance_1 = require("../../commonStateTypes/coaBalance/coaBalance");
11
11
  const sortBalancesByFreeRangeTotal_1 = require("../../commonStateTypes/coaBalance/sortBalancesByFreeRangeTotal");
12
12
  const accountState_1 = require("./accountState");
13
+ // create a selector to get the account by accountId
14
+ const getAccountByAccountId = (accountState, accountId) => {
15
+ const accounts = Object.values(accountState.accountsByKey);
16
+ const account = accounts.find((account) => account.accountId === accountId);
17
+ return account;
18
+ };
19
+ exports.getAccountByAccountId = getAccountByAccountId;
13
20
  function getCommonAccountFields(accountState, id) {
14
21
  const key = (0, accountState_1.getAccountKey)(id.reportId, id.accountId, id.classesViewParentId, id.accountsViewParentId);
15
22
  const account = accountState.accountsByKey[key];
@@ -2,6 +2,12 @@ import flatMap from 'lodash/flatMap';
2
2
  import { getCOABalances } from '../../commonStateTypes/coaBalance/coaBalance';
3
3
  import { sortComparator } from '../../commonStateTypes/coaBalance/sortBalancesByFreeRangeTotal';
4
4
  import { getAccountKey, } from './accountState';
5
+ // create a selector to get the account by accountId
6
+ export const getAccountByAccountId = (accountState, accountId) => {
7
+ const accounts = Object.values(accountState.accountsByKey);
8
+ const account = accounts.find((account) => account.accountId === accountId);
9
+ return account;
10
+ };
5
11
  function getCommonAccountFields(accountState, id) {
6
12
  const key = getAccountKey(id.reportId, id.accountId, id.classesViewParentId, id.accountsViewParentId);
7
13
  const account = accountState.accountsByKey[key];
@@ -3,7 +3,7 @@ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { getAccountReconByAccountIdAndSelectedPeriod } from '../../../../entity/accountRecon/accountReconSelector';
4
4
  import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
5
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
6
- import { excludeAccountFromReconciliation, excludeAccountFromReconciliationFailure, excludeAccountFromReconciliationSuccess, fetchReconciliation, } from '../../reducers/reconciliationViewReducer';
6
+ import { excludeAccountFromReconciliation, excludeAccountFromReconciliationFailure, excludeAccountFromReconciliationSuccess, } from '../../reducers/reconciliationViewReducer';
7
7
  export const excludeAccountFromReconciliationEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(excludeAccountFromReconciliation.match), mergeMap((action) => {
8
8
  const { accountId } = action.payload;
9
9
  const state = state$.value;
@@ -21,7 +21,10 @@ export const excludeAccountFromReconciliationEpic = (actions$, state$, zeniAPI)
21
21
  .postAndGetJSON(apiUrl, payload)
22
22
  .pipe(mergeMap((response) => {
23
23
  if (isSuccessResponse(response)) {
24
- return of(excludeAccountFromReconciliationSuccess({ accountId }), fetchReconciliation(selectedPeriod, undefined, true, true));
24
+ return of(excludeAccountFromReconciliationSuccess({
25
+ account: response.data?.excluded_account ?? undefined,
26
+ selectedPeriod,
27
+ }));
25
28
  }
26
29
  else {
27
30
  return of(excludeAccountFromReconciliationFailure({
@@ -443,8 +443,36 @@ const expenseAutomationReconciliationView = createSlice({
443
443
  fetchState: 'Completed',
444
444
  error: undefined,
445
445
  };
446
- if (!draft.excludedAccountIDs.includes(action.payload.accountId)) {
447
- draft.excludedAccountIDs.push(action.payload.accountId);
446
+ const { account, selectedPeriod } = action.payload;
447
+ if (account != null) {
448
+ if (!draft.excludedAccountIDs.includes(account.account_id)) {
449
+ draft.excludedAccountIDs.push(account.account_id);
450
+ }
451
+ draft.excludedAccountExclusionInfo[account.account_id] = {
452
+ bankBalance: account.bank_balance != null
453
+ ? {
454
+ amount: account.bank_balance,
455
+ currencyCode: account.currency_code ?? 'USD',
456
+ currencySymbol: account.currency_symbol ?? '$',
457
+ }
458
+ : undefined,
459
+ clearedBalance: account.cleared_balance != null
460
+ ? {
461
+ amount: account.cleared_balance,
462
+ currencyCode: account.currency_code ?? 'USD',
463
+ currencySymbol: account.currency_symbol ?? '$',
464
+ }
465
+ : undefined,
466
+ variance: account.variance != null
467
+ ? {
468
+ amount: account.variance,
469
+ currencyCode: account.currency_code ?? 'USD',
470
+ currencySymbol: account.currency_symbol ?? '$',
471
+ }
472
+ : undefined,
473
+ };
474
+ const monthYearPeriodId = toMonthYearPeriodId(selectedPeriod);
475
+ draft.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId].accountIDs = draft.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId].accountIDs.filter((id) => id !== account.account_id);
448
476
  }
449
477
  },
450
478
  excludeAccountFromReconciliationFailure: (draft, action) => {
@@ -5,7 +5,7 @@ import omit from 'lodash/omit';
5
5
  import orderBy from 'lodash/orderBy';
6
6
  import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
7
7
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
8
- import { getAccountWithBalance, getAccountsByType, } from '../../../entity/account/accountSelector';
8
+ import { getAccountByAccountId, getAccountsByType, } from '../../../entity/account/accountSelector';
9
9
  import { getAccountReconByAccountIdAndSelectedPeriod } from '../../../entity/accountRecon/accountReconSelector';
10
10
  import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
11
11
  import { getVendorByVendorId } from '../../../entity/vendor/vendorSelector';
@@ -101,6 +101,7 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
101
101
  totalVariancePercentage: undefined,
102
102
  },
103
103
  },
104
+ excludeAccountFetchState: reconciliationViewState.actionFetchState.excludeAccountFetch,
104
105
  };
105
106
  }
106
107
  const allAccountIDs = accountReconForMonthYearPeriod.accountIDs;
@@ -289,15 +290,14 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
289
290
  };
290
291
  const excludedAccountReconciliationByAccountID = {};
291
292
  reconciliationViewState.excludedAccountIDs.forEach((excludedAccountID) => {
292
- const account = getAccountWithBalance(accountState, {
293
- accountId: excludedAccountID,
294
- reportId: 'excluded_account_reconciliation',
295
- });
293
+ const account = getAccountByAccountId(accountState, excludedAccountID);
296
294
  const exclusionInfo = reconciliationViewState.excludedAccountExclusionInfo[excludedAccountID];
297
- excludedAccountReconciliationByAccountID[excludedAccountID] = {
298
- ...account,
299
- ...exclusionInfo,
300
- };
295
+ if (account != null) {
296
+ excludedAccountReconciliationByAccountID[excludedAccountID] = {
297
+ ...account,
298
+ ...exclusionInfo,
299
+ };
300
+ }
301
301
  });
302
302
  const accountListNestedAccountHierarchy = getNestedAccountListHierarchy(accountListState, 'accountList');
303
303
  const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
@@ -358,6 +358,7 @@ export const getExpenseAutomationReconciliationView = createSelector((state) =>
358
358
  reconListUIState: reconciliationViewState.reconListUIState,
359
359
  excludedAccountReconciliationBySectionID,
360
360
  excludedAccountReconciliationByAccountID,
361
+ excludeAccountFetchState: reconciliationViewState.actionFetchState.excludeAccountFetch,
361
362
  };
362
363
  });
363
364
  export const isAccountReconReport = (reportId) => {
@@ -2,6 +2,6 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
3
  import { RootState } from '../../../../reducer';
4
4
  import { ZeniAPI } from '../../../../zeniAPI';
5
- import { excludeAccountFromReconciliation, excludeAccountFromReconciliationFailure, excludeAccountFromReconciliationSuccess, fetchReconciliation } from '../../reducers/reconciliationViewReducer';
6
- export type ActionType = ReturnType<typeof excludeAccountFromReconciliation> | ReturnType<typeof excludeAccountFromReconciliationSuccess> | ReturnType<typeof excludeAccountFromReconciliationFailure> | ReturnType<typeof fetchReconciliation>;
5
+ import { excludeAccountFromReconciliation, excludeAccountFromReconciliationFailure, excludeAccountFromReconciliationSuccess } from '../../reducers/reconciliationViewReducer';
6
+ export type ActionType = ReturnType<typeof excludeAccountFromReconciliation> | ReturnType<typeof excludeAccountFromReconciliationSuccess> | ReturnType<typeof excludeAccountFromReconciliationFailure>;
7
7
  export declare const excludeAccountFromReconciliationEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -24,7 +24,10 @@ const excludeAccountFromReconciliationEpic = (actions$, state$, zeniAPI) => acti
24
24
  .postAndGetJSON(apiUrl, payload)
25
25
  .pipe((0, operators_1.mergeMap)((response) => {
26
26
  if ((0, responsePayload_1.isSuccessResponse)(response)) {
27
- return (0, rxjs_1.of)((0, reconciliationViewReducer_1.excludeAccountFromReconciliationSuccess)({ accountId }), (0, reconciliationViewReducer_1.fetchReconciliation)(selectedPeriod, undefined, true, true));
27
+ return (0, rxjs_1.of)((0, reconciliationViewReducer_1.excludeAccountFromReconciliationSuccess)({
28
+ account: response.data?.excluded_account ?? undefined,
29
+ selectedPeriod,
30
+ }));
28
31
  }
29
32
  else {
30
33
  return (0, rxjs_1.of)((0, reconciliationViewReducer_1.excludeAccountFromReconciliationFailure)({
@@ -45,7 +45,18 @@ export interface ExcludeAccountFromReconciliationRequestPayload {
45
45
  cleared_balance: number;
46
46
  variance: number;
47
47
  }
48
- export type ExcludeAccountFromReconciliationResponse = ZeniAPIResponse<unknown>;
48
+ export interface ExcludedAccountFromReconciliationPayload {
49
+ account_id: ID;
50
+ bank_balance: number | null;
51
+ cleared_balance: number | null;
52
+ variance: number | null;
53
+ currency_code?: string;
54
+ currency_symbol?: string;
55
+ }
56
+ export interface ExcludeAccountFromReconciliationResponsePayload {
57
+ excluded_account: ExcludedAccountFromReconciliationPayload;
58
+ }
59
+ export type ExcludeAccountFromReconciliationResponse = ZeniAPIResponse<ExcludeAccountFromReconciliationResponsePayload>;
49
60
  export interface DeleteStatementResponsePayload {
50
61
  statement_upload: {
51
62
  statement_data_status: StatusCodeWithLabelPayload;
@@ -3,7 +3,7 @@ import { FetchState, ID } from '../../../commonStateTypes/common';
3
3
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
4
4
  import { MonthYearPeriod } from '../../../commonStateTypes/timePeriod';
5
5
  import { ZeniAPIStatus } from '../../../responsePayload';
6
- import { ReconciliationPayload, UploadStatementDocumentAIPayload } from '../payload/reconciliationPayload';
6
+ import { ExcludedAccountFromReconciliationPayload, ReconciliationPayload, UploadStatementDocumentAIPayload } from '../payload/reconciliationPayload';
7
7
  import { AccountReconciliationLocalData, ActionFetchStates, ExcludeAccountFromReconciliationPayload, ReconReconcileSortKey, ReconReviewSortKey, ReconciliationReviewTabLocalData, ReconciliationTabsState, ReconciliationViewState, ReconciliationViewTabType, SaveReconcileDetailActionPayload, SaveReconciliationDetailFailurePayload, TransactionSummary } from '../types/reconciliationViewState';
8
8
  export declare const initialReconciliationTabsState: ReconciliationTabsState;
9
9
  export declare const initialActionFetchState: ActionFetchStates;
@@ -87,7 +87,8 @@ export declare const fetchReconciliation: import("@reduxjs/toolkit").ActionCreat
87
87
  error: ZeniAPIStatus;
88
88
  selectedPeriod: MonthYearPeriod;
89
89
  }, "expenseAutomationReconciliationView/deleteAccountStatementFailure">, excludeAccountFromReconciliation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: ExcludeAccountFromReconciliationPayload], ExcludeAccountFromReconciliationPayload, "expenseAutomationReconciliationView/excludeAccountFromReconciliation", never, never>, excludeAccountFromReconciliationSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
90
- accountId: ID;
90
+ selectedPeriod: MonthYearPeriod;
91
+ account?: ExcludedAccountFromReconciliationPayload;
91
92
  }, "expenseAutomationReconciliationView/excludeAccountFromReconciliationSuccess">, excludeAccountFromReconciliationFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
92
93
  error: ZeniAPIStatus;
93
94
  }, "expenseAutomationReconciliationView/excludeAccountFromReconciliationFailure">, uploadAccountStatement: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
@@ -447,8 +447,36 @@ const expenseAutomationReconciliationView = (0, toolkit_1.createSlice)({
447
447
  fetchState: 'Completed',
448
448
  error: undefined,
449
449
  };
450
- if (!draft.excludedAccountIDs.includes(action.payload.accountId)) {
451
- draft.excludedAccountIDs.push(action.payload.accountId);
450
+ const { account, selectedPeriod } = action.payload;
451
+ if (account != null) {
452
+ if (!draft.excludedAccountIDs.includes(account.account_id)) {
453
+ draft.excludedAccountIDs.push(account.account_id);
454
+ }
455
+ draft.excludedAccountExclusionInfo[account.account_id] = {
456
+ bankBalance: account.bank_balance != null
457
+ ? {
458
+ amount: account.bank_balance,
459
+ currencyCode: account.currency_code ?? 'USD',
460
+ currencySymbol: account.currency_symbol ?? '$',
461
+ }
462
+ : undefined,
463
+ clearedBalance: account.cleared_balance != null
464
+ ? {
465
+ amount: account.cleared_balance,
466
+ currencyCode: account.currency_code ?? 'USD',
467
+ currencySymbol: account.currency_symbol ?? '$',
468
+ }
469
+ : undefined,
470
+ variance: account.variance != null
471
+ ? {
472
+ amount: account.variance,
473
+ currencyCode: account.currency_code ?? 'USD',
474
+ currencySymbol: account.currency_symbol ?? '$',
475
+ }
476
+ : undefined,
477
+ };
478
+ const monthYearPeriodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
479
+ draft.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId].accountIDs = draft.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId].accountIDs.filter((id) => id !== account.account_id);
452
480
  }
453
481
  },
454
482
  excludeAccountFromReconciliationFailure: (draft, action) => {
@@ -3,8 +3,7 @@ import { Amount } from '../../../commonStateTypes/amount';
3
3
  import { NestedClassHierarchyForReport } from '../../../commonStateTypes/classesView/nestedClassID';
4
4
  import { CompletionStatusType, FetchStateAndError, ID } from '../../../commonStateTypes/common';
5
5
  import { MonthYearPeriod } from '../../../commonStateTypes/timePeriod';
6
- import { AccountWithBalanceReport } from '../../../entity/account/accountSelector';
7
- import { AccountBase } from '../../../entity/account/accountState';
6
+ import { Account, AccountBase } from '../../../entity/account/accountState';
8
7
  import { AccountReconciliationEntity } from '../../../entity/accountRecon/accountReconSelector';
9
8
  import { BankStatusCodeType } from '../../../entity/accountRecon/accountReconState';
10
9
  import { ClassBase } from '../../../entity/class/classState';
@@ -14,7 +13,7 @@ import { AccountReconciliationLocalData, ActionFetchStates, ReconListUIState, Re
14
13
  export declare const ALL_ACCOUNT_RECON_SECTION_IDS: readonly ["assets", "liabilities"];
15
14
  declare const toAccountReconSectionID: (v: string) => "assets" | "liabilities";
16
15
  export type AccountReconSectionID = ReturnType<typeof toAccountReconSectionID>;
17
- export interface ExcludedAccountReconciliation extends AccountWithBalanceReport {
16
+ export interface ExcludedAccountReconciliation extends Account {
18
17
  bankBalance?: Amount;
19
18
  clearedBalance?: Amount;
20
19
  variance?: Amount;
@@ -30,6 +29,7 @@ export interface ExpenseAutomationReconciliationViewSelector {
30
29
  classListNestedAccountHierarchy: NestedClassHierarchyForReport[];
31
30
  completionStatus: CompletionStatusType;
32
31
  creditCards: AccountBase[];
32
+ excludeAccountFetchState: FetchStateAndError;
33
33
  excludedAccountReconciliationByAccountID: Record<ID, ExcludedAccountReconciliation>;
34
34
  excludedAccountReconciliationBySectionID: Record<AccountReconSectionID, AccountReconciliationBySection>;
35
35
  fetchStatus: FetchStateAndError;
@@ -107,6 +107,7 @@ exports.getExpenseAutomationReconciliationView = (0, toolkit_1.createSelector)((
107
107
  totalVariancePercentage: undefined,
108
108
  },
109
109
  },
110
+ excludeAccountFetchState: reconciliationViewState.actionFetchState.excludeAccountFetch,
110
111
  };
111
112
  }
112
113
  const allAccountIDs = accountReconForMonthYearPeriod.accountIDs;
@@ -295,15 +296,14 @@ exports.getExpenseAutomationReconciliationView = (0, toolkit_1.createSelector)((
295
296
  };
296
297
  const excludedAccountReconciliationByAccountID = {};
297
298
  reconciliationViewState.excludedAccountIDs.forEach((excludedAccountID) => {
298
- const account = (0, accountSelector_1.getAccountWithBalance)(accountState, {
299
- accountId: excludedAccountID,
300
- reportId: 'excluded_account_reconciliation',
301
- });
299
+ const account = (0, accountSelector_1.getAccountByAccountId)(accountState, excludedAccountID);
302
300
  const exclusionInfo = reconciliationViewState.excludedAccountExclusionInfo[excludedAccountID];
303
- excludedAccountReconciliationByAccountID[excludedAccountID] = {
304
- ...account,
305
- ...exclusionInfo,
306
- };
301
+ if (account != null) {
302
+ excludedAccountReconciliationByAccountID[excludedAccountID] = {
303
+ ...account,
304
+ ...exclusionInfo,
305
+ };
306
+ }
307
307
  });
308
308
  const accountListNestedAccountHierarchy = (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'accountList');
309
309
  const classListNestedAccountHierarchy = (0, classListSelector_1.getNestedClassListHierarchy)(classListState);
@@ -364,6 +364,7 @@ exports.getExpenseAutomationReconciliationView = (0, toolkit_1.createSelector)((
364
364
  reconListUIState: reconciliationViewState.reconListUIState,
365
365
  excludedAccountReconciliationBySectionID,
366
366
  excludedAccountReconciliationByAccountID,
367
+ excludeAccountFetchState: reconciliationViewState.actionFetchState.excludeAccountFetch,
367
368
  };
368
369
  });
369
370
  const isAccountReconReport = (reportId) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.96-betaJK15",
3
+ "version": "4.19.96-betaJK17",
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",