@zeniai/client-epic-state 5.2.48 → 5.2.49

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.
@@ -102,32 +102,27 @@ const expenseAutomationReconciliationView = createSlice({
102
102
  draft.selectedTab = 'review';
103
103
  draft.selectedAccountId = action.payload.accountId;
104
104
  }
105
- const accountReconciliationRecords = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(action.payload.selectedPeriod)];
106
- const { transactionFetchState } = accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId];
107
- if (transactionFetchState.fetchState !== 'Completed' ||
105
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(action.payload.selectedPeriod)]?.reconciliationByAccountID[action.payload.accountId];
106
+ if (accountRecon == null) {
107
+ return;
108
+ }
109
+ if (accountRecon.transactionFetchState.fetchState !== 'Completed' ||
108
110
  action.payload.cacheOverride === true) {
109
- const data = accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId];
110
111
  if (action.payload.refreshViewInBackground === true) {
111
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId] = {
112
- ...data,
113
- refreshStatus: {
114
- fetchState: 'In-Progress',
115
- error: undefined,
116
- },
117
- accountId: action.payload.accountId,
118
- reconciliationId: undefined,
112
+ accountRecon.refreshStatus = {
113
+ fetchState: 'In-Progress',
114
+ error: undefined,
119
115
  };
116
+ accountRecon.accountId = action.payload.accountId;
117
+ accountRecon.reconciliationId = undefined;
120
118
  }
121
119
  else {
122
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId] = {
123
- ...data,
124
- transactionFetchState: {
125
- fetchState: 'In-Progress',
126
- error: undefined,
127
- },
128
- accountId: action.payload.accountId,
129
- reconciliationId: undefined,
120
+ accountRecon.transactionFetchState = {
121
+ fetchState: 'In-Progress',
122
+ error: undefined,
130
123
  };
124
+ accountRecon.accountId = action.payload.accountId;
125
+ accountRecon.reconciliationId = undefined;
131
126
  }
132
127
  }
133
128
  }
@@ -179,14 +174,17 @@ const expenseAutomationReconciliationView = createSlice({
179
174
  }
180
175
  }
181
176
  else {
182
- const accountReconciliationRecords = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(action.payload.selectedPeriod)];
177
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(action.payload.selectedPeriod)]?.reconciliationByAccountID[action.payload.accountId];
178
+ if (accountRecon == null) {
179
+ return;
180
+ }
183
181
  if (action.payload.refreshViewInBackground === true) {
184
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId].refreshStatus.error = action.payload.error;
185
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId].refreshStatus.fetchState = 'Error';
182
+ accountRecon.refreshStatus.error = action.payload.error;
183
+ accountRecon.refreshStatus.fetchState = 'Error';
186
184
  }
187
185
  else {
188
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId].transactionFetchState.error = action.payload.error;
189
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId].transactionFetchState.fetchState = 'Error';
186
+ accountRecon.transactionFetchState.error = action.payload.error;
187
+ accountRecon.transactionFetchState.fetchState = 'Error';
190
188
  }
191
189
  }
192
190
  },
@@ -391,8 +389,11 @@ const expenseAutomationReconciliationView = createSlice({
391
389
  },
392
390
  setStatementParseInProgress: (draft, action) => {
393
391
  const { accountId, selectedPeriod, statementParseInProgress } = action.payload;
394
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].statementParseInProgress =
395
- statementParseInProgress;
392
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
393
+ if (accountRecon == null) {
394
+ return;
395
+ }
396
+ accountRecon.statementParseInProgress = statementParseInProgress;
396
397
  },
