@zeniai/client-epic-state 5.2.54-betaRD1 → 5.2.55

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 (74) hide show
  1. package/lib/entity/billPay/billTransaction/billTransactionReducer.d.ts +5 -1
  2. package/lib/entity/billPay/billTransaction/billTransactionReducer.js +17 -2
  3. package/lib/entity/invoicing/plan/planSelector.d.ts +9 -0
  4. package/lib/entity/invoicing/plan/planSelector.js +3 -2
  5. package/lib/entity/invoicing/product/productPayload.d.ts +1 -1
  6. package/lib/entity/invoicing/product/productPayload.js +1 -1
  7. package/lib/entity/invoicing/product/productState.d.ts +10 -0
  8. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +1 -4
  9. package/lib/entity/jeSchedules/jeSchedulesReducer.js +5 -79
  10. package/lib/epic.d.ts +3 -2
  11. package/lib/epic.js +8 -6
  12. package/lib/esm/entity/billPay/billTransaction/billTransactionReducer.js +16 -1
  13. package/lib/esm/entity/invoicing/plan/planSelector.js +1 -1
  14. package/lib/esm/entity/invoicing/product/productPayload.js +1 -1
  15. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +4 -78
  16. package/lib/esm/epic.js +8 -6
  17. package/lib/esm/index.js +5 -5
  18. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -14
  19. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +13 -10
  20. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +17 -38
  21. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -17
  22. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -74
  23. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +14 -49
  24. package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +28 -1
  25. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormHelper.js +1 -7
  26. package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewReducer.js +87 -1
  27. package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +1 -0
  28. package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewState.js +4 -0
  29. package/lib/esm/view/spendManagement/billPay/billDetailView/epics/fetchBillRecommendationsEpic.js +97 -0
  30. package/lib/esm/view/spendManagement/billPay/billDetailView/epics/fetchRecommendationsForBill.js +85 -0
  31. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewReducer.js +18 -1
  32. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +3 -0
  33. package/lib/esm/view/spendManagement/billPay/editBillView/epics/applyBillRecommendationsToLocalStoreEpic.js +95 -0
  34. package/lib/index.d.ts +5 -5
  35. package/lib/index.js +22 -22
  36. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
  37. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +0 -13
  38. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +11 -8
  39. package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +17 -38
  40. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
  41. package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -17
  42. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +0 -18
  43. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +3 -10
  44. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +3 -76
  45. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -3
  46. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +14 -49
  47. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -16
  48. package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +7 -2
  49. package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +28 -1
  50. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormHelper.d.ts +2 -2
  51. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/invoicingCatalogItemFormHelper.js +1 -7
  52. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewPayload.d.ts +19 -0
  53. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewReducer.d.ts +10 -1
  54. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewReducer.js +88 -2
  55. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.d.ts +1 -0
  56. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +1 -0
  57. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewState.d.ts +7 -0
  58. package/lib/view/spendManagement/billPay/billDetailView/billDetailViewState.js +4 -0
  59. package/lib/view/spendManagement/billPay/billDetailView/epics/fetchBillRecommendationsEpic.d.ts +37 -0
  60. package/lib/view/spendManagement/billPay/billDetailView/epics/fetchBillRecommendationsEpic.js +104 -0
  61. package/lib/view/spendManagement/billPay/billDetailView/epics/fetchRecommendationsForBill.d.ts +24 -0
  62. package/lib/view/spendManagement/billPay/billDetailView/epics/fetchRecommendationsForBill.js +92 -0
  63. package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.d.ts +4 -1
  64. package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.js +19 -2
  65. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -0
  66. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +3 -0
  67. package/lib/view/spendManagement/billPay/editBillView/epics/applyBillRecommendationsToLocalStoreEpic.d.ts +18 -0
  68. package/lib/view/spendManagement/billPay/editBillView/epics/applyBillRecommendationsToLocalStoreEpic.js +102 -0
  69. package/package.json +1 -1
  70. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -39
  71. package/lib/tsconfig.mocks.tsbuildinfo +0 -1
  72. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  73. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +0 -20
  74. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -43
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.retryOrRefundBillFailure = exports.retryOrRefundBillSuccess = exports.retryOrRefundBill = exports.updateFetchEligibleActionsFailureState = exports.updateEligibleActionsForBill = exports.fetchEligibleActionsForBill = exports.waitForVendorByNameThenUpdateBillDetail = exports.cancelAndDeleteBillSuccessOrFailure = exports.cancelAndDeleteBill = exports.updateApprovalStatusOnSuccess = exports.approveOrRejectBillFailure = exports.approveOrRejectBillSuccess = exports.approveOrRejectBill = exports.deleteBillSuccessOrFailure = exports.deleteBill = exports.removeBillDetail = exports.updateBillDetailFetchState = exports.updateBillDetail = exports.fetchBillDetail = exports.initialState = void 0;
7
+ exports.retryOrRefundBillFailure = exports.retryOrRefundBillSuccess = exports.retryOrRefundBill = exports.updateFetchEligibleActionsFailureState = exports.updateEligibleActionsForBill = exports.fetchEligibleActionsForBill = exports.waitForVendorByNameThenUpdateBillDetail = exports.cancelAndDeleteBillSuccessOrFailure = exports.cancelAndDeleteBill = exports.updateApprovalStatusOnSuccess = exports.approveOrRejectBillFailure = exports.approveOrRejectBillSuccess = exports.approveOrRejectBill = exports.deleteBillSuccessOrFailure = exports.deleteBill = exports.removeBillDetail = exports.updateBillDetailFetchState = exports.updateBillDetail = exports.fetchBillRecommendationsFailure = exports.fetchBillRecommendationsSuccess = exports.fetchBillRecommendations = exports.fetchBillDetail = exports.initialState = void 0;
8
8
  const toolkit_1 = require("@reduxjs/toolkit");
