@zeniai/client-epic-state 4.19.99-betaRD2 → 4.19.99-betaRD21
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/billPay/billTransaction/billTransactionState.d.ts +2 -2
- package/lib/entity/chargeCard/chargeCard.d.ts +1 -1
- package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -1
- package/lib/entity/entityApprovalStatus/entityApprovalStatusState.d.ts +2 -2
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +9 -6
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +36 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +5 -2
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +26 -2
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/tenant/clearAllEpic.d.ts +1 -3
- package/lib/entity/tenant/clearAllEpic.js +0 -4
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +4 -1
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +1 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +1 -0
- package/lib/entity/userRole/userRoleType.d.ts +2 -2
- package/lib/epic.d.ts +1 -5
- package/lib/epic.js +1 -5
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +36 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +5 -2
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -4
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +1 -0
- package/lib/esm/epic.js +1 -5
- package/lib/esm/index.js +0 -7
- package/lib/esm/reducer.js +0 -6
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +4 -3
- package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +0 -1
- package/lib/esm/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +10 -2
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +13 -3
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +11 -3
- package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +22 -9
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +12 -6
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +3 -8
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +144 -63
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +9 -2
- package/lib/index.d.ts +2 -10
- package/lib/index.js +2 -30
- package/lib/reducer.d.ts +0 -6
- package/lib/reducer.js +0 -6
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/companyView/types/cockpitTypes.d.ts +5 -6
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -2
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +1 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +4 -3
- package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +0 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +10 -2
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +13 -3
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +11 -3
- package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +22 -9
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +11 -5
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -0
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -1
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +3 -8
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +144 -63
- package/lib/view/reviewCompanyView/reviewCompanyViewState.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +4 -4
- package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +3 -3
- package/lib/view/subscriptionView/types/subscriptionTypes.d.ts +1 -1
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +1 -0
- package/lib/view/transactionDetail/transactionDetailSelector.js +9 -2
- package/package.json +1 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.d.ts +0 -44
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +0 -53
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.d.ts +0 -9
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +0 -40
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +0 -47
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -54
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.d.ts +0 -52
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -36
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +0 -47
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +0 -36
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -50
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -30
- package/lib/esm/view/aiAccountantView/aiAccountantViewPayload.js +0 -2
- package/lib/esm/view/aiAccountantView/aiAccountantViewReducer.js +0 -145
- package/lib/esm/view/aiAccountantView/aiAccountantViewSelector.js +0 -72
- package/lib/esm/view/aiAccountantView/aiAccountantViewState.js +0 -11
- package/lib/esm/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +0 -26
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +0 -27
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +0 -37
- package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +0 -39
- package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +0 -31
- package/lib/view/aiAccountantView/aiAccountantViewPayload.js +0 -8
- package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +0 -27
- package/lib/view/aiAccountantView/aiAccountantViewReducer.js +0 -149
- package/lib/view/aiAccountantView/aiAccountantViewSelector.d.ts +0 -13
- package/lib/view/aiAccountantView/aiAccountantViewSelector.js +0 -78
- package/lib/view/aiAccountantView/aiAccountantViewState.d.ts +0 -26
- package/lib/view/aiAccountantView/aiAccountantViewState.js +0 -13
- package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.d.ts +0 -20
- package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +0 -30
- package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.d.ts +0 -23
- package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +0 -31
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.d.ts +0 -26
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +0 -41
- package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.d.ts +0 -15
- package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +0 -43
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
4
|
-
import { fetchAiAccountantCustomers, triggerAiAccountantJob, triggerAiAccountantJobFailure, triggerAiAccountantJobSuccess, } from '../aiAccountantViewReducer';
|
|
5
|
-
export const triggerAiAccountantJobEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(triggerAiAccountantJob.match), mergeMap((action) => {
|
|
6
|
-
const { operationType, params, triggeredBy } = action.payload;
|
|
7
|
-
const rootState = state$.value;
|
|
8
|
-
const selectedTenantIds = rootState.aiAccountantViewState.selectedTenantIdsForJobTrigger;
|
|
9
|
-
const entityState = rootState.aiAccountantCustomerState;
|
|
10
|
-
const customers = selectedTenantIds
|
|
11
|
-
.map((tenantId) => {
|
|
12
|
-
const customer = entityState.customerByTenantId[tenantId];
|
|
13
|
-
return customer != null
|
|
14
|
-
? { company_id: customer.companyId, tenant_id: customer.tenantId }
|
|
15
|
-
: undefined;
|
|
16
|
-
})
|
|
17
|
-
.filter((entry) => entry != null);
|
|
18
|
-
const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
|
|
19
|
-
const url = `${base}/ai-accountant/jobs`;
|
|
20
|
-
return zeniAPI
|
|
21
|
-
.postAndGetJSON(url, {
|
|
22
|
-
customers,
|
|
23
|
-
operation_type: operationType,
|
|
24
|
-
params: params ?? {},
|
|
25
|
-
triggered_by: triggeredBy ?? 'cockpit-ui',
|
|
26
|
-
})
|
|
27
|
-
.pipe(mergeMap((response) => {
|
|
28
|
-
if (isSuccessResponse(response)) {
|
|
29
|
-
return from([
|
|
30
|
-
triggerAiAccountantJobSuccess(),
|
|
31
|
-
fetchAiAccountantCustomers(),
|
|
32
|
-
]);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return of(triggerAiAccountantJobFailure(response.status));
|
|
36
|
-
}
|
|
37
|
-
}), catchError((error) => of(triggerAiAccountantJobFailure(createZeniAPIStatus('Unexpected error', 'AI Accountant trigger job failed: ' +
|
|
38
|
-
JSON.stringify(error))))));
|
|
39
|
-
}));
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ZeniAPIResponse } from '../../responsePayload';
|
|
2
|
-
export { AiAccountantCustomerPayload, AiAccountantEnrollmentPayload, AiAccountantJobPayload, toAiAccountantCustomer, toAiAccountantEnrollment, toAiAccountantJob, } from '../../entity/aiAccountantCustomer/aiAccountantCustomerPayload';
|
|
3
|
-
import type { AiAccountantCustomerPayload, AiAccountantJobPayload } from '../../entity/aiAccountantCustomer/aiAccountantCustomerPayload';
|
|
4
|
-
import { UserPayload } from '../../entity/user/userPayload';
|
|
5
|
-
export interface AiAccountantCustomersResponseData {
|
|
6
|
-
customers: AiAccountantCustomerPayload[];
|
|
7
|
-
users: UserPayload[];
|
|
8
|
-
}
|
|
9
|
-
export interface AiAccountantJobsResponseData {
|
|
10
|
-
jobs: AiAccountantJobPayload[];
|
|
11
|
-
limit: number;
|
|
12
|
-
page: number;
|
|
13
|
-
users: UserPayload[];
|
|
14
|
-
}
|
|
15
|
-
export interface AiAccountantTriggerJobResponseData {
|
|
16
|
-
job_ids: string[];
|
|
17
|
-
queued_count: number;
|
|
18
|
-
skipped?: Array<{
|
|
19
|
-
reason: string;
|
|
20
|
-
tenant_id: string;
|
|
21
|
-
}>;
|
|
22
|
-
}
|
|
23
|
-
export interface AiAccountantCancelOnboardingResponseData {
|
|
24
|
-
cancelled_jobs: string[];
|
|
25
|
-
ok: boolean;
|
|
26
|
-
workflow_cancelled: boolean;
|
|
27
|
-
}
|
|
28
|
-
export type AiAccountantCustomersResponse = ZeniAPIResponse<AiAccountantCustomersResponseData>;
|
|
29
|
-
export type AiAccountantJobsResponse = ZeniAPIResponse<AiAccountantJobsResponseData>;
|
|
30
|
-
export type AiAccountantTriggerJobResponse = ZeniAPIResponse<AiAccountantTriggerJobResponseData>;
|
|
31
|
-
export type AiAccountantCancelOnboardingResponse = ZeniAPIResponse<AiAccountantCancelOnboardingResponseData>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toAiAccountantJob = exports.toAiAccountantEnrollment = exports.toAiAccountantCustomer = void 0;
|
|
4
|
-
// Re-export entity payload types and mapping functions.
|
|
5
|
-
var aiAccountantCustomerPayload_1 = require("../../entity/aiAccountantCustomer/aiAccountantCustomerPayload");
|
|
6
|
-
Object.defineProperty(exports, "toAiAccountantCustomer", { enumerable: true, get: function () { return aiAccountantCustomerPayload_1.toAiAccountantCustomer; } });
|
|
7
|
-
Object.defineProperty(exports, "toAiAccountantEnrollment", { enumerable: true, get: function () { return aiAccountantCustomerPayload_1.toAiAccountantEnrollment; } });
|
|
8
|
-
Object.defineProperty(exports, "toAiAccountantJob", { enumerable: true, get: function () { return aiAccountantCustomerPayload_1.toAiAccountantJob; } });
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AiAccountantCustomerPayload } from '../../entity/aiAccountantCustomer/aiAccountantCustomerPayload';
|
|
2
|
-
import { ID } from '../../commonStateTypes/common';
|
|
3
|
-
import { ZeniAPIStatus } from '../../responsePayload';
|
|
4
|
-
import { AiAccountantUIState, AiAccountantViewState } from './aiAccountantViewState';
|
|
5
|
-
export declare const initialAiAccountantViewState: AiAccountantViewState;
|
|
6
|
-
export declare const cancelAiAccountantOnboarding: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[companyId: string, tenantId: string], {
|
|
7
|
-
companyId: string;
|
|
8
|
-
tenantId: string;
|
|
9
|
-
}, "aiAccountantView/cancelAiAccountantOnboarding", never, never>, cancelAiAccountantOnboardingFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, error: ZeniAPIStatus<Record<string, unknown>>], {
|
|
10
|
-
tenantId: string;
|
|
11
|
-
error: ZeniAPIStatus<Record<string, unknown>>;
|
|
12
|
-
}, "aiAccountantView/cancelAiAccountantOnboardingFailure", never, never>, cancelAiAccountantOnboardingSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string], {
|
|
13
|
-
tenantId: string;
|
|
14
|
-
}, "aiAccountantView/cancelAiAccountantOnboardingSuccess", never, never>, clearAiAccountantView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantView/clearAiAccountantView">, fetchAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantView/fetchAiAccountantCustomers">, fetchAiAccountantJobs: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string], {
|
|
15
|
-
tenantId: string;
|
|
16
|
-
}, "aiAccountantView/fetchAiAccountantJobs", never, never>, setSelectedTenantIdsForJobTrigger: import("@reduxjs/toolkit").ActionCreatorWithPayload<string[], "aiAccountantView/setSelectedTenantIdsForJobTrigger">, triggerAiAccountantJob: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[operationType: "onboard" | "offboard" | "retrain" | "full_pipeline" | "cancel_onboarding", params?: Record<string, unknown> | undefined, triggeredBy?: string | undefined], {
|
|
17
|
-
operationType: "onboard" | "offboard" | "retrain" | "full_pipeline" | "cancel_onboarding";
|
|
18
|
-
params: Record<string, unknown> | undefined;
|
|
19
|
-
triggeredBy: string | undefined;
|
|
20
|
-
}, "aiAccountantView/triggerAiAccountantJob", never, never>, triggerAiAccountantJobFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "aiAccountantView/triggerAiAccountantJobFailure">, triggerAiAccountantJobSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantView/triggerAiAccountantJobSuccess">, updateAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiAccountantCustomerPayload[], "aiAccountantView/updateAiAccountantCustomers">, updateAiAccountantCustomersFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "aiAccountantView/updateAiAccountantCustomersFailure">, updateAiAccountantJobs: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string], {
|
|
21
|
-
tenantId: string;
|
|
22
|
-
}, "aiAccountantView/updateAiAccountantJobs", never, never>, updateAiAccountantJobsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
23
|
-
error: ZeniAPIStatus;
|
|
24
|
-
tenantId: ID;
|
|
25
|
-
}, "aiAccountantView/updateAiAccountantJobsFailure">, updateAiAccountantUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<AiAccountantUIState>, "aiAccountantView/updateAiAccountantUIState">;
|
|
26
|
-
declare const _default: import("redux").Reducer<AiAccountantViewState>;
|
|
27
|
-
export default _default;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.updateAiAccountantUIState = exports.updateAiAccountantJobsFailure = exports.updateAiAccountantJobs = exports.updateAiAccountantCustomersFailure = exports.updateAiAccountantCustomers = exports.triggerAiAccountantJobSuccess = exports.triggerAiAccountantJobFailure = exports.triggerAiAccountantJob = exports.setSelectedTenantIdsForJobTrigger = exports.fetchAiAccountantJobs = exports.fetchAiAccountantCustomers = exports.clearAiAccountantView = exports.cancelAiAccountantOnboardingSuccess = exports.cancelAiAccountantOnboardingFailure = exports.cancelAiAccountantOnboarding = exports.initialAiAccountantViewState = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
exports.initialAiAccountantViewState = {
|
|
7
|
-
customersByTenantId: {},
|
|
8
|
-
customersFetchStatus: { fetchState: 'Not-Started' },
|
|
9
|
-
selectedTenantIdsForJobTrigger: [],
|
|
10
|
-
triggerJobStatus: { fetchState: 'Not-Started' },
|
|
11
|
-
uiState: {
|
|
12
|
-
filterText: '',
|
|
13
|
-
filters: {},
|
|
14
|
-
selectedCustomerTenantId: '',
|
|
15
|
-
sortKey: 'companyName',
|
|
16
|
-
sortOrder: 'ascending',
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
const aiAccountantView = (0, toolkit_1.createSlice)({
|
|
20
|
-
name: 'aiAccountantView',
|
|
21
|
-
initialState: exports.initialAiAccountantViewState,
|
|
22
|
-
reducers: {
|
|
23
|
-
// ── Customers ──
|
|
24
|
-
fetchAiAccountantCustomers(draft) {
|
|
25
|
-
draft.customersFetchStatus = { fetchState: 'In-Progress' };
|
|
26
|
-
},
|
|
27
|
-
updateAiAccountantCustomers(draft, action) {
|
|
28
|
-
draft.customersByTenantId = toCustomersByTenantId(action.payload);
|
|
29
|
-
draft.customersFetchStatus = { fetchState: 'Completed' };
|
|
30
|
-
},
|
|
31
|
-
updateAiAccountantCustomersFailure(draft, action) {
|
|
32
|
-
draft.customersFetchStatus = {
|
|
33
|
-
fetchState: 'Error',
|
|
34
|
-
error: action.payload,
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
// ── Jobs ──
|
|
38
|
-
fetchAiAccountantJobs: {
|
|
39
|
-
reducer(draft, action) {
|
|
40
|
-
const customerView = draft.customersByTenantId[action.payload.tenantId];
|
|
41
|
-
if (customerView != null) {
|
|
42
|
-
customerView.jobsFetchStatus = { fetchState: 'In-Progress' };
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
prepare(tenantId) {
|
|
46
|
-
return { payload: { tenantId } };
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
updateAiAccountantJobs: {
|
|
50
|
-
reducer(draft, action) {
|
|
51
|
-
const customerView = draft.customersByTenantId[action.payload.tenantId];
|
|
52
|
-
if (customerView != null) {
|
|
53
|
-
customerView.jobsFetchStatus = { fetchState: 'Completed' };
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
prepare(tenantId) {
|
|
57
|
-
return { payload: { tenantId } };
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
updateAiAccountantJobsFailure(draft, action) {
|
|
61
|
-
const customerView = draft.customersByTenantId[action.payload.tenantId];
|
|
62
|
-
if (customerView != null) {
|
|
63
|
-
customerView.jobsFetchStatus = {
|
|
64
|
-
fetchState: 'Error',
|
|
65
|
-
error: action.payload.error,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
setSelectedTenantIdsForJobTrigger(draft, action) {
|
|
70
|
-
draft.selectedTenantIdsForJobTrigger = action.payload;
|
|
71
|
-
},
|
|
72
|
-
// ── Trigger Job ──
|
|
73
|
-
triggerAiAccountantJob: {
|
|
74
|
-
reducer(draft,
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
76
|
-
_action) {
|
|
77
|
-
draft.triggerJobStatus = { fetchState: 'In-Progress' };
|
|
78
|
-
},
|
|
79
|
-
prepare(operationType, params, triggeredBy) {
|
|
80
|
-
return { payload: { operationType, params, triggeredBy } };
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
triggerAiAccountantJobSuccess(draft) {
|
|
84
|
-
draft.triggerJobStatus = { fetchState: 'Completed' };
|
|
85
|
-
},
|
|
86
|
-
triggerAiAccountantJobFailure(draft, action) {
|
|
87
|
-
draft.triggerJobStatus = { fetchState: 'Error', error: action.payload };
|
|
88
|
-
},
|
|
89
|
-
// ── Cancel Onboarding ──
|
|
90
|
-
cancelAiAccountantOnboarding: {
|
|
91
|
-
reducer(draft, action) {
|
|
92
|
-
const customerView = draft.customersByTenantId[action.payload.tenantId];
|
|
93
|
-
if (customerView != null) {
|
|
94
|
-
customerView.cancelOnboardingStatus = { fetchState: 'In-Progress' };
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
prepare(companyId, tenantId) {
|
|
98
|
-
return { payload: { companyId, tenantId } };
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
cancelAiAccountantOnboardingSuccess: {
|
|
102
|
-
reducer(draft, action) {
|
|
103
|
-
const customerView = draft.customersByTenantId[action.payload.tenantId];
|
|
104
|
-
if (customerView != null) {
|
|
105
|
-
customerView.cancelOnboardingStatus = { fetchState: 'Completed' };
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
prepare(tenantId) {
|
|
109
|
-
return { payload: { tenantId } };
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
cancelAiAccountantOnboardingFailure: {
|
|
113
|
-
reducer(draft, action) {
|
|
114
|
-
const customerView = draft.customersByTenantId[action.payload.tenantId];
|
|
115
|
-
if (customerView != null) {
|
|
116
|
-
customerView.cancelOnboardingStatus = {
|
|
117
|
-
fetchState: 'Error',
|
|
118
|
-
error: action.payload.error,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
prepare(tenantId, error) {
|
|
123
|
-
return { payload: { tenantId, error } };
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
// ── UI State ──
|
|
127
|
-
updateAiAccountantUIState(draft, action) {
|
|
128
|
-
Object.assign(draft.uiState, action.payload);
|
|
129
|
-
},
|
|
130
|
-
// ── Clear ──
|
|
131
|
-
clearAiAccountantView() {
|
|
132
|
-
return exports.initialAiAccountantViewState;
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
_a = aiAccountantView.actions, exports.cancelAiAccountantOnboarding = _a.cancelAiAccountantOnboarding, exports.cancelAiAccountantOnboardingFailure = _a.cancelAiAccountantOnboardingFailure, exports.cancelAiAccountantOnboardingSuccess = _a.cancelAiAccountantOnboardingSuccess, exports.clearAiAccountantView = _a.clearAiAccountantView, exports.fetchAiAccountantCustomers = _a.fetchAiAccountantCustomers, exports.fetchAiAccountantJobs = _a.fetchAiAccountantJobs, exports.setSelectedTenantIdsForJobTrigger = _a.setSelectedTenantIdsForJobTrigger, exports.triggerAiAccountantJob = _a.triggerAiAccountantJob, exports.triggerAiAccountantJobFailure = _a.triggerAiAccountantJobFailure, exports.triggerAiAccountantJobSuccess = _a.triggerAiAccountantJobSuccess, exports.updateAiAccountantCustomers = _a.updateAiAccountantCustomers, exports.updateAiAccountantCustomersFailure = _a.updateAiAccountantCustomersFailure, exports.updateAiAccountantJobs = _a.updateAiAccountantJobs, exports.updateAiAccountantJobsFailure = _a.updateAiAccountantJobsFailure, exports.updateAiAccountantUIState = _a.updateAiAccountantUIState;
|
|
137
|
-
exports.default = aiAccountantView.reducer;
|
|
138
|
-
// ── Helpers ──
|
|
139
|
-
const toCustomersByTenantId = (customers) => {
|
|
140
|
-
const result = {};
|
|
141
|
-
for (const payload of customers) {
|
|
142
|
-
result[payload.tenant_id] = {
|
|
143
|
-
cancelOnboardingStatus: { fetchState: 'Not-Started' },
|
|
144
|
-
jobsFetchStatus: { fetchState: 'Not-Started' },
|
|
145
|
-
tenantId: payload.tenant_id,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
return result;
|
|
149
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FetchStateAndError } from '../../commonStateTypes/common';
|
|
2
|
-
import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
3
|
-
import { AiAccountantCustomerView } from '../../entity/aiAccountantCustomer/aiAccountantCustomerSelector';
|
|
4
|
-
import { RootState } from '../../reducer';
|
|
5
|
-
import { AiAccountantCustomerViewState, AiAccountantUIState } from './aiAccountantViewState';
|
|
6
|
-
export interface AiAccountantCockpitView extends SelectorView {
|
|
7
|
-
customers: AiAccountantCustomerView[];
|
|
8
|
-
customerViewStateByTenantId: Record<string, AiAccountantCustomerViewState>;
|
|
9
|
-
selectedCustomersForJobTrigger: AiAccountantCustomerView[];
|
|
10
|
-
triggerJobStatus: FetchStateAndError;
|
|
11
|
-
uiState: AiAccountantUIState;
|
|
12
|
-
}
|
|
13
|
-
export declare const getAiAccountantCockpitView: (state: RootState) => AiAccountantCockpitView;
|
|
@@ -1,78 +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.getAiAccountantCockpitView = void 0;
|
|
7
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
8
|
-
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
9
|
-
const aiAccountantCustomerSelector_1 = require("../../entity/aiAccountantCustomer/aiAccountantCustomerSelector");
|
|
10
|
-
exports.getAiAccountantCockpitView = (0, toolkit_1.createSelector)((state) => state.aiAccountantViewState, (state) => state.aiAccountantCustomerState, (state) => state.userState, (viewState, customerEntityState, userState) => {
|
|
11
|
-
const { customersByTenantId, customersFetchStatus, selectedTenantIdsForJobTrigger, triggerJobStatus, uiState, } = viewState;
|
|
12
|
-
const allCustomers = (0, aiAccountantCustomerSelector_1.getAiAccountantCustomers)(customerEntityState, userState);
|
|
13
|
-
let filteredCustomers = allCustomers;
|
|
14
|
-
// Text filter
|
|
15
|
-
const trimmedFilterText = uiState.filterText.trim();
|
|
16
|
-
if (trimmedFilterText.length > 0) {
|
|
17
|
-
const query = trimmedFilterText.toLowerCase();
|
|
18
|
-
filteredCustomers = filteredCustomers.filter((customer) => customer.companyName.toLowerCase().includes(query) ||
|
|
19
|
-
customer.tenantId.toLowerCase().includes(query));
|
|
20
|
-
}
|
|
21
|
-
// Cockpit filters (e.g. enrollmentStatus)
|
|
22
|
-
const enrollmentStatusFilter = uiState.filters.categories?.find((category) => category.field === 'enrollmentStatus');
|
|
23
|
-
if (enrollmentStatusFilter != null &&
|
|
24
|
-
enrollmentStatusFilter.values.length > 0) {
|
|
25
|
-
const selectedStatuses = enrollmentStatusFilter.values.map(String);
|
|
26
|
-
const isEqual = enrollmentStatusFilter.matchingOperator === 'equal';
|
|
27
|
-
filteredCustomers = filteredCustomers.filter((customer) => {
|
|
28
|
-
const status = customer.enrollment?.status ?? 'unknown';
|
|
29
|
-
const matches = selectedStatuses.includes(status);
|
|
30
|
-
return isEqual ? matches : !matches;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// Sorting
|
|
34
|
-
const sortedCustomers = getSortedCustomers(filteredCustomers, uiState.sortKey, uiState.sortOrder);
|
|
35
|
-
const selectedCustomersForJobTrigger = allCustomers.filter((customer) => selectedTenantIdsForJobTrigger.includes(customer.tenantId));
|
|
36
|
-
return {
|
|
37
|
-
fetchState: customersFetchStatus.fetchState,
|
|
38
|
-
error: customersFetchStatus.error,
|
|
39
|
-
customers: sortedCustomers,
|
|
40
|
-
customerViewStateByTenantId: customersByTenantId,
|
|
41
|
-
selectedCustomersForJobTrigger,
|
|
42
|
-
triggerJobStatus,
|
|
43
|
-
uiState,
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
// ── Helpers ──
|
|
47
|
-
const getSortedCustomers = (customers, sortKey, sortOrder) => {
|
|
48
|
-
const direction = sortOrder === 'ascending' ? 'asc' : 'desc';
|
|
49
|
-
return (0, orderBy_1.default)(customers, (customer) => {
|
|
50
|
-
switch (sortKey) {
|
|
51
|
-
case 'companyName':
|
|
52
|
-
return customer.companyName.toLowerCase();
|
|
53
|
-
case 'status':
|
|
54
|
-
return (customer.enrollment?.status ?? 'unknown').toLowerCase();
|
|
55
|
-
case 'bookcloseDate':
|
|
56
|
-
return customer.bookcloseDate ?? '';
|
|
57
|
-
case 'latestTraining':
|
|
58
|
-
return customer.enrollment?.latestTraining ?? '';
|
|
59
|
-
case 'latestSync':
|
|
60
|
-
return customer.enrollment?.latestTransactionSync ?? '';
|
|
61
|
-
case 'accuracy':
|
|
62
|
-
return calcCustomerAccuracy(customer);
|
|
63
|
-
default:
|
|
64
|
-
return customer.companyName.toLowerCase();
|
|
65
|
-
}
|
|
66
|
-
}, direction);
|
|
67
|
-
};
|
|
68
|
-
const calcCustomerAccuracy = (customer) => {
|
|
69
|
-
const accuracy = customer.enrollment?.accuracy;
|
|
70
|
-
if (accuracy == null) {
|
|
71
|
-
return 0;
|
|
72
|
-
}
|
|
73
|
-
const values = Object.values(accuracy);
|
|
74
|
-
if (values.length === 0) {
|
|
75
|
-
return 0;
|
|
76
|
-
}
|
|
77
|
-
return values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
78
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FetchStateAndError, ID } from '../../commonStateTypes/common';
|
|
2
|
-
import { SortOrder } from '../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
3
|
-
import { CockpitFilters } from '../companyView/types/cockpitTypes';
|
|
4
|
-
export type { AiAccountantCustomer, AiAccountantEnrollment, AiAccountantEnrollmentStatus, AiAccountantJob, AiAccountantJobStatus, AiAccountantOperationType, } from '../../entity/aiAccountantCustomer/aiAccountantCustomerState';
|
|
5
|
-
declare const toAiAccountantSortKeyType: (v: string) => "status" | "companyName" | "bookcloseDate" | "accuracy" | "latestTraining" | "latestSync";
|
|
6
|
-
export type AiAccountantSortKey = ReturnType<typeof toAiAccountantSortKeyType>;
|
|
7
|
-
export type AiAccountantFilterCategoryField = 'enrollmentStatus';
|
|
8
|
-
export interface AiAccountantUIState {
|
|
9
|
-
filters: CockpitFilters;
|
|
10
|
-
filterText: string;
|
|
11
|
-
selectedCustomerTenantId: string;
|
|
12
|
-
sortKey: AiAccountantSortKey;
|
|
13
|
-
sortOrder: SortOrder;
|
|
14
|
-
}
|
|
15
|
-
export interface AiAccountantCustomerViewState {
|
|
16
|
-
cancelOnboardingStatus: FetchStateAndError;
|
|
17
|
-
jobsFetchStatus: FetchStateAndError;
|
|
18
|
-
tenantId: ID;
|
|
19
|
-
}
|
|
20
|
-
export interface AiAccountantViewState {
|
|
21
|
-
customersByTenantId: Record<ID, AiAccountantCustomerViewState>;
|
|
22
|
-
customersFetchStatus: FetchStateAndError;
|
|
23
|
-
selectedTenantIdsForJobTrigger: ID[];
|
|
24
|
-
triggerJobStatus: FetchStateAndError;
|
|
25
|
-
uiState: AiAccountantUIState;
|
|
26
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
4
|
-
const ALL_AI_ACCOUNTANT_SORT_KEYS = [
|
|
5
|
-
'companyName',
|
|
6
|
-
'status',
|
|
7
|
-
'bookcloseDate',
|
|
8
|
-
'latestTraining',
|
|
9
|
-
'latestSync',
|
|
10
|
-
'accuracy',
|
|
11
|
-
];
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
-
const toAiAccountantSortKeyType = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_AI_ACCOUNTANT_SORT_KEYS);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { RootState } from '../../../reducer';
|
|
3
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
4
|
-
import { cancelAiAccountantOnboarding, cancelAiAccountantOnboardingFailure, cancelAiAccountantOnboardingSuccess, fetchAiAccountantCustomers } from '../aiAccountantViewReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof cancelAiAccountantOnboarding> | ReturnType<typeof cancelAiAccountantOnboardingSuccess> | ReturnType<typeof cancelAiAccountantOnboardingFailure> | ReturnType<typeof fetchAiAccountantCustomers>;
|
|
6
|
-
export declare const cancelAiAccountantOnboardingEpic: (actions$: ActionsObservable<ActionType>, _: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
7
|
-
payload: undefined;
|
|
8
|
-
type: "aiAccountantView/fetchAiAccountantCustomers";
|
|
9
|
-
} | {
|
|
10
|
-
payload: {
|
|
11
|
-
tenantId: string;
|
|
12
|
-
};
|
|
13
|
-
type: "aiAccountantView/cancelAiAccountantOnboardingSuccess";
|
|
14
|
-
} | {
|
|
15
|
-
payload: {
|
|
16
|
-
tenantId: string;
|
|
17
|
-
error: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
|
|
18
|
-
};
|
|
19
|
-
type: "aiAccountantView/cancelAiAccountantOnboardingFailure";
|
|
20
|
-
}>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cancelAiAccountantOnboardingEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
7
|
-
const aiAccountantViewReducer_1 = require("../aiAccountantViewReducer");
|
|
8
|
-
const cancelAiAccountantOnboardingEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiAccountantViewReducer_1.cancelAiAccountantOnboarding.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
-
const { tenantId, companyId } = action.payload;
|
|
10
|
-
const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
|
|
11
|
-
const url = `${base}/ai-accountant/cancel-onboarding`;
|
|
12
|
-
return zeniAPI
|
|
13
|
-
.postAndGetJSON(url, {
|
|
14
|
-
tenant_id: tenantId,
|
|
15
|
-
company_id: companyId,
|
|
16
|
-
})
|
|
17
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
18
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
19
|
-
return (0, rxjs_1.from)([
|
|
20
|
-
(0, aiAccountantViewReducer_1.cancelAiAccountantOnboardingSuccess)(tenantId),
|
|
21
|
-
(0, aiAccountantViewReducer_1.fetchAiAccountantCustomers)(),
|
|
22
|
-
]);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return (0, rxjs_1.of)((0, aiAccountantViewReducer_1.cancelAiAccountantOnboardingFailure)(tenantId, response.status));
|
|
26
|
-
}
|
|
27
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiAccountantViewReducer_1.cancelAiAccountantOnboardingFailure)(tenantId, (0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'AI Accountant cancel onboarding failed: ' +
|
|
28
|
-
JSON.stringify(error))))));
|
|
29
|
-
}));
|
|
30
|
-
exports.cancelAiAccountantOnboardingEpic = cancelAiAccountantOnboardingEpic;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { updateAiAccountantCustomers as updateAiAccountantCustomerEntities } from '../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer';
|
|
3
|
-
import { updateAllUsers } from '../../../entity/user/userReducer';
|
|
4
|
-
import { RootState } from '../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
6
|
-
import { fetchAiAccountantCustomers, updateAiAccountantCustomers, updateAiAccountantCustomersFailure } from '../aiAccountantViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchAiAccountantCustomers> | ReturnType<typeof updateAiAccountantCustomers> | ReturnType<typeof updateAiAccountantCustomersFailure> | ReturnType<typeof updateAiAccountantCustomerEntities> | ReturnType<typeof updateAllUsers>;
|
|
8
|
-
export declare const fetchAiAccountantCustomersEpic: (actions$: ActionsObservable<ActionType>, _: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
9
|
-
payload: {
|
|
10
|
-
users: import("../../..").UserPayload[];
|
|
11
|
-
updateType?: import("../../..").UpdateType;
|
|
12
|
-
};
|
|
13
|
-
type: "user/updateAllUsers";
|
|
14
|
-
} | {
|
|
15
|
-
payload: import("../aiAccountantViewPayload").AiAccountantCustomerPayload[];
|
|
16
|
-
type: "aiAccountantView/updateAiAccountantCustomers";
|
|
17
|
-
} | {
|
|
18
|
-
payload: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
|
|
19
|
-
type: "aiAccountantView/updateAiAccountantCustomersFailure";
|
|
20
|
-
} | {
|
|
21
|
-
payload: import("../aiAccountantViewPayload").AiAccountantCustomerPayload[];
|
|
22
|
-
type: "aiAccountantCustomer/updateAiAccountantCustomers";
|
|
23
|
-
}>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchAiAccountantCustomersEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const aiAccountantCustomerReducer_1 = require("../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer");
|
|
7
|
-
const userReducer_1 = require("../../../entity/user/userReducer");
|
|
8
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
9
|
-
const aiAccountantViewReducer_1 = require("../aiAccountantViewReducer");
|
|
10
|
-
const fetchAiAccountantCustomersEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiAccountantViewReducer_1.fetchAiAccountantCustomers.match), (0, operators_1.switchMap)(() => {
|
|
11
|
-
const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
|
|
12
|
-
const url = `${base}/ai-accountant/customers`;
|
|
13
|
-
return zeniAPI
|
|
14
|
-
.getJSON(url)
|
|
15
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
16
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
17
|
-
const customers = response.data?.customers ?? [];
|
|
18
|
-
const users = response.data?.users ?? [];
|
|
19
|
-
return (0, rxjs_1.from)([
|
|
20
|
-
(0, aiAccountantCustomerReducer_1.updateAiAccountantCustomers)(customers),
|
|
21
|
-
(0, userReducer_1.updateAllUsers)({ users }),
|
|
22
|
-
(0, aiAccountantViewReducer_1.updateAiAccountantCustomers)(customers),
|
|
23
|
-
]);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return (0, rxjs_1.of)((0, aiAccountantViewReducer_1.updateAiAccountantCustomersFailure)(response.status));
|
|
27
|
-
}
|
|
28
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiAccountantViewReducer_1.updateAiAccountantCustomersFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'AI Accountant customers fetch failed: ' +
|
|
29
|
-
JSON.stringify(error))))));
|
|
30
|
-
}));
|
|
31
|
-
exports.fetchAiAccountantCustomersEpic = fetchAiAccountantCustomersEpic;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { updateAiAccountantJobs as updateAiAccountantJobEntities } from '../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer';
|
|
3
|
-
import { updateAllUsers } from '../../../entity/user/userReducer';
|
|
4
|
-
import { RootState } from '../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
6
|
-
import { fetchAiAccountantJobs, updateAiAccountantJobsFailure } from '../aiAccountantViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchAiAccountantJobs> | ReturnType<typeof updateAiAccountantJobEntities> | ReturnType<typeof updateAiAccountantJobsFailure> | ReturnType<typeof updateAllUsers>;
|
|
8
|
-
export declare const fetchAiAccountantJobsEpic: (actions$: ActionsObservable<ActionType>, _: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
9
|
-
payload: {
|
|
10
|
-
users: import("../../..").UserPayload[];
|
|
11
|
-
updateType?: import("../../..").UpdateType;
|
|
12
|
-
};
|
|
13
|
-
type: "user/updateAllUsers";
|
|
14
|
-
} | {
|
|
15
|
-
payload: {
|
|
16
|
-
tenantId: string;
|
|
17
|
-
jobs: import("../aiAccountantViewPayload").AiAccountantJobPayload[];
|
|
18
|
-
};
|
|
19
|
-
type: "aiAccountantCustomer/updateAiAccountantJobs";
|
|
20
|
-
} | {
|
|
21
|
-
payload: {
|
|
22
|
-
error: import("../../../responsePayload").ZeniAPIStatus;
|
|
23
|
-
tenantId: import("../../..").ID;
|
|
24
|
-
};
|
|
25
|
-
type: "aiAccountantView/updateAiAccountantJobsFailure";
|
|
26
|
-
}>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchAiAccountantJobsEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const aiAccountantCustomerReducer_1 = require("../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer");
|
|
7
|
-
const userReducer_1 = require("../../../entity/user/userReducer");
|
|
8
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
9
|
-
const aiAccountantViewReducer_1 = require("../aiAccountantViewReducer");
|
|
10
|
-
const fetchAiAccountantJobsEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiAccountantViewReducer_1.fetchAiAccountantJobs.match), (0, operators_1.switchMap)((action) => {
|
|
11
|
-
const { tenantId } = action.payload;
|
|
12
|
-
const params = new URLSearchParams({
|
|
13
|
-
page: '1',
|
|
14
|
-
limit: '50',
|
|
15
|
-
tenant_id: tenantId,
|
|
16
|
-
});
|
|
17
|
-
const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
|
|
18
|
-
const url = `${base}/ai-accountant/jobs?${params.toString()}`;
|
|
19
|
-
return zeniAPI
|
|
20
|
-
.getJSON(url)
|
|
21
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
22
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
23
|
-
const jobs = response.data?.jobs ?? [];
|
|
24
|
-
const users = response.data?.users ?? [];
|
|
25
|
-
return (0, rxjs_1.from)([
|
|
26
|
-
(0, userReducer_1.updateAllUsers)({ users }),
|
|
27
|
-
(0, aiAccountantCustomerReducer_1.updateAiAccountantJobs)(tenantId, jobs),
|
|
28
|
-
]);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return (0, rxjs_1.of)((0, aiAccountantViewReducer_1.updateAiAccountantJobsFailure)({
|
|
32
|
-
tenantId,
|
|
33
|
-
error: response.status,
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiAccountantViewReducer_1.updateAiAccountantJobsFailure)({
|
|
37
|
-
tenantId,
|
|
38
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'AI Accountant jobs fetch failed: ' + JSON.stringify(error)),
|
|
39
|
-
}))));
|
|
40
|
-
}));
|
|
41
|
-
exports.fetchAiAccountantJobsEpic = fetchAiAccountantJobsEpic;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { RootState } from '../../../reducer';
|
|
3
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
4
|
-
import { fetchAiAccountantCustomers, triggerAiAccountantJob, triggerAiAccountantJobFailure, triggerAiAccountantJobSuccess } from '../aiAccountantViewReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof triggerAiAccountantJob> | ReturnType<typeof triggerAiAccountantJobSuccess> | ReturnType<typeof triggerAiAccountantJobFailure> | ReturnType<typeof fetchAiAccountantCustomers>;
|
|
6
|
-
export declare const triggerAiAccountantJobEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
7
|
-
payload: undefined;
|
|
8
|
-
type: "aiAccountantView/fetchAiAccountantCustomers";
|
|
9
|
-
} | {
|
|
10
|
-
payload: undefined;
|
|
11
|
-
type: "aiAccountantView/triggerAiAccountantJobSuccess";
|
|
12
|
-
} | {
|
|
13
|
-
payload: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
|
|
14
|
-
type: "aiAccountantView/triggerAiAccountantJobFailure";
|
|
15
|
-
}>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.triggerAiAccountantJobEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
7
|
-
const aiAccountantViewReducer_1 = require("../aiAccountantViewReducer");
|
|
8
|
-
const triggerAiAccountantJobEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiAccountantViewReducer_1.triggerAiAccountantJob.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
-
const { operationType, params, triggeredBy } = action.payload;
|
|
10
|
-
const rootState = state$.value;
|
|
11
|
-
const selectedTenantIds = rootState.aiAccountantViewState.selectedTenantIdsForJobTrigger;
|
|
12
|
-
const entityState = rootState.aiAccountantCustomerState;
|
|
13
|
-
const customers = selectedTenantIds
|
|
14
|
-
.map((tenantId) => {
|
|
15
|
-
const customer = entityState.customerByTenantId[tenantId];
|
|
16
|
-
return customer != null
|
|
17
|
-
? { company_id: customer.companyId, tenant_id: customer.tenantId }
|
|
18
|
-
: undefined;
|
|
19
|
-
})
|
|
20
|
-
.filter((entry) => entry != null);
|
|
21
|
-
const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
|
|
22
|
-
const url = `${base}/ai-accountant/jobs`;
|
|
23
|
-
return zeniAPI
|
|
24
|
-
.postAndGetJSON(url, {
|
|
25
|
-
customers,
|
|
26
|
-
operation_type: operationType,
|
|
27
|
-
params: params ?? {},
|
|
28
|
-
triggered_by: triggeredBy ?? 'cockpit-ui',
|
|
29
|
-
})
|
|
30
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
31
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
32
|
-
return (0, rxjs_1.from)([
|
|
33
|
-
(0, aiAccountantViewReducer_1.triggerAiAccountantJobSuccess)(),
|
|
34
|
-
(0, aiAccountantViewReducer_1.fetchAiAccountantCustomers)(),
|
|
35
|
-
]);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return (0, rxjs_1.of)((0, aiAccountantViewReducer_1.triggerAiAccountantJobFailure)(response.status));
|
|
39
|
-
}
|
|
40
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiAccountantViewReducer_1.triggerAiAccountantJobFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'AI Accountant trigger job failed: ' +
|
|
41
|
-
JSON.stringify(error))))));
|
|
42
|
-
}));
|
|
43
|
-
exports.triggerAiAccountantJobEpic = triggerAiAccountantJobEpic;
|