@zeniai/client-epic-state 5.2.35-beta4MM → 5.2.35-beta6MM

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.
Files changed (27) hide show
  1. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -0
  2. package/lib/entity/jeSchedules/jeSchedulesPayload.js +1 -0
  3. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -0
  4. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  5. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  6. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +1 -0
  7. package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
  8. package/lib/esm/index.js +3 -3
  9. package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +71 -12
  10. package/lib/esm/view/expenseAutomationView/epics/actualMatching/undoReversalAccrualsEpic.js +41 -3
  11. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +10 -5
  12. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +35 -4
  13. package/lib/index.d.ts +3 -3
  14. package/lib/index.js +20 -18
  15. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.d.ts +2 -1
  16. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +69 -10
  17. package/lib/view/expenseAutomationView/epics/actualMatching/undoReversalAccrualsEpic.d.ts +2 -1
  18. package/lib/view/expenseAutomationView/epics/actualMatching/undoReversalAccrualsEpic.js +41 -3
  19. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  20. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +1 -1
  21. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +3 -3
  22. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +11 -6
  23. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +3 -0
  24. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +2 -2
  25. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +36 -4
  26. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +2 -2
  27. package/package.json +1 -1
@@ -19,6 +19,8 @@ export interface ActualMatchingRow extends JEOneTimeAccrual {
19
19
  matchId: string;
20
20
  groupedAccrualIds?: ID[];
21
21
  groupedMembers?: ActualMatchingGroupedAccrual[];
22
+ intendedAccrualIds?: ID[];
23
+ leftovers?: ActualMatchingGroupedAccrual[];
22
24
  matchShape?: string;
23
25
  matchTier?: string;
24
26
  reversalDate?: ZeniDate;
@@ -69,6 +71,7 @@ export interface ActualMatchingMatchModalView {
69
71
  prefill?: {
70
72
  selectedAccrualIds: ID[];
71
73
  actualAmount?: number;
74
+ consumedLineIds?: ID[];
72
75
  matchedLineId?: string;
73
76
  matchedTransactionId?: string;
74
77
  };
@@ -8,7 +8,7 @@ import { JEOneTimeAccrualMatchSuggestion } from '../../../entity/jeSchedules/jeS
8
8
  import { RootState } from '../../../rootStateTypes';
9
9
  import { ZeniDate } from '../../../zeniDayJS';
10
10
  import { ActualMatchingKpiSummary, ActualMatchingRow, ActualMatchingRowKind, ExpenseAutomationActualMatchingViewSelector } from '../selectorTypes/actualMatchingViewSelectorTypes';
11
- import { MatchAndReverseResult, UndoReversalResult } from '../types/actualMatchingViewState';
11
+ import { MatchAndReverseResult } from '../types/actualMatchingViewState';
12
12
  export declare function getSelectedMonthYearForCurrentTenant(state: RootState): MonthYearPeriod | undefined;
13
13
  export declare function getTenantDisplayCurrency(state: RootState): DisplayCurrencyFallback | undefined;
14
14
  export declare function parseActualMatchingMatchId(matchId: string): {
@@ -30,8 +30,8 @@ export interface ExpenseAutomationActualMatchingMatchView {
30
30
  refreshStatus: FetchStateAndError;
31
31
  undoReversalStatus: FetchStateAndError;
32
32
  lastMatchResults?: MatchAndReverseResult[];
33
- lastUndoResults?: UndoReversalResult[];
34
33
  match?: ActualMatchingMatch;
35
34
  }
36
35
  export declare function getExpenseAutomationActualMatchingMatchView(state: RootState, matchId: ActualMatchingMatchId): ExpenseAutomationActualMatchingMatchView;
36
+ export declare function getCloseMatchAfterUndo(state: RootState): boolean;
37
37
  export declare function getExpenseAutomationActualMatchingView(state: RootState): ExpenseAutomationActualMatchingViewSelector;
@@ -15,6 +15,7 @@ exports.getActualMatchingAmount = getActualMatchingAmount;
15
15
  exports.getActualMatchingReversalDate = getActualMatchingReversalDate;
16
16
  exports.buildActualMatchingKpiSummary = buildActualMatchingKpiSummary;
17
17
  exports.getExpenseAutomationActualMatchingMatchView = getExpenseAutomationActualMatchingMatchView;
18
+ exports.getCloseMatchAfterUndo = getCloseMatchAfterUndo;
18
19
  exports.getExpenseAutomationActualMatchingView = getExpenseAutomationActualMatchingView;
19
20
  const orderBy_1 = __importDefault(require("lodash/orderBy"));
20
21
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
@@ -128,12 +129,32 @@ function collectGroupedMembers(members) {
128
129
  serviceMonth: member.serviceMonth,
129
130
  }));
130
131
  }