9
9
  const get_1 = __importDefault(require("lodash/get"));
10
10
  const rootActions_1 = require("../../../../rootActions");
@@ -25,6 +25,12 @@ const billDetailView = (0, toolkit_1.createSlice)({
25
25
  detail.fetchState !== 'In-Progress') {
26
26
  draft.billDetailById[key] = {
27
27
  ...billDetailViewState_1.initialBillDetailView,
28
+ // Deliberately independent of the detail fetch: recommendations
29
+ // are requested separately and must not be reset by a detail
30
+ // refresh, which on the edit route lands right after the
31
+ // recommendations request has already started.
32
+ recommendationsFetchStatus: detail?.recommendationsFetchStatus ??
33
+ billDetailViewState_1.initialBillDetailView.recommendationsFetchStatus,
28
34
  };
29
35
  }
30
36
  },
@@ -76,6 +82,86 @@ const billDetailView = (0, toolkit_1.createSlice)({
76
82
  };
77
83
  },
78
84
  },
85
+ fetchBillRecommendations: {
86
+ reducer(draft, action) {
87
+ const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(action.payload.billId);
88
+ // The edit route can mount before the bill detail entry exists — its
89
+ // screen dispatches this before the parent requests the detail. Seed
90
+ // the entry rather than bailing, or the status would sit at
91
+ // `Not-Started` for the whole wait and round trip.
92
+ const detail = (0, get_1.default)(draft.billDetailById, key, undefined) ?? {
93
+ ...billDetailViewState_1.initialBillDetailView,
94
+ billId: action.payload.billId,
95
+ };
96
+ const { fetchState } = detail.recommendationsFetchStatus;
97
+ // Both screens dispatch once per bill — on mount, keyed by bill id,
98
+ // not on every render — so this guard is not what prevents a render
99
+ // loop; the epic's per-bill `exhaustMap` is what collapses the two
100
+ // sites' dispatches into one request.
101
+ //
102
+ // `Error` is deliberately allowed through: a bill whose fetch failed
103
+ // must be able to try again when the screen is next opened.
104
+ if (action.payload.cacheOverride === true ||
105
+ (fetchState !== 'In-Progress' && fetchState !== 'Completed')) {
106
+ draft.billDetailById[key] = {
107
+ ...detail,
108
+ recommendationsFetchStatus: {
109
+ fetchState: 'In-Progress',
110
+ error: undefined,
111
+ },
112
+ };
113
+ }
114
+ },
115
+ prepare(billId, cacheOverride = false) {
116
+ return {
117
+ payload: { billId, cacheOverride },
118
+ };
119
+ },
120
+ },
121
+ fetchBillRecommendationsSuccess: {
122
+ reducer(draft, action) {
123
+ const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(action.payload.billId);
124
+ const detail = (0, get_1.default)(draft.billDetailById, key, undefined);
125
+ if (detail != null) {
126
+ draft.billDetailById[key] = {
127
+ ...detail,
128
+ recommendationsFetchStatus: {
129
+ fetchState: 'Completed',
130
+ error: undefined,
131
+ },
132
+ };
133
+ }
134
+ },
135
+ // `didWriteRecommendations` is false on the skip paths, which resolve
136
+ // the status without fetching anything. Consumers that react by
137
+ // recomputing local state must not run then — there is nothing new to
138
+ // apply, and recomputing would reset the line's "update to" selections.
139
+ prepare(billId, didWriteRecommendations = false) {
140
+ return {
141
+ payload: { billId, didWriteRecommendations },
142
+ };
143
+ },
144
+ },
145
+ fetchBillRecommendationsFailure: {
146
+ reducer(draft, action) {
147
+ const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(action.payload.billId);
148
+ const detail = (0, get_1.default)(draft.billDetailById, key, undefined);
149
+ if (detail != null) {
150
+ draft.billDetailById[key] = {
151
+ ...detail,
152
+ recommendationsFetchStatus: {
153
+ fetchState: 'Error',
154
+ error: action.payload.error,
155
+ },
156
+ };
157
+ }
158
+ },
159
+ prepare(billId, error) {
160
+ return {
161
+ payload: { billId, error },
162
+ };
163
+ },
164
+ },
79
165
  deleteBill: {
80
166
  reducer(draft, action) {
81
167
  const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(action.payload.billId);
@@ -469,5 +555,5 @@ const billDetailView = (0, toolkit_1.createSlice)({
469
555
  });
470
556
  },
471
557
  });