397
398
  setStatementProcessingDismissedToBackground: (draft, action) => {
398
399
  const { accountId, selectedPeriod, dismissedToBackground } = action.payload;
@@ -476,15 +477,23 @@ const expenseAutomationReconciliationView = createSlice({
476
477
  },
477
478
  uploadAccountStatementSuccess: (draft, action) => {
478
479
  const { accountId, selectedPeriod } = action.payload;
479
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].statementUploadStatus = {
480
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
481
+ if (accountRecon == null) {
482
+ return;
483
+ }
484
+ accountRecon.statementUploadStatus = {
480
485
  fetchState: 'Completed',
481
486
  error: undefined,
482
487
  };
483
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].statementParseInProgress = true;
488
+ accountRecon.statementParseInProgress = true;
484
489
  },
485
490
  uploadAccountStatementFailure: (draft, action) => {
486
491
  const { accountId, selectedPeriod } = action.payload;
487
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].statementUploadStatus = {
492
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
493
+ if (accountRecon == null) {
494
+ return;
495
+ }
496
+ accountRecon.statementUploadStatus = {
488
497
  fetchState: 'Error',
489
498
  error: action.payload.error,
490
499
  };
@@ -677,23 +686,34 @@ const expenseAutomationReconciliationView = createSlice({
677
686
  },
678
687
  reparseStatementFailure: (draft, action) => {
679
688
  const { accountId, selectedPeriod } = action.payload;
680
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].reparseStatementStatus = {
689
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
690
+ if (accountRecon == null) {
691
+ return;
692
+ }
693
+ accountRecon.reparseStatementStatus = {
681
694
  fetchState: 'Error',
682
695
  error: action.payload.error,
683
696
  };
684
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].statementProcessingFailed = true;
697
+ accountRecon.statementProcessingFailed = true;
685
698
  },
686
699
  resetReparseStatementStatus: (draft, action) => {
687
700
  const { accountId, selectedPeriod } = action.payload;
688
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].reparseStatementStatus = {
701
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
702
+ if (accountRecon == null) {
703
+ return;
704
+ }
705
+ accountRecon.reparseStatementStatus = {
689
706
  fetchState: 'Not-Started',
690
707
  error: undefined,
691
708
  };
692
709
  },
693
710
  updateParsedStatementData: (draft, action) => {
694
711
  const { accountId, selectedPeriod, parsedStatementData } = action.payload;
695
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].parsedStatementData =
696
- parsedStatementData;
712
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
713
+ if (accountRecon == null) {
714
+ return;
715
+ }
716
+ accountRecon.parsedStatementData = parsedStatementData;
697
717
  },
698
718
  updateStatementUpdateLocalData: (draft, action) => {
699
719
  const { accountId, selectedPeriod, statementUpdateLocalData, statementUploadId, } = action.payload;
@@ -819,17 +839,21 @@ const expenseAutomationReconciliationView = createSlice({
819
839
  },
820
840
  updateAccountReconciliationLocalData: (draft, action) => {
821
841
  const { accountId, selectedPeriod, localData } = action.payload;
822
- const oldLocalData = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].localData;
842
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
843
+ if (accountRecon == null) {
844
+ return;
845
+ }
846
+ const oldLocalData = accountRecon.localData;
823
847
  if (oldLocalData == null) {
824
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].localData = localData;
848
+ accountRecon.localData = localData;
825
849
  }
826
850
  else {
827
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].localData = {
851
+ accountRecon.localData = {
828
852
  ...oldLocalData,
829
853
  ...localData,
830
854
  };
831
855
  }
832
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId].localData = {
856
+ accountRecon.localData = {
833
857
  ...oldLocalData,
834
858
  ...localData,
835
859
  };
@@ -1119,7 +1143,10 @@ function updateAllReconciliation(draft, accounts, selectedPeriod, reconciliation
1119
1143
  }
1120
1144
  }
1121
1145
  function updateReconciliationByAccountID(draft, accounts, selectedPeriod, accountId, reconciliationData, refreshViewInBackground) {
1122
- const oldRecord = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId];
1146
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)]?.reconciliationByAccountID[accountId];
1147
+ if (accountRecon == null) {
1148
+ return;
1149
+ }
1123
1150
  const oldConnectionStatus = draft.accountConnectionStatusByAccountID[accountId];
1124
1151
  draft.accountConnectionStatusByAccountID[accountId] = {
1125
1152
  status: toBankStatusCodeType(reconciliationData.bank_status.code),
@@ -1129,21 +1156,17 @@ function updateReconciliationByAccountID(draft, accounts, selectedPeriod, accoun
1129
1156
  : false,
1130
1157
  paymentAccountId: accounts.payment_account_id ?? undefined,
1131
1158
  };
1132
- const statementParseInProgress = resolveStatementParseInProgressAfterFetch(oldRecord, reconciliationData);
1159
+ const statementParseInProgress = resolveStatementParseInProgressAfterFetch(accountRecon, reconciliationData);
1160
+ accountRecon.reconciliationId =
1161
+ reconciliationData.reconciliation_id ?? undefined;
1162
+ accountRecon.statementParseInProgress = statementParseInProgress;
1133
1163
  if (refreshViewInBackground === true) {
1134
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId] = {
1135
- ...oldRecord,
1136
- reconciliationId: reconciliationData.reconciliation_id ?? undefined,
1137
- refreshStatus: { fetchState: 'Completed', error: undefined },
1138
- statementParseInProgress,
1139
- };
1164
+ accountRecon.refreshStatus = { fetchState: 'Completed', error: undefined };
1140
1165
  }