132
+ function collectLeftoverMembers(leftovers) {
133
+ if (leftovers == null || leftovers.length === 0) {
134
+ return undefined;
135
+ }
136
+ return leftovers.map((member) => ({
137
+ accrualId: member.accrualId,
138
+ estimatedAmount: member.estimatedAmount,
139
+ jeDebitAccountName: member.jeDebitAccountName,
140
+ memo: member.memo,
141
+ serviceMonth: member.serviceMonth,
142
+ }));
143
+ }
131
144
  function toActualMatchingRow(match) {
132
145
  const firstMember = match.members[0];
133
146
  if (firstMember == null) {
134
147
  throw new Error('Actual matching row requires at least one member');
135
148
  }
136
149
  const first = toMatchModalAccrual(firstMember);
150
+ const leftoverMembers = match.leftovers ?? [];
151
+ const fromCleared = firstMember.cleared?.intendedAccrualIds;
152
+ const intendedAccrualIds = fromCleared != null && fromCleared.length > 0
153
+ ? fromCleared
154
+ : [
155
+ ...match.members.map((member) => member.accrualId),
156
+ ...leftoverMembers.map((leftover) => leftover.accrualId),
157
+ ];
137
158
  return {
138
159
  ...first,
139
160
  matchId: match.matchId,
@@ -146,6 +167,8 @@ function toActualMatchingRow(match) {
146
167
  transactionDate: match.transactionDate,
147
168
  groupedAccrualIds: match.members.map((member) => member.accrualId),
148
169
  groupedMembers: collectGroupedMembers(match.members),
170
+ intendedAccrualIds,
171
+ leftovers: collectLeftoverMembers(match.leftovers),
149
172
  reversalDate: getActualMatchingReversalDate(first),
150
173
  vendorName: match.vendorName != null && match.vendorName !== ''
151
174
  ? match.vendorName
@@ -309,10 +332,12 @@ function getExpenseAutomationActualMatchingMatchView(state, matchId) {
309
332
  detailFetchState: view.detailFetchStateByMatchId[matchId] ?? NOT_STARTED,
310
333
  refreshStatus: view.detailRefreshStatusByMatchId[matchId] ?? NOT_STARTED,
311
334
  undoReversalStatus: view.undoReversalStatusByMatchId[matchId] ?? NOT_STARTED,
312
- lastUndoResults: view.lastUndoResultsByMatchId[matchId],
313
335
  lastMatchResults: view.lastMatchResultsByMatchId?.[matchId],
314
336
  };
315
337
  }
338
+ function getCloseMatchAfterUndo(state) {
339
+ return state.expenseAutomationActualMatchingViewState.closeMatchAfterUndo;
340
+ }
316
341
  function getExpenseAutomationActualMatchingView(state) {
317
342
  const { expenseAutomationActualMatchingViewState } = state;
318
343
  const { matchIdsByPeriod, fetchState, error, refreshStatus, uiState, matchModal, } = expenseAutomationActualMatchingViewState;
@@ -338,7 +363,11 @@ function getExpenseAutomationActualMatchingView(state) {
338
363
  ...(openedMatch?.members ?? []),
339
364
  ...(openedMatch?.leftovers ?? []),
340
365
  ].map(toMatchModalAccrual);
341
- const firstSuggestion = openedMatch?.members[0]?.matchSuggestion;
366
+ const firstMember = openedMatch?.members[0];
367
+ const cleared = firstMember?.cleared;
368
+ const suggestion = firstMember?.matchSuggestion;
369
+ const stamp = cleared ?? suggestion;
370
+ const consumedLineIds = cleared?.consumedLineIds;
342
371
  const prefill = openedMatch == null
343
372
  ? undefined
344
373
  : {
@@ -347,8 +376,11 @@ function getExpenseAutomationActualMatchingView(state) {
347
376
  ...(openedMatch.leftovers ?? []).map((leftover) => leftover.accrualId),
348
377
  ],
349
378
  actualAmount: openedMatch.actualAmount.amount,
350
- matchedLineId: firstSuggestion?.matchedLineId,
351
- matchedTransactionId: firstSuggestion?.matchedTransactionId,
379
+ matchedTransactionId: stamp?.matchedTransactionId,
380
+ matchedLineId: cleared == null ? suggestion?.matchedLineId : undefined,
381
+ ...(consumedLineIds != null && consumedLineIds.length > 0
382
+ ? { consumedLineIds }
383
+ : {}),
352
384
  };
353
385
  return {
354
386
  fetchState,
@@ -51,7 +51,7 @@ export interface MatchAndReverseResult {
51
51
  }
52
52
  export interface MatchAndReverseAccrualsParams {
53
53
  accrualIds: ID[];
54
- lineId: string;
54
+ lineIds: ID[];
55
55
  transactionId: ID;
56
56
  transactionIntegrationId: string;
57
57
  transactionSyncToken: string;
@@ -91,10 +91,10 @@ export interface ActualMatchingMatchModalState {
91
91
  }
92
92
  export declare function actualMatchingTransactionLineKey(transactionType: string, transactionIntegrationId: string, lineId: string): string;
93
93
  export interface ActualMatchingViewState extends FetchedState {
94
+ closeMatchAfterUndo: boolean;
94
95
  detailFetchStateByMatchId: Record<ActualMatchingMatchId, FetchStateAndError>;
95
96
  detailRefreshStatusByMatchId: Record<ActualMatchingMatchId, FetchStateAndError>;
96
97
  lastMatchResultsByMatchId: Record<ActualMatchingMatchId, MatchAndReverseResult[]>;
97
- lastUndoResultsByMatchId: Record<ActualMatchingMatchId, UndoReversalResult[]>;
98
98
  matchIdsByPeriod: Record<MonthYearPeriodId, ActualMatchingMatchId[]>;
99
99
  matchModal: ActualMatchingMatchModalState;
100
100
  refreshStatus: FetchStateAndError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.35-beta4MM",
3
+ "version": "5.2.35-beta6MM",
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",