@zeniai/client-epic-state 5.0.44-betaRD3 → 5.0.45
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/commonStateTypes/recommendationBase.d.ts +1 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
- package/lib/commonStateTypes/viewAndReport/viewAndReport.js +0 -1
- package/lib/entity/account/accountState.d.ts +1 -1
- package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
- package/lib/entity/chargeCardRepayment/chargeCardRepayment.d.ts +1 -1
- package/lib/entity/class/classReducer.d.ts +4 -4
- package/lib/entity/class/classState.d.ts +1 -1
- package/lib/entity/forecast/forecastState.d.ts +1 -1
- package/lib/entity/project/projectPayload.d.ts +0 -7
- package/lib/entity/project/projectPayload.js +1 -15
- package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
- package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
- package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -3
- package/lib/entity/tenant/clearAllEpic.d.ts +3 -6
- package/lib/entity/tenant/clearAllEpic.js +2 -8
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.d.ts +0 -2
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +0 -9
- package/lib/entity/transaction/stateTypes/transactionLine.d.ts +0 -2
- package/lib/epic.d.ts +1 -10
- package/lib/epic.js +1 -10
- package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +0 -1
- package/lib/esm/entity/project/projectPayload.js +0 -12
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -3
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -8
- package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +0 -9
- package/lib/esm/epic.js +1 -10
- package/lib/esm/index.js +10 -19
- package/lib/esm/reducer.js +3 -12
- package/lib/esm/view/transactionDetail/epics/saveTransactionHelper.js +0 -1
- package/lib/esm/view/transactionDetail/epics/transactionDetailEpic.js +0 -6
- package/lib/esm/view/transactionDetail/epics/updateTransactionDetailEpic.js +0 -3
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +2 -14
- package/lib/esm/view/transactionList/transactionListReducer.js +2 -83
- package/lib/esm/view/transactionList/transactionListState.js +0 -10
- package/lib/index.d.ts +14 -25
- package/lib/index.js +46 -86
- package/lib/reducer.d.ts +3 -12
- package/lib/reducer.js +3 -12
- package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
- package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
- package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
- package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
- package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
- package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
- package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
- package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
- package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
- package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
- package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
- package/lib/view/topEx/topExSelector.d.ts +1 -1
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +0 -1
- package/lib/view/transactionDetail/epics/transactionDetailEpic.d.ts +1 -2
- package/lib/view/transactionDetail/epics/transactionDetailEpic.js +0 -6
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +0 -3
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -3
- package/lib/view/transactionDetail/transactionDetailSelector.js +1 -13
- package/lib/view/transactionDetail/transactionDetailState.d.ts +0 -2
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -2
- package/lib/view/transactionList/transactionListPayload.d.ts +0 -15
- package/lib/view/transactionList/transactionListReducer.d.ts +2 -25
- package/lib/view/transactionList/transactionListReducer.js +2 -83
- package/lib/view/transactionList/transactionListState.d.ts +0 -15
- package/lib/view/transactionList/transactionListState.js +1 -13
- package/package.json +1 -1
- package/lib/entity/creditAgent/creditAgentPayload.d.ts +0 -41
- package/lib/entity/creditAgent/creditAgentPayload.js +0 -40
- package/lib/entity/creditAgent/creditAgentReducer.d.ts +0 -9
- package/lib/entity/creditAgent/creditAgentReducer.js +0 -37
- package/lib/entity/creditAgent/creditAgentSelector.d.ts +0 -3
- package/lib/entity/creditAgent/creditAgentSelector.js +0 -10
- package/lib/entity/creditAgent/creditAgentState.d.ts +0 -39
- package/lib/entity/creditAgent/creditAgentState.js +0 -17
- package/lib/esm/entity/creditAgent/creditAgentPayload.js +0 -36
- package/lib/esm/entity/creditAgent/creditAgentReducer.js +0 -33
- package/lib/esm/entity/creditAgent/creditAgentSelector.js +0 -6
- package/lib/esm/entity/creditAgent/creditAgentState.js +0 -13
- package/lib/esm/view/creditAgentView/buildCreditReportCsv.js +0 -44
- package/lib/esm/view/creditAgentView/creditAgentViewPayload.js +0 -2
- package/lib/esm/view/creditAgentView/creditAgentViewReducer.js +0 -183
- package/lib/esm/view/creditAgentView/creditAgentViewSelector.js +0 -85
- package/lib/esm/view/creditAgentView/creditAgentViewState.js +0 -20
- package/lib/esm/view/creditAgentView/epics/fetchCardProfilesEpic.js +0 -20
- package/lib/esm/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -13
- package/lib/esm/view/creditAgentView/epics/fetchCreditAgentMacroEpic.js +0 -19
- package/lib/esm/view/creditAgentView/epics/saveCreditAgentMacroEpic.js +0 -58
- package/lib/esm/view/creditAgentView/epics/scheduleTenantCreditScoreCronEpic.js +0 -39
- package/lib/esm/view/creditAgentView/epics/updateCardProfileEpic.js +0 -62
- package/lib/esm/view/projectList/fetchProjectListEpic.js +0 -38
- package/lib/esm/view/projectList/projectListPayload.js +0 -1
- package/lib/esm/view/projectList/projectListReducer.js +0 -39
- package/lib/esm/view/projectList/projectListSelector.js +0 -9
- package/lib/esm/view/projectList/projectListState.js +0 -1
- package/lib/esm/view/transactionList/fetchTransactionListByProjectEpic.js +0 -45
- package/lib/esm/view/transactionList/parallelFetchProjectTransactionListEpic.js +0 -32
- package/lib/esm/view/transactionList/transactionListByProjectSelector.js +0 -58
- package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
- package/lib/view/creditAgentView/buildCreditReportCsv.d.ts +0 -17
- package/lib/view/creditAgentView/buildCreditReportCsv.js +0 -47
- package/lib/view/creditAgentView/creditAgentViewPayload.d.ts +0 -9
- package/lib/view/creditAgentView/creditAgentViewPayload.js +0 -7
- package/lib/view/creditAgentView/creditAgentViewReducer.d.ts +0 -41
- package/lib/view/creditAgentView/creditAgentViewReducer.js +0 -187
- package/lib/view/creditAgentView/creditAgentViewSelector.d.ts +0 -20
- package/lib/view/creditAgentView/creditAgentViewSelector.js +0 -93
- package/lib/view/creditAgentView/creditAgentViewState.d.ts +0 -34
- package/lib/view/creditAgentView/creditAgentViewState.js +0 -22
- package/lib/view/creditAgentView/epics/fetchCardProfilesEpic.d.ts +0 -15
- package/lib/view/creditAgentView/epics/fetchCardProfilesEpic.js +0 -24
- package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.d.ts +0 -11
- package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -17
- package/lib/view/creditAgentView/epics/fetchCreditAgentMacroEpic.d.ts +0 -15
- package/lib/view/creditAgentView/epics/fetchCreditAgentMacroEpic.js +0 -23
- package/lib/view/creditAgentView/epics/saveCreditAgentMacroEpic.d.ts +0 -29
- package/lib/view/creditAgentView/epics/saveCreditAgentMacroEpic.js +0 -62
- package/lib/view/creditAgentView/epics/scheduleTenantCreditScoreCronEpic.d.ts +0 -30
- package/lib/view/creditAgentView/epics/scheduleTenantCreditScoreCronEpic.js +0 -43
- package/lib/view/creditAgentView/epics/updateCardProfileEpic.d.ts +0 -37
- package/lib/view/creditAgentView/epics/updateCardProfileEpic.js +0 -66
- package/lib/view/projectList/fetchProjectListEpic.d.ts +0 -8
- package/lib/view/projectList/fetchProjectListEpic.js +0 -42
- package/lib/view/projectList/projectListPayload.d.ts +0 -7
- package/lib/view/projectList/projectListPayload.js +0 -2
- package/lib/view/projectList/projectListReducer.d.ts +0 -9
- package/lib/view/projectList/projectListReducer.js +0 -43
- package/lib/view/projectList/projectListSelector.d.ts +0 -8
- package/lib/view/projectList/projectListSelector.js +0 -13
- package/lib/view/projectList/projectListState.d.ts +0 -4
- package/lib/view/projectList/projectListState.js +0 -2
- package/lib/view/transactionList/fetchTransactionListByProjectEpic.d.ts +0 -8
- package/lib/view/transactionList/fetchTransactionListByProjectEpic.js +0 -52
- package/lib/view/transactionList/parallelFetchProjectTransactionListEpic.d.ts +0 -6
- package/lib/view/transactionList/parallelFetchProjectTransactionListEpic.js +0 -36
- package/lib/view/transactionList/transactionListByProjectSelector.d.ts +0 -22
- package/lib/view/transactionList/transactionListByProjectSelector.js +0 -66
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveCreditAgentMacroEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const creditAgentReducer_1 = require("../../../entity/creditAgent/creditAgentReducer");
|
|
7
|
-
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
8
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
9
|
-
const creditAgentViewReducer_1 = require("../creditAgentViewReducer");
|
|
10
|
-
const saveCreditAgentMacroEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(creditAgentViewReducer_1.saveCreditAgentMacro.match), (0, operators_1.switchMap)((action) => {
|
|
11
|
-
const { instructions } = action.payload;
|
|
12
|
-
const existingMacro = state$.value.creditAgentEntityState.macro;
|
|
13
|
-
// Fail fast if macro has not been loaded yet — avoids overwriting server-side
|
|
14
|
-
// name/description fields with empty defaults.
|
|
15
|
-
if (existingMacro == null) {
|
|
16
|
-
return (0, rxjs_1.from)([
|
|
17
|
-
(0, creditAgentViewReducer_1.saveCreditAgentMacroFailure)((0, responsePayload_1.createZeniAPIStatus)('Save failed', 'Cannot save macro: macro data has not been loaded yet.')),
|
|
18
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
19
|
-
messageSection: 'credit_agent_save_macro',
|
|
20
|
-
messageText: 'failed',
|
|
21
|
-
type: 'error',
|
|
22
|
-
}),
|
|
23
|
-
]);
|
|
24
|
-
}
|
|
25
|
-
const url = `${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/macros/credit-agent`;
|
|
26
|
-
const body = {
|
|
27
|
-
instructions,
|
|
28
|
-
name: existingMacro.name,
|
|
29
|
-
description: existingMacro.description,
|
|
30
|
-
};
|
|
31
|
-
return zeniAPI.putAndGetJSON(url, body).pipe((0, operators_1.mergeMap)((response) => {
|
|
32
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
33
|
-
return (0, rxjs_1.from)([
|
|
34
|
-
(0, creditAgentReducer_1.updateCreditAgentMacro)(response.data),
|
|
35
|
-
(0, creditAgentViewReducer_1.saveCreditAgentMacroSuccess)(),
|
|
36
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
37
|
-
messageSection: 'credit_agent_save_macro',
|
|
38
|
-
messageText: 'success',
|
|
39
|
-
type: 'success',
|
|
40
|
-
}),
|
|
41
|
-
]);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
return (0, rxjs_1.from)([
|
|
45
|
-
(0, creditAgentViewReducer_1.saveCreditAgentMacroFailure)(response.status),
|
|
46
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
47
|
-
messageSection: 'credit_agent_save_macro',
|
|
48
|
-
messageText: 'failed',
|
|
49
|
-
type: 'error',
|
|
50
|
-
}),
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
54
|
-
(0, creditAgentViewReducer_1.saveCreditAgentMacroFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'REST API call errored out: ' + JSON.stringify(error))),
|
|
55
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
56
|
-
messageSection: 'credit_agent_save_macro',
|
|
57
|
-
messageText: 'failed',
|
|
58
|
-
type: 'error',
|
|
59
|
-
}),
|
|
60
|
-
])));
|
|
61
|
-
}));
|
|
62
|
-
exports.saveCreditAgentMacroEpic = saveCreditAgentMacroEpic;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
3
|
-
import { RootState } from '../../../reducer';
|
|
4
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
5
|
-
import { scheduleTenantCreditScoreCron, scheduleTenantCreditScoreCronFailure, scheduleTenantCreditScoreCronSuccess } from '../creditAgentViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof scheduleTenantCreditScoreCron> | ReturnType<typeof scheduleTenantCreditScoreCronSuccess> | ReturnType<typeof scheduleTenantCreditScoreCronFailure> | ReturnType<typeof openSnackbar>;
|
|
7
|
-
export declare const scheduleTenantCreditScoreCronEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
8
|
-
payload: {
|
|
9
|
-
messageSection: import("../../..").SnackbarMessageSections;
|
|
10
|
-
messageText: import("../../..").SnackbarMessageSectionTexts;
|
|
11
|
-
type: import("../../..").SnackbarMessageType;
|
|
12
|
-
showStatusIcon?: boolean;
|
|
13
|
-
variables?: {
|
|
14
|
-
variableName: string;
|
|
15
|
-
variableValue: string;
|
|
16
|
-
}[];
|
|
17
|
-
};
|
|
18
|
-
type: "snackbar/openSnackbar";
|
|
19
|
-
} | {
|
|
20
|
-
payload: {
|
|
21
|
-
tenantId: string | undefined;
|
|
22
|
-
};
|
|
23
|
-
type: "creditAgentView/scheduleTenantCreditScoreCronSuccess";
|
|
24
|
-
} | {
|
|
25
|
-
payload: {
|
|
26
|
-
tenantId: string | undefined;
|
|
27
|
-
error: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
|
|
28
|
-
};
|
|
29
|
-
type: "creditAgentView/scheduleTenantCreditScoreCronFailure";
|
|
30
|
-
}>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scheduleTenantCreditScoreCronEpic = 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 creditAgentViewReducer_1 = require("../creditAgentViewReducer");
|
|
9
|
-
const scheduleTenantCreditScoreCronEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(creditAgentViewReducer_1.scheduleTenantCreditScoreCron.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
-
const { tenantId } = action.payload;
|
|
11
|
-
const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/crons/cards/tenant-credit-score`;
|
|
12
|
-
const body = tenantId != null ? { tenant_id: tenantId } : {};
|
|
13
|
-
return zeniAPI.postAndGetJSON(url, body).pipe((0, operators_1.mergeMap)((response) => {
|
|
14
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
15
|
-
return (0, rxjs_1.from)([
|
|
16
|
-
(0, creditAgentViewReducer_1.scheduleTenantCreditScoreCronSuccess)(tenantId),
|
|
17
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
18
|
-
messageSection: 'credit_agent_schedule_cron',
|
|
19
|
-
messageText: 'success',
|
|
20
|
-
type: 'success',
|
|
21
|
-
}),
|
|
22
|
-
]);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return (0, rxjs_1.from)([
|
|
26
|
-
(0, creditAgentViewReducer_1.scheduleTenantCreditScoreCronFailure)(tenantId, response.status),
|
|
27
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
28
|
-
messageSection: 'credit_agent_schedule_cron',
|
|
29
|
-
messageText: 'failed',
|
|
30
|
-
type: 'error',
|
|
31
|
-
}),
|
|
32
|
-
]);
|
|
33
|
-
}
|
|
34
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
35
|
-
(0, creditAgentViewReducer_1.scheduleTenantCreditScoreCronFailure)(tenantId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'REST API call errored out: ' + JSON.stringify(error))),
|
|
36
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
37
|
-
messageSection: 'credit_agent_schedule_cron',
|
|
38
|
-
messageText: 'failed',
|
|
39
|
-
type: 'error',
|
|
40
|
-
}),
|
|
41
|
-
])));
|
|
42
|
-
}));
|
|
43
|
-
exports.scheduleTenantCreditScoreCronEpic = scheduleTenantCreditScoreCronEpic;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { updateCreditAgentRow } from '../../../entity/creditAgent/creditAgentReducer';
|
|
3
|
-
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { RootState } from '../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
6
|
-
import { updateCardProfile, updateCardProfileFailure, updateCardProfileSuccess } from '../creditAgentViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof updateCardProfile> | ReturnType<typeof updateCardProfileSuccess> | ReturnType<typeof updateCardProfileFailure> | ReturnType<typeof updateCreditAgentRow> | ReturnType<typeof openSnackbar>;
|
|
8
|
-
export declare const updateCardProfileEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
9
|
-
payload: {
|
|
10
|
-
messageSection: import("../../..").SnackbarMessageSections;
|
|
11
|
-
messageText: import("../../..").SnackbarMessageSectionTexts;
|
|
12
|
-
type: import("../../..").SnackbarMessageType;
|
|
13
|
-
showStatusIcon?: boolean;
|
|
14
|
-
variables?: {
|
|
15
|
-
variableName: string;
|
|
16
|
-
variableValue: string;
|
|
17
|
-
}[];
|
|
18
|
-
};
|
|
19
|
-
type: "snackbar/openSnackbar";
|
|
20
|
-
} | {
|
|
21
|
-
payload: {
|
|
22
|
-
tenantId: string;
|
|
23
|
-
};
|
|
24
|
-
type: "creditAgentView/updateCardProfileSuccess";
|
|
25
|
-
} | {
|
|
26
|
-
payload: {
|
|
27
|
-
tenantId: string;
|
|
28
|
-
error: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
|
|
29
|
-
};
|
|
30
|
-
type: "creditAgentView/updateCardProfileFailure";
|
|
31
|
-
} | {
|
|
32
|
-
payload: {
|
|
33
|
-
payload: import("../creditAgentViewPayload").CardTenantProfileRowPayload;
|
|
34
|
-
tenantId: string;
|
|
35
|
-
};
|
|
36
|
-
type: "creditAgent/updateCreditAgentRow";
|
|
37
|
-
}>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateCardProfileEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const creditAgentReducer_1 = require("../../../entity/creditAgent/creditAgentReducer");
|
|
7
|
-
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
8
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
9
|
-
const creditAgentViewReducer_1 = require("../creditAgentViewReducer");
|
|
10
|
-
const updateCardProfileEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(creditAgentViewReducer_1.updateCardProfile.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
-
const { tenantId, tenantEmailDomain, update } = action.payload;
|
|
12
|
-
const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cockpit/card-tenant-profiles`;
|
|
13
|
-
const body = {
|
|
14
|
-
tenant_namespace: tenantEmailDomain,
|
|
15
|
-
};
|
|
16
|
-
if (update.cardStatus != null) {
|
|
17
|
-
body.card_status = update.cardStatus;
|
|
18
|
-
}
|
|
19
|
-
if (update.creditLimit != null) {
|
|
20
|
-
body.credit_limit = update.creditLimit;
|
|
21
|
-
}
|
|
22
|
-
if (update.updatedByName != null) {
|
|
23
|
-
body.updated_by_name = update.updatedByName;
|
|
24
|
-
}
|
|
25
|
-
if (update.reason != null && update.reason.trim() !== '') {
|
|
26
|
-
body.reason = update.reason.trim();
|
|
27
|
-
}
|
|
28
|
-
return zeniAPI
|
|
29
|
-
.putAndGetJSON(url, body)
|
|
30
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
31
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) &&
|
|
32
|
-
response.data != null &&
|
|
33
|
-
response.data.profile != null) {
|
|
34
|
-
return (0, rxjs_1.from)([
|
|
35
|
-
(0, creditAgentReducer_1.updateCreditAgentRow)({
|
|
36
|
-
payload: response.data.profile,
|
|
37
|
-
tenantId,
|
|
38
|
-
}),
|
|
39
|
-
(0, creditAgentViewReducer_1.updateCardProfileSuccess)(tenantId),
|
|
40
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
41
|
-
messageSection: 'credit_agent_update_profile',
|
|
42
|
-
messageText: 'success',
|
|
43
|
-
type: 'success',
|
|
44
|
-
}),
|
|
45
|
-
]);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return (0, rxjs_1.from)([
|
|
49
|
-
(0, creditAgentViewReducer_1.updateCardProfileFailure)(tenantId, response.status),
|
|
50
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
51
|
-
messageSection: 'credit_agent_update_profile',
|
|
52
|
-
messageText: 'failed',
|
|
53
|
-
type: 'error',
|
|
54
|
-
}),
|
|
55
|
-
]);
|
|
56
|
-
}
|
|
57
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
58
|
-
(0, creditAgentViewReducer_1.updateCardProfileFailure)(tenantId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'REST API call errored out: ' + JSON.stringify(error))),
|
|
59
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
60
|
-
messageSection: 'credit_agent_update_profile',
|
|
61
|
-
messageText: 'failed',
|
|
62
|
-
type: 'error',
|
|
63
|
-
}),
|
|
64
|
-
])));
|
|
65
|
-
}));
|
|
66
|
-
exports.updateCardProfileEpic = updateCardProfileEpic;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateProjects } from '../../entity/project/projectReducer';
|
|
4
|
-
import { RootState } from '../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../zeniAPI';
|
|
6
|
-
import { fetchProjectList, updateProjectList, updateProjectListFailure } from './projectListReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchProjectList> | ReturnType<typeof updateProjects> | ReturnType<typeof updateProjectList> | ReturnType<typeof updateProjectListFailure>;
|
|
8
|
-
export declare const fetchProjectListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchProjectListEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const projectReducer_1 = require("../../entity/project/projectReducer");
|
|
7
|
-
const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
|
|
8
|
-
const responsePayload_1 = require("../../responsePayload");
|
|
9
|
-
const projectListReducer_1 = require("./projectListReducer");
|
|
10
|
-
const buildProjectListQuery = (isIncludeDeleted) => {
|
|
11
|
-
const query = {
|
|
12
|
-
is_deleted: isIncludeDeleted,
|
|
13
|
-
sort_by: 'project_name',
|
|
14
|
-
sort_order: 'asc',
|
|
15
|
-
is_full: true,
|
|
16
|
-
};
|
|
17
|
-
return `?query=${encodeURIComponent(JSON.stringify(query))}`;
|
|
18
|
-
};
|
|
19
|
-
const fetchProjectListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(projectListReducer_1.fetchProjectList.match), (0, operators_1.withLatestFrom)(state$), (0, operators_1.switchMap)(([action, state]) => {
|
|
20
|
-
if (!(0, tenantSelector_1.getIsAccountingProjectsEnabled)(state)) {
|
|
21
|
-
return (0, rxjs_1.of)((0, projectListReducer_1.updateProjectList)({
|
|
22
|
-
status: (0, responsePayload_1.createZeniAPIStatus)('Success', ''),
|
|
23
|
-
data: { projects: [] },
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
const { isIncludeDeleted } = action.payload;
|
|
27
|
-
const queryParams = buildProjectListQuery(isIncludeDeleted);
|
|
28
|
-
return zeniAPI
|
|
29
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/projects${queryParams}`)
|
|
30
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
31
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
32
|
-
return (0, rxjs_1.of)((0, projectReducer_1.updateProjects)(response.data?.projects ?? []), (0, projectListReducer_1.updateProjectList)(response));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return (0, rxjs_1.of)((0, projectListReducer_1.updateProjectListFailure)(response.status));
|
|
36
|
-
}
|
|
37
|
-
}), (0, operators_1.catchError)((error) => {
|
|
38
|
-
return (0, rxjs_1.of)((0, projectListReducer_1.updateProjectListFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch Projects REST API call errored out' +
|
|
39
|
-
JSON.stringify(error))));
|
|
40
|
-
}));
|
|
41
|
-
}));
|
|
42
|
-
exports.fetchProjectListEpic = fetchProjectListEpic;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ProjectMetadataPayload } from '../../entity/project/projectPayload';
|
|
2
|
-
import { ZeniAPIResponse } from '../../responsePayload';
|
|
3
|
-
interface ProjectListPayloadData {
|
|
4
|
-
projects: ProjectMetadataPayload[];
|
|
5
|
-
}
|
|
6
|
-
export type ProjectListResponse = ZeniAPIResponse<ProjectListPayloadData>;
|
|
7
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ZeniAPIStatus } from '../../responsePayload';
|
|
2
|
-
import { ProjectListResponse } from './projectListPayload';
|
|
3
|
-
import { ProjectListState } from './projectListState';
|
|
4
|
-
export declare const initialState: ProjectListState;
|
|
5
|
-
export declare const fetchProjectList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[isIncludeDeleted?: boolean | undefined], {
|
|
6
|
-
isIncludeDeleted: boolean;
|
|
7
|
-
}, "projectList/fetchProjectList", never, never>, updateProjectList: import("@reduxjs/toolkit").ActionCreatorWithPayload<ProjectListResponse, "projectList/updateProjectList">, updateProjectListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "projectList/updateProjectListFailure">, clearProjectList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"projectList/clearProjectList">;
|
|
8
|
-
declare const _default: import("redux").Reducer<ProjectListState>;
|
|
9
|
-
export default _default;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearProjectList = exports.updateProjectListFailure = exports.updateProjectList = exports.fetchProjectList = exports.initialState = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
exports.initialState = {
|
|
7
|
-
fetchState: 'Not-Started',
|
|
8
|
-
error: undefined,
|
|
9
|
-
projectIds: [],
|
|
10
|
-
hasValidState() {
|
|
11
|
-
return this.fetchState == 'Completed';
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
const projectList = (0, toolkit_1.createSlice)({
|
|
15
|
-
name: 'projectList',
|
|
16
|
-
initialState: exports.initialState,
|
|
17
|
-
reducers: {
|
|
18
|
-
fetchProjectList: {
|
|
19
|
-
reducer(draft) {
|
|
20
|
-
draft.fetchState = 'In-Progress';
|
|
21
|
-
draft.error = undefined;
|
|
22
|
-
},
|
|
23
|
-
prepare(isIncludeDeleted) {
|
|
24
|
-
return { payload: { isIncludeDeleted: isIncludeDeleted ?? false } };
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
updateProjectList(draft, action) {
|
|
28
|
-
draft.projectIds =
|
|
29
|
-
action.payload.data?.projects.map((project) => project.zeni_project_id) ?? [];
|
|
30
|
-
draft.fetchState = 'Completed';
|
|
31
|
-
draft.error = undefined;
|
|
32
|
-
},
|
|
33
|
-
updateProjectListFailure(draft, action) {
|
|
34
|
-
draft.fetchState = 'Error';
|
|
35
|
-
draft.error = action.payload;
|
|
36
|
-
},
|
|
37
|
-
clearProjectList(draft) {
|
|
38
|
-
Object.assign(draft, exports.initialState);
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
_a = projectList.actions, exports.fetchProjectList = _a.fetchProjectList, exports.updateProjectList = _a.updateProjectList, exports.updateProjectListFailure = _a.updateProjectListFailure, exports.clearProjectList = _a.clearProjectList;
|
|
43
|
-
exports.default = projectList.reducer;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
2
|
-
import { ProjectState } from '../../entity/project/projectReducer';
|
|
3
|
-
import { Project } from '../../entity/project/projectState';
|
|
4
|
-
import { ProjectListState } from './projectListState';
|
|
5
|
-
export interface ProjectListSelectorView extends SelectorView {
|
|
6
|
-
projects: Project[];
|
|
7
|
-
}
|
|
8
|
-
export declare const getProjectList: (projectState: ProjectState, projectListState: ProjectListState) => ProjectListSelectorView;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectList = void 0;
|
|
4
|
-
const projectSelector_1 = require("../../entity/project/projectSelector");
|
|
5
|
-
const getProjectList = (projectState, projectListState) => {
|
|
6
|
-
return {
|
|
7
|
-
projects: (0, projectSelector_1.getProjectsByIds)(projectState, projectListState.projectIds),
|
|
8
|
-
fetchState: projectListState.fetchState,
|
|
9
|
-
error: projectListState.error,
|
|
10
|
-
version: 0,
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
exports.getProjectList = getProjectList;
|
|
@@ -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 { fetchProjectTransactionList, updateTransactionListByProject, updateTransactionListByProjectFailure } from './transactionListReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchProjectTransactionList> | ReturnType<typeof updateTransactions> | ReturnType<typeof updateTransactionListByProject> | ReturnType<typeof updateTransactionListByProjectFailure>;
|
|
8
|
-
export declare const fetchTransactionListByProjectEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchTransactionListByProjectEpic = void 0;
|
|
7
|
-
const js_base64_1 = require("js-base64");
|
|
8
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
-
const rxjs_1 = require("rxjs");
|
|
10
|
-
const operators_1 = require("rxjs/operators");
|
|
11
|
-
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
12
|
-
const transactionReducer_1 = require("../../entity/transaction/transactionReducer");
|
|
13
|
-
const responsePayload_1 = require("../../responsePayload");
|
|
14
|
-
const transactionListReducer_1 = require("./transactionListReducer");
|
|
15
|
-
const transactionListState_1 = require("./transactionListState");
|
|
16
|
-
const fetchTransactionListByProjectEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(transactionListReducer_1.fetchProjectTransactionList.match), (0, operators_1.mergeMap)((action) => {
|
|
17
|
-
const state = state$.value;
|
|
18
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
|
|
19
|
-
const projectTransactions = (0, get_1.default)(state.transactionListState.byProject.transactionListByProjectKey, key, undefined);
|
|
20
|
-
if (action.payload.cacheOverride === true ||
|
|
21
|
-
projectTransactions == null ||
|
|
22
|
-
projectTransactions.hasValidState() === false) {
|
|
23
|
-
const queryParam = {
|
|
24
|
-
start_date: (0, timePeriod_1.toString)(action.payload.period.start),
|
|
25
|
-
end_date: (0, timePeriod_1.toString)(action.payload.period.end),
|
|
26
|
-
sort_by: 'create_time',
|
|
27
|
-
sort_order: 'desc',
|
|
28
|
-
account_id: action.payload.accountId,
|
|
29
|
-
account_type: action.payload.accountType,
|
|
30
|
-
zeni_project_id: action.payload.projectId,
|
|
31
|
-
};
|
|
32
|
-
const base64AccountId = (0, js_base64_1.toBase64)(action.payload.accountId);
|
|
33
|
-
return zeniAPI
|
|
34
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${base64AccountId}/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
35
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
36
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
37
|
-
const updateActions = [];
|
|
38
|
-
updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.account.transactions, (value) => value.transaction_id));
|
|
39
|
-
updateActions.push((0, transactionListReducer_1.updateTransactionListByProject)(response.data));
|
|
40
|
-
return (0, rxjs_1.from)(updateActions);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return (0, rxjs_1.of)((0, transactionListReducer_1.updateTransactionListByProjectFailure)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period, response.status));
|
|
44
|
-
}
|
|
45
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, transactionListReducer_1.updateTransactionListByProjectFailure)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch transaction list REST API call errored out' +
|
|
46
|
-
JSON.stringify(error))))));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return (0, rxjs_1.from)([]);
|
|
50
|
-
}
|
|
51
|
-
}));
|
|
52
|
-
exports.fetchTransactionListByProjectEpic = fetchTransactionListByProjectEpic;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { RootState } from '../../reducer';
|
|
4
|
-
import { fetchProjectTransactionList, parallelFetchProjectTransactionList } from './transactionListReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof parallelFetchProjectTransactionList> | ReturnType<typeof fetchProjectTransactionList>;
|
|
6
|
-
export declare const parallelFetchProjectTransactionListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parallelFetchProjectTransactionListEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const parallelFetchClassTransactionListEpic_1 = require("./parallelFetchClassTransactionListEpic");
|
|
7
|
-
const transactionListReducer_1 = require("./transactionListReducer");
|
|
8
|
-
const transactionListState_1 = require("./transactionListState");
|
|
9
|
-
const parallelFetchProjectTransactionListEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionListReducer_1.parallelFetchProjectTransactionList.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
-
const state = state$.value.transactionListState;
|
|
11
|
-
const timePeriods = (0, parallelFetchClassTransactionListEpic_1.splitPeriod)(action.payload.period);
|
|
12
|
-
const filteredTimePeriods = timePeriods.filter((value) => {
|
|
13
|
-
if (action.payload.cacheOverride === false) {
|
|
14
|
-
return (isDataAvailableOrFetching(state.byProject, action.payload.accountId, action.payload.accountType, action.payload.projectId, value) === false);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
if (filteredTimePeriods.length > 12) {
|
|
21
|
-
console.error('Only maximum 12 parallel fetch are allowed!');
|
|
22
|
-
return (0, rxjs_1.from)([]);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
const fetchActions = filteredTimePeriods.map((period) => (0, transactionListReducer_1.fetchProjectTransactionList)(action.payload.accountId, action.payload.accountType, action.payload.projectId, period, true));
|
|
26
|
-
return (0, rxjs_1.from)(fetchActions);
|
|
27
|
-
}
|
|
28
|
-
}));
|
|
29
|
-
exports.parallelFetchProjectTransactionListEpic = parallelFetchProjectTransactionListEpic;
|
|
30
|
-
function isDataAvailableOrFetching(state, accountId, accountType, projectId, period) {
|
|
31
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(accountId, accountType, projectId, period);
|
|
32
|
-
const projectTransactions = state.transactionListByProjectKey[key];
|
|
33
|
-
return (projectTransactions != null &&
|
|
34
|
-
(projectTransactions.fetchState === 'In-Progress' ||
|
|
35
|
-
projectTransactions.hasValidState()));
|
|
36
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { COABalanceTimeFrame } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
2
|
-
import { ID } from '../../commonStateTypes/common';
|
|
3
|
-
import { EntityOrder } from '../../commonStateTypes/selectorTypes/selectorTypes';
|
|
4
|
-
import { TimePeriod } from '../../commonStateTypes/timePeriod';
|
|
5
|
-
import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
6
|
-
import { AccountBase, AccountType } from '../../entity/account/accountState';
|
|
7
|
-
import { Transaction } from '../../entity/transaction/stateTypes/transaction';
|
|
8
|
-
import { TransactionState } from '../../entity/transaction/transactionState';
|
|
9
|
-
import { TransactionListSelectorView, TransactionListState, TransactionListUIState } from './transactionListState';
|
|
10
|
-
export interface TransactionListByProjectReport extends SelectorView, TransactionListSelectorView {
|
|
11
|
-
accountId: ID;
|
|
12
|
-
accountType: AccountType;
|
|
13
|
-
filterByTimePeriod: TimePeriod;
|
|
14
|
-
projectId: ID;
|
|
15
|
-
timeframe: COABalanceTimeFrame;
|
|
16
|
-
transactionOrder: EntityOrder;
|
|
17
|
-
transactions: Transaction[];
|
|
18
|
-
uiState: TransactionListUIState;
|
|
19
|
-
account?: AccountBase;
|
|
20
|
-
}
|
|
21
|
-
export declare const getTransactionListByProject: (transactionState: TransactionState, transactionListState: TransactionListState, accountId: ID, accountType: AccountType, projectId: ID, timeframe: COABalanceTimeFrame, filterByTimePeriod: TimePeriod) => TransactionListByProjectReport;
|
|
22
|
-
export declare const getTransactionListUIStateByProjectKey: (transactionListState: TransactionListState, accountId: ID, accountType: AccountType, projectId: ID) => TransactionListUIState | undefined;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getTransactionListUIStateByProjectKey = exports.getTransactionListByProject = void 0;
|
|
7
|
-
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
8
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
9
|
-
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
10
|
-
const transactionSelector_1 = require("../../entity/transaction/transactionSelector");
|
|
11
|
-
const parallelFetchAccountTransactionListEpic_1 = require("./parallelFetchAccountTransactionListEpic");
|
|
12
|
-
const reduceTransactionListFetchState_1 = require("./reduceTransactionListFetchState");
|
|
13
|
-
const transactionListState_1 = require("./transactionListState");
|
|
14
|
-
const getTransactionListByProject = (transactionState, transactionListState, accountId, accountType, projectId, timeframe, filterByTimePeriod) => {
|
|
15
|
-
const timePeriods = (0, parallelFetchAccountTransactionListEpic_1.splitPeriod)(filterByTimePeriod); // Note: Split by months.
|
|
16
|
-
const accountTransactions = timePeriods
|
|
17
|
-
.map((thisTimePeriod) => {
|
|
18
|
-
const key = (0, transactionListState_1.getProjectAcTranKey)(accountId, accountType, projectId, thisTimePeriod);
|
|
19
|
-
return (0, get_1.default)(transactionListState.byProject.transactionListByProjectKey, key, undefined);
|
|
20
|
-
})
|
|
21
|
-
.filter((acTransaction) => acTransaction != null);
|
|
22
|
-
let account = undefined;
|
|
23
|
-
if (accountTransactions.length > 0) {
|
|
24
|
-
account = accountTransactions[0].account;
|
|
25
|
-
}
|
|
26
|
-
const fetchState = (0, reduceTransactionListFetchState_1.reduceFetchState)(accountTransactions);
|
|
27
|
-
let transactions = [];
|
|
28
|
-
if ((0, reduceTransactionListFetchState_1.isAnyFetchCompleted)(accountTransactions)) {
|
|
29
|
-
const allTransactionIDs = (0, flatMap_1.default)(accountTransactions, (value) => value.transactionIDs);
|
|
30
|
-
const transactionsUnsorted = allTransactionIDs
|
|
31
|
-
.map((transactionId) => (0, transactionSelector_1.getSupportedTransactionById)(transactionState, transactionId))
|
|
32
|
-
.filter((value) => {
|
|
33
|
-
if (value == null) {
|
|
34
|
-
console.error("Can't have null transaction at this stage!");
|
|
35
|
-
}
|
|
36
|
-
return value != null;
|
|
37
|
-
});
|
|
38
|
-
transactions = (0, orderBy_1.default)(transactionsUnsorted, (value) => value.date.valueOf(), 'desc');
|
|
39
|
-
}
|
|
40
|
-
const key = (0, transactionListState_1.getProjectAcKey)(accountId, accountType, projectId);
|
|
41
|
-
const uiState = (0, get_1.default)(transactionListState.byProject.transactionListUIStateByProjectKey, key, {});
|
|
42
|
-
return {
|
|
43
|
-
reportId: 'transaction_list_of_account_by_project',
|
|
44
|
-
reportTitle: 'Transaction List of Account By Project',
|
|
45
|
-
version: 1,
|
|
46
|
-
status: undefined,
|
|
47
|
-
fetchState: fetchState.fetchState,
|
|
48
|
-
error: fetchState.error,
|
|
49
|
-
timeframe,
|
|
50
|
-
filterByTimePeriod,
|
|
51
|
-
accountId,
|
|
52
|
-
accountType,
|
|
53
|
-
projectId,
|
|
54
|
-
account,
|
|
55
|
-
transactionOrder: 'descending_transaction_date',
|
|
56
|
-
transactions,
|
|
57
|
-
uiState,
|
|
58
|
-
latestTransactionId: transactionListState.latestTransactionId,
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
exports.getTransactionListByProject = getTransactionListByProject;
|
|
62
|
-
const getTransactionListUIStateByProjectKey = (transactionListState, accountId, accountType, projectId) => {
|
|
63
|
-
const key = (0, transactionListState_1.getProjectAcKey)(accountId, accountType, projectId);
|
|
64
|
-
return (0, get_1.default)(transactionListState.byProject.transactionListUIStateByProjectKey, key, undefined);
|
|
65
|
-
};
|
|
66
|
-
exports.getTransactionListUIStateByProjectKey = getTransactionListUIStateByProjectKey;
|