@zeniai/client-epic-state 4.19.37-betaVR9 → 4.19.38
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 +0 -1
- package/lib/epic.d.ts +1 -9
- package/lib/epic.js +1 -9
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/esm/epic.js +1 -9
- package/lib/esm/index.js +6 -8
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +1 -100
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -264
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +1 -128
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +10 -1
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +4 -2
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +5 -2
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +10 -1
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +4 -2
- package/lib/esm/zeniAPI.js +3 -41
- package/lib/index.d.ts +9 -11
- package/lib/index.js +32 -58
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +0 -108
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +0 -107
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +3 -51
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -265
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -61
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +0 -127
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +0 -104
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +11 -2
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +4 -2
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelectorTypes.d.ts +2 -0
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +1 -0
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -0
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +5 -2
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +2 -0
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +11 -2
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +4 -2
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelectorTypes.d.ts +2 -0
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +1 -0
- package/lib/zeniAPI.d.ts +0 -9
- package/lib/zeniAPI.js +2 -40
- package/package.json +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -24
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -49
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -31
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -41
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -57
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -35
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -27
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -41
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +0 -15
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +0 -28
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +0 -7
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +0 -53
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +0 -35
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +0 -7
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +0 -45
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +0 -61
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +0 -39
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +0 -6
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +0 -31
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +0 -15
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +0 -46
package/lib/zeniAPI.js
CHANGED
|
@@ -82,6 +82,8 @@ class ZeniAPIClient {
|
|
|
82
82
|
return (0, rxjs_1.from)(promise);
|
|
83
83
|
}
|
|
84
84
|
postFormData(restEndPoint, formData, signal) {
|
|
85
|
+
// Use apiHeaders for auth headers, then remove Content-Type
|
|
86
|
+
// so the browser sets multipart/form-data with the correct boundary
|
|
85
87
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
86
88
|
const { 'Content-Type': _contentType, ...headers } = this.apiHeaders();
|
|
87
89
|
const promise = (0, cross_fetch_1.fetch)(restEndPoint, {
|
|
@@ -92,46 +94,6 @@ class ZeniAPIClient {
|
|
|
92
94
|
}).then((response) => this.processJsonResponse(response));
|
|
93
95
|
return (0, rxjs_1.from)(promise);
|
|
94
96
|
}
|
|
95
|
-
postFormDataWithProgress(restEndPoint, formData, signal) {
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
97
|
-
const { 'Content-Type': _ct, ...headers } = this.apiHeaders();
|
|
98
|
-
return new rxjs_1.Observable((subscriber) => {
|
|
99
|
-
const xhr = new XMLHttpRequest();
|
|
100
|
-
xhr.upload.onprogress = (event) => {
|
|
101
|
-
if (event.lengthComputable) {
|
|
102
|
-
const percentage = Math.round((event.loaded / event.total) * 100);
|
|
103
|
-
subscriber.next({ type: 'progress', percentage });
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
xhr.onload = () => {
|
|
107
|
-
try {
|
|
108
|
-
const json = JSON.parse(xhr.responseText);
|
|
109
|
-
this.checkSessionValidity(json);
|
|
110
|
-
subscriber.next({ type: 'response', data: json });
|
|
111
|
-
subscriber.complete();
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
subscriber.error(e);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
xhr.onerror = () => {
|
|
118
|
-
subscriber.error(new Error('Upload failed'));
|
|
119
|
-
};
|
|
120
|
-
xhr.open('POST', restEndPoint);
|
|
121
|
-
Object.entries(headers).forEach(([key, value]) => {
|
|
122
|
-
xhr.setRequestHeader(key, String(value));
|
|
123
|
-
});
|
|
124
|
-
xhr.send(formData);
|
|
125
|
-
if (signal != null) {
|
|
126
|
-
signal.addEventListener('abort', () => xhr.abort());
|
|
127
|
-
}
|
|
128
|
-
return () => {
|
|
129
|
-
if (xhr.readyState !== XMLHttpRequest.DONE) {
|
|
130
|
-
xhr.abort();
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
97
|
deleteAndGetJSON(restEndPoint, body, headers, signal) {
|
|
136
98
|
let apiHeaders = this.apiHeaders(headers);
|
|
137
99
|
if (body != null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.
|
|
3
|
+
"version": "4.19.38",
|
|
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",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"find-dead-code": "ts-prune | grep -v '(used in module)'",
|
|
112
112
|
"find-unused-exports": "ts-unused-exports ./tsconfig.json",
|
|
113
113
|
"circular-dependency": "npx madge --circular --extensions ts ./src",
|
|
114
|
-
"build": "concurrently --kill-others-on-fail --handle-input \"echo 'Running ESLint...' && eslint . --ext .js,.jsx,.ts,.tsx\" \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\"",
|
|
114
|
+
"build": "concurrently --kill-others-on-fail --handle-input \"echo 'Running ESLint...' && eslint . --ext .js,.jsx,.ts,.tsx\" \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\" \"echo 'Running tests and typecheck...' && pnpm test\" && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
|
|
115
115
|
"only-build": "eslint . --ext .js,.jsx,.ts,.tsx && time tsc && tsc -p tsconfig.esm.json && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
|
|
116
116
|
"format": "prettier --write --ignore-unknown \"src/**/*\" && pnpm lint",
|
|
117
117
|
"format-watch": "(git diff --name-only --diff-filter=ACM && git ls-files --others --exclude-standard) | grep -E '\\.(ts|tsx)$' | xargs prettier --write",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
-
import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
5
|
-
export const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(bulkUploadReceipts.match), mergeMap((action) => {
|
|
6
|
-
const { files } = action.payload;
|
|
7
|
-
const formData = new FormData();
|
|
8
|
-
for (const file of files) {
|
|
9
|
-
formData.append('files', file, file.name);
|
|
10
|
-
}
|
|
11
|
-
return zeniAPI
|
|
12
|
-
.postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
|
|
13
|
-
.pipe(mergeMap((response) => {
|
|
14
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
15
|
-
return of(bulkUploadReceiptsSuccess({
|
|
16
|
-
batchId: response.data.batch_id,
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
return of(bulkUploadReceiptsFailure({ error: response.status }));
|
|
20
|
-
}), catchError((error) => of(bulkUploadReceiptsFailure({
|
|
21
|
-
error: createZeniAPIStatus('Unexpected Error', 'Bulk upload receipts API call errored out: ' +
|
|
22
|
-
JSON.stringify(error)),
|
|
23
|
-
}))));
|
|
24
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
-
import { confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export const confirmBulkUploadMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(confirmBulkUploadMatch.match), mergeMap((action) => {
|
|
7
|
-
const { batchId, attachmentId, transactionId, transactionType, fileName } = action.payload;
|
|
8
|
-
return zeniAPI
|
|
9
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`, {
|
|
10
|
-
attachment_id: attachmentId,
|
|
11
|
-
transaction_id: transactionId,
|
|
12
|
-
transaction_type: transactionType,
|
|
13
|
-
file_name: fileName,
|
|
14
|
-
})
|
|
15
|
-
.pipe(mergeMap((response) => {
|
|
16
|
-
if (isSuccessResponse(response)) {
|
|
17
|
-
return from([
|
|
18
|
-
confirmBulkUploadMatchSuccess({
|
|
19
|
-
batchId,
|
|
20
|
-
attachmentId,
|
|
21
|
-
transactionId,
|
|
22
|
-
}),
|
|
23
|
-
openSnackbar({
|
|
24
|
-
messageSection: 'receipt_match',
|
|
25
|
-
messageText: 'success',
|
|
26
|
-
type: 'success',
|
|
27
|
-
}),
|
|
28
|
-
]);
|
|
29
|
-
}
|
|
30
|
-
return from([
|
|
31
|
-
confirmBulkUploadMatchFailure({ error: response.status }),
|
|
32
|
-
openSnackbar({
|
|
33
|
-
messageSection: 'receipt_match',
|
|
34
|
-
messageText: 'failed',
|
|
35
|
-
type: 'error',
|
|
36
|
-
}),
|
|
37
|
-
]);
|
|
38
|
-
}), catchError((error) => from([
|
|
39
|
-
confirmBulkUploadMatchFailure({
|
|
40
|
-
error: createZeniAPIStatus('Unexpected Error', 'Confirm bulk upload match errored out: ' +
|
|
41
|
-
JSON.stringify(error)),
|
|
42
|
-
}),
|
|
43
|
-
openSnackbar({
|
|
44
|
-
messageSection: 'receipt_match',
|
|
45
|
-
messageText: 'failed',
|
|
46
|
-
type: 'error',
|
|
47
|
-
}),
|
|
48
|
-
])));
|
|
49
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
-
import { extractTransactionPayloadsFromBatchFiles, toBatchDetails, } from '../../payload/missingReceiptsPayload';
|
|
6
|
-
import { fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsFailure, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
-
export const fetchBulkUploadBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatchDetails.match), mergeMap(() => {
|
|
8
|
-
const { currentBatchId } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
9
|
-
if (currentBatchId == null) {
|
|
10
|
-
return of(fetchBulkUploadBatchDetailsFailure({
|
|
11
|
-
error: createZeniAPIStatus('Unexpected Error', 'No current batch ID available'),
|
|
12
|
-
}));
|
|
13
|
-
}
|
|
14
|
-
return zeniAPI
|
|
15
|
-
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/batches/${currentBatchId}`)
|
|
16
|
-
.pipe(mergeMap((response) => {
|
|
17
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
18
|
-
const actions = [];
|
|
19
|
-
const transactionPayloads = extractTransactionPayloadsFromBatchFiles(response.data.files);
|
|
20
|
-
if (transactionPayloads.length > 0) {
|
|
21
|
-
actions.push(updateTransactions(transactionPayloads, (value) => value.transaction_id));
|
|
22
|
-
}
|
|
23
|
-
actions.push(fetchBulkUploadBatchDetailsSuccess(toBatchDetails(response.data)));
|
|
24
|
-
actions.push(fetchBulkUploadBatches(true));
|
|
25
|
-
return from(actions);
|
|
26
|
-
}
|
|
27
|
-
return of(fetchBulkUploadBatchDetailsFailure({ error: response.status }));
|
|
28
|
-
}), catchError((error) => of(fetchBulkUploadBatchDetailsFailure({
|
|
29
|
-
error: createZeniAPIStatus('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)),
|
|
30
|
-
}))));
|
|
31
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { convertToPeriod, toMonthYearPeriodId, } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
-
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
|
-
import { toBatchListItem, } from '../../payload/missingReceiptsPayload';
|
|
7
|
-
import { fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
8
|
-
export const fetchBulkUploadBatchesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatches.match), switchMap((action) => {
|
|
9
|
-
const { cacheOverride } = action.payload;
|
|
10
|
-
const state = state$.value;
|
|
11
|
-
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
12
|
-
const currentTenant = getCurrentTenant(state);
|
|
13
|
-
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
14
|
-
const periodId = toMonthYearPeriodId(selectedPeriod);
|
|
15
|
-
const existingBatches = bulkUpload.batchListByPeriod[periodId] ?? [];
|
|
16
|
-
if (cacheOverride !== true && existingBatches.length > 0) {
|
|
17
|
-
return of(fetchBulkUploadBatchesSuccess({
|
|
18
|
-
batchList: existingBatches,
|
|
19
|
-
selectedPeriod,
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
const period = convertToPeriod(selectedPeriod);
|
|
23
|
-
return zeniAPI
|
|
24
|
-
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/batches?start_date=${period.start}&end_date=${period.end}`)
|
|
25
|
-
.pipe(mergeMap((response) => {
|
|
26
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
27
|
-
return of(fetchBulkUploadBatchesSuccess({
|
|
28
|
-
batchList: response.data.batches.map(toBatchListItem),
|
|
29
|
-
selectedPeriod,
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
return of(fetchBulkUploadBatchesFailure({
|
|
33
|
-
error: response.status,
|
|
34
|
-
selectedPeriod,
|
|
35
|
-
}));
|
|
36
|
-
}), catchError((error) => of(fetchBulkUploadBatchesFailure({
|
|
37
|
-
error: createZeniAPIStatus('Unexpected Error', 'Fetch bulk upload batches errored out: ' +
|
|
38
|
-
JSON.stringify(error)),
|
|
39
|
-
selectedPeriod,
|
|
40
|
-
}))));
|
|
41
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { convertToPeriod, toMonthYearPeriodId, } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
-
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
6
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
7
|
-
import { fetchCompletedTransactions, fetchCompletedTransactionsFailure, fetchCompletedTransactionsSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
8
|
-
export const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchCompletedTransactions.match), switchMap((action) => {
|
|
9
|
-
const state = state$.value;
|
|
10
|
-
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
11
|
-
const currentTenant = getCurrentTenant(state);
|
|
12
|
-
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
13
|
-
const periodId = toMonthYearPeriodId(selectedPeriod);
|
|
14
|
-
const isInitialLoad = action.payload.pageToken == null;
|
|
15
|
-
const existingData = bulkUpload.completedTransactionsByPeriod[periodId];
|
|
16
|
-
if (isInitialLoad && existingData != null && existingData.transactionIds.length > 0) {
|
|
17
|
-
return from([]);
|
|
18
|
-
}
|
|
19
|
-
const period = convertToPeriod(selectedPeriod);
|
|
20
|
-
const queryPayload = {
|
|
21
|
-
start_date: period.start,
|
|
22
|
-
end_date: period.end,
|
|
23
|
-
sort_by: bulkUpload.sortKey,
|
|
24
|
-
sort_order: bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc',
|
|
25
|
-
page_token: action.payload.pageToken ?? null,
|
|
26
|
-
page_size: 25,
|
|
27
|
-
};
|
|
28
|
-
if (bulkUpload.completedSubTab !== 'all') {
|
|
29
|
-
queryPayload.match_type = bulkUpload.completedSubTab;
|
|
30
|
-
}
|
|
31
|
-
const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
|
|
32
|
-
return zeniAPI
|
|
33
|
-
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${encodedQuery}`)
|
|
34
|
-
.pipe(mergeMap((response) => {
|
|
35
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
36
|
-
const transactionIds = response.data.transactions.map((t) => t.transaction_id);
|
|
37
|
-
const updateActions = [];
|
|
38
|
-
updateActions.push(updateTransactions(response.data.transactions, (value) => value.transaction_id));
|
|
39
|
-
updateActions.push(fetchCompletedTransactionsSuccess({
|
|
40
|
-
isInitialLoad,
|
|
41
|
-
transactionIds,
|
|
42
|
-
nextPageToken: response.data.next_page_token,
|
|
43
|
-
totalCount: response.data.total_count,
|
|
44
|
-
selectedPeriod,
|
|
45
|
-
}));
|
|
46
|
-
return from(updateActions);
|
|
47
|
-
}
|
|
48
|
-
return of(fetchCompletedTransactionsFailure({
|
|
49
|
-
error: response.status,
|
|
50
|
-
selectedPeriod,
|
|
51
|
-
}));
|
|
52
|
-
}), catchError((error) => of(fetchCompletedTransactionsFailure({
|
|
53
|
-
error: createZeniAPIStatus('Unexpected Error', 'Fetch completed transactions errored: ' +
|
|
54
|
-
JSON.stringify(error)),
|
|
55
|
-
selectedPeriod,
|
|
56
|
-
}))));
|
|
57
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { EMPTY, from } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
-
import { extractTransactionPayloadsFromBatchFiles, toBatchDetails, } from '../../payload/missingReceiptsPayload';
|
|
6
|
-
import { fetchBulkUploadBatchesSuccess, storeBatchDetails, } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
-
export const fetchMultipleBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBulkUploadBatchesSuccess.match), mergeMap((action) => {
|
|
8
|
-
const batchList = action.payload.batchList;
|
|
9
|
-
const { batchDetailsById } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
10
|
-
const completedBatchIds = batchList
|
|
11
|
-
.filter((batch) => batch.status === 'completed' &&
|
|
12
|
-
batchDetailsById[batch.batchId] == null)
|
|
13
|
-
.map((batch) => batch.batchId);
|
|
14
|
-
if (completedBatchIds.length === 0) {
|
|
15
|
-
return EMPTY;
|
|
16
|
-
}
|
|
17
|
-
return from(completedBatchIds).pipe(mergeMap((batchId) => zeniAPI
|
|
18
|
-
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}`)
|
|
19
|
-
.pipe(mergeMap((response) => {
|
|
20
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
21
|
-
const actions = [];
|
|
22
|
-
const transactionPayloads = extractTransactionPayloadsFromBatchFiles(response.data.files);
|
|
23
|
-
if (transactionPayloads.length > 0) {
|
|
24
|
-
actions.push(updateTransactions(transactionPayloads, (value) => value.transaction_id));
|
|
25
|
-
}
|
|
26
|
-
actions.push(storeBatchDetails(toBatchDetails(response.data)));
|
|
27
|
-
return from(actions);
|
|
28
|
-
}
|
|
29
|
-
return EMPTY;
|
|
30
|
-
}), catchError((error) => {
|
|
31
|
-
console.error(`Failed to fetch batch details for ${batchId}:`, createZeniAPIStatus('Unexpected Error', 'Fetch batch details errored out: ' +
|
|
32
|
-
JSON.stringify(error)));
|
|
33
|
-
return EMPTY;
|
|
34
|
-
})), 5));
|
|
35
|
-
}));
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, debounceTime, filter, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
-
import { toManualSearchResult, } from '../../payload/missingReceiptsPayload';
|
|
5
|
-
import { searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export const searchTransactionsForManualMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(searchTransactionsForManualMatch.match), debounceTime(300), switchMap((action) => {
|
|
7
|
-
const { query } = action.payload;
|
|
8
|
-
const searchQuery = JSON.stringify({
|
|
9
|
-
search_text: query,
|
|
10
|
-
search_fields: ['date', 'amount', 'vendor_name'],
|
|
11
|
-
});
|
|
12
|
-
const encodedQuery = encodeURIComponent(searchQuery);
|
|
13
|
-
return zeniAPI
|
|
14
|
-
.getJSON(`${zeniAPI.apiEndPoints.searchMicroServiceBaseUrl}/1.0/transaction-search?query=${encodedQuery}`)
|
|
15
|
-
.pipe(switchMap((response) => {
|
|
16
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
17
|
-
const results = response.data.transactions.map(toManualSearchResult);
|
|
18
|
-
return of(searchTransactionsForManualMatchSuccess(results));
|
|
19
|
-
}
|
|
20
|
-
return of(searchTransactionsForManualMatchFailure({
|
|
21
|
-
error: response.status,
|
|
22
|
-
}));
|
|
23
|
-
}), catchError((error) => of(searchTransactionsForManualMatchFailure({
|
|
24
|
-
error: createZeniAPIStatus('Unexpected Error', 'Search transactions for manual match errored: ' +
|
|
25
|
-
JSON.stringify(error)),
|
|
26
|
-
}))));
|
|
27
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { of, timer } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap, takeUntil, takeWhile, } from 'rxjs/operators';
|
|
3
|
-
import { isSuccessResponse } from '../../../../responsePayload';
|
|
4
|
-
import { toBatchStatus, } from '../../payload/missingReceiptsPayload';
|
|
5
|
-
import { bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetails, pusherBatchStatusUpdate, updateBulkUploadBatchStatus, } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
/**
|
|
7
|
-
* Watches batch status using two strategies:
|
|
8
|
-
* 1. Pusher (primary): Reacts to `pusherBatchStatusUpdate` dispatched by the UI layer
|
|
9
|
-
* when a Pusher event arrives. Immediately fetches full details on completion.
|
|
10
|
-
* 2. Polling (fallback): Starts a relaxed 10s poll after upload success as a safety net
|
|
11
|
-
* in case the Pusher event is missed. Stops on completion or `clearBulkUpload`.
|
|
12
|
-
*/
|
|
13
|
-
// Pusher-driven: when Pusher delivers a completed status, fetch details
|
|
14
|
-
export const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe(filter(pusherBatchStatusUpdate.match), filter((action) => action.payload.status === 'completed'), mergeMap(() => of(fetchBulkUploadBatchDetails())));
|
|
15
|
-
// Polling fallback: relaxed interval as safety net
|
|
16
|
-
const FALLBACK_POLL_INTERVAL_MS = 10000;
|
|
17
|
-
export const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(bulkUploadReceiptsSuccess.match), switchMap((action) => {
|
|
18
|
-
const { batchId } = action.payload;
|
|
19
|
-
return timer(0, FALLBACK_POLL_INTERVAL_MS).pipe(takeUntil(actions$.pipe(filter((a) => clearBulkUpload.match(a) ||
|
|
20
|
-
(pusherBatchStatusUpdate.match(a) &&
|
|
21
|
-
a.payload.status === 'completed')))), switchMap(() => zeniAPI
|
|
22
|
-
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/batches/${batchId}/status`)
|
|
23
|
-
.pipe(mergeMap((response) => {
|
|
24
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
25
|
-
const batchStatus = toBatchStatus(response.data);
|
|
26
|
-
const actions = [
|
|
27
|
-
updateBulkUploadBatchStatus(batchStatus),
|
|
28
|
-
];
|
|
29
|
-
if (batchStatus.status === 'completed') {
|
|
30
|
-
actions.push(fetchBulkUploadBatchDetails());
|
|
31
|
-
}
|
|
32
|
-
return actions;
|
|
33
|
-
}
|
|
34
|
-
return [];
|
|
35
|
-
}), catchError(() => of()))), takeWhile((action) => {
|
|
36
|
-
if (fetchBulkUploadBatchDetails.match(action)) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
}, true));
|
|
41
|
-
}));
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
3
|
-
import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
4
|
-
export type ActionType = ReturnType<typeof bulkUploadReceipts> | ReturnType<typeof bulkUploadReceiptsSuccess> | ReturnType<typeof bulkUploadReceiptsFailure>;
|
|
5
|
-
export declare const bulkUploadReceiptsEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
6
|
-
payload: {
|
|
7
|
-
batchId: import("../../../..").ID;
|
|
8
|
-
};
|
|
9
|
-
type: "expenseAutomationMissingReceiptsView/bulkUploadReceiptsSuccess";
|
|
10
|
-
} | {
|
|
11
|
-
payload: {
|
|
12
|
-
error: import("../../../../responsePayload").ZeniAPIStatus;
|
|
13
|
-
};
|
|
14
|
-
type: "expenseAutomationMissingReceiptsView/bulkUploadReceiptsFailure";
|
|
15
|
-
}>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bulkUploadReceiptsEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
8
|
-
const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceipts.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
-
const { files } = action.payload;
|
|
10
|
-
const formData = new FormData();
|
|
11
|
-
for (const file of files) {
|
|
12
|
-
formData.append('files', file, file.name);
|
|
13
|
-
}
|
|
14
|
-
return zeniAPI
|
|
15
|
-
.postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
|
|
16
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
17
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
18
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess)({
|
|
19
|
-
batchId: response.data.batch_id,
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({ error: response.status }));
|
|
23
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsFailure)({
|
|
24
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Bulk upload receipts API call errored out: ' +
|
|
25
|
-
JSON.stringify(error)),
|
|
26
|
-
}))));
|
|
27
|
-
}));
|
|
28
|
-
exports.bulkUploadReceiptsEpic = bulkUploadReceiptsEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
-
import { confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof confirmBulkUploadMatch> | ReturnType<typeof confirmBulkUploadMatchSuccess> | ReturnType<typeof confirmBulkUploadMatchFailure> | ReturnType<typeof openSnackbar>;
|
|
7
|
-
export declare const confirmBulkUploadMatchEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.confirmBulkUploadMatchEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
9
|
-
const confirmBulkUploadMatchEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.confirmBulkUploadMatch.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
-
const { batchId, attachmentId, transactionId, transactionType, fileName } = action.payload;
|
|
11
|
-
return zeniAPI
|
|
12
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`, {
|
|
13
|
-
attachment_id: attachmentId,
|
|
14
|
-
transaction_id: transactionId,
|
|
15
|
-
transaction_type: transactionType,
|
|
16
|
-
file_name: fileName,
|
|
17
|
-
})
|
|
18
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
19
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
20
|
-
return (0, rxjs_1.from)([
|
|
21
|
-
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchSuccess)({
|
|
22
|
-
batchId,
|
|
23
|
-
attachmentId,
|
|
24
|
-
transactionId,
|
|
25
|
-
}),
|
|
26
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
27
|
-
messageSection: 'receipt_match',
|
|
28
|
-
messageText: 'success',
|
|
29
|
-
type: 'success',
|
|
30
|
-
}),
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
return (0, rxjs_1.from)([
|
|
34
|
-
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({ error: response.status }),
|
|
35
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
36
|
-
messageSection: 'receipt_match',
|
|
37
|
-
messageText: 'failed',
|
|
38
|
-
type: 'error',
|
|
39
|
-
}),
|
|
40
|
-
]);
|
|
41
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
42
|
-
(0, missingReceiptsViewReducer_1.confirmBulkUploadMatchFailure)({
|
|
43
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Confirm bulk upload match errored out: ' +
|
|
44
|
-
JSON.stringify(error)),
|
|
45
|
-
}),
|
|
46
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
47
|
-
messageSection: 'receipt_match',
|
|
48
|
-
messageText: 'failed',
|
|
49
|
-
type: 'error',
|
|
50
|
-
}),
|
|
51
|
-
])));
|
|
52
|
-
}));
|
|
53
|
-
exports.confirmBulkUploadMatchEpic = confirmBulkUploadMatchEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { RootState } from '../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
-
import { fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsFailure, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchBulkUploadBatchDetails> | ReturnType<typeof updateTransactions> | ReturnType<typeof fetchBulkUploadBatchDetailsSuccess> | ReturnType<typeof fetchBulkUploadBatchDetailsFailure> | ReturnType<typeof fetchBulkUploadBatches>;
|
|
8
|
-
export declare const fetchBulkUploadBatchDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchBulkUploadBatchDetailsEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
-
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
9
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
10
|
-
const fetchBulkUploadBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatchDetails.match), (0, operators_1.mergeMap)(() => {
|
|
11
|
-
const { currentBatchId } = state$.value.expenseAutomationMissingReceiptsViewState.bulkUpload;
|
|
12
|
-
if (currentBatchId == null) {
|
|
13
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({
|
|
14
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No current batch ID available'),
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
return zeniAPI
|
|
18
|
-
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/batches/${currentBatchId}`)
|
|
19
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
20
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
21
|
-
const actions = [];
|
|
22
|
-
const transactionPayloads = (0, missingReceiptsPayload_1.extractTransactionPayloadsFromBatchFiles)(response.data.files);
|
|
23
|
-
if (transactionPayloads.length > 0) {
|
|
24
|
-
actions.push((0, transactionReducer_1.updateTransactions)(transactionPayloads, (value) => value.transaction_id));
|
|
25
|
-
}
|
|
26
|
-
actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsSuccess)((0, missingReceiptsPayload_1.toBatchDetails)(response.data)));
|
|
27
|
-
actions.push((0, missingReceiptsViewReducer_1.fetchBulkUploadBatches)(true));
|
|
28
|
-
return (0, rxjs_1.from)(actions);
|
|
29
|
-
}
|
|
30
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({ error: response.status }));
|
|
31
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchDetailsFailure)({
|
|
32
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch batch details errored out: ' + JSON.stringify(error)),
|
|
33
|
-
}))));
|
|
34
|
-
}));
|
|
35
|
-
exports.fetchBulkUploadBatchDetailsEpic = fetchBulkUploadBatchDetailsEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts
DELETED
|
@@ -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 { fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof fetchBulkUploadBatches> | ReturnType<typeof fetchBulkUploadBatchesSuccess> | ReturnType<typeof fetchBulkUploadBatchesFailure>;
|
|
7
|
-
export declare const fetchBulkUploadBatchesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchBulkUploadBatchesEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
7
|
-
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
8
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
9
|
-
const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
|
|
10
|
-
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
11
|
-
const fetchBulkUploadBatchesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.fetchBulkUploadBatches.match), (0, operators_1.switchMap)((action) => {
|
|
12
|
-
const { cacheOverride } = action.payload;
|
|
13
|
-
const state = state$.value;
|
|
14
|
-
const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload }, } = state;
|
|
15
|
-
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
16
|
-
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
17
|
-
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
|
|
18
|
-
const existingBatches = bulkUpload.batchListByPeriod[periodId] ?? [];
|
|
19
|
-
if (cacheOverride !== true && existingBatches.length > 0) {
|
|
20
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
|
|
21
|
-
batchList: existingBatches,
|
|
22
|
-
selectedPeriod,
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
|
|
26
|
-
return zeniAPI
|
|
27
|
-
.getJSON(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/batches?start_date=${period.start}&end_date=${period.end}`)
|
|
28
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
29
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
30
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesSuccess)({
|
|
31
|
-
batchList: response.data.batches.map(missingReceiptsPayload_1.toBatchListItem),
|
|
32
|
-
selectedPeriod,
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
|
|
36
|
-
error: response.status,
|
|
37
|
-
selectedPeriod,
|
|
38
|
-
}));
|
|
39
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.fetchBulkUploadBatchesFailure)({
|
|
40
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch bulk upload batches errored out: ' +
|
|
41
|
-
JSON.stringify(error)),
|
|
42
|
-
selectedPeriod,
|
|
43
|
-
}))));
|
|
44
|
-
}));
|
|
45
|
-
exports.fetchBulkUploadBatchesEpic = fetchBulkUploadBatchesEpic;
|
package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateTransactions } from '../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { RootState } from '../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
-
import { fetchCompletedTransactions, fetchCompletedTransactionsFailure, fetchCompletedTransactionsSuccess } from '../../reducers/missingReceiptsViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchCompletedTransactions> | ReturnType<typeof updateTransactions> | ReturnType<typeof fetchCompletedTransactionsSuccess> | ReturnType<typeof fetchCompletedTransactionsFailure>;
|
|
8
|
-
export declare const fetchCompletedTransactionsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|