1141
1166
  else {
1142
- draft.accountReconciliationRecordsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)].reconciliationByAccountID[accountId] = {
1143
- ...oldRecord,
1144
- statementParseInProgress,
1145
- reconciliationId: reconciliationData.reconciliation_id ?? undefined,
1146
- transactionFetchState: { fetchState: 'Completed', error: undefined },
1167
+ accountRecon.transactionFetchState = {
1168
+ fetchState: 'Completed',
1169
+ error: undefined,
1147
1170
  };
1148
1171
  }
1149
1172
  }
@@ -1173,7 +1196,11 @@ const updateExcludedAccountExclusionInfo = (draft, account) => {
1173
1196
  };
1174
1197
  };
1175
1198
  const updateReconciliationByAccountIDOnIncludeAccount = (draft, accountId, reconciliation, monthYearPeriodId) => {
1176
- draft.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId].reconciliationByAccountID[accountId] = {
1199
+ const accountReconciliationRecords = draft.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId];
1200
+ if (accountReconciliationRecords == null) {
1201
+ return;
1202
+ }
1203
+ accountReconciliationRecords.reconciliationByAccountID[accountId] = {
1177
1204
  accountId,
1178
1205
  reconciliationId: reconciliation.reconciliation_id ?? undefined,
1179
1206
  transactionFetchState: { fetchState: 'Not-Started', error: undefined },
@@ -107,32 +107,27 @@ const expenseAutomationReconciliationView = (0, toolkit_1.createSlice)({
107
107
  draft.selectedTab = 'review';
108
108
  draft.selectedAccountId = action.payload.accountId;
109
109
  }
110
- const accountReconciliationRecords = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(action.payload.selectedPeriod)];
111
- const { transactionFetchState } = accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId];
112
- if (transactionFetchState.fetchState !== 'Completed' ||
110
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(action.payload.selectedPeriod)]?.reconciliationByAccountID[action.payload.accountId];
111
+ if (accountRecon == null) {
112
+ return;
113
+ }
114
+ if (accountRecon.transactionFetchState.fetchState !== 'Completed' ||
113
115
  action.payload.cacheOverride === true) {
114
- const data = accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId];
115
116
  if (action.payload.refreshViewInBackground === true) {
116
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId] = {
117
- ...data,
118
- refreshStatus: {
119
- fetchState: 'In-Progress',
120
- error: undefined,
121
- },
122
- accountId: action.payload.accountId,
123
- reconciliationId: undefined,
117
+ accountRecon.refreshStatus = {
118
+ fetchState: 'In-Progress',
119
+ error: undefined,
124
120
  };
121
+ accountRecon.accountId = action.payload.accountId;
122
+ accountRecon.reconciliationId = undefined;
125
123
  }
126
124
  else {
127
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId] = {
128
- ...data,
129
- transactionFetchState: {
130
- fetchState: 'In-Progress',
131
- error: undefined,
132
- },
133
- accountId: action.payload.accountId,
134
- reconciliationId: undefined,
125
+ accountRecon.transactionFetchState = {
126
+ fetchState: 'In-Progress',
127
+ error: undefined,
135
128
  };
129
+ accountRecon.accountId = action.payload.accountId;
130
+ accountRecon.reconciliationId = undefined;
136
131
  }
137
132
  }
138
133
  }
@@ -184,14 +179,17 @@ const expenseAutomationReconciliationView = (0, toolkit_1.createSlice)({
184
179
  }
185
180
  }
186
181
  else {
187
- const accountReconciliationRecords = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(action.payload.selectedPeriod)];
182
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(action.payload.selectedPeriod)]?.reconciliationByAccountID[action.payload.accountId];
183
+ if (accountRecon == null) {
184
+ return;
185
+ }
188
186
  if (action.payload.refreshViewInBackground === true) {
189
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId].refreshStatus.error = action.payload.error;
190
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId].refreshStatus.fetchState = 'Error';
187
+ accountRecon.refreshStatus.error = action.payload.error;
188
+ accountRecon.refreshStatus.fetchState = 'Error';
191
189
  }
