@zeniai/client-epic-state 4.8.11 → 4.8.13
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/view/commonVendorView/vendorView/epics/saveVendorEpic.js +22 -5
- package/lib/view/scheduleView/scheduleListView/scheduleListHelper.js +3 -1
- package/lib/view/vendorReviewView/common/payload/commonTypes.js +15 -10
- package/lib/view/vendorReviewView/common/state/commonTypes.js +11 -9
- package/lib/view/vendorReviewView/vendorFirstReviewView/epics/fetchVendorFirstReviewViewEpic.js +3 -7
- package/lib/view/vendorReviewView/vendorFirstReviewView/vendorFirstReviewViewReducer.js +4 -3
- package/lib/view/vendorReviewView/vendorFirstReviewView/vendorFirstReviewViewSelector.js +4 -4
- package/lib/view/vendorReviewView/vendorGlobalReviewView/epics/fetchVendorGlobalReviewViewEpic.js +6 -9
- package/package.json +1 -1
|
@@ -21,8 +21,11 @@ const paymentInstrumentReducer_1 = require("../../../../entity/paymentInstrument
|
|
|
21
21
|
const classSelectorV2_1 = require("../../../../entity/class/classSelectorV2");
|
|
22
22
|
const editBillViewState_1 = require("../../../spendManagement/billPay/editBillView/editBillViewState");
|
|
23
23
|
const currencyHelper_1 = require("../../../../commonStateTypes/currencyHelper");
|
|
24
|
+
const zeniDayJS_1 = require("../../../../zeniDayJS");
|
|
25
|
+
const workingDayHelper_1 = require("../../../../commonStateTypes/workingDayHelper");
|
|
26
|
+
const companySelector_1 = require("../../../../entity/company/companySelector");
|
|
24
27
|
const saveVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(vendorViewReducer_1.saveVendor.match), (0, operators_1.mergeMap)((action) => {
|
|
25
|
-
var _a, _b, _c, _d, _e;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
26
29
|
const state = state$.value;
|
|
27
30
|
const newlySelectedVendor = (_b = (_a = state.vendorViewState.newVendorState) === null || _a === void 0 ? void 0 : _a.vendorDetailLocalData) === null || _b === void 0 ? void 0 : _b.vendorId;
|
|
28
31
|
const vendorDetailsUpdated = action.payload.vendorId != null
|
|
@@ -32,6 +35,16 @@ const saveVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operator
|
|
|
32
35
|
const effectiveVendorId = (_c = action.payload.vendorId) !== null && _c !== void 0 ? _c : newlySelectedVendor;
|
|
33
36
|
const payload = (0, vendorViewPayload_1.prepareEditVendorPayload)(state, vendorDetailsUpdated !== null && vendorDetailsUpdated !== void 0 ? vendorDetailsUpdated : vendorViewReducer_1.initialVendorDetailLocalData, effectiveVendorId);
|
|
34
37
|
let billInLocalStore = state.editBillDetailViewState.newBillState;
|
|
38
|
+
const { tenantState, companyState } = state;
|
|
39
|
+
const { currentTenantId } = tenantState;
|
|
40
|
+
const companyId = currentTenantId != null
|
|
41
|
+
? (_e = (_d = tenantState.tenantsById) === null || _d === void 0 ? void 0 : _d[currentTenantId]) === null || _e === void 0 ? void 0 : _e.companyId
|
|
42
|
+
: undefined;
|
|
43
|
+
const currentCompany = (0, companySelector_1.getCompanyByCompanyId)(companyState, companyId !== null && companyId !== void 0 ? companyId : '');
|
|
44
|
+
const payNowCutOffTime = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach;
|
|
45
|
+
const isPayNowEnabled = payNowCutOffTime != null
|
|
46
|
+
? (0, zeniDayJS_1.dateNow)().isSameOrBefore(payNowCutOffTime)
|
|
47
|
+
: false;
|
|
35
48
|
if (action.payload.billId != null) {
|
|
36
49
|
const billDetailKey = (0, billDetailViewState_1.getBillTransactionDetailKey)(action.payload.billId);
|
|
37
50
|
billInLocalStore =
|
|
@@ -42,9 +55,9 @@ const saveVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operator
|
|
|
42
55
|
const saveVendorApi = effectiveVendorId != null
|
|
43
56
|
? zeniAPI.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${effectiveVendorId}`, payload)
|
|
44
57
|
: zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors`, payload);
|
|
45
|
-
const userId = (
|
|
58
|
+
const userId = (_g = (_f = state.tenantState.loggedInUser) === null || _f === void 0 ? void 0 : _f.userId) !== null && _g !== void 0 ? _g : '';
|
|
46
59
|
return saveVendorApi.pipe((0, operators_1.mergeMap)((response) => {
|
|
47
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
48
61
|
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
49
62
|
const updatedVendor = ((_a = response.data) === null || _a === void 0 ? void 0 : _a.vendors[0]) != null
|
|
50
63
|
? (0, vendorPayload_1.mapVendorPayloadToVendor)((_b = response.data) === null || _b === void 0 ? void 0 : _b.vendors[0])
|
|
@@ -106,7 +119,11 @@ const saveVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operator
|
|
|
106
119
|
updatesByLineId: updatedLines,
|
|
107
120
|
whatForSection: Object.assign(Object.assign({}, billInLocalStore.billDetailLocalData.whatForSection), { currencyCode: updatedVendor === null || updatedVendor === void 0 ? void 0 : updatedVendor.vendorCurrencyCode }),
|
|
108
121
|
paymentDetailsSection: Object.assign(Object.assign({}, billInLocalStore.billDetailLocalData
|
|
109
|
-
.paymentDetailsSection), { paymentTo: undefined, internationalTransferFeeBearerPaymentMethod: updatedVendor === null || updatedVendor === void 0 ? void 0 : updatedVendor.preferredInternationalTransferFeeBearerPaymentMethod
|
|
122
|
+
.paymentDetailsSection), { paymentTo: undefined, internationalTransferFeeBearerPaymentMethod: updatedVendor === null || updatedVendor === void 0 ? void 0 : updatedVendor.preferredInternationalTransferFeeBearerPaymentMethod, paymentDate: (_t = (_s = billInLocalStore.billDetailLocalData
|
|
123
|
+
.paymentDetailsSection) === null || _s === void 0 ? void 0 : _s.paymentDate) !== null && _t !== void 0 ? _t :
|
|
124
|
+
//in case paymentDate is not present in the billDetailLocalData, then today/next working date will be considered.
|
|
125
|
+
//this is done beacuse we are doing similar calcualtion in getDefaultValues of editBillDetailPage.
|
|
126
|
+
(0, zeniDayJS_1.date)((0, workingDayHelper_1.getNextNthWorkingDay)((0, zeniDayJS_1.dateNow)().toDate(), [0, 6], isPayNowEnabled ? 0 : 1).toISOString()) }),
|
|
110
127
|
isCollectToAccountInfoFromVendorContact: false,
|
|
111
128
|
isRecurring: false,
|
|
112
129
|
},
|
|
@@ -128,7 +145,7 @@ const saveVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operator
|
|
|
128
145
|
return (0, rxjs_1.from)(actions);
|
|
129
146
|
}
|
|
130
147
|
else {
|
|
131
|
-
if (((
|
|
148
|
+
if (((_u = response.data) === null || _u === void 0 ? void 0 : _u.error_code) === 1001) {
|
|
132
149
|
return (0, rxjs_1.of)((0, vendorViewReducer_1.saveVendorSuccessOrFailure)('Error', action.payload.vendorId, response.status, true), (0, vendorViewReducer_1.fetchUserDetails)({ userId: userId }));
|
|
133
150
|
}
|
|
134
151
|
return (0, rxjs_1.of)((0, vendorViewReducer_1.saveVendorSuccessOrFailure)('Error', action.payload.vendorId, response.status), (0, snackbarReducer_1.openSnackbar)({
|
|
@@ -197,7 +197,9 @@ const countStatusForDuration = (statusCode) => {
|
|
|
197
197
|
const getDurationOfMonthOutTotalMonth = (jeSchedule) => {
|
|
198
198
|
let totalDurationCompleted = 0;
|
|
199
199
|
const scheduledEntries = jeSchedule.scheduledJournalEntry;
|
|
200
|
-
|
|
200
|
+
const allowedJEScheduleStatus = ['ongoing', 'completed'];
|
|
201
|
+
if (allowedJEScheduleStatus.includes(jeSchedule.status.code) === true &&
|
|
202
|
+
scheduledEntries.length > 0) {
|
|
201
203
|
totalDurationCompleted = scheduledEntries.filter((scheduledEntry) => countStatusForDuration(scheduledEntry.status.code)).length;
|
|
202
204
|
}
|
|
203
205
|
return totalDurationCompleted;
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.toGlobalMerchantsBasePayload = exports.toVendorReviewViewRecommendationPayload = exports.toNonExistingRecommendationGlobalMerchantBasePayload = exports.toUserPayload = void 0;
|
|
7
|
-
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
8
7
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
9
8
|
const globalMerchantPayload_1 = require("../../../../entity/globalMerchant/globalMerchantPayload");
|
|
10
9
|
/**
|
|
@@ -69,19 +68,25 @@ const toVendorReviewViewRecommendationPayload = (recommendations, nonExistingRec
|
|
|
69
68
|
global_merchants: recommendationEntities,
|
|
70
69
|
};
|
|
71
70
|
});
|
|
72
|
-
const allRecommendations =
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
const allRecommendations = [
|
|
72
|
+
{
|
|
73
|
+
global_merchants: [
|
|
74
|
+
...recommendationsPayload[0].global_merchants,
|
|
75
|
+
...nonExistingRecommendationsPayload[0].global_merchants,
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
];
|
|
75
79
|
return allRecommendations;
|
|
76
80
|
};
|
|
77
81
|
exports.toVendorReviewViewRecommendationPayload = toVendorReviewViewRecommendationPayload;
|
|
78
82
|
const toGlobalMerchantsBasePayload = (vendorsRecommendationsPayload) => {
|
|
79
|
-
var _a
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
.
|
|
84
|
-
|
|
83
|
+
var _a;
|
|
84
|
+
const globalMerchantBasePayload = [];
|
|
85
|
+
(_a = vendorsRecommendationsPayload[0]) === null || _a === void 0 ? void 0 : _a.global_merchants.forEach((globalMerchantPayload) => {
|
|
86
|
+
if (globalMerchantPayload.global_merchant_id != null) {
|
|
87
|
+
globalMerchantBasePayload.push(globalMerchantPayload);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
85
90
|
return globalMerchantBasePayload;
|
|
86
91
|
};
|
|
87
92
|
exports.toGlobalMerchantsBasePayload = toGlobalMerchantsBasePayload;
|
|
@@ -67,15 +67,17 @@ const toNonExistingGlobalMerchantBase = (globalMerchantPayload) => {
|
|
|
67
67
|
};
|
|
68
68
|
exports.toNonExistingGlobalMerchantBase = toNonExistingGlobalMerchantBase;
|
|
69
69
|
const toAllRecommendationsFromPayload = (recommendationsPayload) => {
|
|
70
|
-
var _a
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
const recommendations = [];
|
|
72
|
+
const nonExistingRecommendations = [];
|
|
73
|
+
(_a = recommendationsPayload[0]) === null || _a === void 0 ? void 0 : _a.global_merchants.forEach((globalmerchant) => {
|
|
74
|
+
if (globalmerchant.global_merchant_id != null) {
|
|
75
|
+
recommendations.push((0, globalMerchantPayload_1.toGlobalMerchantBase)(globalmerchant));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
nonExistingRecommendations.push((0, exports.toNonExistingGlobalMerchantBase)(globalmerchant));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
79
81
|
const recommendationIds = recommendations.map((recommendation) => recommendation.globalMerchantId);
|
|
80
82
|
return {
|
|
81
83
|
recommendationIds,
|
package/lib/view/vendorReviewView/vendorFirstReviewView/epics/fetchVendorFirstReviewViewEpic.js
CHANGED
|
@@ -82,17 +82,13 @@ exports.mapUsersPayloadFromVendorFirstReviewViewResponse = mapUsersPayloadFromVe
|
|
|
82
82
|
const mapGlobalMerchantsBasePayloadFromVendorFirstReviewViewResponse = (vendorsResponse) => {
|
|
83
83
|
const globalMerchantBasePayload = [];
|
|
84
84
|
vendorsResponse.forEach((vendor) => {
|
|
85
|
-
var _a
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
85
|
+
var _a;
|
|
86
|
+
const existingMerchants = (_a = vendor.recommendations[0]) === null || _a === void 0 ? void 0 : _a.global_merchants.filter((merchant) => merchant.global_merchant_id != null);
|
|
87
|
+
mapEntitiesRecommendationsPayloadToGlobalMerchantsBasePayload(existingMerchants, globalMerchantBasePayload);
|
|
89
88
|
});
|
|
90
89
|
return globalMerchantBasePayload;
|
|
91
90
|
};
|
|
92
91
|
exports.mapGlobalMerchantsBasePayloadFromVendorFirstReviewViewResponse = mapGlobalMerchantsBasePayloadFromVendorFirstReviewViewResponse;
|
|
93
|
-
const mapVendorRecommendationsToGlobalMerchantBasePayload = (recommendations, globalMerchantBasePayload) => {
|
|
94
|
-
recommendations.forEach((recommendation) => mapEntitiesRecommendationsPayloadToGlobalMerchantsBasePayload(recommendation.global_merchants, globalMerchantBasePayload));
|
|
95
|
-
};
|
|
96
92
|
const mapEntitiesRecommendationsPayloadToGlobalMerchantsBasePayload = (entities, globalMerchantBasePayload) => {
|
|
97
93
|
entities.forEach((entity) => globalMerchantBasePayload.push(entity));
|
|
98
94
|
};
|
|
@@ -83,8 +83,9 @@ const vendorFirstReviewView = (0, toolkit_1.createSlice)({
|
|
|
83
83
|
const isRecommendationSelected = selectedGlobalMerchantId != null &&
|
|
84
84
|
(selectedGlobalMerchantId ===
|
|
85
85
|
vendorLocalData.recommendationIds[0] ||
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
(vendorLocalData.recommendationIds.length === 0 &&
|
|
87
|
+
selectedGlobalMerchantId ===
|
|
88
|
+
((_a = vendorLocalData.recommendedNonExistingGlobalMerchants[0]) === null || _a === void 0 ? void 0 : _a.globalMerchantName)));
|
|
88
89
|
const isRetainSelected = selectedGlobalMerchantId != null &&
|
|
89
90
|
selectedGlobalMerchantId === vendorLocalData.vendorId;
|
|
90
91
|
currentSelection =
|
|
@@ -244,7 +245,7 @@ const mapPayloadToVendorFirstReviewView = (payload) => {
|
|
|
244
245
|
},
|
|
245
246
|
currentSelection: null,
|
|
246
247
|
recommendationIds,
|
|
247
|
-
recommendedNonExistingGlobalMerchants:
|
|
248
|
+
recommendedNonExistingGlobalMerchants: nonExistingRecommendations,
|
|
248
249
|
lastUpdatedVendorNameByUserId: (_a = payload.last_updated_vendor_name_by_user) === null || _a === void 0 ? void 0 : _a.user_id,
|
|
249
250
|
};
|
|
250
251
|
};
|
|
@@ -19,10 +19,10 @@ const getVendorFirstReviewView = (state) => {
|
|
|
19
19
|
const currentVendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, vendorLocalData.vendorId);
|
|
20
20
|
const users = (0, userSelector_1.getUsersByUserIds)(userState, userIds);
|
|
21
21
|
let recommendations = (0, globalMerchantSelector_1.getGlobalMerchantsByMerchantIds)(globalMerchantState, vendorLocalData.recommendationIds);
|
|
22
|
-
recommendations =
|
|
23
|
-
recommendations
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
recommendations = [
|
|
23
|
+
...recommendations,
|
|
24
|
+
...vendorLocalData.recommendedNonExistingGlobalMerchants,
|
|
25
|
+
];
|
|
26
26
|
let selectedVendor;
|
|
27
27
|
const vendor = (0, vendorSelector_1.getVendorByVendorId)(vendorState, vendorLocalData.selectedVendorId);
|
|
28
28
|
if (vendor != null) {
|
package/lib/view/vendorReviewView/vendorGlobalReviewView/epics/fetchVendorGlobalReviewViewEpic.js
CHANGED
|
@@ -71,15 +71,12 @@ exports.toUsersPayload = toUsersPayload;
|
|
|
71
71
|
const mapGlobalReviewPayloadToGlobalMerchantsBasePayload = (vendorsResponse) => {
|
|
72
72
|
let globalMerchantBasePayload = [];
|
|
73
73
|
vendorsResponse.forEach((vendor) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
]),
|
|
81
|
-
];
|
|
82
|
-
}
|
|
74
|
+
globalMerchantBasePayload = [
|
|
75
|
+
...new Set([
|
|
76
|
+
...globalMerchantBasePayload,
|
|
77
|
+
...(0, commonTypes_1.toGlobalMerchantsBasePayload)(vendor.recommendations),
|
|
78
|
+
]),
|
|
79
|
+
];
|
|
83
80
|
});
|
|
84
81
|
return globalMerchantBasePayload;
|
|
85
82
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.13",
|
|
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
|
"types": "lib/index.d.ts",
|