@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.
Files changed (107) hide show
  1. package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +2 -2
  2. package/lib/entity/chargeCard/chargeCard.d.ts +1 -1
  3. package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -1
  4. package/lib/entity/entityApprovalStatus/entityApprovalStatusState.d.ts +2 -2
  5. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +9 -6
  6. package/lib/entity/jeSchedules/jeSchedulesPayload.js +36 -2
  7. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +4 -2
  8. package/lib/entity/jeSchedules/jeSchedulesSelector.js +5 -2
  9. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +26 -2
  10. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  11. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  12. package/lib/entity/tenant/clearAllEpic.d.ts +1 -3
  13. package/lib/entity/tenant/clearAllEpic.js +0 -4
  14. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +4 -1
  15. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +1 -0
  16. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +1 -0
  17. package/lib/entity/userRole/userRoleType.d.ts +2 -2
  18. package/lib/epic.d.ts +1 -5
  19. package/lib/epic.js +1 -5
  20. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +36 -2
  21. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +5 -2
  22. package/lib/esm/entity/tenant/clearAllEpic.js +0 -4
  23. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +1 -0
  24. package/lib/esm/epic.js +1 -5
  25. package/lib/esm/index.js +0 -7
  26. package/lib/esm/reducer.js +0 -6
  27. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -2
  28. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +2 -2
  29. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +4 -3
  30. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +0 -1
  31. package/lib/esm/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +10 -2
  32. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +13 -3
  33. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +11 -3
  34. package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +22 -9
  35. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +12 -6
  36. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -0
  37. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +3 -8
  38. package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +144 -63
  39. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +9 -2
  40. package/lib/index.d.ts +2 -10
  41. package/lib/index.js +2 -30
  42. package/lib/reducer.d.ts +0 -6
  43. package/lib/reducer.js +0 -6
  44. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  45. package/lib/view/companyView/types/cockpitTypes.d.ts +5 -6
  46. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -2
  47. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +1 -1
  48. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +4 -3
  49. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +0 -1
  50. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  51. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +1 -1
  52. package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +10 -2
  53. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +13 -3
  54. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +11 -3
  55. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +22 -9
  56. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +11 -5
  57. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  58. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -0
  59. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -1
  60. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +3 -8
  61. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +144 -63
  62. package/lib/view/reviewCompanyView/reviewCompanyViewState.d.ts +1 -1
  63. package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +1 -1
  64. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  65. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +4 -4
  66. package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +1 -1
  67. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +3 -3
  68. package/lib/view/subscriptionView/types/subscriptionTypes.d.ts +1 -1
  69. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +1 -0
  70. package/lib/view/transactionDetail/transactionDetailSelector.js +9 -2
  71. package/package.json +1 -1
  72. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.d.ts +0 -44
  73. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +0 -53
  74. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.d.ts +0 -9
  75. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +0 -40
  76. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +0 -47
  77. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -54
  78. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.d.ts +0 -52
  79. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -36
  80. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +0 -47
  81. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +0 -36
  82. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -50
  83. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -30
  84. package/lib/esm/view/aiAccountantView/aiAccountantViewPayload.js +0 -2
  85. package/lib/esm/view/aiAccountantView/aiAccountantViewReducer.js +0 -145
  86. package/lib/esm/view/aiAccountantView/aiAccountantViewSelector.js +0 -72
  87. package/lib/esm/view/aiAccountantView/aiAccountantViewState.js +0 -11
  88. package/lib/esm/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +0 -26
  89. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +0 -27
  90. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +0 -37
  91. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +0 -39
  92. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +0 -31
  93. package/lib/view/aiAccountantView/aiAccountantViewPayload.js +0 -8
  94. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +0 -27
  95. package/lib/view/aiAccountantView/aiAccountantViewReducer.js +0 -149
  96. package/lib/view/aiAccountantView/aiAccountantViewSelector.d.ts +0 -13
  97. package/lib/view/aiAccountantView/aiAccountantViewSelector.js +0 -78
  98. package/lib/view/aiAccountantView/aiAccountantViewState.d.ts +0 -26
  99. package/lib/view/aiAccountantView/aiAccountantViewState.js +0 -13
  100. package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.d.ts +0 -20
  101. package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +0 -30
  102. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.d.ts +0 -23
  103. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +0 -31
  104. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.d.ts +0 -26
  105. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +0 -41
  106. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.d.ts +0 -15
  107. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +0 -43
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAiAccountantCustomers = getAiAccountantCustomers;
4
- exports.getAiAccountantJobsByTenantId = getAiAccountantJobsByTenantId;
5
- const userSelector_1 = require("../user/userSelector");
6
- // ── Selectors ──
7
- function getAiAccountantCustomers(customerState, userState) {
8
- return Object.values(customerState.customerByTenantId).map((customer) => toCustomerView(customer, userState));
9
- }
10
- function getAiAccountantJobsByTenantId(customerState, userState, tenantId) {
11
- const jobs = customerState.jobsByTenantId[tenantId] ?? [];
12
- return jobs.map((job) => toJobView(job, userState));
13
- }
14
- // ── Helpers ──
15
- function toCustomerView(customer, userState) {
16
- return {
17
- companyId: customer.companyId,
18
- companyName: customer.companyName,
19
- tenantId: customer.tenantId,
20
- bookcloseDate: customer.bookcloseDate,
21
- enrollment: customer.enrollment != null
22
- ? {
23
- ...customer.enrollment,
24
- offboardedBy: customer.enrollment.offboardedBy != null
25
- ? (0, userSelector_1.getUserByUserId)(userState, customer.enrollment.offboardedBy)
26
- : undefined,
27
- onboardedBy: customer.enrollment.onboardedBy != null
28
- ? (0, userSelector_1.getUserByUserId)(userState, customer.enrollment.onboardedBy)
29
- : undefined,
30
- }
31
- : undefined,
32
- };
33
- }
34
- function toJobView(job, userState) {
35
- return {
36
- companyId: job.companyId,
37
- createdAt: job.createdAt,
38
- jobId: job.jobId,
39
- operationType: job.operationType,
40
- status: job.status,
41
- tenantId: job.tenantId,
42
- triggeredBy: job.triggeredBy != null
43
- ? (0, userSelector_1.getUserByUserId)(userState, job.triggeredBy)
44
- : undefined,
45
- companyNamespace: job.companyNamespace,
46
- completedAt: job.completedAt,
47
- errorMessage: job.errorMessage,
48
- parameters: job.parameters,
49
- retryCount: job.retryCount,
50
- startedAt: job.startedAt,
51
- steps: job.steps,
52
- validationResults: job.validationResults,
53
- };
54
- }
@@ -1,52 +0,0 @@
1
- import { ID } from '../../commonStateTypes/common';
2
- import { ZeniDate } from '../../zeniDayJS';
3
- export declare const toAiAccountantOperationType: (v: string) => "onboard" | "offboard" | "retrain" | "full_pipeline" | "cancel_onboarding";
4
- export type AiAccountantOperationType = ReturnType<typeof toAiAccountantOperationType>;
5
- export declare const toAiAccountantEnrollmentStatus: (v: string) => "onboarding" | "error" | "active" | "pending" | "offboarding" | "offboarded" | "failed";
6
- export type AiAccountantEnrollmentStatus = ReturnType<typeof toAiAccountantEnrollmentStatus>;
7
- export declare const toAiAccountantJobStatus: (v: string) => "failed" | "queued" | "running" | "completed" | "cancelled";
8
- export type AiAccountantJobStatus = ReturnType<typeof toAiAccountantJobStatus>;
9
- export interface AiAccountantEnrollment {
10
- status: AiAccountantEnrollmentStatus;
11
- accuracy?: Record<string, number>;
12
- latestTraining?: string;
13
- latestTransactionSync?: ZeniDate;
14
- offboardedAt?: ZeniDate;
15
- offboardedBy?: ID;
16
- onboardedAt?: ZeniDate;
17
- onboardedBy?: ID;
18
- validationResults?: Array<{
19
- accuracy: number;
20
- modelType: string;
21
- passed: boolean;
22
- threshold: number;
23
- }>;
24
- }
25
- export interface AiAccountantJob {
26
- companyId: ID;
27
- createdAt: ZeniDate;
28
- jobId: ID;
29
- operationType: AiAccountantOperationType;
30
- status: AiAccountantJobStatus;
31
- tenantId: ID;
32
- triggeredBy: ID;
33
- companyNamespace?: string;
34
- completedAt?: ZeniDate;
35
- errorMessage?: string;
36
- parameters?: Record<string, unknown>;
37
- retryCount?: number;
38
- startedAt?: ZeniDate;
39
- steps?: Array<Record<string, unknown>>;
40
- validationResults?: Array<Record<string, unknown>>;
41
- }
42
- export interface AiAccountantCustomer {
43
- companyId: ID;
44
- companyName: string;
45
- tenantId: ID;
46
- bookcloseDate?: ZeniDate;
47
- enrollment?: AiAccountantEnrollment;
48
- }
49
- export interface AiAccountantCustomerState {
50
- customerByTenantId: Record<ID, AiAccountantCustomer>;
51
- jobsByTenantId: Record<ID, AiAccountantJob[]>;
52
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toAiAccountantJobStatus = exports.toAiAccountantEnrollmentStatus = exports.toAiAccountantOperationType = void 0;
4
- const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
- // ── Operation Type ──
6
- const ALL_OPERATION_TYPES = [
7
- 'onboard',
8
- 'offboard',
9
- 'retrain',
10
- 'full_pipeline',
11
- 'cancel_onboarding',
12
- ];
13
- const toAiAccountantOperationType = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_OPERATION_TYPES);
14
- exports.toAiAccountantOperationType = toAiAccountantOperationType;
15
- // ── Enrollment Status ──
16
- const ALL_ENROLLMENT_STATUSES = [
17
- 'active',
18
- 'pending',
19
- 'onboarding',
20
- 'offboarding',
21
- 'offboarded',
22
- 'failed',
23
- 'error',
24
- ];
25
- const toAiAccountantEnrollmentStatus = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_ENROLLMENT_STATUSES);
26
- exports.toAiAccountantEnrollmentStatus = toAiAccountantEnrollmentStatus;
27
- // ── Job Status ──
28
- const ALL_JOB_STATUSES = [
29
- 'queued',
30
- 'running',
31
- 'completed',
32
- 'failed',
33
- 'cancelled',
34
- ];
35
- const toAiAccountantJobStatus = (v) => (0, stringToUnion_1.stringToUnion)(v, ALL_JOB_STATUSES);
36
- exports.toAiAccountantJobStatus = toAiAccountantJobStatus;
@@ -1,47 +0,0 @@
1
- import { date } from '../../zeniDayJS';
2
- import { toAiAccountantEnrollmentStatus, toAiAccountantJobStatus, toAiAccountantOperationType, } from './aiAccountantCustomerState';
3
- // ── Mapping functions (payload → state) ──
4
- export const toAiAccountantEnrollment = (payload) => ({
5
- status: toAiAccountantEnrollmentStatus(payload.status),
6
- accuracy: payload.accuracy,
7
- latestTraining: payload.latest_training,
8
- latestTransactionSync: payload.latest_transaction_sync != null
9
- ? date(payload.latest_transaction_sync)
10
- : undefined,
11
- offboardedAt: payload.offboarded_at != null ? date(payload.offboarded_at) : undefined,
12
- offboardedBy: payload.offboarded_by,
13
- onboardedAt: payload.onboarded_at != null ? date(payload.onboarded_at) : undefined,
14
- onboardedBy: payload.onboarded_by,
15
- validationResults: payload.validation_results?.map((vr) => ({
16
- accuracy: vr.accuracy,
17
- modelType: vr.model_type,
18
- passed: vr.passed,
19
- threshold: vr.threshold,
20
- })),
21
- });
22
- export const toAiAccountantCustomer = (payload) => ({
23
- companyId: payload.company_id,
24
- companyName: payload.company_name,
25
- tenantId: payload.tenant_id,
26
- bookcloseDate: payload.bookclose_date != null ? date(payload.bookclose_date) : undefined,
27
- enrollment: payload.enrollment != null
28
- ? toAiAccountantEnrollment(payload.enrollment)
29
- : undefined,
30
- });
31
- export const toAiAccountantJob = (payload) => ({
32
- companyId: payload.company_id,
33
- createdAt: date(payload.created_at),
34
- jobId: payload.job_id,
35
- operationType: toAiAccountantOperationType(payload.operation_type),
36
- status: toAiAccountantJobStatus(payload.status),
37
- tenantId: payload.tenant_id,
38
- triggeredBy: payload.triggered_by,
39
- companyNamespace: payload.company_namespace,
40
- completedAt: payload.completed_at != null ? date(payload.completed_at) : undefined,
41
- errorMessage: payload.error_message,
42
- parameters: payload.parameters,
43
- retryCount: payload.retry_count,
44
- startedAt: payload.started_at != null ? date(payload.started_at) : undefined,
45
- steps: payload.steps,
46
- validationResults: payload.validation_results,
47
- });
@@ -1,36 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- import { toAiAccountantCustomer, toAiAccountantJob, } from './aiAccountantCustomerPayload';
3
- export const initialAiAccountantCustomerState = {
4
- customerByTenantId: {},
5
- jobsByTenantId: {},
6
- };
7
- const aiAccountantCustomer = createSlice({
8
- name: 'aiAccountantCustomer',
9
- initialState: initialAiAccountantCustomerState,
10
- reducers: {
11
- updateAiAccountantCustomers(draft, action) {
12
- action.payload.forEach((payload) => {
13
- const customer = toAiAccountantCustomer(payload);
14
- draft.customerByTenantId[customer.tenantId] = customer;
15
- });
16
- },
17
- updateAiAccountantCustomer(draft, action) {
18
- const customer = toAiAccountantCustomer(action.payload);
19
- draft.customerByTenantId[customer.tenantId] = customer;
20
- },
21
- updateAiAccountantJobs: {
22
- reducer(draft, action) {
23
- draft.jobsByTenantId[action.payload.tenantId] =
24
- action.payload.jobs.map(toAiAccountantJob);
25
- },
26
- prepare(tenantId, jobs) {
27
- return { payload: { tenantId, jobs } };
28
- },
29
- },
30
- clearAllAiAccountantCustomers(draft) {
31
- Object.assign(draft, initialAiAccountantCustomerState);
32
- },
33
- },
34
- });
35
- export const { clearAllAiAccountantCustomers, updateAiAccountantCustomers, updateAiAccountantCustomer, updateAiAccountantJobs, } = aiAccountantCustomer.actions;
36
- export default aiAccountantCustomer.reducer;
@@ -1,50 +0,0 @@
1
- import { getUserByUserId } from '../user/userSelector';
2
- // ── Selectors ──
3
- export function getAiAccountantCustomers(customerState, userState) {
4
- return Object.values(customerState.customerByTenantId).map((customer) => toCustomerView(customer, userState));
5
- }
6
- export function getAiAccountantJobsByTenantId(customerState, userState, tenantId) {
7
- const jobs = customerState.jobsByTenantId[tenantId] ?? [];
8
- return jobs.map((job) => toJobView(job, userState));
9
- }
10
- // ── Helpers ──
11
- function toCustomerView(customer, userState) {
12
- return {
13
- companyId: customer.companyId,
14
- companyName: customer.companyName,
15
- tenantId: customer.tenantId,
16
- bookcloseDate: customer.bookcloseDate,
17
- enrollment: customer.enrollment != null
18
- ? {
19
- ...customer.enrollment,
20
- offboardedBy: customer.enrollment.offboardedBy != null
21
- ? getUserByUserId(userState, customer.enrollment.offboardedBy)
22
- : undefined,
23
- onboardedBy: customer.enrollment.onboardedBy != null
24
- ? getUserByUserId(userState, customer.enrollment.onboardedBy)
25
- : undefined,
26
- }
27
- : undefined,
28
- };
29
- }
30
- function toJobView(job, userState) {
31
- return {
32
- companyId: job.companyId,
33
- createdAt: job.createdAt,
34
- jobId: job.jobId,
35
- operationType: job.operationType,
36
- status: job.status,
37
- tenantId: job.tenantId,
38
- triggeredBy: job.triggeredBy != null
39
- ? getUserByUserId(userState, job.triggeredBy)
40
- : undefined,
41
- companyNamespace: job.companyNamespace,
42
- completedAt: job.completedAt,
43
- errorMessage: job.errorMessage,
44
- parameters: job.parameters,
45
- retryCount: job.retryCount,
46
- startedAt: job.startedAt,
47
- steps: job.steps,
48
- validationResults: job.validationResults,
49
- };
50
- }
@@ -1,30 +0,0 @@
1
- import { stringToUnion } from '../../commonStateTypes/stringToUnion';
2
- // ── Operation Type ──
3
- const ALL_OPERATION_TYPES = [
4
- 'onboard',
5
- 'offboard',
6
- 'retrain',
7
- 'full_pipeline',
8
- 'cancel_onboarding',
9
- ];
10
- export const toAiAccountantOperationType = (v) => stringToUnion(v, ALL_OPERATION_TYPES);
11
- // ── Enrollment Status ──
12
- const ALL_ENROLLMENT_STATUSES = [
13
- 'active',
14
- 'pending',
15
- 'onboarding',
16
- 'offboarding',
17
- 'offboarded',
18
- 'failed',
19
- 'error',
20
- ];
21
- export const toAiAccountantEnrollmentStatus = (v) => stringToUnion(v, ALL_ENROLLMENT_STATUSES);
22
- // ── Job Status ──
23
- const ALL_JOB_STATUSES = [
24
- 'queued',
25
- 'running',
26
- 'completed',
27
- 'failed',
28
- 'cancelled',
29
- ];
30
- export const toAiAccountantJobStatus = (v) => stringToUnion(v, ALL_JOB_STATUSES);
@@ -1,2 +0,0 @@
1
- // Re-export entity payload types and mapping functions.
2
- export { toAiAccountantCustomer, toAiAccountantEnrollment, toAiAccountantJob, } from '../../entity/aiAccountantCustomer/aiAccountantCustomerPayload';
@@ -1,145 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- export const initialAiAccountantViewState = {
3
- customersByTenantId: {},
4
- customersFetchStatus: { fetchState: 'Not-Started' },
5
- selectedTenantIdsForJobTrigger: [],
6
- triggerJobStatus: { fetchState: 'Not-Started' },
7
- uiState: {
8
- filterText: '',
9
- filters: {},
10
- selectedCustomerTenantId: '',
11
- sortKey: 'companyName',
12
- sortOrder: 'ascending',
13
- },
14
- };
15
- const aiAccountantView = createSlice({
16
- name: 'aiAccountantView',
17
- initialState: initialAiAccountantViewState,
18
- reducers: {
19
- // ── Customers ──
20
- fetchAiAccountantCustomers(draft) {
21
- draft.customersFetchStatus = { fetchState: 'In-Progress' };
22
- },
23
- updateAiAccountantCustomers(draft, action) {
24
- draft.customersByTenantId = toCustomersByTenantId(action.payload);
25
- draft.customersFetchStatus = { fetchState: 'Completed' };
26
- },
27
- updateAiAccountantCustomersFailure(draft, action) {
28
- draft.customersFetchStatus = {
29
- fetchState: 'Error',
30
- error: action.payload,
31
- };
32
- },
33
- // ── Jobs ──
34
- fetchAiAccountantJobs: {
35
- reducer(draft, action) {
36
- const customerView = draft.customersByTenantId[action.payload.tenantId];
37
- if (customerView != null) {
38
- customerView.jobsFetchStatus = { fetchState: 'In-Progress' };
39
- }
40
- },
41
- prepare(tenantId) {
42
- return { payload: { tenantId } };
43
- },
44
- },
45
- updateAiAccountantJobs: {
46
- reducer(draft, action) {
47
- const customerView = draft.customersByTenantId[action.payload.tenantId];
48
- if (customerView != null) {
49
- customerView.jobsFetchStatus = { fetchState: 'Completed' };
50
- }
51
- },
52
- prepare(tenantId) {
53
- return { payload: { tenantId } };
54
- },
55
- },
56
- updateAiAccountantJobsFailure(draft, action) {
57
- const customerView = draft.customersByTenantId[action.payload.tenantId];
58
- if (customerView != null) {
59
- customerView.jobsFetchStatus = {
60
- fetchState: 'Error',
61
- error: action.payload.error,
62
- };
63
- }
64
- },
65
- setSelectedTenantIdsForJobTrigger(draft, action) {
66
- draft.selectedTenantIdsForJobTrigger = action.payload;
67
- },
68
- // ── Trigger Job ──
69
- triggerAiAccountantJob: {
70
- reducer(draft,
71
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
72
- _action) {
73
- draft.triggerJobStatus = { fetchState: 'In-Progress' };
74
- },
75
- prepare(operationType, params, triggeredBy) {
76
- return { payload: { operationType, params, triggeredBy } };
77
- },
78
- },
79
- triggerAiAccountantJobSuccess(draft) {
80
- draft.triggerJobStatus = { fetchState: 'Completed' };
81
- },
82
- triggerAiAccountantJobFailure(draft, action) {
83
- draft.triggerJobStatus = { fetchState: 'Error', error: action.payload };
84
- },
85
- // ── Cancel Onboarding ──
86
- cancelAiAccountantOnboarding: {
87
- reducer(draft, action) {
88
- const customerView = draft.customersByTenantId[action.payload.tenantId];
89
- if (customerView != null) {
90
- customerView.cancelOnboardingStatus = { fetchState: 'In-Progress' };
91
- }
92
- },
93
- prepare(companyId, tenantId) {
94
- return { payload: { companyId, tenantId } };
95
- },
96
- },
97
- cancelAiAccountantOnboardingSuccess: {
98
- reducer(draft, action) {
99
- const customerView = draft.customersByTenantId[action.payload.tenantId];
100
- if (customerView != null) {
101
- customerView.cancelOnboardingStatus = { fetchState: 'Completed' };
102
- }
103
- },
104
- prepare(tenantId) {
105
- return { payload: { tenantId } };
106
- },
107
- },
108
- cancelAiAccountantOnboardingFailure: {
109
- reducer(draft, action) {
110
- const customerView = draft.customersByTenantId[action.payload.tenantId];
111
- if (customerView != null) {
112
- customerView.cancelOnboardingStatus = {
113
- fetchState: 'Error',
114
- error: action.payload.error,
115
- };
116
- }
117
- },
118
- prepare(tenantId, error) {
119
- return { payload: { tenantId, error } };
120
- },
121
- },
122
- // ── UI State ──
123
- updateAiAccountantUIState(draft, action) {
124
- Object.assign(draft.uiState, action.payload);
125
- },
126
- // ── Clear ──
127
- clearAiAccountantView() {
128
- return initialAiAccountantViewState;
129
- },
130
- },
131
- });
132
- export const { cancelAiAccountantOnboarding, cancelAiAccountantOnboardingFailure, cancelAiAccountantOnboardingSuccess, clearAiAccountantView, fetchAiAccountantCustomers, fetchAiAccountantJobs, setSelectedTenantIdsForJobTrigger, triggerAiAccountantJob, triggerAiAccountantJobFailure, triggerAiAccountantJobSuccess, updateAiAccountantCustomers, updateAiAccountantCustomersFailure, updateAiAccountantJobs, updateAiAccountantJobsFailure, updateAiAccountantUIState, } = aiAccountantView.actions;
133
- export default aiAccountantView.reducer;
134
- // ── Helpers ──
135
- const toCustomersByTenantId = (customers) => {
136
- const result = {};
137
- for (const payload of customers) {
138
- result[payload.tenant_id] = {
139
- cancelOnboardingStatus: { fetchState: 'Not-Started' },
140
- jobsFetchStatus: { fetchState: 'Not-Started' },
141
- tenantId: payload.tenant_id,
142
- };
143
- }
144
- return result;
145
- };
@@ -1,72 +0,0 @@
1
- import { createSelector } from '@reduxjs/toolkit';
2
- import orderBy from 'lodash/orderBy';
3
- import { getAiAccountantCustomers, } from '../../entity/aiAccountantCustomer/aiAccountantCustomerSelector';
4
- export const getAiAccountantCockpitView = createSelector((state) => state.aiAccountantViewState, (state) => state.aiAccountantCustomerState, (state) => state.userState, (viewState, customerEntityState, userState) => {
5
- const { customersByTenantId, customersFetchStatus, selectedTenantIdsForJobTrigger, triggerJobStatus, uiState, } = viewState;
6
- const allCustomers = getAiAccountantCustomers(customerEntityState, userState);
7
- let filteredCustomers = allCustomers;
8
- // Text filter
9
- const trimmedFilterText = uiState.filterText.trim();
10
- if (trimmedFilterText.length > 0) {
11
- const query = trimmedFilterText.toLowerCase();
12
- filteredCustomers = filteredCustomers.filter((customer) => customer.companyName.toLowerCase().includes(query) ||
13
- customer.tenantId.toLowerCase().includes(query));
14
- }
15
- // Cockpit filters (e.g. enrollmentStatus)
16
- const enrollmentStatusFilter = uiState.filters.categories?.find((category) => category.field === 'enrollmentStatus');
17
- if (enrollmentStatusFilter != null &&
18
- enrollmentStatusFilter.values.length > 0) {
19
- const selectedStatuses = enrollmentStatusFilter.values.map(String);
20
- const isEqual = enrollmentStatusFilter.matchingOperator === 'equal';
21
- filteredCustomers = filteredCustomers.filter((customer) => {
22
- const status = customer.enrollment?.status ?? 'unknown';
23
- const matches = selectedStatuses.includes(status);
24
- return isEqual ? matches : !matches;
25
- });
26
- }
27
- // Sorting
28
- const sortedCustomers = getSortedCustomers(filteredCustomers, uiState.sortKey, uiState.sortOrder);
29
- const selectedCustomersForJobTrigger = allCustomers.filter((customer) => selectedTenantIdsForJobTrigger.includes(customer.tenantId));
30
- return {
31
- fetchState: customersFetchStatus.fetchState,
32
- error: customersFetchStatus.error,
33
- customers: sortedCustomers,
34
- customerViewStateByTenantId: customersByTenantId,
35
- selectedCustomersForJobTrigger,
36
- triggerJobStatus,
37
- uiState,
38
- };
39
- });
40
- // ── Helpers ──
41
- const getSortedCustomers = (customers, sortKey, sortOrder) => {
42
- const direction = sortOrder === 'ascending' ? 'asc' : 'desc';
43
- return orderBy(customers, (customer) => {
44
- switch (sortKey) {
45
- case 'companyName':
46
- return customer.companyName.toLowerCase();
47
- case 'status':
48
- return (customer.enrollment?.status ?? 'unknown').toLowerCase();
49
- case 'bookcloseDate':
50
- return customer.bookcloseDate ?? '';
51
- case 'latestTraining':
52
- return customer.enrollment?.latestTraining ?? '';
53
- case 'latestSync':
54
- return customer.enrollment?.latestTransactionSync ?? '';
55
- case 'accuracy':
56
- return calcCustomerAccuracy(customer);
57
- default:
58
- return customer.companyName.toLowerCase();
59
- }
60
- }, direction);
61
- };
62
- const calcCustomerAccuracy = (customer) => {
63
- const accuracy = customer.enrollment?.accuracy;
64
- if (accuracy == null) {
65
- return 0;
66
- }
67
- const values = Object.values(accuracy);
68
- if (values.length === 0) {
69
- return 0;
70
- }
71
- return values.reduce((sum, value) => sum + value, 0) / values.length;
72
- };
@@ -1,11 +0,0 @@
1
- import { stringToUnion } from '../../commonStateTypes/stringToUnion';
2
- const ALL_AI_ACCOUNTANT_SORT_KEYS = [
3
- 'companyName',
4
- 'status',
5
- 'bookcloseDate',
6
- 'latestTraining',
7
- 'latestSync',
8
- 'accuracy',
9
- ];
10
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
- const toAiAccountantSortKeyType = (v) => stringToUnion(v, ALL_AI_ACCOUNTANT_SORT_KEYS);
@@ -1,26 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
4
- import { cancelAiAccountantOnboarding, cancelAiAccountantOnboardingFailure, cancelAiAccountantOnboardingSuccess, fetchAiAccountantCustomers, } from '../aiAccountantViewReducer';
5
- export const cancelAiAccountantOnboardingEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(cancelAiAccountantOnboarding.match), mergeMap((action) => {
6
- const { tenantId, companyId } = action.payload;
7
- const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
8
- const url = `${base}/ai-accountant/cancel-onboarding`;
9
- return zeniAPI
10
- .postAndGetJSON(url, {
11
- tenant_id: tenantId,
12
- company_id: companyId,
13
- })
14
- .pipe(mergeMap((response) => {
15
- if (isSuccessResponse(response)) {
16
- return from([
17
- cancelAiAccountantOnboardingSuccess(tenantId),
18
- fetchAiAccountantCustomers(),
19
- ]);
20
- }
21
- else {
22
- return of(cancelAiAccountantOnboardingFailure(tenantId, response.status));
23
- }
24
- }), catchError((error) => of(cancelAiAccountantOnboardingFailure(tenantId, createZeniAPIStatus('Unexpected error', 'AI Accountant cancel onboarding failed: ' +
25
- JSON.stringify(error))))));
26
- }));
@@ -1,27 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateAiAccountantCustomers as updateAiAccountantCustomerEntities } from '../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer';
4
- import { updateAllUsers } from '../../../entity/user/userReducer';
5
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
6
- import { fetchAiAccountantCustomers, updateAiAccountantCustomers, updateAiAccountantCustomersFailure, } from '../aiAccountantViewReducer';
7
- export const fetchAiAccountantCustomersEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(fetchAiAccountantCustomers.match), switchMap(() => {
8
- const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
9
- const url = `${base}/ai-accountant/customers`;
10
- return zeniAPI
11
- .getJSON(url)
12
- .pipe(mergeMap((response) => {
13
- if (isSuccessResponse(response)) {
14
- const customers = response.data?.customers ?? [];
15
- const users = response.data?.users ?? [];
16
- return from([
17
- updateAiAccountantCustomerEntities(customers),
18
- updateAllUsers({ users }),
19
- updateAiAccountantCustomers(customers),
20
- ]);
21
- }
22
- else {
23
- return of(updateAiAccountantCustomersFailure(response.status));
24
- }
25
- }), catchError((error) => of(updateAiAccountantCustomersFailure(createZeniAPIStatus('Unexpected error', 'AI Accountant customers fetch failed: ' +
26
- JSON.stringify(error))))));
27
- }));
@@ -1,37 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateAiAccountantJobs as updateAiAccountantJobEntities } from '../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer';
4
- import { updateAllUsers } from '../../../entity/user/userReducer';
5
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
6
- import { fetchAiAccountantJobs, updateAiAccountantJobsFailure, } from '../aiAccountantViewReducer';
7
- export const fetchAiAccountantJobsEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(fetchAiAccountantJobs.match), switchMap((action) => {
8
- const { tenantId } = action.payload;
9
- const params = new URLSearchParams({
10
- page: '1',
11
- limit: '50',
12
- tenant_id: tenantId,
13
- });
14
- const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
15
- const url = `${base}/ai-accountant/jobs?${params.toString()}`;
16
- return zeniAPI
17
- .getJSON(url)
18
- .pipe(mergeMap((response) => {
19
- if (isSuccessResponse(response)) {
20
- const jobs = response.data?.jobs ?? [];
21
- const users = response.data?.users ?? [];
22
- return from([
23
- updateAllUsers({ users }),
24
- updateAiAccountantJobEntities(tenantId, jobs),
25
- ]);
26
- }
27
- else {
28
- return of(updateAiAccountantJobsFailure({
29
- tenantId,
30
- error: response.status,
31
- }));
32
- }
33
- }), catchError((error) => of(updateAiAccountantJobsFailure({
34
- tenantId,
35
- error: createZeniAPIStatus('Unexpected error', 'AI Accountant jobs fetch failed: ' + JSON.stringify(error)),
36
- }))));
37
- }));