472
- _a = billDetailView.actions, exports.fetchBillDetail = _a.fetchBillDetail, exports.updateBillDetail = _a.updateBillDetail, exports.updateBillDetailFetchState = _a.updateBillDetailFetchState, exports.removeBillDetail = _a.removeBillDetail, exports.deleteBill = _a.deleteBill, exports.deleteBillSuccessOrFailure = _a.deleteBillSuccessOrFailure, exports.approveOrRejectBill = _a.approveOrRejectBill, exports.approveOrRejectBillSuccess = _a.approveOrRejectBillSuccess, exports.approveOrRejectBillFailure = _a.approveOrRejectBillFailure, exports.updateApprovalStatusOnSuccess = _a.updateApprovalStatusOnSuccess, exports.cancelAndDeleteBill = _a.cancelAndDeleteBill, exports.cancelAndDeleteBillSuccessOrFailure = _a.cancelAndDeleteBillSuccessOrFailure, exports.waitForVendorByNameThenUpdateBillDetail = _a.waitForVendorByNameThenUpdateBillDetail, exports.fetchEligibleActionsForBill = _a.fetchEligibleActionsForBill, exports.updateEligibleActionsForBill = _a.updateEligibleActionsForBill, exports.updateFetchEligibleActionsFailureState = _a.updateFetchEligibleActionsFailureState, exports.retryOrRefundBill = _a.retryOrRefundBill, exports.retryOrRefundBillSuccess = _a.retryOrRefundBillSuccess, exports.retryOrRefundBillFailure = _a.retryOrRefundBillFailure;
558
+ _a = billDetailView.actions, exports.fetchBillDetail = _a.fetchBillDetail, exports.fetchBillRecommendations = _a.fetchBillRecommendations, exports.fetchBillRecommendationsSuccess = _a.fetchBillRecommendationsSuccess, exports.fetchBillRecommendationsFailure = _a.fetchBillRecommendationsFailure, exports.updateBillDetail = _a.updateBillDetail, exports.updateBillDetailFetchState = _a.updateBillDetailFetchState, exports.removeBillDetail = _a.removeBillDetail, exports.deleteBill = _a.deleteBill, exports.deleteBillSuccessOrFailure = _a.deleteBillSuccessOrFailure, exports.approveOrRejectBill = _a.approveOrRejectBill, exports.approveOrRejectBillSuccess = _a.approveOrRejectBillSuccess, exports.approveOrRejectBillFailure = _a.approveOrRejectBillFailure, exports.updateApprovalStatusOnSuccess = _a.updateApprovalStatusOnSuccess, exports.cancelAndDeleteBill = _a.cancelAndDeleteBill, exports.cancelAndDeleteBillSuccessOrFailure = _a.cancelAndDeleteBillSuccessOrFailure, exports.waitForVendorByNameThenUpdateBillDetail = _a.waitForVendorByNameThenUpdateBillDetail, exports.fetchEligibleActionsForBill = _a.fetchEligibleActionsForBill, exports.updateEligibleActionsForBill = _a.updateEligibleActionsForBill, exports.updateFetchEligibleActionsFailureState = _a.updateFetchEligibleActionsFailureState, exports.retryOrRefundBill = _a.retryOrRefundBill, exports.retryOrRefundBillSuccess = _a.retryOrRefundBillSuccess, exports.retryOrRefundBillFailure = _a.retryOrRefundBillFailure;
473
559
  exports.default = billDetailView.reducer;