192
190
  else {
193
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId].transactionFetchState.error = action.payload.error;
194
- accountReconciliationRecords.reconciliationByAccountID[action.payload.accountId].transactionFetchState.fetchState = 'Error';
191
+ accountRecon.transactionFetchState.error = action.payload.error;
192
+ accountRecon.transactionFetchState.fetchState = 'Error';
195
193
  }
196
194
  }
197
195
  },
@@ -396,8 +394,11 @@ const expenseAutomationReconciliationView = (0, toolkit_1.createSlice)({
396
394
  },
397
395
  setStatementParseInProgress: (draft, action) => {
398
396
  const { accountId, selectedPeriod, statementParseInProgress } = action.payload;
399
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].statementParseInProgress =
400
- statementParseInProgress;
397
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]?.reconciliationByAccountID[accountId];
398
+ if (accountRecon == null) {
399
+ return;
400
+ }
401
+ accountRecon.statementParseInProgress = statementParseInProgress;
401
402
  },
402
403
  setStatementProcessingDismissedToBackground: (draft, action) => {
403
404
  const { accountId, selectedPeriod, dismissedToBackground } = action.payload;
@@ -481,15 +482,23 @@ const expenseAutomationReconciliationView = (0, toolkit_1.createSlice)({
481
482
  },
482
483
  uploadAccountStatementSuccess: (draft, action) => {
483
484
  const { accountId, selectedPeriod } = action.payload;
484
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].statementUploadStatus = {
485
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]?.reconciliationByAccountID[accountId];
486
+ if (accountRecon == null) {
487
+ return;
488
+ }
489
+ accountRecon.statementUploadStatus = {
485
490
  fetchState: 'Completed',
486
491
  error: undefined,
487
492
  };
488
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].statementParseInProgress = true;
493
+ accountRecon.statementParseInProgress = true;
489
494
  },
490
495
  uploadAccountStatementFailure: (draft, action) => {
491
496
  const { accountId, selectedPeriod } = action.payload;
492
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].statementUploadStatus = {
497
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]?.reconciliationByAccountID[accountId];
498
+ if (accountRecon == null) {
499
+ return;
500
+ }
501
+ accountRecon.statementUploadStatus = {
493
502
  fetchState: 'Error',
494
503
  error: action.payload.error,
495
504
  };
@@ -682,23 +691,34 @@ const expenseAutomationReconciliationView = (0, toolkit_1.createSlice)({
682
691
  },
683
692
  reparseStatementFailure: (draft, action) => {
684
693
  const { accountId, selectedPeriod } = action.payload;
685
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].reparseStatementStatus = {
694
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]?.reconciliationByAccountID[accountId];
695
+ if (accountRecon == null) {
696
+ return;
697
+ }
698
+ accountRecon.reparseStatementStatus = {
686
699
  fetchState: 'Error',
687
700
  error: action.payload.error,
688
701
  };
689
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].statementProcessingFailed = true;
702
+ accountRecon.statementProcessingFailed = true;
690
703
  },
691
704
  resetReparseStatementStatus: (draft, action) => {
692
705
  const { accountId, selectedPeriod } = action.payload;
693
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].reparseStatementStatus = {
706
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]?.reconciliationByAccountID[accountId];
707
+ if (accountRecon == null) {
708
+ return;
709
+ }
710
+ accountRecon.reparseStatementStatus = {
694
711
  fetchState: 'Not-Started',
695
712
  error: undefined,
696
713
  };
697
714
  },
698
715
  updateParsedStatementData: (draft, action) => {
699
716
  const { accountId, selectedPeriod, parsedStatementData } = action.payload;
700
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].parsedStatementData =
701
- parsedStatementData;
717
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]?.reconciliationByAccountID[accountId];
718
+ if (accountRecon == null) {
719
+ return;
720
+ }
721
+ accountRecon.parsedStatementData = parsedStatementData;
702
722
  },
