@zeniai/client-epic-state 5.2.54 → 5.2.56-betaRD1
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.
- package/lib/entity/billPay/billTransaction/billTransactionReducer.d.ts +5 -1
- package/lib/entity/billPay/billTransaction/billTransactionReducer.js +17 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -1
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +79 -5
- package/lib/epic.d.ts +4 -1
- package/lib/epic.js +10 -4
- package/lib/esm/entity/billPay/billTransaction/billTransactionReducer.js +16 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +78 -4
- package/lib/esm/epic.js +10 -4
- package/lib/esm/index.js +5 -5
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +39 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +14 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +10 -13
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +38 -17
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +17 -1
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +74 -1
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +49 -14
- package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewReducer.js +87 -1
- package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +1 -0
- package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewState.js +4 -0
- package/lib/esm/view/spendManagement/billPay/billDetailView/epics/fetchBillRecommendationsEpic.js +97 -0
- package/lib/esm/view/spendManagement/billPay/billDetailView/epics/fetchRecommendationsForBill.js +85 -0
- package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewReducer.js +18 -1
- package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +3 -0
- package/lib/esm/view/spendManagement/billPay/editBillView/epics/applyBillRecommendationsToLocalStoreEpic.js +95 -0
- package/lib/index.d.ts +5 -5
- package/lib/index.js +51 -49
- package/lib/tsconfig.mocks.tsbuildinfo +1 -0
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +20 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +43 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +8 -11
- package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +38 -17
- package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +17 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +18 -0
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +10 -3
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +76 -3
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +3 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +49 -14
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +16 -0
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewPayload.d.ts +19 -0
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewReducer.d.ts +10 -1
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewReducer.js +88 -2
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.d.ts +1 -0
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +1 -0
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewState.d.ts +7 -0
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewState.js +4 -0
- package/lib/view/spendManagement/billPay/billDetailView/epics/fetchBillRecommendationsEpic.d.ts +37 -0
- package/lib/view/spendManagement/billPay/billDetailView/epics/fetchBillRecommendationsEpic.js +104 -0
- package/lib/view/spendManagement/billPay/billDetailView/epics/fetchRecommendationsForBill.d.ts +24 -0
- package/lib/view/spendManagement/billPay/billDetailView/epics/fetchRecommendationsForBill.js +92 -0
- package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.d.ts +4 -1
- package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.js +19 -2
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -0
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +3 -0
- package/lib/view/spendManagement/billPay/editBillView/epics/applyBillRecommendationsToLocalStoreEpic.d.ts +18 -0
- package/lib/view/spendManagement/billPay/editBillView/epics/applyBillRecommendationsToLocalStoreEpic.js +102 -0
- package/package.json +1 -1
|
@@ -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">,
|
|
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>;
|
|
@@ -0,0 +1,102 @@
|
|
|
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.applyBillRecommendationsToLocalStoreEpic = 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 accountListSelector_1 = require("../../../../accountList/accountListSelector");
|
|
11
|
+
const classListSelector_1 = require("../../../../classList/classListSelector");
|
|
12
|
+
const billDetailViewReducer_1 = require("../../billDetailView/billDetailViewReducer");
|
|
13
|
+
const billDetailViewState_1 = require("../../billDetailView/billDetailViewState");
|
|
14
|
+
const editBillViewReducer_1 = require("../editBillViewReducer");
|
|
15
|
+
const initializeBillToLocalStoreEpic_1 = require("./initializeBillToLocalStoreEpic");
|
|
16
|
+
/**
|
|
17
|
+
* Back-fills the edit local store once the standalone recommendations fetch
|
|
18
|
+
* resolves. `initializeBillToLocalStore` reads `transaction.recommendations`
|
|
19
|
+
* exactly once and is guarded against re-running, so the recommendation-derived
|
|
20
|
+
* line data (category/class autofill, `recommendedCategory` / `recommendedClass`
|
|
21
|
+
* behind the "update to" checkbox) has to be recomputed here instead.
|
|
22
|
+
*
|
|
23
|
+
* Recomputes from the entity lines with the same helper the initializer uses, so
|
|
24
|
+
* an untouched line ends up exactly as it would have had the recommendations
|
|
25
|
+
* been present at init time.
|
|
26
|
+
*/
|
|
27
|
+
const applyBillRecommendationsToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(billDetailViewReducer_1.fetchBillRecommendationsSuccess.match),
|
|
28
|
+
// The skip paths resolve the status without fetching — a draft whose
|
|
29
|
+
// recommendations came on the bill detail response, or a stage that is not
|
|
30
|
+
// served any. `initializeBillToLocalStore` has already read those, so
|
|
31
|
+
// recomputing here would only reset the line's "update to" selections.
|
|
32
|
+
(0, operators_1.filter)((action) => action.payload.didWriteRecommendations), (0, operators_1.mergeMap)((action) => {
|
|
33
|
+
const { billId } = action.payload;
|
|
34
|
+
const state = state$.value;
|
|
35
|
+
const key = (0, billDetailViewState_1.getBillTransactionDetailKey)(billId);
|
|
36
|
+
const editBillState = (0, get_1.default)(state.editBillDetailViewState.editBillStateById, key, undefined);
|
|
37
|
+
const transaction = (0, get_1.default)(state.billTransactionState.transactionById, billId, undefined);
|
|
38
|
+
const recommendations = transaction?.recommendations;
|
|
39
|
+
if (editBillState == null ||
|
|
40
|
+
transaction == null ||
|
|
41
|
+
transaction.lines == null ||
|
|
42
|
+
recommendations == null ||
|
|
43
|
+
Object.keys(recommendations).length === 0) {
|
|
44
|
+
return rxjs_1.EMPTY;
|
|
45
|
+
}
|
|
46
|
+
const localData = editBillState.billDetailLocalData;
|
|
47
|
+
// The recommendations were requested for the vendor on the bill. If the
|
|
48
|
+
// user has since switched vendors, `fetchVendorAndUpdateBillLocalData`
|
|
49
|
+
// owns the line data and these are stale — leave it alone.
|
|
50
|
+
//
|
|
51
|
+
// Both sides are QBO ids despite the field names suggesting otherwise.
|
|
52
|
+
// `transaction.vendor` is built by `mapVendorBasePayloadToVendorBase`,
|
|
53
|
+
// whose id is `getVendorPayloadIdentifier` = `vendor_id ?? qbo_id`, and
|
|
54
|
+
// on a bill transaction payload `vendor_id` IS the QBO id — the Zeni id
|
|
55
|
+
// rides separately as `zeni_vendor_id`. Verified against live DEV and QA
|
|
56
|
+
// responses, both of which have `vendor_id === qbo_vendor_id`.
|
|
57
|
+
if (localData.vendor?.qboId !== transaction.vendor?.id) {
|
|
58
|
+
return rxjs_1.EMPTY;
|
|
59
|
+
}
|
|
60
|
+
const accountList = (0, accountListSelector_1.getAccountList)(state.accountState, state.accountListState, 'billPayAccountList');
|
|
61
|
+
const classList = (0, classListSelector_1.getClassList)(state.classState, state.classListState);
|
|
62
|
+
const updatesByLineId = {};
|
|
63
|
+
transaction.lines.forEach((line) => {
|
|
64
|
+
// A line whose category/class the user already set keeps their input.
|
|
65
|
+
const localLine = localData.updatesByLineId[line.id];
|
|
66
|
+
if (localLine?.isCategoryOrClassUpdated) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// The helper spreads whatever line it is given into its result, and
|
|
70
|
+
// the reducer replaces the entry wholesale, so the local line has to
|
|
71
|
+
// go in or edits that leave `isCategoryOrClassUpdated` untouched — an
|
|
72
|
+
// amount or description changed while this fetch was in flight — get
|
|
73
|
+
// reverted.
|
|
74
|
+
//
|
|
75
|
+
// Category and class are the exception and come from the ENTITY line,
|
|
76
|
+
// exactly as at init. By now the local line may hold a category the
|
|
77
|
+
// vendor default autofilled when no recommendation was available yet,
|
|
78
|
+
// and the helper reads whatever it is given as the line's original
|
|
79
|
+
// value and will not replace one. Passing that back would leave an
|
|
80
|
+
// untouched line on the vendor default instead of the per-line
|
|
81
|
+
// recommendation, so the back-fill would not match what init would
|
|
82
|
+
// have produced had the recommendations been there all along.
|
|
83
|
+
const localLineWithEntityCategory = localLine == null || hasAccountAndClass(line) === false
|
|
84
|
+
? line
|
|
85
|
+
: {
|
|
86
|
+
...localLine,
|
|
87
|
+
account: line.account,
|
|
88
|
+
class: line.class,
|
|
89
|
+
};
|
|
90
|
+
updatesByLineId[line.id] = (0, initializeBillToLocalStoreEpic_1.getLineRecommendationsLocalData)(line.id, localLineWithEntityCategory, recommendations, accountList, classList, localData.vendor);
|
|
91
|
+
});
|
|
92
|
+
if (Object.keys(updatesByLineId).length === 0) {
|
|
93
|
+
return rxjs_1.EMPTY;
|
|
94
|
+
}
|
|
95
|
+
return (0, rxjs_1.of)((0, editBillViewReducer_1.updateBillLineRecommendationsInLocalStore)(billId, updatesByLineId));
|
|
96
|
+
}));
|
|
97
|
+
exports.applyBillRecommendationsToLocalStoreEpic = applyBillRecommendationsToLocalStoreEpic;
|
|
98
|
+
// Only some `Line` members carry a category and class. A guard rather than a
|
|
99
|
+
// cast so a shape change is a compile error, not a silent `undefined`.
|
|
100
|
+
function hasAccountAndClass(line) {
|
|
101
|
+
return 'account' in line;
|
|
102
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.56-betaRD1",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|