@zeniai/client-epic-state 4.8.46 → 4.8.48
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/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/epic.d.ts +3 -1
- package/lib/epic.js +3 -1
- package/lib/index.d.ts +11 -10
- package/lib/index.js +27 -15
- package/lib/view/commonVendorView/vendorView/epics/saveVendorEpic.js +31 -4
- package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewReducer.d.ts +5 -1
- package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewReducer.js +12 -2
- package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector.d.ts +14 -0
- package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector.js +36 -4
- package/lib/view/commonVendorView/vendorsTabVendorView/vendorsTabVendorViewState.d.ts +7 -0
- package/lib/view/people/changeZeniPersonRolesEpic.d.ts +1 -1
- package/lib/view/people/deletePersonEpic.d.ts +1 -1
- package/lib/view/people/invitePeopleEpic.d.ts +1 -1
- package/lib/view/people/inviteZeniPeopleEpic.d.ts +1 -1
- package/lib/view/people/resendInviteEpic.d.ts +1 -1
- package/lib/view/settingsView/epic/fetchNotificationSettingsEpic.d.ts +17 -0
- package/lib/view/settingsView/epic/fetchNotificationSettingsEpic.js +23 -0
- package/lib/view/settingsView/epic/saveNotificationSettingsEpic.d.ts +31 -0
- package/lib/view/settingsView/epic/saveNotificationSettingsEpic.js +70 -0
- package/lib/view/settingsView/settingsViewHelpers.d.ts +2 -0
- package/lib/view/settingsView/settingsViewHelpers.js +11 -0
- package/lib/view/settingsView/settingsViewPayload.d.ts +7 -0
- package/lib/view/settingsView/settingsViewReducer.d.ts +7 -2
- package/lib/view/settingsView/settingsViewReducer.js +115 -2
- package/lib/view/settingsView/settingsViewSelector.d.ts +2 -0
- package/lib/view/settingsView/settingsViewSelector.js +4 -1
- package/lib/view/settingsView/settingsViewState.d.ts +18 -0
- package/lib/view/settingsView/settingsViewState.js +15 -0
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -0
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +24 -22
- package/lib/view/spendManagement/billPay/editBillView/editBillViewState.d.ts +1 -0
- package/lib/view/spendManagement/billPay/editBillView/editBillViewState.js +1 -0
- package/lib/view/spendManagement/billPay/editBillView/epics/initializeBillToLocalStoreEpic.js +1 -0
- package/lib/view/spendManagement/billPay/editBillView/epics/parseInvoiceToBillEpic.d.ts +1 -1
- package/lib/view/spendManagement/billPay/editBillView/epics/parseInvoiceToBillEpic.js +7 -2
- package/lib/view/spendManagement/helpers.js +11 -4
- package/lib/view/transactionList/fetchTransactionListByEntityEpic.js +3 -0
- package/lib/view/transactionList/transactionListByEntitySelector.d.ts +4 -0
- package/lib/view/transactionList/transactionListByEntitySelector.js +62 -1
- package/lib/view/transactionList/transactionListReducer.d.ts +2 -1
- package/lib/view/transactionList/transactionListReducer.js +2 -2
- package/lib/zeniAPI.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearSettingsView = exports.fetchBankAccountsList = exports.updateBankConnectionOnFailure = exports.updateBankConnectionOnSuccess = exports.fetchBankConnectionsView = exports.updateMyProfileOnFailure = exports.updateMyProfileOnSuccess = exports.fetchMyProfile = exports.fetchMyProfileView = exports.initialState = void 0;
|
|
4
|
+
exports.clearSettingsView = exports.updateNotificationSettingsOnSaveFailure = exports.updateNotificationSettingsOnSaveSuccess = exports.saveNotificationSettings = exports.resetNotificationSettingsLocalData = exports.updateNotificationSettingsLocalData = exports.updateNotificationSettingsOnFailure = exports.updateNotificationSettingsOnSuccess = exports.fetchNotificationSettings = exports.fetchBankAccountsList = exports.updateBankConnectionOnFailure = exports.updateBankConnectionOnSuccess = exports.fetchBankConnectionsView = exports.updateMyProfileOnFailure = exports.updateMyProfileOnSuccess = exports.fetchMyProfile = exports.fetchMyProfileView = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const initialNotificationSettingsData = {
|
|
7
|
+
missingReceiptNotification: null,
|
|
8
|
+
uncategorizedTransactionNotification: null,
|
|
9
|
+
pendingBillApprovalNotification: null,
|
|
10
|
+
pendingReimbursementApprovalNotification: null,
|
|
11
|
+
};
|
|
12
|
+
const initialNotificationSettingsLocalData = {
|
|
13
|
+
reminders: {
|
|
14
|
+
isMissingReceiptNotificationActive: null,
|
|
15
|
+
isUncategorizedTransactionNotificationActive: null,
|
|
16
|
+
isPendingReimbursementApprovalNotificationActive: null,
|
|
17
|
+
isPendingBillApprovalNotificationActive: null,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
6
20
|
exports.initialState = {
|
|
7
21
|
profile: {
|
|
8
22
|
fetchState: 'Not-Started',
|
|
@@ -14,6 +28,16 @@ exports.initialState = {
|
|
|
14
28
|
error: undefined,
|
|
15
29
|
bankAccountIds: [],
|
|
16
30
|
},
|
|
31
|
+
notification: {
|
|
32
|
+
fetchState: 'Not-Started',
|
|
33
|
+
error: undefined,
|
|
34
|
+
updateStatus: {
|
|
35
|
+
fetchState: 'Not-Started',
|
|
36
|
+
error: undefined,
|
|
37
|
+
},
|
|
38
|
+
notificationSettings: Object.assign({}, initialNotificationSettingsData),
|
|
39
|
+
notificationSettingsLocalData: Object.assign({}, initialNotificationSettingsLocalData),
|
|
40
|
+
},
|
|
17
41
|
};
|
|
18
42
|
const settings = (0, toolkit_1.createSlice)({
|
|
19
43
|
name: 'settings',
|
|
@@ -62,10 +86,99 @@ const settings = (0, toolkit_1.createSlice)({
|
|
|
62
86
|
draft.bankConnection.fetchState = 'Error';
|
|
63
87
|
draft.bankConnection.error = action.payload;
|
|
64
88
|
},
|
|
89
|
+
fetchNotificationSettings(draft) {
|
|
90
|
+
draft.notification.fetchState = 'In-Progress';
|
|
91
|
+
draft.notification.error = undefined;
|
|
92
|
+
},
|
|
93
|
+
updateNotificationSettingsOnSuccess: {
|
|
94
|
+
prepare(data) {
|
|
95
|
+
return {
|
|
96
|
+
payload: {
|
|
97
|
+
data,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
reducer(draft, action) {
|
|
102
|
+
const { data } = action.payload;
|
|
103
|
+
const notificationSettings = toNotificationSettings(data);
|
|
104
|
+
draft.notification.fetchState = 'Completed';
|
|
105
|
+
draft.notification.error = undefined;
|
|
106
|
+
draft.notification.notificationSettings = notificationSettings;
|
|
107
|
+
draft.notification.notificationSettingsLocalData =
|
|
108
|
+
toNotificationSettingsLocalData(notificationSettings);
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
updateNotificationSettingsOnFailure(draft, action) {
|
|
112
|
+
draft.notification.fetchState = 'Error';
|
|
113
|
+
draft.notification.error = action.payload;
|
|
114
|
+
},
|
|
115
|
+
updateNotificationSettingsLocalData(draft, action) {
|
|
116
|
+
draft.notification.notificationSettingsLocalData = action.payload;
|
|
117
|
+
},
|
|
118
|
+
resetNotificationSettingsLocalData(draft) {
|
|
119
|
+
draft.notification.notificationSettingsLocalData =
|
|
120
|
+
toNotificationSettingsLocalData(draft.notification.notificationSettings);
|
|
121
|
+
},
|
|
122
|
+
saveNotificationSettings(draft) {
|
|
123
|
+
draft.notification.updateStatus.fetchState = 'In-Progress';
|
|
124
|
+
draft.notification.error = undefined;
|
|
125
|
+
},
|
|
126
|
+
updateNotificationSettingsOnSaveSuccess(draft, action) {
|
|
127
|
+
const { data } = action.payload;
|
|
128
|
+
draft.notification.updateStatus.fetchState = 'Completed';
|
|
129
|
+
draft.notification.updateStatus.error = undefined;
|
|
130
|
+
draft.notification.notificationSettings = toNotificationSettings(data);
|
|
131
|
+
},
|
|
132
|
+
updateNotificationSettingsOnSaveFailure(draft, action) {
|
|
133
|
+
draft.notification.updateStatus.fetchState = 'Error';
|
|
134
|
+
draft.notification.updateStatus.error = action.payload;
|
|
135
|
+
},
|
|
65
136
|
clearSettingsView(draft) {
|
|
66
137
|
Object.assign(draft, exports.initialState);
|
|
67
138
|
},
|
|
68
139
|
},
|
|
69
140
|
});
|
|
70
|
-
_a = settings.actions, exports.fetchMyProfileView = _a.fetchMyProfileView, exports.fetchMyProfile = _a.fetchMyProfile, exports.updateMyProfileOnSuccess = _a.updateMyProfileOnSuccess, exports.updateMyProfileOnFailure = _a.updateMyProfileOnFailure, exports.fetchBankConnectionsView = _a.fetchBankConnectionsView, exports.updateBankConnectionOnSuccess = _a.updateBankConnectionOnSuccess, exports.updateBankConnectionOnFailure = _a.updateBankConnectionOnFailure, exports.fetchBankAccountsList = _a.fetchBankAccountsList, exports.clearSettingsView = _a.clearSettingsView;
|
|
141
|
+
_a = settings.actions, exports.fetchMyProfileView = _a.fetchMyProfileView, exports.fetchMyProfile = _a.fetchMyProfile, exports.updateMyProfileOnSuccess = _a.updateMyProfileOnSuccess, exports.updateMyProfileOnFailure = _a.updateMyProfileOnFailure, exports.fetchBankConnectionsView = _a.fetchBankConnectionsView, exports.updateBankConnectionOnSuccess = _a.updateBankConnectionOnSuccess, exports.updateBankConnectionOnFailure = _a.updateBankConnectionOnFailure, exports.fetchBankAccountsList = _a.fetchBankAccountsList, exports.fetchNotificationSettings = _a.fetchNotificationSettings, exports.updateNotificationSettingsOnSuccess = _a.updateNotificationSettingsOnSuccess, exports.updateNotificationSettingsOnFailure = _a.updateNotificationSettingsOnFailure, exports.updateNotificationSettingsLocalData = _a.updateNotificationSettingsLocalData, exports.resetNotificationSettingsLocalData = _a.resetNotificationSettingsLocalData, exports.saveNotificationSettings = _a.saveNotificationSettings, exports.updateNotificationSettingsOnSaveSuccess = _a.updateNotificationSettingsOnSaveSuccess, exports.updateNotificationSettingsOnSaveFailure = _a.updateNotificationSettingsOnSaveFailure, exports.clearSettingsView = _a.clearSettingsView;
|
|
71
142
|
exports.default = settings.reducer;
|
|
143
|
+
const toNotificationSettings = (data) => {
|
|
144
|
+
const notificationSettingsData = Object.assign({}, initialNotificationSettingsData);
|
|
145
|
+
if (data.is_missing_receipt_notification_active != null) {
|
|
146
|
+
notificationSettingsData.missingReceiptNotification = {
|
|
147
|
+
active: data.is_missing_receipt_notification_active,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (data.is_pending_bill_approval_notification_active != null) {
|
|
151
|
+
notificationSettingsData.pendingBillApprovalNotification = {
|
|
152
|
+
active: data.is_pending_bill_approval_notification_active,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (data.is_pending_reimbursement_approval_notification_active != null) {
|
|
156
|
+
notificationSettingsData.pendingReimbursementApprovalNotification = {
|
|
157
|
+
active: data.is_pending_reimbursement_approval_notification_active,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (data.is_uncategorized_transaction_notification_active != null) {
|
|
161
|
+
notificationSettingsData.uncategorizedTransactionNotification = {
|
|
162
|
+
active: data.is_uncategorized_transaction_notification_active,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return notificationSettingsData;
|
|
166
|
+
};
|
|
167
|
+
const toNotificationSettingsLocalData = (data) => {
|
|
168
|
+
return {
|
|
169
|
+
reminders: {
|
|
170
|
+
isMissingReceiptNotificationActive: data.missingReceiptNotification != null
|
|
171
|
+
? data.missingReceiptNotification.active
|
|
172
|
+
: null,
|
|
173
|
+
isPendingBillApprovalNotificationActive: data.pendingBillApprovalNotification != null
|
|
174
|
+
? data.pendingBillApprovalNotification.active
|
|
175
|
+
: null,
|
|
176
|
+
isPendingReimbursementApprovalNotificationActive: data.pendingReimbursementApprovalNotification != null
|
|
177
|
+
? data.pendingReimbursementApprovalNotification.active
|
|
178
|
+
: null,
|
|
179
|
+
isUncategorizedTransactionNotificationActive: data.uncategorizedTransactionNotification != null
|
|
180
|
+
? data.uncategorizedTransactionNotification.active
|
|
181
|
+
: null,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
};
|
|
@@ -3,6 +3,7 @@ import { FetchStateAndError, ID } from '../../commonStateTypes/common';
|
|
|
3
3
|
import { TenantExternalConnections } from '../../entity/tenant/tenantState';
|
|
4
4
|
import { Company } from '../../entity/company/companyStateTypes';
|
|
5
5
|
import { MyBankConnectionsView, BankConnectionsSetupView, MyProfileSelectorView } from './types/settingsViewSelectorTypes';
|
|
6
|
+
import { NotificationSettings } from './settingsViewState';
|
|
6
7
|
export declare function getApprovalRuleViewDetails(state: RootState): FetchStateAndError;
|
|
7
8
|
export declare function getBankConnectionsSetupViewDetails(state: RootState, companyId: ID): BankConnectionsSetupView;
|
|
8
9
|
export declare function getMyBankConnectionsDetails(state: RootState, userId: ID): MyBankConnectionsView;
|
|
@@ -12,3 +13,4 @@ export interface IntegrationsView {
|
|
|
12
13
|
}
|
|
13
14
|
export declare function getIntegrationsView(state: RootState, companyId: ID): IntegrationsView;
|
|
14
15
|
export declare const getMyProfileView: (state: RootState) => MyProfileSelectorView;
|
|
16
|
+
export declare const getNotificationSettingsView: (state: RootState) => NotificationSettings;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMyProfileView = exports.getIntegrationsView = exports.getMyBankConnectionsDetails = exports.getBankConnectionsSetupViewDetails = exports.getApprovalRuleViewDetails = void 0;
|
|
3
|
+
exports.getNotificationSettingsView = exports.getMyProfileView = exports.getIntegrationsView = exports.getMyBankConnectionsDetails = exports.getBankConnectionsSetupViewDetails = exports.getApprovalRuleViewDetails = void 0;
|
|
4
4
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
5
|
const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
|
|
6
6
|
const companySelector_1 = require("../../entity/company/companySelector");
|
|
@@ -117,3 +117,6 @@ exports.getMyProfileView = (0, toolkit_1.createSelector)((state) => state.tenant
|
|
|
117
117
|
}
|
|
118
118
|
return myProfilePeopleView;
|
|
119
119
|
});
|
|
120
|
+
exports.getNotificationSettingsView = (0, toolkit_1.createSelector)((state) => state.settingsViewState, (settingsViewState) => {
|
|
121
|
+
return settingsViewState.notification;
|
|
122
|
+
});
|
|
@@ -5,8 +5,26 @@ interface MyProfile extends FetchStateAndError {
|
|
|
5
5
|
interface BankConnection extends FetchStateAndError {
|
|
6
6
|
bankAccountIds: ID[];
|
|
7
7
|
}
|
|
8
|
+
declare const toReminderTypeKey: (v: string) => "missingReceiptNotification" | "uncategorizedTransactionNotification" | "pendingBillApprovalNotification" | "pendingReimbursementApprovalNotification";
|
|
9
|
+
declare type ReminderTypeKey = ReturnType<typeof toReminderTypeKey>;
|
|
10
|
+
declare const toReminderFlagTypeKey: (v: string) => "isMissingReceiptNotificationActive" | "isUncategorizedTransactionNotificationActive" | "isPendingBillApprovalNotificationActive" | "isPendingReimbursementApprovalNotificationActive";
|
|
11
|
+
declare type ReminderFlagTypeKey = ReturnType<typeof toReminderFlagTypeKey>;
|
|
12
|
+
export declare type ReminderNotificationSettingsLocalData = Record<ReminderFlagTypeKey, boolean | null>;
|
|
13
|
+
export interface NotificationSettingsLocalData {
|
|
14
|
+
reminders: ReminderNotificationSettingsLocalData;
|
|
15
|
+
}
|
|
16
|
+
interface ReminderNotificationSettingDetails {
|
|
17
|
+
active: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare type ReminderNotificationSettingsData = Record<ReminderTypeKey, ReminderNotificationSettingDetails | null>;
|
|
20
|
+
export interface NotificationSettings extends FetchStateAndError {
|
|
21
|
+
notificationSettings: ReminderNotificationSettingsData;
|
|
22
|
+
notificationSettingsLocalData: NotificationSettingsLocalData;
|
|
23
|
+
updateStatus: FetchStateAndError;
|
|
24
|
+
}
|
|
8
25
|
export interface SettingsViewState {
|
|
9
26
|
profile: MyProfile;
|
|
10
27
|
bankConnection: BankConnection;
|
|
28
|
+
notification: NotificationSettings;
|
|
11
29
|
}
|
|
12
30
|
export {};
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
4
|
+
const REMINDER_NOTIFICATION_TYPES = [
|
|
5
|
+
'missingReceiptNotification',
|
|
6
|
+
'uncategorizedTransactionNotification',
|
|
7
|
+
'pendingBillApprovalNotification',
|
|
8
|
+
'pendingReimbursementApprovalNotification',
|
|
9
|
+
];
|
|
10
|
+
const REMINDER_NOTIFICATION_FLAG_TYPES = [
|
|
11
|
+
'isMissingReceiptNotificationActive',
|
|
12
|
+
'isUncategorizedTransactionNotificationActive',
|
|
13
|
+
'isPendingBillApprovalNotificationActive',
|
|
14
|
+
'isPendingReimbursementApprovalNotificationActive',
|
|
15
|
+
];
|
|
16
|
+
const toReminderTypeKey = (v) => (0, stringToUnion_1.stringToUnion)(v, REMINDER_NOTIFICATION_TYPES);
|
|
17
|
+
const toReminderFlagTypeKey = (v) => (0, stringToUnion_1.stringToUnion)(v, REMINDER_NOTIFICATION_FLAG_TYPES);
|
|
@@ -74,6 +74,7 @@ export interface EditBillDetailSelectorView extends SelectorView {
|
|
|
74
74
|
billPayConfigList: BillPayConfig[];
|
|
75
75
|
file: Attachment | undefined;
|
|
76
76
|
previousBills: PreviousBillsSelectorView;
|
|
77
|
+
showVendorGptRecommendationText: boolean;
|
|
77
78
|
isCancelled: boolean;
|
|
78
79
|
isDeleted: boolean;
|
|
79
80
|
showAutofill: boolean;
|
|
@@ -30,7 +30,7 @@ const transferDetailSelector_1 = require("../../zeniAccounts/transferDetail/tran
|
|
|
30
30
|
const depositAccountListSelector_1 = require("../../zeniAccounts/depositAccountList/depositAccountListSelector");
|
|
31
31
|
const depositAccountSelector_1 = require("../../../../entity/depositAccount/depositAccountSelector");
|
|
32
32
|
const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAccountsEnabled, billId) => {
|
|
33
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
34
34
|
const { accountListState, accountState, bankAccountState, billDetailViewState, setupViewState, billTransactionState, billPayConfigState, classListState, classState, editBillDetailViewState, paymentAccountState, vendorState, tenantState, companyState, userState, commonHistoryState, contactState, paymentInstrumentState, recurringBillState, depositAccountListState, depositAccountState, } = state;
|
|
35
35
|
const transaction = (0, get_1.default)(billTransactionState.transactionById, billId !== null && billId !== void 0 ? billId : '', undefined);
|
|
36
36
|
let recommendations = {};
|
|
@@ -41,6 +41,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
41
41
|
const sourceBillDetail = billId != null
|
|
42
42
|
? (_a = editBillDetailViewState.editBillStateById) === null || _a === void 0 ? void 0 : _a[key]
|
|
43
43
|
: editBillDetailViewState.newBillState;
|
|
44
|
+
const showVendorGptRecommendationText = (_b = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.billDetailLocalData.showVendorGptRecommendationText) !== null && _b !== void 0 ? _b : false;
|
|
44
45
|
let vendorDetails;
|
|
45
46
|
let recommendedVendor;
|
|
46
47
|
let lastRecommendedVendorName;
|
|
@@ -91,10 +92,10 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
91
92
|
let qboId;
|
|
92
93
|
const { currentTenantId } = tenantState;
|
|
93
94
|
const bookCloseDate = currentTenantId != null
|
|
94
|
-
? (
|
|
95
|
+
? (_d = (_c = tenantState.tenantsById) === null || _c === void 0 ? void 0 : _c[currentTenantId]) === null || _d === void 0 ? void 0 : _d.bookCloseDate
|
|
95
96
|
: undefined;
|
|
96
97
|
const companyId = currentTenantId != null
|
|
97
|
-
? (
|
|
98
|
+
? (_f = (_e = tenantState.tenantsById) === null || _e === void 0 ? void 0 : _e[currentTenantId]) === null || _f === void 0 ? void 0 : _f.companyId
|
|
98
99
|
: undefined;
|
|
99
100
|
const currentCompany = (0, companySelector_1.getCompanyByCompanyId)(companyState, companyId !== null && companyId !== void 0 ? companyId : '');
|
|
100
101
|
const payNowCutOffTime = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach;
|
|
@@ -116,15 +117,15 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
116
117
|
let recurringConfig;
|
|
117
118
|
let recurringBillInstances;
|
|
118
119
|
if (billId != null) {
|
|
119
|
-
isDeleted = (
|
|
120
|
-
createdBy = (0, userSelector_1.getUserByUserId)(userState, (
|
|
120
|
+
isDeleted = (_g = transaction === null || transaction === void 0 ? void 0 : transaction.isDeleted) !== null && _g !== void 0 ? _g : false;
|
|
121
|
+
createdBy = (0, userSelector_1.getUserByUserId)(userState, (_h = transaction === null || transaction === void 0 ? void 0 : transaction.createdBy) !== null && _h !== void 0 ? _h : '');
|
|
121
122
|
createTime = transaction === null || transaction === void 0 ? void 0 : transaction.createTime;
|
|
122
|
-
qboId = (
|
|
123
|
+
qboId = (_j = transaction === null || transaction === void 0 ? void 0 : transaction.account) === null || _j === void 0 ? void 0 : _j.qboId;
|
|
123
124
|
billPayInfo = transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo;
|
|
124
125
|
toAccountVendorEmail = transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.toAccountVendorEmail;
|
|
125
126
|
isCollectToAccountInfoFromVendorContact =
|
|
126
|
-
(
|
|
127
|
-
const initialVendor = (0, vendorSelector_1.getVendorByQboId)(vendorState, (
|
|
127
|
+
(_k = transaction === null || transaction === void 0 ? void 0 : transaction.billPayInfo.isCollectToAccountInfoFromVendorContact) !== null && _k !== void 0 ? _k : false;
|
|
128
|
+
const initialVendor = (0, vendorSelector_1.getVendorByQboId)(vendorState, (_m = (_l = transaction === null || transaction === void 0 ? void 0 : transaction.vendor) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : '');
|
|
128
129
|
const initialWhatForSection = {
|
|
129
130
|
invoiceNumber: transaction === null || transaction === void 0 ? void 0 : transaction.documentId,
|
|
130
131
|
invoiceDate: transaction === null || transaction === void 0 ? void 0 : transaction.date,
|
|
@@ -133,7 +134,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
133
134
|
};
|
|
134
135
|
const updatesByLineId = {};
|
|
135
136
|
if (accountList.fetchState === 'Completed') {
|
|
136
|
-
(
|
|
137
|
+
(_o = transaction === null || transaction === void 0 ? void 0 : transaction.lines) === null || _o === void 0 ? void 0 : _o.forEach((line) => {
|
|
137
138
|
var _a;
|
|
138
139
|
updatesByLineId[line.id] = Object.assign(Object.assign({}, line), { account: (_a = accountList.accounts.find((account) => {
|
|
139
140
|
var _a;
|
|
@@ -143,10 +144,10 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
const initialPaymentDetailsSection = {
|
|
146
|
-
paymentType: (0, exports.getPaymentMethodType)(billPayConfigState, (
|
|
147
|
+
paymentType: (0, exports.getPaymentMethodType)(billPayConfigState, (_p = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.fromAccount.billAccountType) !== null && _p !== void 0 ? _p : 'depositAccount', billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.billPaymentMethodType, billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.internationalTransferFeeBearerPaymentMethod),
|
|
147
148
|
paymentDate: billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.paymentDate,
|
|
148
|
-
withdrawFrom: (0, exports.getWithdrawFrom)(paymentAccountState, depositAccountState, (
|
|
149
|
-
paymentTo: ((
|
|
149
|
+
withdrawFrom: (0, exports.getWithdrawFrom)(paymentAccountState, depositAccountState, (_q = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.fromAccount.billAccountId) !== null && _q !== void 0 ? _q : '', (_r = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.fromAccount.billAccountType) !== null && _r !== void 0 ? _r : ''),
|
|
150
|
+
paymentTo: ((_s = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.toAccount.billAccountId) === null || _s === void 0 ? void 0 : _s.length) != null &&
|
|
150
151
|
(billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.toAccount.billAccountId.length) > 0
|
|
151
152
|
? billPayInfo.toAccount.billAccountId
|
|
152
153
|
: undefined,
|
|
@@ -163,7 +164,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
163
164
|
if (sourceBillDetail != null) {
|
|
164
165
|
const billViewState = billDetailViewState.billDetailById[key];
|
|
165
166
|
isCancelled = sourceBillDetail.billDetailLocalData.isCancelled;
|
|
166
|
-
billStage = (
|
|
167
|
+
billStage = (_t = billPayInfo === null || billPayInfo === void 0 ? void 0 : billPayInfo.stage.code) !== null && _t !== void 0 ? _t : 'draft';
|
|
167
168
|
if (billViewState != null) {
|
|
168
169
|
fetchState = (0, reduceFetchState_1.reduceFetchState)([
|
|
169
170
|
sourceBillDetail.fetchStatus,
|
|
@@ -175,7 +176,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
//recurringBill Details
|
|
178
|
-
isRecurring = (
|
|
179
|
+
isRecurring = (_u = transaction === null || transaction === void 0 ? void 0 : transaction.isRecurring) !== null && _u !== void 0 ? _u : false;
|
|
179
180
|
if (isRecurring && transaction != null) {
|
|
180
181
|
const { recurringConfigLocalData, recurringBillInstancesLocalData } = (0, exports.getRecurringBillLocalData)(recurringBillState, transaction);
|
|
181
182
|
recurringConfig = recurringConfigLocalData;
|
|
@@ -205,9 +206,9 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
205
206
|
? (0, vendorSelector_1.getVendorByVendorId)(vendorState, updatedRecord.vendor.id)
|
|
206
207
|
: undefined;
|
|
207
208
|
file = updatedRecord.file;
|
|
208
|
-
const bankAccInBill = (0, bankAccountSelector_1.getBankAccountByBankAccountId)(bankAccountState, (
|
|
209
|
-
const vendorBankAccounts = (0, bankAccountSelector_1.getBankAccountsByBankAccountIds)(bankAccountState, (
|
|
210
|
-
const vendorPaymentInstruments = (0, paymentInstrumentSelector_1.getPaymentInstrumentsByIds)(paymentInstrumentState, (
|
|
209
|
+
const bankAccInBill = (0, bankAccountSelector_1.getBankAccountByBankAccountId)(bankAccountState, (_w = (_v = updatedRecord.paymentDetailsSection) === null || _v === void 0 ? void 0 : _v.paymentTo) !== null && _w !== void 0 ? _w : '');
|
|
210
|
+
const vendorBankAccounts = (0, bankAccountSelector_1.getBankAccountsByBankAccountIds)(bankAccountState, (_x = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.bankAccountIds) !== null && _x !== void 0 ? _x : []);
|
|
211
|
+
const vendorPaymentInstruments = (0, paymentInstrumentSelector_1.getPaymentInstrumentsByIds)(paymentInstrumentState, (_y = vendorDetails === null || vendorDetails === void 0 ? void 0 : vendorDetails.paymentInstrumentIds) !== null && _y !== void 0 ? _y : []);
|
|
211
212
|
const isBankAccInBillExistInVendor = bankAccInBill != null
|
|
212
213
|
? vendorBankAccounts
|
|
213
214
|
.map((bankAc) => bankAc.bankAccountId)
|
|
@@ -257,7 +258,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
257
258
|
(recommendedVendor === null || recommendedVendor === void 0 ? void 0 : recommendedVendor.vendorCurrencyCode) != null) {
|
|
258
259
|
whatForSection.currencyCode = recommendedVendor.vendorCurrencyCode;
|
|
259
260
|
}
|
|
260
|
-
isRecurring = (
|
|
261
|
+
isRecurring = (_z = sourceBillDetail.billDetailLocalData.isRecurring) !== null && _z !== void 0 ? _z : false;
|
|
261
262
|
recurringConfig = sourceBillDetail.billDetailLocalData.recurringConfig;
|
|
262
263
|
recurringBillInstances =
|
|
263
264
|
sourceBillDetail.billDetailLocalData.recurringBillInstances;
|
|
@@ -277,7 +278,7 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
277
278
|
}
|
|
278
279
|
const vendorContactSaveStatus = editBillDetailViewState.updateVendorContactState;
|
|
279
280
|
const lineDetailSection = {};
|
|
280
|
-
const lineDetailSectionUpdatesByLineId = (
|
|
281
|
+
const lineDetailSectionUpdatesByLineId = (_1 = (_0 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.billDetailLocalData) === null || _0 === void 0 ? void 0 : _0.updatesByLineId) !== null && _1 !== void 0 ? _1 : {};
|
|
281
282
|
const classList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
282
283
|
if (accountList.fetchState === 'Completed') {
|
|
283
284
|
Object.keys(lineDetailSectionUpdatesByLineId).forEach((lineId) => {
|
|
@@ -299,13 +300,14 @@ const getEditBillDetail = (state, isVendorRecommendationFeatureEnabled, isZeniAc
|
|
|
299
300
|
const classHeirarchyList = (0, classListSelector_1.getNestedClassListHeirarchy)(classListState);
|
|
300
301
|
const duplicateBills = (0, billPayReviewSelector_1.getDuplicateBills)(state, billId);
|
|
301
302
|
return {
|
|
303
|
+
showVendorGptRecommendationText,
|
|
302
304
|
recommendedVendor,
|
|
303
305
|
lastRecommendedVendorName,
|
|
304
306
|
duplicateBills,
|
|
305
307
|
fetchState: fetchState,
|
|
306
|
-
saveStatus: (
|
|
307
|
-
error: (
|
|
308
|
-
uploadStatus: (
|
|
308
|
+
saveStatus: (_2 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.saveStatus) !== null && _2 !== void 0 ? _2 : undefined,
|
|
309
|
+
error: (_4 = (_3 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.fetchStatus) === null || _3 === void 0 ? void 0 : _3.error) !== null && _4 !== void 0 ? _4 : undefined,
|
|
310
|
+
uploadStatus: (_5 = sourceBillDetail === null || sourceBillDetail === void 0 ? void 0 : sourceBillDetail.uploadFetchState) !== null && _5 !== void 0 ? _5 : undefined,
|
|
309
311
|
version: 0,
|
|
310
312
|
createdBy,
|
|
311
313
|
createTime,
|
|
@@ -45,6 +45,7 @@ export interface RecurringBillInstance {
|
|
|
45
45
|
billPaymentStatus?: RecurringBillPaymentStatus;
|
|
46
46
|
}
|
|
47
47
|
export interface BillDetailLocalData {
|
|
48
|
+
showVendorGptRecommendationText: boolean;
|
|
48
49
|
vendor?: Vendor;
|
|
49
50
|
candidateVendorname?: string;
|
|
50
51
|
whatForSection?: WhatForSection;
|
package/lib/view/spendManagement/billPay/editBillView/epics/initializeBillToLocalStoreEpic.js
CHANGED
|
@@ -174,6 +174,7 @@ const initializeBillToLocalStoreEpic = (actions$, state$) => actions$.pipe((0, o
|
|
|
174
174
|
recurringBillInstances = recurringBillInstancesLocalData;
|
|
175
175
|
}
|
|
176
176
|
const billDetailLocalData = {
|
|
177
|
+
showVendorGptRecommendationText: false,
|
|
177
178
|
vendor,
|
|
178
179
|
whatForSection,
|
|
179
180
|
updatesByLineId,
|
|
@@ -10,5 +10,5 @@ import { fetchPreviousBills } from '../../previousBills/previousBillsReducer';
|
|
|
10
10
|
import { fetchDuplicateBill } from '../../billPayReview/billPayReviewReducer';
|
|
11
11
|
export declare type ActionType = ReturnType<typeof parseInvoiceToBill> | ReturnType<typeof saveBillUpdatesToLocalStore> | ReturnType<typeof fetchClassList> | ReturnType<typeof fetchPreviousBills> | ReturnType<typeof fetchDuplicateBill> | ReturnType<typeof updateShowAutofill> | ReturnType<typeof updateAddBillAutoFields> | ReturnType<typeof updateBillUploadFetchState>;
|
|
12
12
|
export declare const parseInvoiceToBillEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
13
|
-
export declare const toBillDetailLocalData: (state: RootState, billPayload: Partial<BillTransactionPayload>, vendor: Vendor | undefined, recommendedVendorId?: string | undefined) => BillDetailLocalData;
|
|
13
|
+
export declare const toBillDetailLocalData: (state: RootState, showVendorGptRecommendationText: boolean, billPayload: Partial<BillTransactionPayload>, vendor: Vendor | undefined, recommendedVendorId?: string | undefined) => BillDetailLocalData;
|
|
14
14
|
export declare const getAutoFieldsData: (finalBill: BillDetailLocalData, isVendorWithNewCurrency: boolean, tentativeVendorName?: string | undefined, currencyInInvoice?: string | undefined, vendorCurrency?: string | undefined) => AddBillAutoFields;
|
|
@@ -54,6 +54,7 @@ const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators
|
|
|
54
54
|
let vendorCurrency = '';
|
|
55
55
|
const vendors = (0, vendorListSelector_1.getVendorList)(state).vendors;
|
|
56
56
|
let recommendedVendorId;
|
|
57
|
+
let showVendorGptRecommendationText = false;
|
|
57
58
|
let suggestedVendor;
|
|
58
59
|
if (vendorNameFromInvoice != null && vendorNameFromInvoice.length > 0) {
|
|
59
60
|
finalVendor = vendors.filter((vendor) => vendor.name.toLowerCase() === vendorNameFromInvoice.toLowerCase())[0];
|
|
@@ -71,6 +72,7 @@ const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators
|
|
|
71
72
|
if (matchScore > 85) {
|
|
72
73
|
if (vendorCurrency === currencyInInvoice) {
|
|
73
74
|
finalVendor = suggestedVendor;
|
|
75
|
+
showVendorGptRecommendationText = true;
|
|
74
76
|
}
|
|
75
77
|
else {
|
|
76
78
|
isVendorWithNewCurrency = true;
|
|
@@ -81,6 +83,7 @@ const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators
|
|
|
81
83
|
vendorNameFromInvoice.toLowerCase()) {
|
|
82
84
|
if (vendorCurrency === currencyInInvoice) {
|
|
83
85
|
finalVendor = suggestedVendor;
|
|
86
|
+
showVendorGptRecommendationText = true;
|
|
84
87
|
}
|
|
85
88
|
else {
|
|
86
89
|
isVendorWithNewCurrency = true;
|
|
@@ -89,12 +92,13 @@ const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators
|
|
|
89
92
|
else {
|
|
90
93
|
recommendedVendorId = suggestedVendor === null || suggestedVendor === void 0 ? void 0 : suggestedVendor.id;
|
|
91
94
|
finalVendor = suggestedVendor;
|
|
95
|
+
showVendorGptRecommendationText = true;
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
const file = (0, attachmentPayload_1.mapFiletoAttachment)(invoiceProcessingPayload.files[0]);
|
|
97
|
-
const finalBill = Object.assign(Object.assign({}, (0, exports.toBillDetailLocalData)(state, invoiceProcessingPayload.bills[0], finalVendor, recommendedVendorId)), { file: file });
|
|
101
|
+
const finalBill = Object.assign(Object.assign({}, (0, exports.toBillDetailLocalData)(state, showVendorGptRecommendationText, invoiceProcessingPayload.bills[0], finalVendor, recommendedVendorId)), { file: file });
|
|
98
102
|
const addBillAutoFields = (0, exports.getAutoFieldsData)(finalBill, isVendorWithNewCurrency, vendorNameFromInvoice, currencyInInvoice, vendorCurrency);
|
|
99
103
|
if (finalVendor != null) {
|
|
100
104
|
return (0, rxjs_1.of)((0, editBillViewReducer_1.saveBillUpdatesToLocalStore)({ billDetailLocalData: finalBill }), (0, previousBillsReducer_1.fetchPreviousBills)(finalVendor.qboId, false), (0, billPayReviewReducer_1.fetchDuplicateBill)(finalVendor.name, finalVendor.id, (_e = (_d = finalBill.totalAmount) === null || _d === void 0 ? void 0 : _d.amount) !== null && _e !== void 0 ? _e : 0, (_f = finalBill.whatForSection) === null || _f === void 0 ? void 0 : _f.invoiceNumber), (0, editBillViewReducer_1.updateShowAutofill)(false), (0, editBillViewReducer_1.updateAddBillAutoFields)(addBillAutoFields), (0, editBillViewReducer_1.updateBillUploadFetchState)({
|
|
@@ -120,7 +124,7 @@ const parseInvoiceToBillEpic = (actions$, state$) => actions$.pipe((0, operators
|
|
|
120
124
|
}
|
|
121
125
|
}));
|
|
122
126
|
exports.parseInvoiceToBillEpic = parseInvoiceToBillEpic;
|
|
123
|
-
const toBillDetailLocalData = (state, billPayload, vendor, recommendedVendorId) => {
|
|
127
|
+
const toBillDetailLocalData = (state, showVendorGptRecommendationText, billPayload, vendor, recommendedVendorId) => {
|
|
124
128
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
125
129
|
const currency = {
|
|
126
130
|
currencyCode: (_a = billPayload.currency_code) !== null && _a !== void 0 ? _a : '',
|
|
@@ -186,6 +190,7 @@ const toBillDetailLocalData = (state, billPayload, vendor, recommendedVendorId)
|
|
|
186
190
|
const fromAccountType = (0, billPayConfigPayload_1.getAccountTypeSubConfigCodeKey)((0, billPayConfigState_1.toAccType)((_m = (_l = billPayload.bill_pay_info) === null || _l === void 0 ? void 0 : _l.from_account.account_type) !== null && _m !== void 0 ? _m : ''));
|
|
187
191
|
return {
|
|
188
192
|
recommendedVendorId,
|
|
193
|
+
showVendorGptRecommendationText,
|
|
189
194
|
lastRecommendedVendorName: recommendedVendorId != null ? vendor === null || vendor === void 0 ? void 0 : vendor.name : undefined,
|
|
190
195
|
vendor: vendor,
|
|
191
196
|
whatForSection: {
|
|
@@ -128,7 +128,9 @@ const getTotalPayments = (startDate, endDate, frequency, currentInstance) => {
|
|
|
128
128
|
switch (frequency) {
|
|
129
129
|
case 'weekly':
|
|
130
130
|
case 'biweekly':
|
|
131
|
-
totalPayments =
|
|
131
|
+
totalPayments =
|
|
132
|
+
endDate.diff(currentStartDate, 'day') /
|
|
133
|
+
getRecurringFrequencyInDays(frequency);
|
|
132
134
|
break;
|
|
133
135
|
case 'monthly':
|
|
134
136
|
totalPayments = endDate.diff(currentStartDate, 'month');
|
|
@@ -168,9 +170,15 @@ function getRecurringBillInstances(startDate, frequency, totalPayments, currentI
|
|
|
168
170
|
const getRecurringFrequencyWithOffset = (frequency) => {
|
|
169
171
|
switch (frequency) {
|
|
170
172
|
case 'weekly':
|
|
171
|
-
return {
|
|
173
|
+
return {
|
|
174
|
+
offSetValue: getRecurringFrequencyInDays(frequency),
|
|
175
|
+
offSetUnit: 'day',
|
|
176
|
+
};
|
|
172
177
|
case 'biweekly':
|
|
173
|
-
return {
|
|
178
|
+
return {
|
|
179
|
+
offSetValue: getRecurringFrequencyInDays(frequency),
|
|
180
|
+
offSetUnit: 'day',
|
|
181
|
+
};
|
|
174
182
|
case 'monthly':
|
|
175
183
|
return { offSetValue: 1, offSetUnit: 'month' };
|
|
176
184
|
case 'quarterly':
|
|
@@ -181,7 +189,6 @@ function getRecurringBillInstances(startDate, frequency, totalPayments, currentI
|
|
|
181
189
|
for (let i = 0; i < totalPayments; i++) {
|
|
182
190
|
updatedInstances.push(Object.assign({ instance: currentInstance + i, isDeleted: false, amount: billAmount }, checkIfHolidayAndGetNextDate(startDate.add(i * offSetValue, offSetUnit))));
|
|
183
191
|
}
|
|
184
|
-
;
|
|
185
192
|
return updatedInstances;
|
|
186
193
|
}
|
|
187
194
|
function getRecurringFrequencyInDays(frequency) {
|
|
@@ -27,6 +27,9 @@ const fetchTransactionListByEntityEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
27
27
|
entity_id: action.payload.entity.id,
|
|
28
28
|
entity_name: action.payload.entity.name,
|
|
29
29
|
entity_type: action.payload.entity.type,
|
|
30
|
+
is_fetch_all_transactions: action.payload.isFetchAllTransactions === true
|
|
31
|
+
? action.payload.isFetchAllTransactions
|
|
32
|
+
: null,
|
|
30
33
|
};
|
|
31
34
|
return zeniAPI
|
|
32
35
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
@@ -4,9 +4,13 @@ import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport
|
|
|
4
4
|
import { Entity } from '../../entity/genericEntity/entity';
|
|
5
5
|
import { SupportedTransaction, TransactionState } from '../../entity/transaction/transactionState';
|
|
6
6
|
import { TransactionListSelectorView, TransactionListState } from './transactionListState';
|
|
7
|
+
import { Month, TimePeriod } from '../../commonStateTypes/timePeriod';
|
|
8
|
+
import { RootState } from '../../reducer';
|
|
7
9
|
export interface TransactionListByEntityView extends SelectorView, TransactionListSelectorView {
|
|
8
10
|
transactionOrder: EntityOrder;
|
|
9
11
|
transactions: SupportedTransaction[];
|
|
10
12
|
entity: Entity;
|
|
11
13
|
}
|
|
12
14
|
export declare const getTransactionListByEntity: (transactionState: TransactionState, transactionListState: TransactionListState, filterByTimePeriod: TimeframeTick, entity: Entity) => TransactionListByEntityView;
|
|
15
|
+
export declare const getTransactionListByEntityForSinglePeriod: (state: RootState, entity: Entity, numberOfQuartersFetched: number) => TransactionListByEntityView;
|
|
16
|
+
export declare function splitPeriodIntoQuarters(numberOfQuartersFetched: number, firstMonthOfFY: Month): TimePeriod[];
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getTransactionListByEntity = void 0;
|
|
6
|
+
exports.splitPeriodIntoQuarters = exports.getTransactionListByEntityForSinglePeriod = exports.getTransactionListByEntity = void 0;
|
|
7
7
|
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
9
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
@@ -12,6 +12,9 @@ const parallelFetchAccountTransactionListEpic_1 = require("./parallelFetchAccoun
|
|
|
12
12
|
const reduceTransactionListFetchState_1 = require("./reduceTransactionListFetchState");
|
|
13
13
|
const transactionListState_1 = require("./transactionListState");
|
|
14
14
|
const transactionSelector_1 = require("../../entity/transaction/transactionSelector");
|
|
15
|
+
const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
|
|
16
|
+
const vendorsTabVendorViewSelector_1 = require("../commonVendorView/vendorsTabVendorView/vendorsTabVendorViewSelector");
|
|
17
|
+
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
15
18
|
const getTransactionListByEntity = (transactionState, transactionListState, filterByTimePeriod, entity) => {
|
|
16
19
|
const timePeriods = (0, parallelFetchAccountTransactionListEpic_1.splitPeriod)((0, timeframeTick_1.toTimePeriod)(filterByTimePeriod)); // Note: Split by months.
|
|
17
20
|
const entityTransactions = timePeriods
|
|
@@ -46,3 +49,61 @@ const getTransactionListByEntity = (transactionState, transactionListState, filt
|
|
|
46
49
|
};
|
|
47
50
|
};
|
|
48
51
|
exports.getTransactionListByEntity = getTransactionListByEntity;
|
|
52
|
+
/*
|
|
53
|
+
NOTE: getTransactionListByEntityForSinglePeriod - this selector is to be used when we are not making parallel fetch
|
|
54
|
+
and thus, do not want to split period month wise - as done in above selector getTransactionListByEntity
|
|
55
|
+
This usecase is on vendors tab detail page, to fetch all transactions tab data
|
|
56
|
+
*/
|
|
57
|
+
const getTransactionListByEntityForSinglePeriod = (state, entity, numberOfQuartersFetched) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const { transactionListState, transactionState } = state;
|
|
60
|
+
const firstMonthOfFY = (_b = (_a = (0, tenantSelector_1.getCurrentTenant)(state).company) === null || _a === void 0 ? void 0 : _a.companyInfo.firstMonthOfFY) !== null && _b !== void 0 ? _b : 1;
|
|
61
|
+
const initialFetchPeriod = (0, timeframeTick_1.toTimePeriod)({
|
|
62
|
+
startDate: (0, vendorsTabVendorViewSelector_1.getVendorAllTransactionsDefaultTimePeriod)(firstMonthOfFY, 2)
|
|
63
|
+
.startDate,
|
|
64
|
+
endDate: (0, zeniDayJS_1.dateNow)(),
|
|
65
|
+
});
|
|
66
|
+
const timePeriods = [
|
|
67
|
+
initialFetchPeriod,
|
|
68
|
+
...splitPeriodIntoQuarters(numberOfQuartersFetched, firstMonthOfFY),
|
|
69
|
+
];
|
|
70
|
+
const entityTransactions = timePeriods
|
|
71
|
+
.map((thisTimePeriod) => {
|
|
72
|
+
const key = (0, transactionListState_1.getEntityTranKey)(entity, thisTimePeriod);
|
|
73
|
+
return (0, get_1.default)(transactionListState.byEntity.transactionListByEntityKey, key, undefined);
|
|
74
|
+
})
|
|
75
|
+
.filter((eTransaction) => eTransaction != null);
|
|
76
|
+
const fetchState = (0, reduceTransactionListFetchState_1.reduceFetchState)(entityTransactions);
|
|
77
|
+
let transactions = [];
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
79
|
+
if ((0, reduceTransactionListFetchState_1.isAnyFetchCompleted)(entityTransactions)) {
|
|
80
|
+
const allTransactionIDs = (0, flatMap_1.default)(entityTransactions, (value) => value.transactionIDs);
|
|
81
|
+
const transactionsUnsorted = allTransactionIDs
|
|
82
|
+
.map((transactionId) => (0, transactionSelector_1.getSupportedTransactionById)(transactionState, transactionId))
|
|
83
|
+
.filter((value) => {
|
|
84
|
+
if (value == null) {
|
|
85
|
+
console.error("Can't have null transaction at this stage!");
|
|
86
|
+
}
|
|
87
|
+
return value != null;
|
|
88
|
+
});
|
|
89
|
+
transactions = (0, orderBy_1.default)(transactionsUnsorted, (value) => value.date.valueOf(), 'desc');
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
version: '1.0',
|
|
93
|
+
fetchState: fetchState.fetchState,
|
|
94
|
+
error: fetchState.error,
|
|
95
|
+
entity: entity,
|
|
96
|
+
transactionOrder: 'descending_transaction_date',
|
|
97
|
+
transactions,
|
|
98
|
+
latestTransactionId: transactionListState.latestTransactionId,
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
exports.getTransactionListByEntityForSinglePeriod = getTransactionListByEntityForSinglePeriod;
|
|
102
|
+
function splitPeriodIntoQuarters(numberOfQuartersFetched, firstMonthOfFY) {
|
|
103
|
+
const result = [];
|
|
104
|
+
for (let index = 0; index <= numberOfQuartersFetched - 1; index++) {
|
|
105
|
+
result.push((0, timeframeTick_1.toTimePeriod)((0, vendorsTabVendorViewSelector_1.getVendorAllTransactionsDefaultTimePeriod)(firstMonthOfFY, index)));
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
exports.splitPeriodIntoQuarters = splitPeriodIntoQuarters;
|
|
@@ -32,10 +32,11 @@ export declare const parallelFetchAccountTransactionList: import("@reduxjs/toolk
|
|
|
32
32
|
entity: Entity;
|
|
33
33
|
period: TimePeriod;
|
|
34
34
|
cacheOverride: any;
|
|
35
|
-
}, string, never, never>, fetchEntityTransactionList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, period: TimePeriod, cacheOverride?: any], {
|
|
35
|
+
}, string, never, never>, fetchEntityTransactionList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, period: TimePeriod, cacheOverride?: any, isFetchAllTransactions?: any], {
|
|
36
36
|
entity: Entity;
|
|
37
37
|
period: TimePeriod;
|
|
38
38
|
cacheOverride: any;
|
|
39
|
+
isFetchAllTransactions: any;
|
|
39
40
|
}, string, never, never>, updateTransactionListByEntity: import("@reduxjs/toolkit").ActionCreatorWithPayload<TransactionListByEntityPayload, string>, updateTransactionListByEntityFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, period: TimePeriod, error: ZeniAPIStatus<Record<string, unknown>>], {
|
|
40
41
|
entity: Entity;
|
|
41
42
|
period: TimePeriod;
|