@zeniai/client-epic-state 4.9.56 → 4.9.57

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 (36) hide show
  1. package/lib/epic.d.ts +1 -3
  2. package/lib/epic.js +1 -3
  3. package/lib/index.d.ts +7 -8
  4. package/lib/index.js +10 -14
  5. package/lib/view/commonVendorView/vendorView/epics/fetchVendorEpic.d.ts +2 -2
  6. package/lib/view/commonVendorView/vendorView/epics/fetchVendorEpic.js +0 -1
  7. package/lib/view/commonVendorView/vendorView/vendorViewReducer.d.ts +1 -1
  8. package/lib/view/commonVendorView/vendorView/vendorViewReducer.js +2 -5
  9. package/lib/view/referralView/epics/fetchReferralsEpic.js +1 -1
  10. package/lib/view/referralView/epics/resendReferralInviteEpic.js +1 -1
  11. package/lib/view/referralView/epics/sendReferralInviteEpic.js +1 -1
  12. package/lib/view/referralView/referralPayload.d.ts +5 -4
  13. package/lib/view/referralView/referralReducer.d.ts +1 -1
  14. package/lib/view/referralView/referralReducer.js +16 -8
  15. package/lib/view/referralView/referralSelector.d.ts +4 -1
  16. package/lib/view/referralView/referralSelector.js +5 -2
  17. package/lib/view/referralView/referralState.d.ts +6 -4
  18. package/lib/view/referralView/referralState.js +0 -2
  19. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigState.d.ts +1 -1
  20. package/lib/view/spendManagement/billPay/billPayConfig/billPayConfigState.js +1 -4
  21. package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.d.ts +1 -7
  22. package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.js +2 -18
  23. package/lib/view/spendManagement/billPay/editBillView/epics/parseInvoiceToBillEpic.js +1 -4
  24. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +3 -3
  25. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailPayload.d.ts +0 -15
  26. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailPayload.js +0 -11
  27. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailReducer.d.ts +1 -2
  28. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailReducer.js +2 -33
  29. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailSelector.d.ts +1 -2
  30. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailSelector.js +1 -2
  31. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailState.d.ts +0 -13
  32. package/package.json +1 -1
  33. package/lib/view/spendManagement/billPay/editBillView/epics/fetchVendorAndUpdateBillLocalDataEpic.d.ts +0 -10
  34. package/lib/view/spendManagement/billPay/editBillView/epics/fetchVendorAndUpdateBillLocalDataEpic.js +0 -121
  35. package/lib/view/spendManagement/zeniAccounts/transferDetail/fetchReviewTransferDetailEpic.d.ts +0 -7
  36. package/lib/view/spendManagement/zeniAccounts/transferDetail/fetchReviewTransferDetailEpic.js +0 -40
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitForVendorByIdThenSaveBillUpdatetoLocalStoreEpic = exports.fetchVendorAndUpdateBillLocalDataEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const editBillViewReducer_1 = require("../editBillViewReducer");
7
- const vendorSelector_1 = require("../../../../../entity/vendor/vendorSelector");
8
- const billDetailViewState_1 = require("../../billDetailView/billDetailViewState");
9
- const zeniDayJS_1 = require("../../../../../zeniDayJS");
10
- const workingDayHelper_1 = require("../../../../../commonStateTypes/workingDayHelper");
11
- const companySelector_1 = require("../../../../../entity/company/companySelector");
12
- const accountSelector_1 = require("../../../../../entity/account/accountSelector");
13
- const classSelector_1 = require("../../../../../entity/class/classSelector");
14
- const editBillViewState_1 = require("../../../../spendManagement/billPay/editBillView/editBillViewState");
15
- const vendorViewReducer_1 = require("../../../../commonVendorView/vendorView/vendorViewReducer");
16
- const previousBillsReducer_1 = require("../../previousBills/previousBillsReducer");
17
- const fetchVendorAndUpdateBillLocalDataEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editBillViewReducer_1.fetchVendorAndUpdateBillLocalData.match), (0, operators_1.mergeMap)((action) => {
18
- const fetchActions = [];
19
- const { vendorId } = action.payload;
20
- const state = state$.value;
21
- const vendor = (0, vendorSelector_1.getVendorByVendorId)(state.vendorState, vendorId);
22
- let billInLocalStore = state.editBillDetailViewState.newBillState;
23
- if (action.payload.billId != null) {
24
- const billDetailKey = (0, billDetailViewState_1.getBillTransactionDetailKey)(action.payload.billId);
25
- billInLocalStore =
26
- state.editBillDetailViewState.editBillStateById[billDetailKey];
27
- }
28
- if (vendor != null) {
29
- fetchActions.push((0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({
30
- billDetailLocalData: prepareBillLocalData(state, billInLocalStore, vendor),
31
- billId: action.payload.billId,
32
- }));
33
- fetchActions.push((0, previousBillsReducer_1.fetchPreviousBills)(vendor.qboId, false));
34
- }
35
- else {
36
- fetchActions.push((0, vendorViewReducer_1.fetchVendor)(vendorId), (0, editBillViewReducer_1.waitForVendorByIdThenSaveBillUpdatetoLocalStore)(vendorId, action.payload.billId));
37
- }
38
- return (0, rxjs_1.from)(fetchActions);
39
- }));
40
- exports.fetchVendorAndUpdateBillLocalDataEpic = fetchVendorAndUpdateBillLocalDataEpic;
41
- const waitForVendorByIdThenSaveBillUpdatetoLocalStoreEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editBillViewReducer_1.waitForVendorByIdThenSaveBillUpdatetoLocalStore.match), (0, operators_1.switchMap)((action) => {
42
- const { vendorId } = action.payload;
43
- return actions$.pipe((0, operators_1.filter)((value) => vendorViewReducer_1.indicateReadyToInitializeBillLocalStore.match(value)), (0, operators_1.take)(1), // don't listen forever! IMPORTANT!
44
- (0, operators_1.mergeMap)(() => {
45
- const state = state$.value;
46
- const fetchActions = [];
47
- const vendor = (0, vendorSelector_1.getVendorByVendorId)(state.vendorState, vendorId);
48
- let billInLocalStore = state.editBillDetailViewState.newBillState;
49
- if (action.payload.billId != null) {
50
- const billDetailKey = (0, billDetailViewState_1.getBillTransactionDetailKey)(action.payload.billId);
51
- billInLocalStore =
52
- state.editBillDetailViewState.editBillStateById[billDetailKey];
53
- }
54
- if (vendor != null) {
55
- fetchActions.push((0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({
56
- billDetailLocalData: prepareBillLocalData(state, billInLocalStore, vendor),
57
- billId: action.payload.billId,
58
- }));
59
- fetchActions.push((0, previousBillsReducer_1.fetchPreviousBills)(vendor.qboId, false));
60
- }
61
- return (0, rxjs_1.from)(fetchActions);
62
- }));
63
- }));
64
- exports.waitForVendorByIdThenSaveBillUpdatetoLocalStoreEpic = waitForVendorByIdThenSaveBillUpdatetoLocalStoreEpic;
65
- function prepareBillLocalData(state, billInLocalStore, vendor) {
66
- var _a, _b, _c, _d;
67
- const isCancelled = billInLocalStore.billDetailLocalData.isCancelled;
68
- const lines = billInLocalStore.billDetailLocalData.updatesByLineId;
69
- const updatedLines = Object.assign({}, lines);
70
- const vendorCategory = vendor.accountId != null
71
- ? (0, accountSelector_1.getAccountBase)(state.accountState, vendor.accountId, 'account_list')
72
- : undefined;
73
- const vendorClass = vendor.classId != null
74
- ? (0, classSelector_1.getClassById)(state.classState, {
75
- classId: vendor.classId,
76
- reportId: 'class_list',
77
- })
78
- : undefined;
79
- const vendorCurrencyCode = vendor.vendorCurrencyCode;
80
- const vendorCurrencySymbol = vendor.vendorCurrencySymbol;
81
- const { tenantState, companyState } = state;
82
- const { currentTenantId } = tenantState;
83
- const companyId = currentTenantId != null
84
- ? (_b = (_a = tenantState.tenantsById) === null || _a === void 0 ? void 0 : _a[currentTenantId]) === null || _b === void 0 ? void 0 : _b.companyId
85
- : undefined;
86
- const currentCompany = (0, companySelector_1.getCompanyByCompanyId)(companyState, companyId !== null && companyId !== void 0 ? companyId : '');
87
- const payNowCutOffTime = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach;
88
- const isPayNowEnabled = payNowCutOffTime != null
89
- ? (0, zeniDayJS_1.dateNow)().isSameOrBefore(payNowCutOffTime)
90
- : false;
91
- Object.keys(updatedLines).forEach((lineId) => {
92
- var _a, _b;
93
- const line = lines[lineId];
94
- updatedLines[lineId] = Object.assign(Object.assign({}, line), { account: Boolean((_a = line.account) === null || _a === void 0 ? void 0 : _a.accountId) === false && vendorCategory != null
95
- ? vendorCategory
96
- : line.account, class: Boolean((_b = line.class) === null || _b === void 0 ? void 0 : _b.classId) === false && vendorClass != null
97
- ? vendorClass
98
- : line.class });
99
- });
100
- //when it's a new bill and it doesn't have any line item, we want to default the account and class to vendor's account and class
101
- if (Object.keys(updatedLines).length === 0) {
102
- updatedLines['1'] = Object.assign({ account: vendorCategory, class: vendorClass, amount: {
103
- amount: 0,
104
- currencyCode: vendorCurrencyCode,
105
- currencySymbol: vendorCurrencySymbol,
106
- }, id: '1', lineDescription: '', platformLineDetailType: 'account_based_expense_line_detail', type: 'transaction_with_account_and_class_line', billable: 'not_billable', isCategoryMiscategorized: false, isClassMiscategorized: false }, editBillViewState_1.defaultRecommendationStateObj);
107
- }
108
- return {
109
- showVendorGptRecommendationText: false,
110
- vendor: vendor,
111
- isCancelled: isCancelled,
112
- updatesByLineId: updatedLines,
113
- whatForSection: Object.assign(Object.assign({}, billInLocalStore.billDetailLocalData.whatForSection), { currencyCode: vendor === null || vendor === void 0 ? void 0 : vendor.vendorCurrencyCode }),
114
- paymentDetailsSection: Object.assign(Object.assign({}, billInLocalStore.billDetailLocalData.paymentDetailsSection), { paymentTo: undefined, internationalTransferFeeBearerPaymentMethod: vendor === null || vendor === void 0 ? void 0 : vendor.preferredInternationalTransferFeeBearerPaymentMethod, paymentDate: (_d = (_c = billInLocalStore.billDetailLocalData.paymentDetailsSection) === null || _c === void 0 ? void 0 : _c.paymentDate) !== null && _d !== void 0 ? _d :
115
- //in case paymentDate is not present in the billDetailLocalData, then today/next working date will be considered.
116
- //this is done beacuse we are doing similar calcualtion in getDefaultValues of editBillDetailPage.
117
- (0, zeniDayJS_1.date)((0, workingDayHelper_1.getNextNthWorkingDay)((0, zeniDayJS_1.dateNow)().toDate(), [0, 6], isPayNowEnabled ? 0 : 1).toISOString()) }),
118
- isCollectToAccountInfoFromVendorContact: false,
119
- isRecurring: false,
120
- };
121
- }
@@ -1,7 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { RootState } from '../../../../reducer';
4
- import { ZeniAPI } from '../../../../zeniAPI';
5
- import { fetchReviewTransferDetail, updateReviewTransferDetail, updateReviewTransferDetailFailure } from './transferDetailReducer';
6
- export declare type ActionType = ReturnType<typeof fetchReviewTransferDetail> | ReturnType<typeof updateReviewTransferDetail> | ReturnType<typeof updateReviewTransferDetailFailure>;
7
- export declare const fetchReviewTransferDetailEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchReviewTransferDetailEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../../responsePayload");
7
- const transferDetailReducer_1 = require("./transferDetailReducer");
8
- const helpers_1 = require("../../helpers");
9
- const fetchReviewTransferDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(transferDetailReducer_1.fetchReviewTransferDetail.match), (0, operators_1.switchMap)(() => {
10
- var _a, _b, _c, _d, _e, _f;
11
- const state = state$.value;
12
- const localData = state.transferDetailState.localData;
13
- const payload = {
14
- from_account: {
15
- account_id: (_a = localData.transferFrom) === null || _a === void 0 ? void 0 : _a.id,
16
- account_type: (_c = (0, helpers_1.accountTypeSubConfigCodeToAccType)((_b = localData.transferFrom) === null || _b === void 0 ? void 0 : _b.accType)) !== null && _c !== void 0 ? _c : '',
17
- },
18
- to_account: {
19
- account_id: (_d = localData.transferTo) === null || _d === void 0 ? void 0 : _d.id,
20
- account_type: (_f = (0, helpers_1.accountTypeSubConfigCodeToAccType)((_e = localData.transferTo) === null || _e === void 0 ? void 0 : _e.accType)) !== null && _f !== void 0 ? _f : '',
21
- },
22
- amount: localData.amount.amount,
23
- currency_code: localData.amount.currencyCode,
24
- currency_symbol: localData.amount.currencySymbol,
25
- };
26
- return zeniAPI
27
- .postAndGetJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/deposit-accounts/transfers/review`, payload)
28
- .pipe((0, operators_1.mergeMap)((response) => {
29
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
30
- return (0, rxjs_1.of)((0, transferDetailReducer_1.updateReviewTransferDetail)(response.data));
31
- }
32
- else {
33
- return (0, rxjs_1.of)((0, transferDetailReducer_1.updateReviewTransferDetailFailure)(response.status));
34
- }
35
- }), (0, operators_1.catchError)((error) => {
36
- return (0, rxjs_1.of)((0, transferDetailReducer_1.updateReviewTransferDetailFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Review Transfer Detail REST API call errored out' +
37
- JSON.stringify(error))));
38
- }));
39
- }));
40
- exports.fetchReviewTransferDetailEpic = fetchReviewTransferDetailEpic;