@zeniai/client-epic-state 5.2.62-beta0MM → 5.2.62-beta1KB

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 (70) hide show
  1. package/lib/entity/actualMatching/actualMatchingReducer.d.ts +1 -3
  2. package/lib/entity/actualMatching/actualMatchingReducer.js +2 -11
  3. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +0 -1
  4. package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -1
  5. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -1
  6. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  7. package/lib/entity/snackbar/snackbarTypes.js +1 -1
  8. package/lib/entity/transaction/stateTypes/paymentType.d.ts +2 -2
  9. package/lib/entity/transaction/stateTypes/paymentType.js +9 -1
  10. package/lib/entity/transaction/stateTypes/printStatus.d.ts +4 -0
  11. package/lib/entity/transaction/stateTypes/printStatus.js +15 -0
  12. package/lib/epic.d.ts +4 -2
  13. package/lib/epic.js +6 -2
  14. package/lib/esm/entity/actualMatching/actualMatchingReducer.js +1 -9
  15. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -1
  16. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -1
  17. package/lib/esm/entity/transaction/stateTypes/paymentType.js +9 -1
  18. package/lib/esm/entity/transaction/stateTypes/printStatus.js +11 -0
  19. package/lib/esm/epic.js +6 -2
  20. package/lib/esm/index.js +10 -7
  21. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +3 -7
  22. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +23 -2
  23. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +35 -66
  24. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +64 -60
  25. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +0 -15
  26. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -30
  27. package/lib/esm/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +133 -0
  28. package/lib/esm/view/transactionDetail/createTransaction/createTransactionPayload.js +124 -0
  29. package/lib/esm/view/transactionDetail/createTransaction/createTransactionSelector.js +41 -0
  30. package/lib/esm/view/transactionDetail/createTransaction/createTransactionState.js +11 -0
  31. package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +58 -0
  32. package/lib/esm/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +55 -0
  33. package/lib/esm/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +14 -0
  34. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +174 -1
  35. package/lib/index.d.ts +12 -8
  36. package/lib/index.js +70 -57
  37. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +3 -7
  38. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +22 -1
  39. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  40. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +1 -12
  41. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +8 -16
  42. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +36 -67
  43. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +8 -20
  44. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +4 -7
  45. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +64 -63
  46. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +4 -20
  47. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +1 -18
  48. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -1
  49. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -30
  50. package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.d.ts +51 -0
  51. package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +148 -0
  52. package/lib/view/transactionDetail/createTransaction/createTransactionPayload.d.ts +82 -0
  53. package/lib/view/transactionDetail/createTransaction/createTransactionPayload.js +128 -0
  54. package/lib/view/transactionDetail/createTransaction/createTransactionSelector.d.ts +40 -0
  55. package/lib/view/transactionDetail/createTransaction/createTransactionSelector.js +48 -0
  56. package/lib/view/transactionDetail/createTransaction/createTransactionState.d.ts +81 -0
  57. package/lib/view/transactionDetail/createTransaction/createTransactionState.js +14 -0
  58. package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.d.ts +9 -0
  59. package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +62 -0
  60. package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.d.ts +20 -0
  61. package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +59 -0
  62. package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.d.ts +12 -0
  63. package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +18 -0
  64. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +37 -1
  65. package/lib/view/transactionDetail/transactionDetailReducer.js +176 -2
  66. package/lib/view/transactionDetail/transactionDetailState.d.ts +12 -0
  67. package/package.json +1 -1
  68. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.js +0 -50
  69. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.d.ts +0 -10
  70. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.js +0 -54
@@ -16,18 +16,15 @@ exports.getActualMatchingReversalDate = getActualMatchingReversalDate;
16
16
  exports.buildActualMatchingKpiSummary = buildActualMatchingKpiSummary;
17
17
  exports.getExpenseAutomationActualMatchingMatchView = getExpenseAutomationActualMatchingMatchView;
18
18
  exports.getCloseMatchAfterUndo = getCloseMatchAfterUndo;
19
- exports.getCloseMatchAfterUndoMatchId = getCloseMatchAfterUndoMatchId;
20
- exports.getCloseMatchAfterIgnoreMatchId = getCloseMatchAfterIgnoreMatchId;
21
- exports.getActualMatchingMatchModalConfirmStatus = getActualMatchingMatchModalConfirmStatus;
22
19
  exports.getExpenseAutomationActualMatchingView = getExpenseAutomationActualMatchingView;
23
20
  const orderBy_1 = __importDefault(require("lodash/orderBy"));
24
- const toolkit_1 = require("@reduxjs/toolkit");
25
21
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
26
22
  const actualMatchingSelector_1 = require("../../../entity/actualMatching/actualMatchingSelector");
27
23
  const jeScheduleHelper_1 = require("../../../entity/jeSchedules/jeScheduleHelper");
28
24
  const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
29
25
  const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
30
26
  const zeniDayJS_1 = require("../../../zeniDayJS");
