@zeniai/client-epic-state 5.2.14 → 5.2.16

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 (132) hide show
  1. package/lib/entity/accountRecon/accountReconReducer.d.ts +2 -1
  2. package/lib/entity/accountRecon/accountReconReducer.js +22 -10
  3. package/lib/entity/accountRecon/accountReconSelector.d.ts +1 -0
  4. package/lib/entity/accountRecon/accountReconSelector.js +1 -0
  5. package/lib/entity/approvalRule/approvalRuleConflict.d.ts +13 -0
  6. package/lib/entity/approvalRule/approvalRuleConflict.js +16 -1
  7. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
  8. package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
  9. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +78 -1
  10. package/lib/entity/jeSchedules/jeSchedulesPayload.js +183 -4
  11. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
  12. package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  13. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
  14. package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
  15. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +123 -1
  16. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
  17. package/lib/entity/jeSchedules/jeSchedulesTypes.js +96 -1
  18. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  19. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  20. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
  21. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  22. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
  23. package/lib/epic.d.ts +10 -1
  24. package/lib/epic.js +18 -0
  25. package/lib/esm/entity/accountRecon/accountReconReducer.js +22 -10
  26. package/lib/esm/entity/accountRecon/accountReconSelector.js +1 -0
  27. package/lib/esm/entity/approvalRule/approvalRuleConflict.js +16 -1
  28. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
  29. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +183 -5
  30. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  31. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
  32. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +86 -0
  33. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  34. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  35. package/lib/esm/epic.js +18 -0
  36. package/lib/esm/index.js +16 -10
  37. package/lib/esm/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.js +2 -2
  38. package/lib/esm/view/expenseAutomationView/epics/accountRecon/deleteCombinedStatementEpic.js +54 -0
  39. package/lib/esm/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +1 -1
  40. package/lib/esm/view/expenseAutomationView/epics/accountRecon/updateCombinedStatementInfoEpic.js +3 -6
  41. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
  42. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  43. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
  44. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
  45. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  46. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +104 -0
  47. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
  48. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +138 -0
  49. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
  50. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +180 -0
  51. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +111 -0
  52. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +28 -0
  53. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
  54. package/lib/esm/view/expenseAutomationView/helpers/reconciliationHelpers.js +12 -0
  55. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
  56. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +319 -29
  57. package/lib/esm/view/expenseAutomationView/reducers/reconciliationViewReducer.js +20 -2
  58. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
  59. package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  60. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
  61. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +327 -22
  62. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
  63. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  64. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  65. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  66. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +20 -1
  67. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +20 -1
  68. package/lib/index.d.ts +18 -13
  69. package/lib/index.js +92 -47
  70. package/lib/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.d.ts +10 -2
  71. package/lib/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.js +1 -1
  72. package/lib/view/expenseAutomationView/epics/accountRecon/deleteCombinedStatementEpic.d.ts +9 -0
  73. package/lib/view/expenseAutomationView/epics/accountRecon/deleteCombinedStatementEpic.js +58 -0
  74. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +1 -1
  75. package/lib/view/expenseAutomationView/epics/accountRecon/updateCombinedStatementInfoEpic.js +3 -6
  76. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
  77. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  78. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
  79. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
  80. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +21 -0
  81. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
  82. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  83. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +9 -0
  84. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +108 -0
  85. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
  86. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
  87. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +9 -0
  88. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +142 -0
  89. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
  90. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
  91. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +13 -0
  92. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +187 -0
  93. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
  94. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +115 -0
  95. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
  96. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +32 -0
  97. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
  98. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
  99. package/lib/view/expenseAutomationView/helpers/reconciliationHelpers.d.ts +6 -0
  100. package/lib/view/expenseAutomationView/helpers/reconciliationHelpers.js +13 -0
  101. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  102. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +86 -3
  103. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
  104. package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +4 -0
  105. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +93 -12
  106. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +321 -29
  107. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  108. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +6 -1
  109. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +22 -4
  110. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  111. package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +1 -0
  112. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
  113. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
  114. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +41 -7
  115. package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  116. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
  117. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
  118. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
  119. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +335 -21
  120. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  121. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +83 -8
  122. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
  123. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  124. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  125. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  126. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
  127. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  128. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +20 -1
  129. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelectorTypes.d.ts +3 -0
  130. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +20 -1
  131. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelectorTypes.d.ts +3 -0
  132. package/package.json +1 -1