703
723
  updateStatementUpdateLocalData: (draft, action) => {
704
724
  const { accountId, selectedPeriod, statementUpdateLocalData, statementUploadId, } = action.payload;
@@ -824,17 +844,21 @@ const expenseAutomationReconciliationView = (0, toolkit_1.createSlice)({
824
844
  },
825
845
  updateAccountReconciliationLocalData: (draft, action) => {
826
846
  const { accountId, selectedPeriod, localData } = action.payload;
827
- const oldLocalData = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].localData;
847
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]?.reconciliationByAccountID[accountId];
848
+ if (accountRecon == null) {
849
+ return;
850
+ }
851
+ const oldLocalData = accountRecon.localData;
828
852
  if (oldLocalData == null) {
829
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].localData = localData;
853
+ accountRecon.localData = localData;
830
854
  }
831
855
  else {
832
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].localData = {
856
+ accountRecon.localData = {
833
857
  ...oldLocalData,
834
858
  ...localData,
835
859
  };
836
860
  }
837
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId].localData = {
861
+ accountRecon.localData = {
838
862
  ...oldLocalData,
839
863
  ...localData,
840
864
  };
@@ -1124,7 +1148,10 @@ function updateAllReconciliation(draft, accounts, selectedPeriod, reconciliation
1124
1148
  }
1125
1149
  }
1126
1150
  function updateReconciliationByAccountID(draft, accounts, selectedPeriod, accountId, reconciliationData, refreshViewInBackground) {
1127
- const oldRecord = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId];
1151
+ const accountRecon = draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]?.reconciliationByAccountID[accountId];
1152
+ if (accountRecon == null) {
1153
+ return;
1154
+ }
1128
1155
  const oldConnectionStatus = draft.accountConnectionStatusByAccountID[accountId];
1129
1156
  draft.accountConnectionStatusByAccountID[accountId] = {
1130
1157
  status: (0, accountReconState_1.toBankStatusCodeType)(reconciliationData.bank_status.code),
@@ -1134,21 +1161,17 @@ function updateReconciliationByAccountID(draft, accounts, selectedPeriod, accoun
1134
1161
  : false,
1135
1162
  paymentAccountId: accounts.payment_account_id ?? undefined,
1136
1163
  };
1137
- const statementParseInProgress = resolveStatementParseInProgressAfterFetch(oldRecord, reconciliationData);
1164
+ const statementParseInProgress = resolveStatementParseInProgressAfterFetch(accountRecon, reconciliationData);
1165
+ accountRecon.reconciliationId =
1166
+ reconciliationData.reconciliation_id ?? undefined;
1167
+ accountRecon.statementParseInProgress = statementParseInProgress;
1138
1168
  if (refreshViewInBackground === true) {
1139
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId] = {
1140
- ...oldRecord,
1141
- reconciliationId: reconciliationData.reconciliation_id ?? undefined,
1142
- refreshStatus: { fetchState: 'Completed', error: undefined },
1143
- statementParseInProgress,
1144
- };
1169
+ accountRecon.refreshStatus = { fetchState: 'Completed', error: undefined };
1145
1170
  }
1146
1171
  else {
1147
- draft.accountReconciliationRecordsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)].reconciliationByAccountID[accountId] = {
1148
- ...oldRecord,
1149
- statementParseInProgress,
1150
- reconciliationId: reconciliationData.reconciliation_id ?? undefined,
1151
- transactionFetchState: { fetchState: 'Completed', error: undefined },
1172
+ accountRecon.transactionFetchState = {
1173
+ fetchState: 'Completed',
1174
+ error: undefined,
1152
1175
  };
1153
1176
  }
1154
1177
  }
@@ -1178,7 +1201,11 @@ const updateExcludedAccountExclusionInfo = (draft, account) => {
1178
1201
  };
1179
1202
  };
1180
1203
  const updateReconciliationByAccountIDOnIncludeAccount = (draft, accountId, reconciliation, monthYearPeriodId) => {
1181
- draft.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId].reconciliationByAccountID[accountId] = {
1204
+ const accountReconciliationRecords = draft.accountReconciliationRecordsBySelectedPeriod[monthYearPeriodId];
1205
+ if (accountReconciliationRecords == null) {
1206
+ return;
1207
+ }
1208
+ accountReconciliationRecords.reconciliationByAccountID[accountId] = {
1182
1209
  accountId,
1183
1210
  reconciliationId: reconciliation.reconciliation_id ?? undefined,
1184
1211
  transactionFetchState: { fetchState: 'Not-Started', error: undefined },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.48",
3
+ "version": "5.2.49",
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",