27
+ const actualMatchingViewState_1 = require("../types/actualMatchingViewState");
31
28
  function getSelectedMonthYearForCurrentTenant(state) {
32
29
  const tenantId = (0, tenantSelector_1.getCurrentTenant)(state)?.tenantId;
33
30
  if (tenantId == null) {
@@ -56,6 +53,27 @@ function toMatchModalAccrual(member) {
56
53
  jeOneTimeAccrualKey: (0, jeScheduleHelper_1.generateJEOneTimeAccrualKey)(member.accrualId),
57
54
  };
58
55
  }
56
+ function uniqueMatchModalAccruals(pinned, searched) {
57
+ const byId = new Map();
58
+ pinned.forEach((row) => byId.set(row.accrualId, row));
59
+ searched.forEach((row) => {
60
+ if (!byId.has(row.accrualId)) {
61
+ byId.set(row.accrualId, row);
62
+ }
63
+ });
64
+ return Array.from(byId.values());
65
+ }
66
+ function uniqueTransactionSearchResults(pinned, searched) {
67
+ const byKey = new Map();
68
+ pinned.forEach((row) => byKey.set((0, actualMatchingViewState_1.actualMatchingTransactionLineKey)(row.transactionType, row.transactionIntegrationId, row.lineId), row));
69
+ searched.forEach((row) => {
70
+ const key = (0, actualMatchingViewState_1.actualMatchingTransactionLineKey)(row.transactionType, row.transactionIntegrationId, row.lineId);
71
+ if (!byKey.has(key)) {
72
+ byKey.set(key, row);
73
+ }
74
+ });
75
+ return Array.from(byKey.values());
76
+ }
59
77
  function parseActualMatchingMatchId(matchId) {
60
78
  const separator = matchId.indexOf(':');
61
79
  if (separator <= 0 || separator === matchId.length - 1) {
@@ -228,7 +246,6 @@ function emptyKpiSummary() {
228
246
  actualsReceived: { count: 0, expectedCount: 0, vendorsPending: 0 },
229
247
  autoReversed: { count: 0, percent: 0, clearedAmount: 0 },
230
248
  pendingReview: { count: 0, amount: 0, estimatedMinutesToClear: 0 },
231
- reversed: { count: 0 },
232
249
  variance: { percent: 0, averagePercentPerMatch: 0, netAmount: 0 },
233
250
  };
234
251
  }
@@ -284,7 +301,6 @@ function buildActualMatchingKpiSummary(rows, displayCurrencyCode) {
284
301
  }
285
302
  const autoReversed = kpiRows.filter((row) => row.kind === 'auto_reversed');
286
303
  const pendingReview = kpiRows.filter((row) => row.kind === 'pending_review');
287
- const reversed = kpiRows.filter((row) => isReversedMatchKind(row.kind));
288
304
  const receivedCount = kpiRows.length;
289
305
  const rowsWithActual = kpiRows.filter((row) => row.actualAmount?.amount != null);
290
306
  const accruedTotal = rowsWithActual.reduce((sum, row) => sum + (row.accruedAmount?.amount ?? row.estimatedAmount.amount), 0);
@@ -310,9 +326,6 @@ function buildActualMatchingKpiSummary(rows, displayCurrencyCode) {
310
326
  amount: sumRowAmounts(pendingReview, displayCurrencyCode),
311
327
  estimatedMinutesToClear: pendingReview.length * ESTIMATED_MINUTES_PER_PENDING_MATCH,
312
328
  },
313
- reversed: {
314
- count: reversed.length,
315
- },
316
329
  variance: {
317
330
  percent: accruedTotal === 0
318
331
  ? 0
@@ -325,55 +338,23 @@ function buildActualMatchingKpiSummary(rows, displayCurrencyCode) {
325
338
  },
326
339
  };
327
340
  }
328
- function toActualMatchingMatchView(match) {
341
+ function getExpenseAutomationActualMatchingMatchView(state, matchId) {
342
+ const view = state.expenseAutomationActualMatchingViewState;
329
343
  return {
330
- ...match,
331
- members: match.members.map(toMatchModalAccrual),
332
- leftovers: match.leftovers == null
333
- ? undefined
334
- : match.leftovers.map(toMatchModalAccrual),
344
+ match: (0, actualMatchingSelector_1.getActualMatchingMatchById)(state.actualMatchingState, matchId),
345
+ detailFetchState: view.detailFetchStateByMatchId[matchId] ?? NOT_STARTED,
346
+ refreshStatus: view.detailRefreshStatusByMatchId[matchId] ?? NOT_STARTED,
347
+ undoReversalStatus: view.undoReversalStatusByMatchId[matchId] ?? NOT_STARTED,
348
+ lastMatchResults: view.lastMatchResultsByMatchId?.[matchId],
349
+ lastUndoResults: view.lastUndoResultsByMatchId?.[matchId],
335
350
  };
336
351
  }
337
- const EMPTY_ACTUAL_MATCHING_ROWS = [];
338
- const matchViewSelectorById = new Map();
339
- function getExpenseAutomationActualMatchingMatchView(state, matchId) {
340
- let selector = matchViewSelectorById.get(matchId);
341
- if (selector == null) {
342
- selector = (0, toolkit_1.createSelector)([
343
- (root) => root.expenseAutomationActualMatchingViewState,
344
- (root) => (0, actualMatchingSelector_1.getActualMatchingMatchById)(root.actualMatchingState, matchId),
345
- ], (view, match) => ({
346
- detailFetchState: view.detailFetchStateByMatchId[matchId] ?? NOT_STARTED,
347
- ignoreStatus: view.ignoreStatusByMatchId[matchId] ?? NOT_STARTED,
348
- lastMatchResults: view.lastMatchResultsByMatchId?.[matchId],
349
- lastUndoResults: view.lastUndoResultsByMatchId?.[matchId],
350
- match: match == null ? undefined : toActualMatchingMatchView(match),
351
- refreshStatus: view.detailRefreshStatusByMatchId[matchId] ?? NOT_STARTED,
352
- undoReversalStatus: view.undoReversalStatusByMatchId[matchId] ?? NOT_STARTED,
353
- }));
354
- matchViewSelectorById.set(matchId, selector);
355
- }
356
- return selector(state);
357
- }
358
352
  function getCloseMatchAfterUndo(state) {
359
- return state.expenseAutomationActualMatchingViewState.closeMatchAfterUndoMatchId;
360
- }
361
- function getCloseMatchAfterUndoMatchId(state) {
362
- return getCloseMatchAfterUndo(state);
363
- }
364
- function getCloseMatchAfterIgnoreMatchId(state) {
365
- return state.expenseAutomationActualMatchingViewState
366
- .closeMatchAfterIgnoreMatchId;
367
- }
368
- function getActualMatchingMatchModalConfirmStatus(state, matchId) {
369
- if (matchId != null && matchId !== '') {
370
- return (state.expenseAutomationActualMatchingViewState.confirmStatusByMatchId[matchId] ?? NOT_STARTED);
371
- }
372
- return state.expenseAutomationActualMatchingViewState.matchModal.confirmStatus;
353
+ return state.expenseAutomationActualMatchingViewState.closeMatchAfterUndo;
373
354
  }
374
355
  function getExpenseAutomationActualMatchingView(state) {
375
356
  const { expenseAutomationActualMatchingViewState } = state;
376
- const { matchIdsByPeriod, fetchState, error, refreshStatus, uiState, matchModal, ignoreStatusByMatchId, undoReversalStatusByMatchId, } = expenseAutomationActualMatchingViewState;
357
+ const { matchIdsByPeriod, fetchState, error, refreshStatus, uiState, matchModal, } = expenseAutomationActualMatchingViewState;
377
358
  const selectedPeriod = getSelectedMonthYearForCurrentTenant(state);
378
359
  const monthYearPeriodId = selectedPeriod != null ? (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod) : undefined;
379
360
  const matchIds = monthYearPeriodId != null ? matchIdsByPeriod[monthYearPeriodId] : undefined;
@@ -383,18 +364,38 @@ function getExpenseAutomationActualMatchingView(state) {
383
364
  .filter((match) => match.members.length > 0)
384
365
  .map(toActualMatchingRow);
385
366
  const rows = allRows.filter((row) => matchesSearch(row, uiState.searchString));
386
- const includePendingReview = uiState.statusFilter !== 'reversed';
387
- const includeReversed = uiState.statusFilter !== 'pending_review';
388
- const reversed = includeReversed
389
- ? sortActualMatchingRows(rows.filter((row) => isReversedMatchKind(row.kind)), uiState)
390
- : EMPTY_ACTUAL_MATCHING_ROWS;
391
- const pendingReview = includePendingReview
392
- ? sortActualMatchingRows(rows.filter((row) => row.kind === 'pending_review'), uiState)
393
- : EMPTY_ACTUAL_MATCHING_ROWS;
367
+ const reversed = sortActualMatchingRows(rows.filter((row) => isReversedMatchKind(row.kind)), uiState);
368
+ const pendingReview = sortActualMatchingRows(rows.filter((row) => row.kind === 'pending_review'), uiState);
394
369
  const kpiSummary = buildActualMatchingKpiSummary(allRows, getTenantDisplayCurrency(state)?.currencyCode);
395
370
  const searchedAccruals = matchModal.accrualSearch.results
396
371
  .map((key) => (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)(key, state.jeSchedulesState))
397
372
  .filter((accrual) => accrual != null);
373
+ const openedMatch = matchModal.openedFromMatchId != null
374
+ ? (0, actualMatchingSelector_1.getActualMatchingMatchById)(state.actualMatchingState, matchModal.openedFromMatchId)
375
+ : undefined;
376
+ const pinnedAccruals = [
377
+ ...(openedMatch?.members ?? []),
378
+ ...(openedMatch?.leftovers ?? []),
379
+ ].map(toMatchModalAccrual);
380
+ const firstMember = openedMatch?.members[0];
381
+ const cleared = firstMember?.cleared;
382
+ const suggestion = firstMember?.matchSuggestion;
383
+ const stamp = cleared ?? suggestion;
384
+ const consumedLineIds = cleared?.consumedLineIds;
385
+ const prefill = openedMatch == null
386
+ ? undefined
387
+ : {
388
+ selectedAccrualIds: [
389
+ ...openedMatch.members.map((member) => member.accrualId),
390
+ ...(openedMatch.leftovers ?? []).map((leftover) => leftover.accrualId),
391
+ ],
392
+ actualAmount: openedMatch.actualAmount.amount,
393
+ matchedTransactionId: stamp?.matchedTransactionId,
394
+ matchedLineId: cleared == null ? suggestion?.matchedLineId : undefined,
395
+ ...(consumedLineIds != null && consumedLineIds.length > 0
396
+ ? { consumedLineIds }
397
+ : {}),
398
+ };
398
399
  // `fetchState` is a flat slice field that survives a period switch. Until this
399
400
  // month's ids land, leftover Completed/Error is the previous month. Report
400
401
  // Not-Started so chrome matches Review's "cache slot missing" skeleton, not
@@ -412,16 +413,16 @@ function getExpenseAutomationActualMatchingView(state) {
412
413
  kpiSummary,
413
414
  uiState,
414
415
  refreshStatus,
415
- ignoreStatusByMatchId,
416
- undoReversalStatusByMatchId,
417
416
  hasLoadedForSelectedPeriod: matchIds != null,
418
417
  matchModal: {
419
418
  isOpen: matchModal.isOpen,
419
+ openedFromMatchId: matchModal.openedFromMatchId,
420
+ prefill,
420
421
  confirmStatus: matchModal.confirmStatus,
421
422
  lastBatchResults: matchModal.lastBatchResults,
422
423
  transactionSearch: {
423
424
  query: matchModal.transactionSearch.query,
424
- results: matchModal.transactionSearch.results,
425
+ results: uniqueTransactionSearchResults(matchModal.pinnedTransactionResults, matchModal.transactionSearch.results),
425
426
  fetchState: {
426
427
  fetchState: matchModal.transactionSearch.fetchState,
427
428
  error: matchModal.transactionSearch.error,
@@ -431,7 +432,7 @@ function getExpenseAutomationActualMatchingView(state) {
431
432
  },
432
433
  accrualSearch: {
433
434
  query: matchModal.accrualSearch.query,
434
- results: searchedAccruals,
435
+ results: uniqueMatchModalAccruals(pinnedAccruals, searchedAccruals),
435
436
  fetchState: {
436
437
  fetchState: matchModal.accrualSearch.fetchState,
437
438
  error: matchModal.accrualSearch.error,
@@ -5,8 +5,6 @@ import { ActualMatchingMatchId } from '../../../entity/actualMatching/actualMatc
5
5
  import { JEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeSchedulesTypes';
6
6
  export declare const toActualMatchingSortKey: (v: string) => "type" | "date" | "vendor" | "category" | "class" | "amount" | "variance" | "lifecycle" | "service" | "accrued" | "actual";
7
7
  export type ActualMatchingSortKey = ReturnType<typeof toActualMatchingSortKey>;
8
- export declare const toActualMatchingStatusFilter: (v: string) => "pending_review" | "reversed" | "all";
9
- export type ActualMatchingStatusFilter = ReturnType<typeof toActualMatchingStatusFilter>;
10
8
  export declare const MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
11
9
  export declare const MATCH_ACCRUAL_SEARCH_LIMIT = 50;
12
10
  export declare const MATCH_SEARCH_DEBOUNCE_MS = 300;
@@ -20,12 +18,6 @@ export interface ActualMatchingViewUIState {
20
18
  searchString: string;
21
19
  sortKey: ActualMatchingSortKey;
22
20
  sortOrder: SortOrder;
23
- /**
24
- * List-only filter. `all` shows both groups; `pending_review` / `reversed`
25
- * empty the other group (`reversed` includes auto and manual). KPI summary
26
- * stays on the unfiltered period.
27
- */
28
- statusFilter: ActualMatchingStatusFilter;
29
21
  }
30
22
  /**
31
23
  * Sibling of Missing Receipts `MatchCandidate`. Confirm needs `lineId` and
@@ -77,14 +69,6 @@ export interface UndoReversalAccrualsParams {
77
69
  accrualIds: ID[];
78
70
  matchId: ActualMatchingMatchId;
79
71
  }
80
- export declare const toActualMatchingIgnoreReasonType: (v: string) => "other_ignore" | "already_handled" | "amount_off" | "wrong_period" | "wrong_bill";
81
- export type ActualMatchingIgnoreReasonType = ReturnType<typeof toActualMatchingIgnoreReasonType>;
82
- export declare const ALL_ACTUAL_MATCHING_IGNORE_REASONS: readonly ActualMatchingIgnoreReasonType[];
83
- export interface IgnoreActualMatchingSuggestionParams {
84
- matchId: ActualMatchingMatchId;
85
- reason: ActualMatchingIgnoreReasonType;
86
- note?: string;
87
- }
88
72
  export interface ActualMatchingTransactionSearchState extends FetchStateAndError {
89
73
  isLoadingMore: boolean;
90
74
  nextPageToken: string | null;
@@ -100,16 +84,18 @@ export interface ActualMatchingAccrualSearchState extends FetchStateAndError {
100
84
  export interface ActualMatchingMatchModalState {
101
85
  accrualSearch: ActualMatchingAccrualSearchState;
102
86
  confirmStatus: FetchStateAndError;
87
+ didPinPrefillTransactions: boolean;
103
88
  isOpen: boolean;
89
+ pinnedTransactionResults: ActualMatchingTransactionSearchResult[];
104
90
  transactionSearch: ActualMatchingTransactionSearchState;
105
91
  lastBatchResults?: MatchAndReverseResult[];
92
+ openedFromMatchId?: ActualMatchingMatchId;
106
93
  }
107
94
  export declare function actualMatchingTransactionLineKey(transactionType: string, transactionIntegrationId: string, lineId: string): string;
108
95
  export interface ActualMatchingViewState extends FetchedState {
109
- confirmStatusByMatchId: Record<ActualMatchingMatchId, FetchStateAndError>;
96
+ closeMatchAfterUndo: boolean;
110
97
  detailFetchStateByMatchId: Record<ActualMatchingMatchId, FetchStateAndError>;
111
98
  detailRefreshStatusByMatchId: Record<ActualMatchingMatchId, FetchStateAndError>;
112
- ignoreStatusByMatchId: Record<ActualMatchingMatchId, FetchStateAndError>;
113
99
  lastMatchResultsByMatchId: Record<ActualMatchingMatchId, MatchAndReverseResult[]>;
114
100
  lastUndoResultsByMatchId: Record<ActualMatchingMatchId, UndoReversalResult[]>;
115
101
  matchIdsByPeriod: Record<MonthYearPeriodId, ActualMatchingMatchId[]>;
@@ -117,6 +103,4 @@ export interface ActualMatchingViewState extends FetchedState {
117
103
  refreshStatus: FetchStateAndError;
118
104
  uiState: ActualMatchingViewUIState;
119
105
  undoReversalStatusByMatchId: Record<ActualMatchingMatchId, FetchStateAndError>;
120
- closeMatchAfterIgnoreMatchId?: ActualMatchingMatchId;
121
- closeMatchAfterUndoMatchId?: ActualMatchingMatchId;
122
106
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALL_ACTUAL_MATCHING_IGNORE_REASONS = exports.toActualMatchingIgnoreReasonType = exports.toUndoReversalResultStatus = exports.toMatchAndReverseResultStatus = exports.MATCH_SEARCH_DEBOUNCE_MS = exports.MATCH_ACCRUAL_SEARCH_LIMIT = exports.MATCH_TRANSACTION_SEARCH_PAGE_SIZE = exports.toActualMatchingStatusFilter = exports.toActualMatchingSortKey = void 0;
3
+ exports.toUndoReversalResultStatus = exports.toMatchAndReverseResultStatus = exports.MATCH_SEARCH_DEBOUNCE_MS = exports.MATCH_ACCRUAL_SEARCH_LIMIT = exports.MATCH_TRANSACTION_SEARCH_PAGE_SIZE = exports.toActualMatchingSortKey = void 0;
4
4
  exports.isMatchAndReverseCompleteStatus = isMatchAndReverseCompleteStatus;
5
5
  exports.actualMatchingTransactionLineKey = actualMatchingTransactionLineKey;
6
6
  const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
@@ -19,13 +19,6 @@ const ACTUAL_MATCHING_SORT_KEYS = [
19
19
  ];
20
20
  const toActualMatchingSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, ACTUAL_MATCHING_SORT_KEYS);
21
21
  exports.toActualMatchingSortKey = toActualMatchingSortKey;
22
- const ACTUAL_MATCHING_STATUS_FILTERS = [
23
- 'all',
24
- 'pending_review',
25
- 'reversed',
26
- ];
27
- const toActualMatchingStatusFilter = (v) => (0, stringToUnion_1.stringToUnion)(v, ACTUAL_MATCHING_STATUS_FILTERS);
28
- exports.toActualMatchingStatusFilter = toActualMatchingStatusFilter;
29
22
  exports.MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
30
23
  exports.MATCH_ACCRUAL_SEARCH_LIMIT = 50;
31
24
  exports.MATCH_SEARCH_DEBOUNCE_MS = 300;
@@ -48,16 +41,6 @@ const UNDO_REVERSAL_RESULT_STATUSES = [
48
41
  ];
49
42
  const toUndoReversalResultStatus = (v) => (0, stringToUnion_1.stringToUnion)(v, UNDO_REVERSAL_RESULT_STATUSES);
50
43
  exports.toUndoReversalResultStatus = toUndoReversalResultStatus;
51
- const ACTUAL_MATCHING_IGNORE_REASONS = [
52
- 'wrong_bill',
53
- 'wrong_period',
54
- 'amount_off',
55
- 'already_handled',
56
- 'other_ignore',
57
- ];
58
- const toActualMatchingIgnoreReasonType = (v) => (0, stringToUnion_1.stringToUnion)(v, ACTUAL_MATCHING_IGNORE_REASONS);
59
- exports.toActualMatchingIgnoreReasonType = toActualMatchingIgnoreReasonType;
60
- exports.ALL_ACTUAL_MATCHING_IGNORE_REASONS = ACTUAL_MATCHING_IGNORE_REASONS;
61
44
  function actualMatchingTransactionLineKey(transactionType, transactionIntegrationId, lineId) {
62
45
  return `${transactionType}:${transactionIntegrationId}:${lineId}`;
63
46
  }
@@ -141,7 +141,7 @@ export declare const getWithdrawFrom: (state: RootState, fromAccountId?: ID, fro
141
141
  accountId: ID;
142
142
  accountType: AccountTypeSubConfigCodeKeyType;
143
143
  }) => FundingAccount | undefined;
144
- export declare const getDefaultWithdrawFromAccount: (state: RootState, depositAccounts: ID[], companyId: ID, lastSelectedFromAccount?: {
144
+ export declare const getDefaultWithdrawFromAccount: (state: RootState, companyId: ID, lastSelectedFromAccount?: {
145
145
  accountId: ID;
146
146
  accountType: AccountTypeSubConfigCodeKeyType;
147
147
  }) => FundingAccount | undefined;
@@ -640,7 +640,7 @@ const getDueDate = (billStageCode, dueDate, invoiceDate, bookCloseDate) => {
640
640
  };
641
641
  exports.getDueDate = getDueDate;
642
642
  const getWithdrawFrom = (state, fromAccountId, fromAccountType, companyId, lastSelectedFromAccount) => {
643
- const { paymentAccountState, depositAccountState, depositAccountListState, paymentAccountListState, } = state;
643
+ const { paymentAccountState, depositAccountState, paymentAccountListState } = state;
644
644
  if (fromAccountId != null) {
645
645
  const withdrawFromAsDepositAcc = (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, fromAccountId);
646
646
  const withdrawFromAsPaymentAcc = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, fromAccountId);
@@ -654,42 +654,16 @@ const getWithdrawFrom = (state, fromAccountId, fromAccountType, companyId, lastS
654
654
  }
655
655
  }
656
656
  else {
657
- return (0, exports.getDefaultWithdrawFromAccount)(state, depositAccountListState.accountIds, companyId ?? '', lastSelectedFromAccount);
657
+ return (0, exports.getDefaultWithdrawFromAccount)(state, companyId ?? '', lastSelectedFromAccount);
658
658
  }
659
659
  return undefined;
660
660
  };
661
661
  exports.getWithdrawFrom = getWithdrawFrom;
662
- const getDefaultWithdrawFromAccount = (state, depositAccounts, companyId, lastSelectedFromAccount) => {
662
+ const getDefaultWithdrawFromAccount = (state, companyId, lastSelectedFromAccount) => {
663
663
  const { depositAccountState, paymentAccountState, paymentAccountListState } = state;
664
664
  const companyView = (0, getCompanyView_1.getCompanyView)(state, companyId, []);
665
665
  const primaryAccount = companyView?.company.company.companyBillPayInfo.primaryFundingAccount;
666
- let defaultAccount = undefined;
667
- // User paying bill for first time or previously paid with external account
668
- if (lastSelectedFromAccount == null ||
669
- lastSelectedFromAccount?.accountType === 'paymentAccount') {
670
- if (depositAccounts.length === 0) {
671
- defaultAccount = primaryAccount;
672
- }
673
- else {
674
- if (primaryAccount?.accountType === 'depositAccount') {
675
- defaultAccount = primaryAccount;
676
- }
677
- }
678
- }
679
- else {
680
- // User paid with Zeni account previously
681
- if (depositAccounts.length === 1) {
682
- defaultAccount = lastSelectedFromAccount;
683
- }
684
- else {
685
- if (primaryAccount?.accountType === 'depositAccount') {
686
- defaultAccount = primaryAccount;
687
- }
688
- else {
689
- defaultAccount = lastSelectedFromAccount;
690
- }
691
- }
692
- }
666
+ const defaultAccount = primaryAccount ?? lastSelectedFromAccount;
693
667
  if (defaultAccount != null) {
694
668
  const defaultAccAsDepositAcc = (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, defaultAccount?.accountId);
695
669
  const defaultAccAsPaymentAcc = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, defaultAccount?.accountId);
@@ -0,0 +1,51 @@
1
+ import { Recommendation, RecommendationWithCOT } from '../../../commonStateTypes/recommendationBase';
2
+ import { TransactionCategory } from '../../../entity/transaction/stateTypes/transactionType';
3
+ import { CreatableTransactionType, CreateTransactionLineLocalData, CreateTransactionLocalData, CreateTransactionLocalDataByType } from './createTransactionState';
4
+ export declare const nextCreateTransactionLineId: () => string;
5
+ /** Test-only: makes line ids predictable from the start of each case. */
6
+ export declare const resetCreateTransactionLineIdCounter: () => void;
7
+ export declare const createEmptyCreateTransactionLine: (postingType?: TransactionCategory) => CreateTransactionLineLocalData;
8
+ /**
9
+ * The lines a freshly-opened form starts with. A journal entry is invalid with fewer than one
10
+ * debit and one credit, so it opens with both rather than making the user add the second row.
11
+ * Transfer has no lines at all.
12
+ */
13
+ export declare const getDefaultCreateTransactionLines: (transactionType: CreatableTransactionType) => CreateTransactionLineLocalData[];
14
+ /**
15
+ * A blank working copy for one type. Note this does NOT seed the date -- the reducer's initial
16
+ * state has to stay a pure constant so `clearAll` restores something stable. The date is seeded
17
+ * by initializeCreateTransactionLocalDataEpic, which runs when the form opens.
18
+ */
19
+ export declare const getEmptyCreateTransactionLocalData: (transactionType: CreatableTransactionType) => CreateTransactionLocalData;
20
+ export declare const getInitialCreateTransactionLocalDataByType: () => CreateTransactionLocalDataByType;
21
+ /**
22
+ * What the form opens with: a blank copy plus today's date, the default line set, and the one
23
+ * payment_type the backend insists on for a check (qbo_purchase.py raises without it).
24
+ */
25
+ export declare const getSeededCreateTransactionLocalData: (transactionType: CreatableTransactionType) => CreateTransactionLocalData;
26
+ /**
27
+ * Merges a partial edit into the working copy. Lines are replaced wholesale when present --
28
+ * a partial line array would silently truncate the form.
29
+ */
30
+ export declare const mergeCreateTransactionLocalData: (current: CreateTransactionLocalData, update: Partial<CreateTransactionLocalData>) => CreateTransactionLocalData;
31
+ export declare const updateCreateTransactionLine: (lines: CreateTransactionLineLocalData[], lineId: string, update: Partial<CreateTransactionLineLocalData>) => CreateTransactionLineLocalData[];
32
+ /**
33
+ * Recommendation -> RecommendationWithCOT. Chain-of-thought and recommendation feedback both
34
+ * need an existing transaction, so cot/reasoning are empty here by design; the dropdown only
35
+ * needs the entities to build its "Recommended" group.
36
+ */
37
+ export declare const toRecommendationsWithCOT: (recommendations: Recommendation[]) => RecommendationWithCOT[];
38
+ /**
39
+ * Applies a vendor's recommendations to one line: always refreshes the dropdown's "Recommended"
40
+ * group, but only prefills account/class when the field is still empty. Anything the user
41
+ * picked wins -- this follows the transaction-categorization helper, which prefills, rather
42
+ * than the detail-page helper, which only suggests.
43
+ */
44
+ export declare const applyRecommendationsToCreateTransactionLine: (line: CreateTransactionLineLocalData, recommendations: Recommendation[], isAccountingClassesEnabled: boolean) => CreateTransactionLineLocalData;
45
+ /**
46
+ * Undoes a prefill when the vendor is cleared. Only the fields the prefill wrote are removed --
47
+ * the per-field flags are what make the user's own choices distinguishable from ours, which is
48
+ * why they are not a single line-level boolean: a hand-picked account alongside a prefilled
49
+ * class is an ordinary state, and clearing must not take the account with it.
50
+ */
51
+ export declare const clearRecommendationsFromCreateTransactionLine: (line: CreateTransactionLineLocalData) => CreateTransactionLineLocalData;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearRecommendationsFromCreateTransactionLine = exports.applyRecommendationsToCreateTransactionLine = exports.toRecommendationsWithCOT = exports.updateCreateTransactionLine = exports.mergeCreateTransactionLocalData = exports.getSeededCreateTransactionLocalData = exports.getInitialCreateTransactionLocalDataByType = exports.getEmptyCreateTransactionLocalData = exports.getDefaultCreateTransactionLines = exports.createEmptyCreateTransactionLine = exports.resetCreateTransactionLineIdCounter = exports.nextCreateTransactionLineId = void 0;
4
+ const zeniDayJS_1 = require("../../../zeniDayJS");
5
+ const createTransactionState_1 = require("./createTransactionState");
6
+ /**
7
+ * Monotonic counter for line row keys. These never leave the client -- the payload builder
8
+ * drops them -- so a counter is enough, and it keeps reducer tests deterministic in a way
9
+ * randomUUID would not.
10
+ */
11
+ let lineIdCounter = 0;
12
+ const nextCreateTransactionLineId = () => `create-transaction-line-${lineIdCounter++}`;
13
+ exports.nextCreateTransactionLineId = nextCreateTransactionLineId;
14
+ /** Test-only: makes line ids predictable from the start of each case. */
15
+ const resetCreateTransactionLineIdCounter = () => {
16
+ lineIdCounter = 0;
17
+ };
18
+ exports.resetCreateTransactionLineIdCounter = resetCreateTransactionLineIdCounter;
19
+ const createEmptyCreateTransactionLine = (postingType) => ({
20
+ id: (0, exports.nextCreateTransactionLineId)(),
21
+ postingType,
22
+ });
23
+ exports.createEmptyCreateTransactionLine = createEmptyCreateTransactionLine;
24
+ /**
25
+ * The lines a freshly-opened form starts with. A journal entry is invalid with fewer than one
26
+ * debit and one credit, so it opens with both rather than making the user add the second row.
27
+ * Transfer has no lines at all.
28
+ */
29
+ const getDefaultCreateTransactionLines = (transactionType) => {
30
+ if (transactionType === 'transfer') {
31
+ return [];
32
+ }
33
+ if (transactionType === 'journal_entry') {
34
+ return [
35
+ (0, exports.createEmptyCreateTransactionLine)('debit'),
36
+ (0, exports.createEmptyCreateTransactionLine)('credit'),
37
+ ];
38
+ }
39
+ return [(0, exports.createEmptyCreateTransactionLine)()];
40
+ };
41
+ exports.getDefaultCreateTransactionLines = getDefaultCreateTransactionLines;
42
+ /**
43
+ * A blank working copy for one type. Note this does NOT seed the date -- the reducer's initial
44
+ * state has to stay a pure constant so `clearAll` restores something stable. The date is seeded
45
+ * by initializeCreateTransactionLocalDataEpic, which runs when the form opens.
46
+ */
47
+ const getEmptyCreateTransactionLocalData = (transactionType) => ({
48
+ lines: [],
49
+ transactionType,
50
+ });
51
+ exports.getEmptyCreateTransactionLocalData = getEmptyCreateTransactionLocalData;
52
+ const getInitialCreateTransactionLocalDataByType = () => createTransactionState_1.ALL_CREATABLE_TRANSACTION_TYPES.reduce((acc, transactionType) => {
53
+ acc[transactionType] =
54
+ (0, exports.getEmptyCreateTransactionLocalData)(transactionType);
55
+ return acc;
56
+ }, {});
57
+ exports.getInitialCreateTransactionLocalDataByType = getInitialCreateTransactionLocalDataByType;
58
+ /**
59
+ * What the form opens with: a blank copy plus today's date, the default line set, and the one
60
+ * payment_type the backend insists on for a check (qbo_purchase.py raises without it).
61
+ */
62
+ const getSeededCreateTransactionLocalData = (transactionType) => ({
63
+ ...(0, exports.getEmptyCreateTransactionLocalData)(transactionType),
64
+ lines: (0, exports.getDefaultCreateTransactionLines)(transactionType),
65
+ paymentType: transactionType === 'check' ? 'check' : undefined,
66
+ transactionDate: (0, zeniDayJS_1.dateNow)(),
67
+ });
68
+ exports.getSeededCreateTransactionLocalData = getSeededCreateTransactionLocalData;
69
+ /**
70
+ * Merges a partial edit into the working copy. Lines are replaced wholesale when present --
71
+ * a partial line array would silently truncate the form.
72
+ */
73
+ const mergeCreateTransactionLocalData = (current, update) => ({
74
+ ...current,
75
+ ...update,
76
+ lines: update.lines ?? current.lines,
77
+ // The type is keyed by the slice, never edited through a merge.
78
+ transactionType: current.transactionType,
79
+ });
80
+ exports.mergeCreateTransactionLocalData = mergeCreateTransactionLocalData;
81
+ const updateCreateTransactionLine = (lines, lineId, update) => lines.map((line) => line.id === lineId ? { ...line, ...update, id: line.id } : line);
82
+ exports.updateCreateTransactionLine = updateCreateTransactionLine;
83
+ /**
84
+ * Recommendation -> RecommendationWithCOT. Chain-of-thought and recommendation feedback both
85
+ * need an existing transaction, so cot/reasoning are empty here by design; the dropdown only
86
+ * needs the entities to build its "Recommended" group.
87
+ */
88
+ const toRecommendationsWithCOT = (recommendations) => recommendations.map((recommendation) => ({
89
+ account: recommendation.account != null
90
+ ? { ...recommendation.account, cot: [], reasoning: '' }
91
+ : undefined,
92
+ class: recommendation.class != null
93
+ ? { ...recommendation.class, cot: [], reasoning: '' }
94
+ : undefined,
95
+ vendor: recommendation.vendor != null
96
+ ? { ...recommendation.vendor, cot: [], reasoning: '' }
97
+ : undefined,
98
+ }));
99
+ exports.toRecommendationsWithCOT = toRecommendationsWithCOT;
100
+ /**
101
+ * Applies a vendor's recommendations to one line: always refreshes the dropdown's "Recommended"
102
+ * group, but only prefills account/class when the field is still empty. Anything the user
103
+ * picked wins -- this follows the transaction-categorization helper, which prefills, rather
104
+ * than the detail-page helper, which only suggests.
105
+ */
106
+ const applyRecommendationsToCreateTransactionLine = (line, recommendations, isAccountingClassesEnabled) => {
107
+ const top = recommendations[0];
108
+ const updated = {
109
+ ...line,
110
+ recommendationsWithCOT: (0, exports.toRecommendationsWithCOT)(recommendations),
111
+ };
112
+ if (line.accountQboId == null && top?.account?.qboId != null) {
113
+ updated.accountQboId = top.account.qboId;
114
+ updated.accountName = top.account.accountName;
115
+ updated.isAccountPreFilled = true;
116
+ }
117
+ if (isAccountingClassesEnabled &&
118
+ line.classId == null &&
119
+ top?.class?.classId != null) {
120
+ updated.classId = top.class.classId;
121
+ updated.isClassPreFilled = true;
122
+ }
123
+ return updated;
124
+ };
125
+ exports.applyRecommendationsToCreateTransactionLine = applyRecommendationsToCreateTransactionLine;
126
+ /**
127
+ * Undoes a prefill when the vendor is cleared. Only the fields the prefill wrote are removed --
128
+ * the per-field flags are what make the user's own choices distinguishable from ours, which is
129
+ * why they are not a single line-level boolean: a hand-picked account alongside a prefilled
130
+ * class is an ordinary state, and clearing must not take the account with it.
131
+ */
132
+ const clearRecommendationsFromCreateTransactionLine = (line) => {
133
+ const cleared = {
134
+ ...line,
135
+ recommendationsWithCOT: undefined,
136
+ };
137
+ if (line.isAccountPreFilled === true) {
138
+ cleared.accountQboId = undefined;
139
+ cleared.accountName = undefined;
140
+ cleared.isAccountPreFilled = undefined;
141
+ }
142
+ if (line.isClassPreFilled === true) {
143
+ cleared.classId = undefined;
144
+ cleared.isClassPreFilled = undefined;
145
+ }
146
+ return cleared;
147
+ };
148
+ exports.clearRecommendationsFromCreateTransactionLine = clearRecommendationsFromCreateTransactionLine;