@@ -3,9 +3,10 @@ import { DeleteStatementResponsePayload, ReparseStatementResponsePayload, Upload
3
3
  import { ReconciliationDataPayload } from './accountReconPayload';
4
4
  import { AccountReconState } from './accountReconState';
5
5
  export declare const initialState: AccountReconState;
6
- export declare const updateAccountRecon: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedPeriod: MonthYearPeriod, accountReconDataPayload: ReconciliationDataPayload[]], {
6
+ export declare const updateAccountRecon: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedPeriod: MonthYearPeriod, accountReconDataPayload: ReconciliationDataPayload[], preserveExistingTransactions?: any], {
7
7
  selectedPeriod: MonthYearPeriod;
8
8
  accountReconDataPayload: ReconciliationDataPayload[];
9
+ preserveExistingTransactions: any;
9
10
  }, "accountRecon/updateAccountRecon", never, never>, excludeReconReviewTransaction: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountReconKey: string, excludedTransactionId: string], {
10
11
  accountReconKey: string;
11
12
  excludedTransactionId: string;
@@ -14,16 +14,17 @@ const accountRecon = (0, toolkit_1.createSlice)({
14
14
  initialState: exports.initialState,
15
15
  reducers: {
16
16
  updateAccountRecon: {
17
- prepare(selectedPeriod, accountReconDataPayload) {
17
+ prepare(selectedPeriod, accountReconDataPayload, preserveExistingTransactions = false) {
18
18
  return {
19
19
  payload: {
20
20
  selectedPeriod,
21
21
  accountReconDataPayload,
22
+ preserveExistingTransactions,
22
23
  },
23
24
  };
24
25
  },
25
26
  reducer(draft, action) {
26
- doUpdateAccountRecon(draft, action.payload.selectedPeriod, action.payload.accountReconDataPayload);
27
+ doUpdateAccountRecon(draft, action.payload.selectedPeriod, action.payload.accountReconDataPayload, action.payload.preserveExistingTransactions);
27
28
  },
28
29
  },
29
30
  updateAccountReconUploadStatement: {
@@ -175,7 +176,7 @@ const accountRecon = (0, toolkit_1.createSlice)({
175
176
  });
176
177
  _a = accountRecon.actions, exports.updateAccountRecon = _a.updateAccountRecon, exports.excludeReconReviewTransaction = _a.excludeReconReviewTransaction, exports.addTransactionToReconcileList = _a.addTransactionToReconcileList, exports.updateAccountReconDeleteStatement = _a.updateAccountReconDeleteStatement, exports.updateAccountReconReparseStatement = _a.updateAccountReconReparseStatement, exports.updateAccountReconUploadStatement = _a.updateAccountReconUploadStatement;
177
178
  exports.default = accountRecon.reducer;
178
- const doUpdateAccountRecon = (draft, selectedPeriod, accountReconDataPayload) => {
179
+ const doUpdateAccountRecon = (draft, selectedPeriod, accountReconDataPayload, preserveExistingTransactions) => {
179
180
  accountReconDataPayload.forEach((accountReconData) => {
180
181
  const accountReconKey = (0, accountReconState_1.toAccountReconKey)(accountReconData.account_id, selectedPeriod);
181
182
  const mappedAccountRecon = (0, accountReconPayload_1.toAccountReconciliationData)(accountReconData);
@@ -185,12 +186,23 @@ const doUpdateAccountRecon = (draft, selectedPeriod, accountReconDataPayload) =>
185
186
  const shouldPreserveMatchProgress = existingAccountRecon != null &&
186
187
  accountReconData.match_progress === undefined &&
187
188
  existingAccountRecon.matchProgress != null;
188
- draft.accountReconByAccountReconKey[accountReconKey] =
189
- shouldPreserveMatchProgress
190
- ? {
191
- ...mappedAccountRecon,
192
- matchProgress: existingAccountRecon.matchProgress,
193
- }
194
- : mappedAccountRecon;
189
+ // Full list fetch does not include transactions; keep detail-loaded
190
+ // reconcile/review lists so a concurrent list refresh cannot wipe them.
191
+ const shouldPreserveTransactions = preserveExistingTransactions === true && existingAccountRecon != null;
192
+ let nextAccountRecon = mappedAccountRecon;
193
+ if (shouldPreserveMatchProgress) {
194
+ nextAccountRecon = {
195
+ ...nextAccountRecon,
196
+ matchProgress: existingAccountRecon.matchProgress,
197
+ };
198
+ }
199
+ if (shouldPreserveTransactions) {
200
+ nextAccountRecon = {
201
+ ...nextAccountRecon,
202
+ transactionsToReconcile: existingAccountRecon.transactionsToReconcile,
203
+ transactionsToReview: existingAccountRecon.transactionsToReview,
204
+ };
205
+ }
206
+ draft.accountReconByAccountReconKey[accountReconKey] = nextAccountRecon;
195
207
  });
196
208
  };
@@ -48,6 +48,7 @@ export interface AccountReconciliationEntity {
48
48
  };
49
49
  statementMetaData?: {
50
50
  file: File | undefined;
51
+ fileId?: ID;
51
52
  statementUploadId?: ID;
52
53
  };
53
54
  user?: User;
@@ -49,6 +49,7 @@ exports.getAccountReconByAccountIdAndSelectedPeriod = (0, toolkit_1.createSelect
49
49
  file: accountRecon.statementMetaData?.fileId != null
50
50
  ? (0, fileSelector_1.getFileByFileId)(fileState, accountRecon.statementMetaData.fileId)
51
51
  : undefined,
52
+ fileId: accountRecon.statementMetaData?.fileId,
52
53
  statementUploadId: accountRecon.statementMetaData?.statementUploadId,
53
54
  },
54
55
  reconUpdatedAt: accountRecon.reconUpdatedAt,
@@ -46,6 +46,19 @@ import { ApprovalRule, Criteria } from './approvalRuleState';
46
46
  export type RuleForOverlapCheck = Pick<ApprovalRule, 'approvalRuleId' | 'criteria' | 'isFallback'>;
47
47
  export interface RuleOverlap<TRule extends RuleForOverlapCheck = ApprovalRule> {
48
48
  conflictingRule: TRule;
49
+ /**
50
+ * 'duplicate' — every criterion matches exactly, including the
51
+ * amount interval (same comparator + min + max, not just an
52
+ * intersecting range). 'partial' — vendor/department match exactly
53
+ * (required for any overlap at all) but the amount intervals only
54
+ * intersect.
55
+ *
56
+ * Callers typically treat 'duplicate' as a blocking error (the
57
+ * candidate rule is unreachable — the existing rule already
58
+ * matches every bill/reimbursement it would) and 'partial' as a
59
+ * dismissible warning.
60
+ */
61
+ overlapKind: 'duplicate' | 'partial';
49
62
  }
50
63
  export interface DetectRuleOverlapInput<TRule extends RuleForOverlapCheck = ApprovalRule> {
51
64
  candidateCriteria: Criteria[];
@@ -23,7 +23,12 @@ function detectRuleOverlap({ candidateCriteria, existingRules, excludeRuleId, })
23
23
  }
24
24
  const ruleAmount = pickAmount(rule.criteria);
25
25
  if (amountsOverlap(candidateAmount, ruleAmount)) {
26
- overlaps.push({ conflictingRule: rule });
26
+ overlaps.push({
27
+ conflictingRule: rule,
28
+ overlapKind: areAmountCriteriaEqual(candidateAmount, ruleAmount)
29
+ ? 'duplicate'
30
+ : 'partial',
31
+ });
27
32
  }
28
33
  }
29
34
  return overlaps;
@@ -75,3 +80,13 @@ const amountsOverlap = (a, b) => {
75
80
  const bHigh = b.max?.amount ?? Number.POSITIVE_INFINITY;
76
81
  return Math.max(aLow, bLow) <= Math.min(aHigh, bHigh);
77
82
  };
83
+ // Only called once `amountsOverlap` is already true, so this decides
84
+ // duplicate vs partial rather than overlap vs no-overlap.
85
+ const areAmountCriteriaEqual = (a, b) => {
86
+ if (a == null || b == null) {
87
+ return a == null && b == null;
88
+ }
89
+ return (a.comparator === b.comparator &&
90
+ (a.min?.amount ?? null) === (b.min?.amount ?? null) &&
91
+ (a.max?.amount ?? null) === (b.max?.amount ?? null));
92
+ };
@@ -1,2 +1,3 @@
1
1
  import { ID } from '../../commonStateTypes/common';
2
2
  export declare function generateJEScheduleKey(jeScheduleId: ID, jeScheduleType: string): `${string}_${string}`;
3
+ export declare function generateJEOneTimeAccrualKey(accrualId: ID): `${string}_one_time_accrual`;
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateJEScheduleKey = generateJEScheduleKey;
4
+ exports.generateJEOneTimeAccrualKey = generateJEOneTimeAccrualKey;
4
5
  function generateJEScheduleKey(jeScheduleId, jeScheduleType) {
5
6
  return `${jeScheduleId}_${jeScheduleType}`;
6
7
  }
8
+ // Suffixed rather than using the bare Mongo _id so the key is a distinct type from
9
+ // JEScheduleKey / JEScheduleTransactionKey and the three cannot be passed interchangeably.
10
+ // The unsuffixed id stays on the entity as `accrualId` for callers that need it.
11
+ function generateJEOneTimeAccrualKey(accrualId) {
12
+ return `${accrualId}_one_time_accrual`;
13
+ }
@@ -7,7 +7,7 @@ import { TransactionIDPayload } from '../transaction/payloadTypes/transactionIDP
7
7
  import { TransactionCategory } from '../transaction/stateTypes/transactionType';
8
8
  import { UserPayload } from '../user/userPayload';
9
9
  import { VendorPayload } from '../vendor/vendorPayload';
10
- import { JEAccruedScheduledTransactionState, JEScheduledTransactionState, ScheduledJournalEntryState } from './jeSchedulesState';
10
+ import { JEAccruedScheduledTransactionState, JEOneTimeAccrualState, JEScheduledTransactionState, ScheduledJournalEntryState } from './jeSchedulesState';
11
11
  import { JEScheduleKey, JEScheduleTransactionKey } from './jeSchedulesTypes';
12
12
  export interface JEScheduleOtherAttributesPayload {
13
13
  asset_id?: string | null;
@@ -19,14 +19,25 @@ export interface JEScheduleAISummaryFieldPayload {
19
19
  cot?: string[];
20
20
  predicted_value?: number | string;
21
21
  }
22
+ /** The whole-recommendation summary. Carries narrative only -- no predicted value, no confidence. */
23
+ export interface JEScheduleSummaryPayload {
24
+ confidence?: number;
25
+ cot?: string[];
26
+ reasoning?: string;
27
+ reasoning_long?: string;
28
+ }
22
29
  export interface JEScheduleAISummariesPayload {
23
30
  credit_account?: JEScheduleAISummaryFieldPayload;
24
31
  credit_accounting_class?: JEScheduleAISummaryFieldPayload;
25
32
  debit_account?: JEScheduleAISummaryFieldPayload;
26
33
  debit_accounting_class?: JEScheduleAISummaryFieldPayload;
34
+ end_date?: JEScheduleAISummaryFieldPayload;
27
35
  period?: JEScheduleAISummaryFieldPayload;
28
36
  posting_date?: JEScheduleAISummaryFieldPayload;
37
+ posting_start_date?: JEScheduleAISummaryFieldPayload;
38
+ schedule_summary?: JEScheduleSummaryPayload;
29
39
  schedule_type?: JEScheduleAISummaryFieldPayload;
40
+ starting_month?: JEScheduleAISummaryFieldPayload;
30
41
  }
31
42
  export interface JEScheduleRecommendationsPayload {
32
43
  credit_account_confidence?: number;
@@ -72,9 +83,13 @@ export interface JEScheduledTransactionPayload {
72
83
  updated_by: UserPayload;
73
84
  vendor: VendorPayload;
74
85
  ai_summaries?: JEScheduleAISummariesPayload;
86
+ confidence_score?: number | null;
87
+ create_time?: string | null;
75
88
  created_by?: UserPayload;
76
89
  end_date?: string | null;
90
+ posted_count?: number | null;
77
91
  recommendations?: JEScheduleRecommendationsPayload;
92
+ recurring_amount?: number | null;
78
93
  updated_at?: string | null;
79
94
  }
80
95
  export interface JEAccruedScheduledTransactionPayload extends Omit<JEScheduledTransactionPayload, 'base_transaction' | 'je_schedule_id' | 'je_schedule_type'> {
@@ -84,6 +99,67 @@ export interface JEAccruedScheduledTransactionPayload extends Omit<JEScheduledTr
84
99
  memo: string;
85
100
  recurring_amount: number;
86
101
  }
102
+ /**
103
+ * The frozen vendor profile the Cron used to decide an accrual, so the detail page can show its
104
+ * reasoning even after the live profile is rebuilt. Present on agent/Cron rows ONLY — a human-created
105
+ * accrual carries none, which is why every consumer has to treat it as absent rather than empty.
106
+ */
107
+ export interface JEOneTimeAccrualProfileSnapshotPayload {
108
+ billing_pattern?: {
109
+ avg_amount?: number | null;
110
+ billing_lag_days?: number | null;
111
+ consistency_score?: number | null;
112
+ frequency?: string | null;
113
+ last_bill_amount?: number | null;
114
+ last_bill_date?: string | null;
115
+ months_of_history?: number | null;
116
+ typical_bill_day?: number | null;
117
+ } | null;
118
+ monthly_totals?: Record<string, number> | null;
119
+ sorted_months?: string[] | null;
120
+ }
121
+ /** The JE the AI originally suggested, frozen at draft time for suggested-vs-posted comparison. */
122
+ export interface JEOneTimeAccrualAiSuggestionPayload {
123
+ estimated_amount?: number | null;
124
+ je_credit_account_id?: ID | null;
125
+ je_credit_account_name?: string | null;
126
+ je_debit_account_id?: ID | null;
127
+ je_debit_account_name?: string | null;
128
+ memo?: string | null;
129
+ }
130
+ export interface JEOneTimeAccrualPayload {
131
+ _id: ID;
132
+ estimated_amount: number;
133
+ origin: string;
134
+ service_month: string;
135
+ status: string;
136
+ vendor_id: ID;
137
+ vendor_name: string;
138
+ actual_post_date?: string | null;
139
+ actual_reversal_post_date?: string | null;
140
+ ai_suggestion?: JEOneTimeAccrualAiSuggestionPayload | null;
141
+ automation_tier?: string | null;
142
+ created_by_user?: UserPayload | null;
143
+ currency?: string | null;
144
+ expected_reversal_date?: string | null;
145
+ is_ignored?: boolean;
146
+ je_credit_account_id?: ID | null;
147
+ je_credit_account_name?: string | null;
148
+ je_credit_accounting_class_id?: ID | null;
149
+ je_credit_accounting_class_name?: string | null;
150
+ je_debit_account_id?: ID | null;
151
+ je_debit_account_name?: string | null;
152
+ je_debit_accounting_class_id?: ID | null;
153
+ je_debit_accounting_class_name?: string | null;
154
+ memo?: string | null;
155
+ posting_date?: string | null;
156
+ profile_snapshot?: JEOneTimeAccrualProfileSnapshotPayload | null;
157
+ reversal_policy?: string | null;
158
+ reversal_transaction_id?: ID | null;
159
+ reversal_trigger?: string | null;
160
+ transaction_id?: ID | null;
161
+ transaction_integration_id?: ID | null;
162
+ }
87
163
  export interface ScheduledJournalEntryPayload {
88
164
  actual_post_date: string | null;
89
165
  create_time: string | null;
@@ -114,3 +190,4 @@ export declare function getJEScheduleTransactionDetailKeyPayload(payload: Schedu
114
190
  export declare function getJEScheduleKey(payload: JEAccruedScheduledTransactionPayload): JEScheduleKey;
115
191
  export declare function toJEScheduledTransaction(payload: JEScheduledTransactionPayload): JEScheduledTransactionState;
116
192
  export declare function toJEAccruedScheduledTransaction(payload: JEAccruedScheduledTransactionPayload): JEAccruedScheduledTransactionState;
193
+ export declare function toJEOneTimeAccrual(payload: JEOneTimeAccrualPayload): JEOneTimeAccrualState;
@@ -8,12 +8,15 @@ exports.getJEScheduleTransactionDetailKeyPayload = getJEScheduleTransactionDetai
8
8
  exports.getJEScheduleKey = getJEScheduleKey;
9
9
  exports.toJEScheduledTransaction = toJEScheduledTransaction;
10
10
  exports.toJEAccruedScheduledTransaction = toJEAccruedScheduledTransaction;
11
+ exports.toJEOneTimeAccrual = toJEOneTimeAccrual;
11
12
  const amount_1 = require("../../commonStateTypes/amount");
12
13
  const timePeriod_1 = require("../../commonStateTypes/timePeriod");
13
14
  const zeniDayJS_1 = require("../../zeniDayJS");
15
+ const zeniUrl_1 = require("../../zeniUrl");
14
16
  const transactionIDPayload_1 = require("../transaction/payloadTypes/transactionIDPayload");
15
17
  const jeScheduleHelper_1 = require("./jeScheduleHelper");
16
18
  const jeSchedulesTypes_1 = require("./jeSchedulesTypes");
19
+ const USD_CURRENCY_CODE = 'USD';
17
20
  function toScheduledJournalEntryState(payload, currency_code, currency_symbol) {
18
21
  return {
19
22
  status: {
@@ -212,6 +215,43 @@ function toJEScheduleAISummaries(payload) {
212
215
  : undefined,
213
216
  };
214
217
  }
218
+ if (payload.starting_month != null) {
219
+ result.startingMonth = {
220
+ confidence: payload.starting_month.confidence,
221
+ reasoning: payload.starting_month.reasoning,
222
+ cot: Array.isArray(payload.starting_month.cot)
223
+ ? payload.starting_month.cot
224
+ : undefined,
225
+ };
226
+ }
227
+ if (payload.end_date != null) {
228
+ result.endDate = {
229
+ confidence: payload.end_date.confidence,
230
+ reasoning: payload.end_date.reasoning,
231
+ cot: Array.isArray(payload.end_date.cot)
232
+ ? payload.end_date.cot
233
+ : undefined,
234
+ };
235
+ }
236
+ if (payload.posting_start_date != null) {
237
+ result.postingStartDate = {
238
+ confidence: payload.posting_start_date.confidence,
239
+ reasoning: payload.posting_start_date.reasoning,
240
+ cot: Array.isArray(payload.posting_start_date.cot)
241
+ ? payload.posting_start_date.cot
242
+ : undefined,
243
+ };
244
+ }
245
+ if (payload.schedule_summary != null) {
246
+ result.scheduleSummary = {
247
+ confidence: payload.schedule_summary.confidence,
248
+ reasoning: payload.schedule_summary.reasoning,
249
+ reasoningLong: payload.schedule_summary.reasoning_long,
250
+ cot: Array.isArray(payload.schedule_summary.cot)
251
+ ? payload.schedule_summary.cot
252
+ : undefined,
253
+ };
254
+ }
215
255
  return Object.keys(result).length > 0 ? result : undefined;
216
256
  }
217
257
  function toJEScheduleRecommendations(payload) {
@@ -258,9 +298,18 @@ function toJEScheduledTransaction(payload) {
258
298
  startDate: payload.start_date != null ? (0, zeniDayJS_1.date)(payload.start_date) : undefined,
259
299
  endDate: payload.end_date != null ? (0, zeniDayJS_1.date)(payload.end_date) : undefined,
260
300
  period: payload.period != null ? Number(payload.period) : undefined,
301
+ recurringAmount: payload.recurring_amount != null
302
+ ? {
303
+ amount: payload.recurring_amount,
304
+ currencyCode: payload.currency_code,
305
+ currencySymbol: payload.currency_symbol,
306
+ }
307
+ : undefined,
308
+ postedCount: payload.posted_count ?? undefined,
261
309
  updatedByUserID: payload.updated_by.user_id,
262
310
  balanceAsOfToday: payload.balance ?? undefined,
263
311
  updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
312
+ createTime: payload.create_time != null ? (0, zeniDayJS_1.date)(payload.create_time) : undefined,
264
313
  jeCredit: {
265
314
  accountId: payload.je_credit_account_id ?? undefined,
266
315
  accountingClassId: payload.je_credit_accounting_class_id ?? undefined,
@@ -285,6 +334,7 @@ function toJEScheduledTransaction(payload) {
285
334
  : {},
286
335
  scheduledJournalEntry: [],
287
336
  aiSummaries: toJEScheduleAISummaries(payload.ai_summaries),
337
+ confidenceScore: payload.confidence_score ?? undefined,
288
338
  createdByUserID: payload.created_by?.user_id ?? undefined,
289
339
  recommendations: toJEScheduleRecommendations(payload.recommendations),
290
340
  };
@@ -297,17 +347,20 @@ function toJEAccruedScheduledTransaction(payload) {
297
347
  label: payload.status.label,
298
348
  },
299
349
  vendorId: payload.vendor.vendor_id,
350
+ // The accrued payload extends JEScheduledTransactionPayload, so it carries currency_code and
351
+ // currency_symbol like every other schedule -- this mapper was hardcoding USD over fields it
352
+ // already had.
300
353
  recurringAmount: {
301
354
  amount: payload.recurring_amount,
302
- currencyCode: 'USD',
303
- currencySymbol: '$',
355
+ currencyCode: payload.currency_code,
356
+ currencySymbol: payload.currency_symbol,
304
357
  },
305
358
  otherAttributes: {
306
359
  startingBalance: payload.other_attributes?.starting_balance != null
307
360
  ? {
308
361
  amount: payload.other_attributes?.starting_balance ?? 0,
309
- currencyCode: 'USD',
310
- currencySymbol: '$',
362
+ currencyCode: payload.currency_code,
363
+ currencySymbol: payload.currency_symbol,
311
364
  }
312
365
  : undefined,
313
366
  },
@@ -316,6 +369,9 @@ function toJEAccruedScheduledTransaction(payload) {
316
369
  endDate: payload.end_date != null ? (0, zeniDayJS_1.date)(payload.end_date) : undefined,
317
370
  period: payload.period != null ? Number(payload.period) : undefined,
318
371
  updatedByUserID: payload.updated_by.user_id,
372
+ // The accrued joiner resolves createdByUserID into the "Created by" cell. Without this the
373
+ // payload's created_by was dropped here and every accrued row rendered a hyphen.
374
+ createdByUserID: payload.created_by?.user_id ?? undefined,
319
375
  balanceAsOfToday: payload.balance ?? undefined,
320
376
  updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
321
377
  jeCredit: {
@@ -342,3 +398,126 @@ function toJEAccruedScheduledTransaction(payload) {
342
398
  jeScheduleType: (0, jeSchedulesTypes_1.toScheduleTypesTypeStrict)(payload.je_schedule_type),
343
399
  };
344
400
  }
401
+ /**
402
+ * Reads the months in the order the snapshot gives them rather than deriving a range: a vendor that
403
+ * skipped a month has no entry for it, so filling gaps would invent history that was never billed.
404
+ */
405
+ function toJEOneTimeAccrualMonthlyTotals(snapshot, currencyCode) {
406
+ const monthlyTotals = snapshot.monthly_totals;
407
+ if (monthlyTotals == null) {
408
+ return [];
409
+ }
410
+ const months = snapshot.sorted_months ?? Object.keys(monthlyTotals).sort();
411
+ return months
412
+ .filter((month) => monthlyTotals[month] != null)
413
+ .map((month) => ({
414
+ month,
415
+ amount: toOneTimeAccrualAmount(monthlyTotals[month], currencyCode),
416
+ }));
417
+ }
418
+ function toJEOneTimeAccrualProfileSnapshot(payload, currencyCode) {
419
+ if (payload == null) {
420
+ return undefined;
421
+ }
422
+ const billingPattern = payload.billing_pattern;
423
+ return {
424
+ monthlyTotals: toJEOneTimeAccrualMonthlyTotals(payload, currencyCode),
425
+ billingPattern: billingPattern != null
426
+ ? {
427
+ frequency: billingPattern.frequency ?? undefined,
428
+ monthsOfHistory: billingPattern.months_of_history ?? undefined,
429
+ consistencyScore: billingPattern.consistency_score ?? undefined,
430
+ billingLagDays: billingPattern.billing_lag_days ?? undefined,
431
+ typicalBillDay: billingPattern.typical_bill_day ?? undefined,
432
+ avgAmount: billingPattern.avg_amount != null
433
+ ? toOneTimeAccrualAmount(billingPattern.avg_amount, currencyCode)
434
+ : undefined,
435
+ lastBillAmount: billingPattern.last_bill_amount != null
436
+ ? toOneTimeAccrualAmount(billingPattern.last_bill_amount, currencyCode)
437
+ : undefined,
438
+ lastBillDate: billingPattern.last_bill_date != null
439
+ ? (0, zeniDayJS_1.date)(billingPattern.last_bill_date)
440
+ : undefined,
441
+ }
442
+ : undefined,
443
+ };
444
+ }
445
+ function toJEOneTimeAccrualAiSuggestion(payload, currencyCode) {
446
+ if (payload == null) {
447
+ return undefined;
448
+ }
449
+ return {
450
+ memo: payload.memo ?? undefined,
451
+ jeDebitAccountName: payload.je_debit_account_name ?? undefined,
452
+ jeCreditAccountName: payload.je_credit_account_name ?? undefined,
453
+ estimatedAmount: payload.estimated_amount != null
454
+ ? toOneTimeAccrualAmount(payload.estimated_amount, currencyCode)
455
+ : undefined,
456
+ };
457
+ }
458
+ function toJEOneTimeAccrual(payload) {
459
+ return {
460
+ accrualId: payload._id,
461
+ vendorId: payload.vendor_id,
462
+ vendorName: payload.vendor_name,
463
+ serviceMonth: payload.service_month,
464
+ accrualStatus: (0, jeSchedulesTypes_1.toOneTimeAccrualStatusCodeType)(payload.status),
465
+ origin: (0, jeSchedulesTypes_1.toOneTimeAccrualOriginType)(payload.origin),
466
+ automationTier: payload.automation_tier != null
467
+ ? (0, jeSchedulesTypes_1.toOneTimeAccrualAutomationTierType)(payload.automation_tier)
468
+ : undefined,
469
+ estimatedAmount: toOneTimeAccrualAmount(payload.estimated_amount, payload.currency),
470
+ memo: payload.memo ?? '',
471
+ profileSnapshot: toJEOneTimeAccrualProfileSnapshot(payload.profile_snapshot, payload.currency),
472
+ isIgnored: payload.is_ignored === true,
473
+ aiSuggestion: toJEOneTimeAccrualAiSuggestion(payload.ai_suggestion, payload.currency),
474
+ // Exclusive by contract: a scheduled row reverses on expectedReversalDate and bills never
475
+ // drive it, so the two never need reconciling. Defaulting to on_bill_match matches the
476
+ // create path's default when the field is absent on an older document.
477
+ reversalPolicy: (0, jeSchedulesTypes_1.toOneTimeAccrualReversalPolicyType)(payload.reversal_policy ?? 'on_bill_match'),
478
+ reversalTrigger: (0, jeSchedulesTypes_1.toOneTimeAccrualReversalTriggerType)(payload.reversal_trigger ?? undefined),
479
+ expectedReversalDate: payload.expected_reversal_date != null
480
+ ? (0, zeniDayJS_1.date)(payload.expected_reversal_date)
481
+ : undefined,
482
+ postingDate: payload.posting_date != null ? (0, zeniDayJS_1.date)(payload.posting_date) : undefined,
483
+ actualPostDate: payload.actual_post_date != null
484
+ ? (0, zeniDayJS_1.date)(payload.actual_post_date)
485
+ : undefined,
486
+ actualReversalPostDate: payload.actual_reversal_post_date != null
487
+ ? (0, zeniDayJS_1.date)(payload.actual_reversal_post_date)
488
+ : undefined,
489
+ jeDebitAccountId: payload.je_debit_account_id ?? undefined,
490
+ jeDebitAccountName: payload.je_debit_account_name ?? undefined,
491
+ jeDebitAccountingClassId: payload.je_debit_accounting_class_id ?? undefined,
492
+ jeDebitAccountingClassName: payload.je_debit_accounting_class_name ?? undefined,
493
+ jeCreditAccountId: payload.je_credit_account_id ?? undefined,
494
+ jeCreditAccountName: payload.je_credit_account_name ?? undefined,
495
+ jeCreditAccountingClassId: payload.je_credit_accounting_class_id ?? undefined,
496
+ jeCreditAccountingClassName: payload.je_credit_accounting_class_name ?? undefined,
497
+ transactionId: payload.transaction_id ?? undefined,
498
+ transactionIntegrationId: payload.transaction_integration_id ?? undefined,
499
+ reversalTransactionId: payload.reversal_transaction_id ?? undefined,
500
+ createdBy: toJEOneTimeAccrualCreator(payload.created_by_user),
501
+ };
502
+ }
503
+ // The accrual wire format carries a currency CODE but no symbol, so the symbol has to be derived.
504
+ // Only USD has a known glyph today (the create path is USD-only); anything else falls back to the
505
+ // code, which reads correctly as "EUR 1,200" rather than silently rendering a wrong "$".
506
+ function toOneTimeAccrualAmount(amount, currencyCode) {
507
+ const code = currencyCode ?? USD_CURRENCY_CODE;
508
+ return (0, amount_1.toAmount)(amount, code, code === USD_CURRENCY_CODE ? '$' : code);
509
+ }
510
+ function toJEOneTimeAccrualCreator(payload) {
511
+ if (payload == null) {
512
+ return undefined;
513
+ }
514
+ return {
515
+ userId: payload.user_id,
516
+ email: payload.email ?? undefined,
517
+ firstName: payload.first_name ?? undefined,
518
+ lastName: payload.last_name ?? undefined,
519
+ photo: payload.photo?.original != null
520
+ ? (0, zeniUrl_1.toZeniUrl)(payload.photo.original)
521
+ : undefined,
522
+ };
523
+ }
@@ -1,5 +1,5 @@
1
1
  import { UpdateType } from '../../commonStateTypes/common';
2
- import { JEAccruedScheduledTransactionPayload, JEScheduledTransactionPayload, ScheduledJournalEntryPayload } from './jeSchedulesPayload';
2
+ import { JEAccruedScheduledTransactionPayload, JEOneTimeAccrualPayload, JEScheduledTransactionPayload, ScheduledJournalEntryPayload } from './jeSchedulesPayload';
3
3
  import { JESchedulesState } from './jeSchedulesState';
4
4
  export declare const initialState: JESchedulesState;
5
5
  export declare const updateJESchedules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeSchedulesTransactionsPayload: JEScheduledTransactionPayload[]], {
@@ -22,6 +22,8 @@ export declare const updateJESchedules: import("@reduxjs/toolkit").ActionCreator
22
22
  jeScheduleTransactionKey: `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_refund_${string}` | `${string}_bill_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`;
23
23
  }, "jeSchedules/deleteJESchedulesDetails", never, never>, deleteAccruedJESchedulesDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[JEScheduleKey: `${string}_${string}`], {
24
24
  JEScheduleKey: `${string}_${string}`;
25
- }, "jeSchedules/deleteAccruedJESchedulesDetails", never, never>;
25
+ }, "jeSchedules/deleteAccruedJESchedulesDetails", never, never>, clearAllAccruedJESchedules: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"jeSchedules/clearAllAccruedJESchedules">, clearAllJEScheduleTransactions: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"jeSchedules/clearAllJEScheduleTransactions">, updateJEOneTimeAccruals: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeOneTimeAccrualsPayload: JEOneTimeAccrualPayload[]], {
26
+ jeOneTimeAccrualsPayload: JEOneTimeAccrualPayload[];
27
+ }, "jeSchedules/updateJEOneTimeAccruals", never, never>;
26
28
  declare const _default: import("redux").Reducer<JESchedulesState>;
27
29
  export default _default;
@@ -4,14 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.deleteAccruedJESchedulesDetails = exports.deleteJESchedulesDetails = exports.updateAccruedJESchedulesDetails = exports.updateJESchedulesDetails = exports.updateAccruedJEScheduledTransaction = exports.updateJEScheduledTransaction = exports.updateAccruedJESchedules = exports.updateJESchedules = exports.initialState = void 0;
7
+ exports.updateJEOneTimeAccruals = exports.clearAllJEScheduleTransactions = exports.clearAllAccruedJESchedules = exports.deleteAccruedJESchedulesDetails = exports.deleteJESchedulesDetails = exports.updateAccruedJESchedulesDetails = exports.updateJESchedulesDetails = exports.updateAccruedJEScheduledTransaction = exports.updateJEScheduledTransaction = exports.updateAccruedJESchedules = exports.updateJESchedules = exports.initialState = void 0;
8
8
  const toolkit_1 = require("@reduxjs/toolkit");
9
9
  const assignWith_1 = __importDefault(require("lodash/assignWith"));
10
10
  const rootActions_1 = require("../../rootActions");
11
+ const jeScheduleHelper_1 = require("./jeScheduleHelper");
11
12
  const jeSchedulesPayload_1 = require("./jeSchedulesPayload");
12
13
  exports.initialState = {
13
14
  schedulesByTransactionKey: {},
14
15
  schedulesByAccruedJEScheduleKey: {},
16
+ oneTimeAccrualsByKey: {},
15
17
  };
16
18
  const jeSchedules = (0, toolkit_1.createSlice)({
17
19
  name: 'jeSchedules',
@@ -116,15 +118,41 @@ const jeSchedules = (0, toolkit_1.createSlice)({
116
118
  delete draft.schedulesByAccruedJEScheduleKey[JEScheduleKey];
117
119
  },
118
120
  },
121
+ // Writes directly, unlike updateAccruedJESchedules / updateJESchedules, which are no-op
122
+ // actions whose only job is to trigger the entity fan-out epic that fetches vendors,
123
+ // accounts, classes and users. An accrual denormalizes all of those as names on the document,
124
+ // so there is nothing to fan out to.
125
+ updateJEOneTimeAccruals: {
126
+ prepare(jeOneTimeAccrualsPayload) {
127
+ return {
128
+ payload: {
129
+ jeOneTimeAccrualsPayload,
130
+ },
131
+ };
132
+ },
133
+ reducer(draft, action) {
134
+ action.payload.jeOneTimeAccrualsPayload.forEach((accrualPayload) => {
135
+ const accrual = (0, jeSchedulesPayload_1.toJEOneTimeAccrual)(accrualPayload);
136
+ draft.oneTimeAccrualsByKey[(0, jeScheduleHelper_1.generateJEOneTimeAccrualKey)(accrual.accrualId)] = accrual;
137
+ });
138
+ },
139
+ },
140
+ clearAllJEScheduleTransactions(draft) {
141
+ draft.schedulesByTransactionKey = {};
142
+ },
143
+ clearAllAccruedJESchedules(draft) {
144
+ draft.schedulesByAccruedJEScheduleKey = {};
145
+ },
119
146
  },
120
147
  extraReducers: (builder) => {
121
148
  builder.addCase(rootActions_1.clearAll, (draft) => {
122
149
  draft.schedulesByAccruedJEScheduleKey = {};
123
150
  draft.schedulesByTransactionKey = {};
151
+ draft.oneTimeAccrualsByKey = {};
124
152
  });
125
153
  },
126
154
  });
127
- _a = jeSchedules.actions, exports.updateJESchedules = _a.updateJESchedules, exports.updateAccruedJESchedules = _a.updateAccruedJESchedules, exports.updateJEScheduledTransaction = _a.updateJEScheduledTransaction, exports.updateAccruedJEScheduledTransaction = _a.updateAccruedJEScheduledTransaction, exports.updateJESchedulesDetails = _a.updateJESchedulesDetails, exports.updateAccruedJESchedulesDetails = _a.updateAccruedJESchedulesDetails, exports.deleteJESchedulesDetails = _a.deleteJESchedulesDetails, exports.deleteAccruedJESchedulesDetails = _a.deleteAccruedJESchedulesDetails;
155
+ _a = jeSchedules.actions, exports.updateJESchedules = _a.updateJESchedules, exports.updateAccruedJESchedules = _a.updateAccruedJESchedules, exports.updateJEScheduledTransaction = _a.updateJEScheduledTransaction, exports.updateAccruedJEScheduledTransaction = _a.updateAccruedJEScheduledTransaction, exports.updateJESchedulesDetails = _a.updateJESchedulesDetails, exports.updateAccruedJESchedulesDetails = _a.updateAccruedJESchedulesDetails, exports.deleteJESchedulesDetails = _a.deleteJESchedulesDetails, exports.deleteAccruedJESchedulesDetails = _a.deleteAccruedJESchedulesDetails, exports.clearAllAccruedJESchedules = _a.clearAllAccruedJESchedules, exports.clearAllJEScheduleTransactions = _a.clearAllJEScheduleTransactions, exports.updateJEOneTimeAccruals = _a.updateJEOneTimeAccruals;
128
156
  exports.default = jeSchedules.reducer;
129
157
  /**
130
158
  * Helper functions
@@ -9,8 +9,8 @@ import { ScheduleTransaction } from '../transaction/stateTypes/scheduleTransacti
9
9
  import { TransactionID } from '../transaction/stateTypes/transactionID';
10
10
  import { User } from '../user/userState';
11
11
  import { Vendor } from '../vendor/vendorState';
12
- import { JEScheduleAISummaries, JEScheduleOtherAttributes, JEScheduleRecommendations, ScheduleJournalStatusCode, ScheduleStatus } from './jeSchedulesState';
13
- import { JEScheduleKey, JEScheduleTransactionKey, JournalEntryErrorCodeType, ScheduleTypes } from './jeSchedulesTypes';
12
+ import { JEOneTimeAccrualState, JEScheduleAISummaries, JEScheduleOtherAttributes, JEScheduleRecommendations, JESchedulesState, ScheduleJournalStatusCode, ScheduleStatus } from './jeSchedulesState';
13
+ import { JEOneTimeAccrualKey, JEScheduleKey, JEScheduleTransactionKey, JournalEntryErrorCodeType, ScheduleTypes } from './jeSchedulesTypes';
14
14
  export interface ScheduledJournalEntry {
15
15
  error: JournalEntryErrorCodeType[];
16
16
  expectedPostDate: ZeniDate;
@@ -55,13 +55,17 @@ export interface JEScheduledTransaction {
55
55
  accountingClass?: Class;
56
56
  };
57
57
  jeScheduleTransactionKey: JEScheduleTransactionKey;
58
+ lifecycleTotal: number;
58
59
  otherAttributes: JEScheduleOtherAttributes;
60
+ postedCount: number;
59
61
  scheduledJournalEntry: ScheduledJournalEntry[];
60
62
  status: ScheduleStatus;
61
63
  vendor: Vendor;
62
64
  aiSummaries?: JEScheduleAISummaries;
63
65
  balanceAsOfToday?: Amount;
66
+ confidenceScore?: number;
64
67
  createdByUser?: User;
68
+ createTime?: ZeniDate;
65
69
  dayOfPostingDate?: ScheduleDaysOfMonth;
66
70
  endDate?: ZeniDate;
67
71
  jeScheduleId?: ID;
@@ -69,9 +73,14 @@ export interface JEScheduledTransaction {
69
73
  lastDayOfMonth?: boolean;
70
74
  period?: number;
71
75
  recommendations?: JEScheduleRecommendations;
76
+ recurringAmount?: Amount;
72
77
  startDate?: ZeniDate;
73
78
  updatedAt?: ZeniDate;
74
79
  updatedByUser?: User;
75
80
  }
81
+ export interface JEOneTimeAccrual extends JEOneTimeAccrualState {
82
+ jeOneTimeAccrualKey: JEOneTimeAccrualKey;
83
+ }
84
+ export declare const getJEOneTimeAccrualByKey: (jeOneTimeAccrualKey: JEOneTimeAccrualKey, jeSchedulesState: JESchedulesState) => JEOneTimeAccrual | undefined;
76
85
  export declare const getJEAccruedScheduleByJEScheduleKey: (JEScheduleKey: JEScheduleKey, state: RootState) => JEAccruedSchedule | undefined;
77
86
  export declare const getJEScheduledTransactionByJEScheduleTransactionKey: (jeScheduleTransactionKey: JEScheduleTransactionKey, state: RootState) => JEScheduledTransaction;