@@ -42,6 +42,7 @@ export interface BillDetailViewSelector extends SelectorView {
42
42
  outsideZeniPaymentInfo?: OutsideZeniPaymentLocalData;
43
43
  paymentInstrument?: PaymentInstrument;
44
44
  paymentMethodType?: BillPayConfig;
45
+ recommendationsFetchStatus?: FetchStateAndError;
45
46
  recurringBillConfigDetail?: RecurringBillConfig;
46
47
  recurringBillInstances?: RecurringBillData[];
47
48
  transactionDetails?: BillTransaction;
@@ -226,6 +226,7 @@ const getBillDetailView = (state, billId) => {
226
226
  fetchState: fetchState.fetchState,
227
227
  error: fetchState.error,
228
228
  version: 0,
229
+ recommendationsFetchStatus: billTransactionDetails?.recommendationsFetchStatus,
229
230
  transactionDetails: transaction,
230
231
  createdBy,
231
232
  bankAccount,
@@ -11,6 +11,13 @@ export interface BillDetailView extends FetchedState {
11
11
  deleteStatus: FetchStateAndError;
12
12
  entityApprovalIds: ID[];
13
13
  eventIds: ID[];
14
+ /**
15
+ * Status of the standalone recommendations fetch for this bill.
16
+ * Deliberately NOT folded into `fetchState` (or any `reduceFetchState` list)
17
+ * so a slow or failing recommendations call can never hold back — or error
18
+ * out — the bill detail / bill edit screens.
19
+ */
20
+ recommendationsFetchStatus: FetchStateAndError;
14
21
  zeniAssist: ZeniAssistForBills;
15
22
  billId?: ID;
16
23
  vendorId?: ID;
@@ -34,6 +34,10 @@ exports.initialBillDetailView = {
34
34
  fetchState: 'Not-Started',
35
35
  error: undefined,
36
36
  },
37
+ recommendationsFetchStatus: {
38
+ fetchState: 'Not-Started',
39
+ error: undefined,
40
+ },
37
41
  billId: undefined,
38
42
  eventIds: [],
39
43
  entityApprovalIds: [],
@@ -0,0 +1,37 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateBillTransactionRecommendations } from '../../../../../entity/billPay/billTransaction/billTransactionReducer';
4
+ import { RootState } from '../../../../../reducer';
5
+ import { ZeniAPI } from '../../../../../zeniAPI';
6
+ import { fetchBillRecommendations, fetchBillRecommendationsFailure, fetchBillRecommendationsSuccess, updateBillDetail, updateBillDetailFetchState } from '../billDetailViewReducer';
7
+ export type ActionType = ReturnType<typeof fetchBillRecommendations> | ReturnType<typeof fetchBillRecommendationsSuccess> | ReturnType<typeof fetchBillRecommendationsFailure> | ReturnType<typeof updateBillDetail> | ReturnType<typeof updateBillDetailFetchState> | ReturnType<typeof updateBillTransactionRecommendations>;
8
+ /**
9
+ * Standalone recommendations fetch for a bill, so neither the bill detail nor
10
+ * the bill edit screen waits on recommendation composition.
11
+ *
12
+ * Which bills need it is decided from the bill's stage: an approval-stage bill
13
+ * gets them from the dedicated endpoint
14
+ * (`GET /1.0/bills/transactions/{transaction_id}/recommendations`), while a
15
+ * draft gets them on the bill detail response itself. The platform makes that
16
+ * split from the bill's status, so neither request carries a flag asking for
17
+ * one behaviour or the other.
18
+ *
19
+ * Only `recommendations` is read — per line, and what drives the "Update to X"
20
+ * checkbox and the Recommended group in the category/class dropdowns. The
21
+ * endpoint returns no entity-level recommendation and the edit form does not
22
+ * render one.
23
+ *
24
+ * Failure is confined to `recommendationsFetchStatus` — no bill-detail action
25
+ * is emitted, so a failed or slow recommendations fetch can neither block nor
26
+ * error out either screen.
27
+ *
28
+ * @precondition Every site dispatching `fetchBillRecommendations` must also
29
+ * cause the bill detail to be requested for that bill. This epic waits for the
30
+ * detail when it is not already in the store, and that wait settles only on a
31
+ * detail write or a detail error. A caller that dispatches without one would
32
+ * leave the wait open, and the per-bill `exhaustMap` would then drop later
33
+ * retries for that bill. Both current callers satisfy this: the bill detail
34
+ * route dispatches `fetchBillDetail` alongside, and the edit route reaches it
35
+ * through `fetchEditBillDetailPage`.
36
+ */
37
+ export declare const fetchBillRecommendationsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchBillRecommendationsEpic = void 0;
7
+ const get_1 = __importDefault(require("lodash/get"));
8
+ const rxjs_1 = require("rxjs");
9
+ const operators_1 = require("rxjs/operators");
10
+ const responsePayload_1 = require("../../../../../responsePayload");
11
+ const billDetailViewReducer_1 = require("../billDetailViewReducer");
12
+ const billDetailViewState_1 = require("../billDetailViewState");
13
+ const fetchRecommendationsForBill_1 = require("./fetchRecommendationsForBill");
14
+ /**
15
+ * Standalone recommendations fetch for a bill, so neither the bill detail nor
16
+ * the bill edit screen waits on recommendation composition.
17
+ *
18
+ * Which bills need it is decided from the bill's stage: an approval-stage bill
19
+ * gets them from the dedicated endpoint
20
+ * (`GET /1.0/bills/transactions/{transaction_id}/recommendations`), while a
21
+ * draft gets them on the bill detail response itself. The platform makes that
22
+ * split from the bill's status, so neither request carries a flag asking for
23
+ * one behaviour or the other.
24
+ *
25
+ * Only `recommendations` is read — per line, and what drives the "Update to X"
26
+ * checkbox and the Recommended group in the category/class dropdowns. The
27
+ * endpoint returns no entity-level recommendation and the edit form does not
28
+ * render one.
29
+ *
30
+ * Failure is confined to `recommendationsFetchStatus` — no bill-detail action
31
+ * is emitted, so a failed or slow recommendations fetch can neither block nor
32
+ * error out either screen.
33
+ *
34
+ * @precondition Every site dispatching `fetchBillRecommendations` must also
35
+ * cause the bill detail to be requested for that bill. This epic waits for the
36
+ * detail when it is not already in the store, and that wait settles only on a
37
+ * detail write or a detail error. A caller that dispatches without one would
38
+ * leave the wait open, and the per-bill `exhaustMap` would then drop later
39
+ * retries for that bill. Both current callers satisfy this: the bill detail
40
+ * route dispatches `fetchBillDetail` alongside, and the edit route reaches it
41
+ * through `fetchEditBillDetailPage`.
42
+ */
43
+ const fetchBillRecommendationsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(billDetailViewReducer_1.fetchBillRecommendations.match),
44
+ // The bill detail route requests these and the edit screen asks again on
45
+ // every mount, so repeats are normal. Drop the ones whose bill is already
46
+ // done before they reach the request.
47
+ (0, operators_1.filter)((action) => action.payload.cacheOverride === true ||
48
+ areRecommendationsAlreadyFetched(state$.value, action.payload.billId) === false),
49
+ // Per bill, then `exhaustMap` rather than `switchMap`: a repeat that
50
+ // arrives while the request (or the wait for the bill detail) is still
51
+ // running is ignored, where `switchMap` would cancel the in-flight one and
52
+ // re-issue it. `groupBy` keeps that per bill, so navigating to another
53
+ // bill mid-flight still fetches for the new one.
54
+ (0, operators_1.groupBy)((action) => action.payload.billId), (0, operators_1.mergeMap)((actionsForBill$) => actionsForBill$.pipe((0, operators_1.exhaustMap)((action) => {
55
+ const { billId, cacheOverride } = action.payload;
56
+ if (isBillReadyForRecommendations(state$.value, billId)) {
57
+ return (0, fetchRecommendationsForBill_1.fetchRecommendationsForBill)(state$.value, billId, zeniAPI, cacheOverride);
58
+ }
59
+ // The edit route can mount before the bill detail response lands,
60
+ // and the request needs the vendor / line ids / amount from it. Wait
61
+ // for the detail write for this bill rather than dropping the fetch,
62
+ // and settle on a detail error too.
63
+ //
64
+ // A leftover `Error` on the bill detail is deliberately NOT treated
65
+ // as terminal here. On the edit route this action is dispatched
66
+ // before the parent screen re-requests the detail — React runs the
67
+ // child's effect first — so failing on the stale error would leave
68
+ // recommendations failed even though the detail is about to succeed.
69
+ //
70
+ // The invariant this relies on: every dispatch site also causes the
71
+ // bill detail to be requested. Both do today. A future site that
72
+ // does not would leave this waiting, and `exhaustMap` would drop
73
+ // later retries for that bill.
74
+ const billDetailSettled$ = actions$.pipe((0, operators_1.filter)((waited) => {
75
+ if (billDetailViewReducer_1.updateBillDetail.match(waited)) {
76
+ return waited.payload.billId === billId;
77
+ }
78
+ return (billDetailViewReducer_1.updateBillDetailFetchState.match(waited) &&
79
+ waited.payload.fetchState === 'Error' &&
80
+ waited.payload.billId === billId);
81
+ }), (0, operators_1.take)(1) // don't listen forever! IMPORTANT!
82
+ );
83
+ return billDetailSettled$.pipe((0, operators_1.mergeMap)((waited) => {
84
+ if (billDetailViewReducer_1.updateBillDetail.match(waited)) {
85
+ return (0, fetchRecommendationsForBill_1.fetchRecommendationsForBill)(state$.value, billId, zeniAPI, cacheOverride);
86
+ }
87
+ // Bill detail failed; there is nothing to recommend against.
88
+ return (0, rxjs_1.of)((0, billDetailViewReducer_1.fetchBillRecommendationsFailure)(billId, waited.payload.error ??
89
+ (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Bill detail fetch failed before recommendations could be requested')));
90
+ }));
91
+ }))));
92
+ exports.fetchBillRecommendationsEpic = fetchBillRecommendationsEpic;
93
+ /**
94
+ * Helper functions
95
+ */
96
+ function areRecommendationsAlreadyFetched(state, billId) {
97
+ const billDetail = (0, get_1.default)(state.billDetailViewState.billDetailById, (0, billDetailViewState_1.getBillTransactionDetailKey)(billId), undefined);
98
+ return billDetail?.recommendationsFetchStatus.fetchState === 'Completed';
99
+ }
100
+ function isBillReadyForRecommendations(state, billId) {
101
+ const billDetail = (0, get_1.default)(state.billDetailViewState.billDetailById, (0, billDetailViewState_1.getBillTransactionDetailKey)(billId), undefined);
102
+ return (billDetail?.fetchState === 'Completed' &&
103
+ (0, fetchRecommendationsForBill_1.getBillTransaction)(state, billId) != null);
104
+ }
@@ -0,0 +1,24 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ID } from '../../../../../commonStateTypes/common';
3
+ import { updateBillTransactionRecommendations } from '../../../../../entity/billPay/billTransaction/billTransactionReducer';
4
+ import { BillTransaction } from '../../../../../entity/billPay/billTransaction/billTransactionState';
5
+ import { RootState } from '../../../../../reducer';
6
+ import { ZeniAPI } from '../../../../../zeniAPI';
7
+ import { fetchBillRecommendationsFailure, fetchBillRecommendationsSuccess } from '../billDetailViewReducer';
8
+ /**
9
+ * What the request itself can emit. `fetchBillRecommendationsEpic` widens this
10
+ * with the actions it consumes; keeping the narrower union here is what lets
11
+ * this module stay free of any import from the epic.
12
+ */
13
+ export type FetchRecommendationsForBillActionType = ReturnType<typeof fetchBillRecommendationsSuccess> | ReturnType<typeof fetchBillRecommendationsFailure> | ReturnType<typeof updateBillTransactionRecommendations>;
14
+ /**
15
+ * Requests the recommendations for one bill and maps them onto the transaction
16
+ * entity, or resolves without a request for a bill that does not need them.
17
+ *
18
+ * Only `recommendations` is read from the response — per line, and what drives
19
+ * the "Update to X" checkbox and the Recommended group in the category/class
20
+ * dropdowns. The endpoint returns no entity-level recommendation and the edit
21
+ * form does not render one.
22
+ */
23
+ export declare function fetchRecommendationsForBill(state: RootState, billId: ID, zeniAPI: ZeniAPI, cacheOverride?: boolean): Observable<FetchRecommendationsForBillActionType>;
24
+ export declare function getBillTransaction(state: RootState, billId: ID): BillTransaction | undefined;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchRecommendationsForBill = fetchRecommendationsForBill;
7
+ exports.getBillTransaction = getBillTransaction;
8
+ const get_1 = __importDefault(require("lodash/get"));
9
+ const rxjs_1 = require("rxjs");
10
+ const operators_1 = require("rxjs/operators");
11
+ const recommendationPayload_1 = require("../../../../../commonPayloadTypes/recommendationPayload");
12
+ const billTransactionReducer_1 = require("../../../../../entity/billPay/billTransaction/billTransactionReducer");
13
+ const responsePayload_1 = require("../../../../../responsePayload");
14
+ const billDetailViewReducer_1 = require("../billDetailViewReducer");
15
+ /**
16
+ * Requests the recommendations for one bill and maps them onto the transaction
17
+ * entity, or resolves without a request for a bill that does not need them.
18
+ *
19
+ * Only `recommendations` is read from the response — per line, and what drives
20
+ * the "Update to X" checkbox and the Recommended group in the category/class
21
+ * dropdowns. The endpoint returns no entity-level recommendation and the edit
22
+ * form does not render one.
23
+ */
24
+ function fetchRecommendationsForBill(state, billId, zeniAPI, cacheOverride = false) {
25
+ const transaction = getBillTransaction(state, billId);
26
+ const lineIds = transaction?.lines?.map((line) => line.id) ?? [];
27
+ if (transaction == null ||
28
+ shouldSkipRecommendations(transaction, cacheOverride)) {
29
+ return (0, rxjs_1.of)((0, billDetailViewReducer_1.fetchBillRecommendationsSuccess)(billId));
30
+ }
31
+ // The bill is scoped by the path, so this endpoint takes no query — there is
32
+ // no `is_include_*` flag to turn off the way the bill detail request has.
33
+ return zeniAPI
34
+ .getJSON(`${zeniAPI.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${billId}/recommendations`)
35
+ .pipe((0, operators_1.mergeMap)((response) => {
36
+ if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
37
+ return (0, rxjs_1.of)((0, billDetailViewReducer_1.fetchBillRecommendationsFailure)(billId, response.status));
38
+ }
39
+ const actions = [];
40
+ // Positional line <-> recommendation mapping, matching
41
+ // `getRecommendationsPerLine` — the mapping the recommendations went
42
+ // through while the bill detail response still carried them. This
43
+ // endpoint returns them flat, not nested under `transaction`.
44
+ const recommendationPayloads = response.data.recommendations ?? [];
45
+ // The pairing is a convention shared with the platform, not
46
+ // something the payload enforces, so a mismatch would otherwise
47
+ // mis-assign or silently drop recommendations. Degrade safely —
48
+ // extra entries are ignored and unmatched lines get none — but say
49
+ // so, because it means the two sides have diverged.
50
+ if (recommendationPayloads.length !== lineIds.length) {
51
+ console.warn(`Bill ${billId}: ${recommendationPayloads.length} recommendation entries for ${lineIds.length} lines. ` +
52
+ 'They are paired by position, so this bill may be scored incorrectly.');
53
+ }
54
+ const recommendationByLineId = {};
55
+ lineIds.forEach((lineId, index) => {
56
+ const recommendationPayload = recommendationPayloads[index];
57
+ if (recommendationPayload != null) {
58
+ recommendationByLineId[lineId] = (0, recommendationPayload_1.transformRecommendation)(recommendationPayload);
59
+ }
60
+ });
61
+ actions.push((0, billTransactionReducer_1.updateBillTransactionRecommendations)(billId, recommendationByLineId));
62
+ // Entity writes first, then the view status, so consumers reading on
63
+ // the status flip already see the recommendations.
64
+ actions.push((0, billDetailViewReducer_1.fetchBillRecommendationsSuccess)(billId, true));
65
+ return (0, rxjs_1.from)(actions);
66
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, billDetailViewReducer_1.fetchBillRecommendationsFailure)(billId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Fetch bill recommendations REST API call errored out ${error}`)))));
67
+ }
68
+ function getBillTransaction(state, billId) {
69
+ return (0, get_1.default)(state.billTransactionState.transactionById, billId, undefined);
70
+ }
71
+ /**
72
+ * Helper functions
73
+ */
74
+ // Awaiting-approval bills are the only ones this request exists for. A draft
75
+ // opens the edit form directly, so its recommendations ride along on the bill
76
+ // detail response; `paid` bills cannot reach the form at all. The platform
77
+ // decides which of those two it is from the bill's status, which is why the
78
+ // request carries no flag asking for either.
79
+ function shouldSkipRecommendations(transaction, cacheOverride) {
80
+ return (transaction.billPayInfo.stage.code !== 'pending_approval' ||
81
+ transaction.isDeleted === true ||
82
+ // No vendor (a draft carrying only a candidate vendor name) means no
83
+ // entity to recommend against — the vendor-selection flow covers that.
84
+ Boolean(transaction.vendor?.id) === false ||
85
+ // The bill detail response already carried them. `toVendorTransaction`
86
+ // maps them straight onto the entity, so requesting again would only
87
+ // re-fetch what is here — this is what lets the platform move the line
88
+ // between embedded and on-demand without a client change. A forced
89
+ // refresh is the one case that still goes to the endpoint.
90
+ (cacheOverride === false &&
91
+ Object.keys(transaction.recommendations ?? {}).length > 0));
92
+ }
@@ -26,7 +26,10 @@ export declare const fetchEditBillDetailPage: import("@reduxjs/toolkit").ActionC
26
26
  }, "editBillView/initializeBillToLocalStore", never, never>, saveBillUpdatesToLocalStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
27
27
  billDetailLocalData: BillDetailLocalData;
28
28
  billId?: ID;
29
- }, "editBillView/saveBillUpdatesToLocalStore">, discardBillUpdatesInLocalStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
29
+ }, "editBillView/saveBillUpdatesToLocalStore">, updateBillLineRecommendationsInLocalStore: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[billId: string, updatesByLineId: Record<string, import("./editBillViewState").LineItemRecommendationsLocalData>], {
30
+ billId: string;
31
+ updatesByLineId: Record<string, import("./editBillViewState").LineItemRecommendationsLocalData>;
32
+ }, "editBillView/updateBillLineRecommendationsInLocalStore", never, never>, discardBillUpdatesInLocalStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
30
33
  billId?: ID;
31
34
  }, "editBillView/discardBillUpdatesInLocalStore">, saveBillDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[billStageCode: "paid" | "pending_approval" | "scheduled" | "draft", isForMarkAsPaid: boolean, isApproverMarkingAsPaid: boolean, billId?: string | undefined], {
32
35
  billStageCode: "paid" | "pending_approval" | "scheduled" | "draft";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.updateShouldReplaceBillData = exports.replaceBillFileInLocalStore = exports.removeBillFileFromLocalStore = exports.updateWithdrawFromAccountId = exports.updateNewAddedBillPaymentAccount = exports.discardOutsideZeniPaymentLocalData = exports.updateOutsideZeniPaymentLocalData = exports.markBillForRetry = exports.waitForVendorByIdThenSaveBillUpdatetoLocalStore = exports.fetchVendorAndUpdateBillLocalData = exports.updateHomeCurrencyConversion = exports.currencyConversionValueSuccessOrFailure = exports.convertAmountToHomeCurrency = exports.updateVendorContactSuccessOrFailure = exports.updateVendorContact = exports.updateSuggestedVendorIdFromParsedInvoice = exports.updateRecommendedVendorId = exports.updateBillUploadFetchState = exports.updateAddBillAutoFields = exports.updateShowAutofill = exports.updateInternationalTransferFeeBearerPaymentMethodInLocalData = exports.waitForVendorByNameThenParsetoLocalStore = exports.waitForBillDetailThenInitializeLocalStore = exports.parseInvoiceToBill = exports.updateEditBillFetchStateCompleted = exports.saveBillSuccessOrFailure = exports.saveBillDetail = exports.discardBillUpdatesInLocalStore = exports.saveBillUpdatesToLocalStore = exports.initializeBillToLocalStore = exports.fetchVendorByNameAndParseInvoice = exports.fetchBillAndInitializeLocalStore = exports.fetchEditBillDetailPage = exports.initialState = void 0;
4
+ exports.updateShouldReplaceBillData = exports.replaceBillFileInLocalStore = exports.removeBillFileFromLocalStore = exports.updateWithdrawFromAccountId = exports.updateNewAddedBillPaymentAccount = exports.discardOutsideZeniPaymentLocalData = exports.updateOutsideZeniPaymentLocalData = exports.markBillForRetry = exports.waitForVendorByIdThenSaveBillUpdatetoLocalStore = exports.fetchVendorAndUpdateBillLocalData = exports.updateHomeCurrencyConversion = exports.currencyConversionValueSuccessOrFailure = exports.convertAmountToHomeCurrency = exports.updateVendorContactSuccessOrFailure = exports.updateVendorContact = exports.updateSuggestedVendorIdFromParsedInvoice = exports.updateRecommendedVendorId = exports.updateBillUploadFetchState = exports.updateAddBillAutoFields = exports.updateShowAutofill = exports.updateInternationalTransferFeeBearerPaymentMethodInLocalData = exports.waitForVendorByNameThenParsetoLocalStore = exports.waitForBillDetailThenInitializeLocalStore = exports.parseInvoiceToBill = exports.updateEditBillFetchStateCompleted = exports.saveBillSuccessOrFailure = exports.saveBillDetail = exports.discardBillUpdatesInLocalStore = exports.updateBillLineRecommendationsInLocalStore = exports.saveBillUpdatesToLocalStore = exports.initializeBillToLocalStore = exports.fetchVendorByNameAndParseInvoice = exports.fetchBillAndInitializeLocalStore = exports.fetchEditBillDetailPage = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const amount_1 = require("../../../../commonStateTypes/amount");
7
7
  const attachmentPayload_1 = require("../../../../entity/transaction/payloadTypes/attachmentPayload");
@@ -153,6 +153,23 @@ const editBillView = (0, toolkit_1.createSlice)({
153
153
  }
154
154
  }
155
155
  },
156
+ // Applied when the standalone recommendations fetch resolves after the
157
+ // edit local store was already initialized. `initializeBillToLocalStore`
158
+ // is guarded to run once, so without this the late recommendations would
159
+ // never reach the category/class autofill or the "update to" checkbox.
160
+ updateBillLineRecommendationsInLocalStore: {
161
+ reducer(draft, action) {
162
+ const { billId, updatesByLineId } = action.payload;
163
+ const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(billId);
164
+ const editBill = draft.editBillStateById[key];
165
+ if (editBill != null) {
166
+ editBill.billDetailLocalData.updatesByLineId = Object.assign({}, editBill.billDetailLocalData.updatesByLineId, updatesByLineId);
167
+ }
168
+ },
169
+ prepare(billId, updatesByLineId) {
170
+ return { payload: { billId, updatesByLineId } };
171
+ },
172
+ },
156
173
  discardBillUpdatesInLocalStore(draft, action) {
157
174
  if (action.payload.billId != null) {
158
175
  const { billId } = action.payload;
@@ -498,7 +515,7 @@ const editBillView = (0, toolkit_1.createSlice)({
498
515
  });
499
516
  },
500
517
  });
501
- _a = editBillView.actions, exports.fetchEditBillDetailPage = _a.fetchEditBillDetailPage, exports.fetchBillAndInitializeLocalStore = _a.fetchBillAndInitializeLocalStore, exports.fetchVendorByNameAndParseInvoice = _a.fetchVendorByNameAndParseInvoice, exports.initializeBillToLocalStore = _a.initializeBillToLocalStore, exports.saveBillUpdatesToLocalStore = _a.saveBillUpdatesToLocalStore, exports.discardBillUpdatesInLocalStore = _a.discardBillUpdatesInLocalStore, exports.saveBillDetail = _a.saveBillDetail, exports.saveBillSuccessOrFailure = _a.saveBillSuccessOrFailure, exports.updateEditBillFetchStateCompleted = _a.updateEditBillFetchStateCompleted, exports.parseInvoiceToBill = _a.parseInvoiceToBill, exports.waitForBillDetailThenInitializeLocalStore = _a.waitForBillDetailThenInitializeLocalStore, exports.waitForVendorByNameThenParsetoLocalStore = _a.waitForVendorByNameThenParsetoLocalStore, exports.updateInternationalTransferFeeBearerPaymentMethodInLocalData = _a.updateInternationalTransferFeeBearerPaymentMethodInLocalData, exports.updateShowAutofill = _a.updateShowAutofill, exports.updateAddBillAutoFields = _a.updateAddBillAutoFields, exports.updateBillUploadFetchState = _a.updateBillUploadFetchState, exports.updateRecommendedVendorId = _a.updateRecommendedVendorId, exports.updateSuggestedVendorIdFromParsedInvoice = _a.updateSuggestedVendorIdFromParsedInvoice, exports.updateVendorContact = _a.updateVendorContact, exports.updateVendorContactSuccessOrFailure = _a.updateVendorContactSuccessOrFailure, exports.convertAmountToHomeCurrency = _a.convertAmountToHomeCurrency, exports.currencyConversionValueSuccessOrFailure = _a.currencyConversionValueSuccessOrFailure, exports.updateHomeCurrencyConversion = _a.updateHomeCurrencyConversion, exports.fetchVendorAndUpdateBillLocalData = _a.fetchVendorAndUpdateBillLocalData, exports.waitForVendorByIdThenSaveBillUpdatetoLocalStore = _a.waitForVendorByIdThenSaveBillUpdatetoLocalStore, exports.markBillForRetry = _a.markBillForRetry, exports.updateOutsideZeniPaymentLocalData = _a.updateOutsideZeniPaymentLocalData, exports.discardOutsideZeniPaymentLocalData = _a.discardOutsideZeniPaymentLocalData, exports.updateNewAddedBillPaymentAccount = _a.updateNewAddedBillPaymentAccount, exports.updateWithdrawFromAccountId = _a.updateWithdrawFromAccountId, exports.removeBillFileFromLocalStore = _a.removeBillFileFromLocalStore, exports.replaceBillFileInLocalStore = _a.replaceBillFileInLocalStore, exports.updateShouldReplaceBillData = _a.updateShouldReplaceBillData;
518
+ _a = editBillView.actions, exports.fetchEditBillDetailPage = _a.fetchEditBillDetailPage, exports.fetchBillAndInitializeLocalStore = _a.fetchBillAndInitializeLocalStore, exports.fetchVendorByNameAndParseInvoice = _a.fetchVendorByNameAndParseInvoice, exports.initializeBillToLocalStore = _a.initializeBillToLocalStore, exports.saveBillUpdatesToLocalStore = _a.saveBillUpdatesToLocalStore, exports.updateBillLineRecommendationsInLocalStore = _a.updateBillLineRecommendationsInLocalStore, exports.discardBillUpdatesInLocalStore = _a.discardBillUpdatesInLocalStore, exports.saveBillDetail = _a.saveBillDetail, exports.saveBillSuccessOrFailure = _a.saveBillSuccessOrFailure, exports.updateEditBillFetchStateCompleted = _a.updateEditBillFetchStateCompleted, exports.parseInvoiceToBill = _a.parseInvoiceToBill, exports.waitForBillDetailThenInitializeLocalStore = _a.waitForBillDetailThenInitializeLocalStore, exports.waitForVendorByNameThenParsetoLocalStore = _a.waitForVendorByNameThenParsetoLocalStore, exports.updateInternationalTransferFeeBearerPaymentMethodInLocalData = _a.updateInternationalTransferFeeBearerPaymentMethodInLocalData, exports.updateShowAutofill = _a.updateShowAutofill, exports.updateAddBillAutoFields = _a.updateAddBillAutoFields, exports.updateBillUploadFetchState = _a.updateBillUploadFetchState, exports.updateRecommendedVendorId = _a.updateRecommendedVendorId, exports.updateSuggestedVendorIdFromParsedInvoice = _a.updateSuggestedVendorIdFromParsedInvoice, exports.updateVendorContact = _a.updateVendorContact, exports.updateVendorContactSuccessOrFailure = _a.updateVendorContactSuccessOrFailure, exports.convertAmountToHomeCurrency = _a.convertAmountToHomeCurrency, exports.currencyConversionValueSuccessOrFailure = _a.currencyConversionValueSuccessOrFailure, exports.updateHomeCurrencyConversion = _a.updateHomeCurrencyConversion, exports.fetchVendorAndUpdateBillLocalData = _a.fetchVendorAndUpdateBillLocalData, exports.waitForVendorByIdThenSaveBillUpdatetoLocalStore = _a.waitForVendorByIdThenSaveBillUpdatetoLocalStore, exports.markBillForRetry = _a.markBillForRetry, exports.updateOutsideZeniPaymentLocalData = _a.updateOutsideZeniPaymentLocalData, exports.discardOutsideZeniPaymentLocalData = _a.discardOutsideZeniPaymentLocalData, exports.updateNewAddedBillPaymentAccount = _a.updateNewAddedBillPaymentAccount, exports.updateWithdrawFromAccountId = _a.updateWithdrawFromAccountId, exports.removeBillFileFromLocalStore = _a.removeBillFileFromLocalStore, exports.replaceBillFileInLocalStore = _a.replaceBillFileInLocalStore, exports.updateShouldReplaceBillData = _a.updateShouldReplaceBillData;
502
519
  exports.default = editBillView.reducer;
503
520
  function doUpdateRecurringBillLocalData(billDetail, currentConfig, prevConfig) {
504
521
  const recurringBillDetail = (0, helpers_1.updateRecurringBillDetails)(currentConfig, prevConfig, billDetail.recurringBillInstances, billDetail.recipientTotalAmount?.amount);
@@ -99,6 +99,7 @@ export interface EditBillDetailSelectorView extends SelectorView {
99
99
  payNowCutOffTime?: ZeniDate;
100
100
  qboId?: ID;
101
101
  recommendationByLineID?: RecommendationByLineId;
102
+ recommendationsFetchStatus?: FetchStateAndError;
102
103
  recommendedVendor?: Vendor;
103
104
  recurringBillInstances?: RecurringBillInstance[];
104
105
  recurringConfig?: RecurringBillConfigLocalData;
@@ -389,6 +389,9 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
389
389
  classHierarchyList,
390
390
  latestApprovedDate: (0, helpers_1.getLatestApprovalDate)(billActivities),
391
391
  recommendationByLineID: recommendations,
392
+ recommendationsFetchStatus: billId != null
393
+ ? billDetailViewState.billDetailById[(0, billDetailViewState_1.getBillTransactionDetailKey)(billId)]?.recommendationsFetchStatus
394
+ : undefined,
392
395
  isRecurring,
393
396
  recurringBillInstances,
394
397
  recurringConfig,
@@ -0,0 +1,18 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../../reducer';
4
+ import { fetchBillRecommendationsSuccess } from '../../billDetailView/billDetailViewReducer';
5
+ import { updateBillLineRecommendationsInLocalStore } from '../editBillViewReducer';
6
+ export type ActionType = ReturnType<typeof fetchBillRecommendationsSuccess> | ReturnType<typeof updateBillLineRecommendationsInLocalStore>;
7
+ /**
8
+ * Back-fills the edit local store once the standalone recommendations fetch
9
+ * resolves. `initializeBillToLocalStore` reads `transaction.recommendations`
10
+ * exactly once and is guarded against re-running, so the recommendation-derived
11
+ * line data (category/class autofill, `recommendedCategory` / `recommendedClass`
12
+ * behind the "update to" checkbox) has to be recomputed here instead.
13
+ *
14
+ * Recomputes from the entity lines with the same helper the initializer uses, so
15
+ * an untouched line ends up exactly as it would have had the recommendations
16
+ * been present at init time.
17
+ */
18
+ export declare const applyBillRecommendationsToLocalStoreEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;