@zeniai/client-epic-state 4.19.99-betaRD21 → 4.19.99-betaRD4

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/aiAccountantCustomer/aiAccountantCustomerPayload.d.ts +44 -0
  2. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +53 -0
  3. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.d.ts +10 -0
  4. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +49 -0
  5. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +48 -0
  6. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +66 -0
  7. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.d.ts +52 -0
  8. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.js +36 -0
  9. package/lib/entity/billPay/billTransaction/billTransactionState.d.ts +2 -2
  10. package/lib/entity/chargeCard/chargeCard.d.ts +1 -1
  11. package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -1
  12. package/lib/entity/entityApprovalStatus/entityApprovalStatusState.d.ts +2 -2
  13. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +6 -9
  14. package/lib/entity/jeSchedules/jeSchedulesPayload.js +2 -36
  15. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -4
  16. package/lib/entity/jeSchedules/jeSchedulesSelector.js +2 -5
  17. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +2 -26
  18. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  19. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  20. package/lib/entity/tenant/clearAllEpic.d.ts +3 -1
  21. package/lib/entity/tenant/clearAllEpic.js +4 -0
  22. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +1 -4
  23. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -1
  24. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -1
  25. package/lib/entity/userRole/userRoleType.d.ts +2 -2
  26. package/lib/epic.d.ts +5 -1
  27. package/lib/epic.js +5 -1
  28. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +47 -0
  29. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +45 -0
  30. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +62 -0
  31. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerState.js +30 -0
  32. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +2 -36
  33. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -5
  34. package/lib/esm/entity/tenant/clearAllEpic.js +4 -0
  35. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -1
  36. package/lib/esm/epic.js +5 -1
  37. package/lib/esm/index.js +7 -0
  38. package/lib/esm/reducer.js +6 -0
  39. package/lib/esm/view/aiAccountantView/aiAccountantViewPayload.js +2 -0
  40. package/lib/esm/view/aiAccountantView/aiAccountantViewReducer.js +147 -0
  41. package/lib/esm/view/aiAccountantView/aiAccountantViewSelector.js +61 -0
  42. package/lib/esm/view/aiAccountantView/aiAccountantViewState.js +11 -0
  43. package/lib/esm/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +26 -0
  44. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +27 -0
  45. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +47 -0
  46. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +39 -0
  47. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -2
  48. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +2 -2
  49. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +3 -4
  50. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -0
  51. package/lib/esm/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -10
  52. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +3 -13
  53. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +3 -11
  54. package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +9 -22
  55. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +6 -12
  56. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +0 -1
  57. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +8 -3
  58. package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +63 -144
  59. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +2 -9
  60. package/lib/index.d.ts +10 -2
  61. package/lib/index.js +30 -2
  62. package/lib/reducer.d.ts +6 -0
  63. package/lib/reducer.js +6 -0
  64. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  65. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +32 -0
  66. package/lib/view/aiAccountantView/aiAccountantViewPayload.js +8 -0
  67. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +29 -0
  68. package/lib/view/aiAccountantView/aiAccountantViewReducer.js +151 -0
  69. package/lib/view/aiAccountantView/aiAccountantViewSelector.d.ts +13 -0
  70. package/lib/view/aiAccountantView/aiAccountantViewSelector.js +67 -0
  71. package/lib/view/aiAccountantView/aiAccountantViewState.d.ts +27 -0
  72. package/lib/view/aiAccountantView/aiAccountantViewState.js +13 -0
  73. package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.d.ts +20 -0
  74. package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +30 -0
  75. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.d.ts +23 -0
  76. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +31 -0
  77. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.d.ts +33 -0
  78. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +51 -0
  79. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.d.ts +15 -0
  80. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +43 -0
  81. package/lib/view/companyView/types/cockpitTypes.d.ts +6 -5
  82. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -2
  83. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +1 -1
  84. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +3 -4
  85. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -0
  86. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  87. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +1 -1
  88. package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -10
  89. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +3 -13
  90. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +3 -11
  91. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +9 -22
  92. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +5 -11
  93. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  94. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +0 -1
  95. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -1
  96. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +8 -3
  97. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +63 -144
  98. package/lib/view/reviewCompanyView/reviewCompanyViewState.d.ts +1 -1
  99. package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +1 -1
  100. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  101. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +4 -4
  102. package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +1 -1
  103. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +3 -3
  104. package/lib/view/subscriptionView/types/subscriptionTypes.d.ts +1 -1
  105. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -1
  106. package/lib/view/transactionDetail/transactionDetailSelector.js +2 -9
  107. package/package.json +1 -1
@@ -0,0 +1,44 @@
1
+ import { AiAccountantCustomer, AiAccountantEnrollment, AiAccountantJob } from './aiAccountantCustomerState';
2
+ export interface AiAccountantEnrollmentPayload {
3
+ status: string;
4
+ accuracy?: Record<string, number>;
5
+ latest_training?: string;
6
+ latest_transaction_sync?: string;
7
+ offboarded_at?: string;
8
+ offboarded_by?: string;
9
+ onboarded_at?: string;
10
+ onboarded_by?: string;
11
+ validation_results?: Array<{
12
+ accuracy: number;
13
+ model_type: string;
14
+ passed: boolean;
15
+ threshold: number;
16
+ }>;
17
+ }
18
+ export interface AiAccountantCustomerPayload {
19
+ company_id: string;
20
+ company_name: string;
21
+ tenant_id: string;
22
+ bookclose_date?: string;
23
+ enrollment?: AiAccountantEnrollmentPayload | null;
24
+ }
25
+ export interface AiAccountantJobPayload {
26
+ company_id: string;
27
+ created_at: string;
28
+ job_id: string;
29
+ operation_type: string;
30
+ status: string;
31
+ tenant_id: string;
32
+ triggered_by: string;
33
+ company_namespace?: string;
34
+ completed_at?: string;
35
+ error_message?: string;
36
+ parameters?: Record<string, unknown>;
37
+ retry_count?: number;
38
+ started_at?: string;
39
+ steps?: Array<Record<string, unknown>>;
40
+ validation_results?: Array<Record<string, unknown>>;
41
+ }
42
+ export declare const toAiAccountantEnrollment: (payload: AiAccountantEnrollmentPayload) => AiAccountantEnrollment;
43
+ export declare const toAiAccountantCustomer: (payload: AiAccountantCustomerPayload) => AiAccountantCustomer;
44
+ export declare const toAiAccountantJob: (payload: AiAccountantJobPayload) => AiAccountantJob;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toAiAccountantJob = exports.toAiAccountantCustomer = exports.toAiAccountantEnrollment = void 0;
4
+ const zeniDayJS_1 = require("../../zeniDayJS");
5
+ const aiAccountantCustomerState_1 = require("./aiAccountantCustomerState");
6
+ // ── Mapping functions (payload → state) ──
7
+ const toAiAccountantEnrollment = (payload) => ({
8
+ status: (0, aiAccountantCustomerState_1.toAiAccountantEnrollmentStatus)(payload.status),
9
+ accuracy: payload.accuracy,
10
+ latestTraining: payload.latest_training,
11
+ latestTransactionSync: payload.latest_transaction_sync != null
12
+ ? (0, zeniDayJS_1.date)(payload.latest_transaction_sync)
13
+ : undefined,
14
+ offboardedAt: payload.offboarded_at != null ? (0, zeniDayJS_1.date)(payload.offboarded_at) : undefined,
15
+ offboardedBy: payload.offboarded_by,
16
+ onboardedAt: payload.onboarded_at != null ? (0, zeniDayJS_1.date)(payload.onboarded_at) : undefined,
17
+ onboardedBy: payload.onboarded_by,
18
+ validationResults: payload.validation_results?.map((vr) => ({
19
+ accuracy: vr.accuracy,
20
+ modelType: vr.model_type,
21
+ passed: vr.passed,
22
+ threshold: vr.threshold,
23
+ })),
24
+ });
25
+ exports.toAiAccountantEnrollment = toAiAccountantEnrollment;
26
+ const toAiAccountantCustomer = (payload) => ({
27
+ companyId: payload.company_id,
28
+ companyName: payload.company_name,
29
+ tenantId: payload.tenant_id,
30
+ bookcloseDate: payload.bookclose_date != null ? (0, zeniDayJS_1.date)(payload.bookclose_date) : undefined,
31
+ enrollment: payload.enrollment != null
32
+ ? (0, exports.toAiAccountantEnrollment)(payload.enrollment)
33
+ : undefined,
34
+ });
35
+ exports.toAiAccountantCustomer = toAiAccountantCustomer;
36
+ const toAiAccountantJob = (payload) => ({
37
+ companyId: payload.company_id,
38
+ createdAt: (0, zeniDayJS_1.date)(payload.created_at),
39
+ jobId: payload.job_id,
40
+ operationType: (0, aiAccountantCustomerState_1.toAiAccountantOperationType)(payload.operation_type),
41
+ status: (0, aiAccountantCustomerState_1.toAiAccountantJobStatus)(payload.status),
42
+ tenantId: payload.tenant_id,
43
+ triggeredBy: payload.triggered_by,
44
+ companyNamespace: payload.company_namespace,
45
+ completedAt: payload.completed_at != null ? (0, zeniDayJS_1.date)(payload.completed_at) : undefined,
46
+ errorMessage: payload.error_message,
47
+ parameters: payload.parameters,
48
+ retryCount: payload.retry_count,
49
+ startedAt: payload.started_at != null ? (0, zeniDayJS_1.date)(payload.started_at) : undefined,
50
+ steps: payload.steps,
51
+ validationResults: payload.validation_results,
52
+ });
53
+ exports.toAiAccountantJob = toAiAccountantJob;
@@ -0,0 +1,10 @@
1
+ import { AiAccountantCustomerPayload, AiAccountantJobPayload } from './aiAccountantCustomerPayload';
2
+ import { AiAccountantCustomerState } from './aiAccountantCustomerState';
3
+ export declare const initialAiAccountantCustomerState: AiAccountantCustomerState;
4
+ export declare const clearAllAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantCustomer/clearAllAiAccountantCustomers">, updateAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiAccountantCustomerPayload[], "aiAccountantCustomer/updateAiAccountantCustomers">, updateAiAccountantCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiAccountantCustomerPayload, "aiAccountantCustomer/updateAiAccountantCustomer">, updateAiAccountantJobs: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, jobs: AiAccountantJobPayload[], append?: boolean | undefined], {
5
+ tenantId: string;
6
+ jobs: AiAccountantJobPayload[];
7
+ append: boolean;
8
+ }, "aiAccountantCustomer/updateAiAccountantJobs", never, never>;
9
+ declare const _default: import("redux").Reducer<AiAccountantCustomerState>;
10
+ export default _default;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.updateAiAccountantJobs = exports.updateAiAccountantCustomer = exports.updateAiAccountantCustomers = exports.clearAllAiAccountantCustomers = exports.initialAiAccountantCustomerState = void 0;
5
+ const toolkit_1 = require("@reduxjs/toolkit");
6
+ const aiAccountantCustomerPayload_1 = require("./aiAccountantCustomerPayload");
7
+ exports.initialAiAccountantCustomerState = {
8
+ customerByTenantId: {},
9
+ jobsByTenantId: {},
10
+ };
11
+ const aiAccountantCustomer = (0, toolkit_1.createSlice)({
12
+ name: 'aiAccountantCustomer',
13
+ initialState: exports.initialAiAccountantCustomerState,
14
+ reducers: {
15
+ updateAiAccountantCustomers(draft, action) {
16
+ action.payload.forEach((payload) => {
17
+ const customer = (0, aiAccountantCustomerPayload_1.toAiAccountantCustomer)(payload);
18
+ draft.customerByTenantId[customer.tenantId] = customer;
19
+ });
20
+ },
21
+ updateAiAccountantCustomer(draft, action) {
22
+ const customer = (0, aiAccountantCustomerPayload_1.toAiAccountantCustomer)(action.payload);
23
+ draft.customerByTenantId[customer.tenantId] = customer;
24
+ },
25
+ updateAiAccountantJobs: {
26
+ reducer(draft, action) {
27
+ const mappedJobs = action.payload.jobs.map(aiAccountantCustomerPayload_1.toAiAccountantJob);
28
+ if (action.payload.append) {
29
+ const existing = draft.jobsByTenantId[action.payload.tenantId] ?? [];
30
+ draft.jobsByTenantId[action.payload.tenantId] = [
31
+ ...existing,
32
+ ...mappedJobs,
33
+ ];
34
+ }
35
+ else {
36
+ draft.jobsByTenantId[action.payload.tenantId] = mappedJobs;
37
+ }
38
+ },
39
+ prepare(tenantId, jobs, append = false) {
40
+ return { payload: { tenantId, jobs, append } };
41
+ },
42
+ },
43
+ clearAllAiAccountantCustomers(draft) {
44
+ Object.assign(draft, exports.initialAiAccountantCustomerState);
45
+ },
46
+ },
47
+ });
48
+ _a = aiAccountantCustomer.actions, exports.clearAllAiAccountantCustomers = _a.clearAllAiAccountantCustomers, exports.updateAiAccountantCustomers = _a.updateAiAccountantCustomers, exports.updateAiAccountantCustomer = _a.updateAiAccountantCustomer, exports.updateAiAccountantJobs = _a.updateAiAccountantJobs;
49
+ exports.default = aiAccountantCustomer.reducer;
@@ -0,0 +1,48 @@
1
+ import { ID } from '../../commonStateTypes/common';
2
+ import { User } from '../user/userState';
3
+ import { UserState } from '../user/userState';
4
+ import { ZeniDate } from '../../zeniDayJS';
5
+ import { AiAccountantCustomerState, AiAccountantEnrollmentStatus, AiAccountantJobStatus, AiAccountantOperationType } from './aiAccountantCustomerState';
6
+ export interface AiAccountantEnrollmentView {
7
+ status: AiAccountantEnrollmentStatus;
8
+ accuracy?: Record<string, number>;
9
+ latestTraining?: string;
10
+ latestTransactionSync?: ZeniDate;
11
+ offboardedAt?: ZeniDate;
12
+ offboardedBy?: User;
13
+ onboardedAt?: ZeniDate;
14
+ onboardedBy?: User;
15
+ validationResults?: Array<{
16
+ accuracy: number;
17
+ modelType: string;
18
+ passed: boolean;
19
+ threshold: number;
20
+ }>;
21
+ }
22
+ export interface AiAccountantCustomerView {
23
+ averageAccuracy: number;
24
+ companyId: ID;
25
+ companyName: string;
26
+ tenantId: ID;
27
+ bookcloseDate?: ZeniDate;
28
+ enrollment?: AiAccountantEnrollmentView;
29
+ }
30
+ export interface AiAccountantJobView {
31
+ companyId: ID;
32
+ createdAt: ZeniDate;
33
+ jobId: ID;
34
+ operationType: AiAccountantOperationType;
35
+ status: AiAccountantJobStatus;
36
+ tenantId: ID;
37
+ companyNamespace?: string;
38
+ completedAt?: ZeniDate;
39
+ errorMessage?: string;
40
+ parameters?: Record<string, unknown>;
41
+ retryCount?: number;
42
+ startedAt?: ZeniDate;
43
+ steps?: Array<Record<string, unknown>>;
44
+ triggeredBy?: User;
45
+ validationResults?: Array<Record<string, unknown>>;
46
+ }
47
+ export declare function getAiAccountantCustomers(customerState: AiAccountantCustomerState, userState: UserState): AiAccountantCustomerView[];
48
+ export declare function getAiAccountantJobsByTenantId(customerState: AiAccountantCustomerState, userState: UserState, tenantId: string): AiAccountantJobView[];
@@ -0,0 +1,66 @@
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
+ averageAccuracy: calcAverageAccuracy(customer),
18
+ companyId: customer.companyId,
19
+ companyName: customer.companyName,
20
+ tenantId: customer.tenantId,
21
+ bookcloseDate: customer.bookcloseDate,
22
+ enrollment: customer.enrollment != null
23
+ ? {
24
+ ...customer.enrollment,
25
+ offboardedBy: customer.enrollment.offboardedBy != null
26
+ ? (0, userSelector_1.getUserByUserId)(userState, customer.enrollment.offboardedBy)
27
+ : undefined,
28
+ onboardedBy: customer.enrollment.onboardedBy != null
29
+ ? (0, userSelector_1.getUserByUserId)(userState, customer.enrollment.onboardedBy)
30
+ : undefined,
31
+ }
32
+ : undefined,
33
+ };
34
+ }
35
+ function toJobView(job, userState) {
36
+ return {
37
+ companyId: job.companyId,
38
+ createdAt: job.createdAt,
39
+ jobId: job.jobId,
40
+ operationType: job.operationType,
41
+ status: job.status,
42
+ tenantId: job.tenantId,
43
+ triggeredBy: job.triggeredBy != null
44
+ ? (0, userSelector_1.getUserByUserId)(userState, job.triggeredBy)
45
+ : undefined,
46
+ companyNamespace: job.companyNamespace,
47
+ completedAt: job.completedAt,
48
+ errorMessage: job.errorMessage,
49
+ parameters: job.parameters,
50
+ retryCount: job.retryCount,
51
+ startedAt: job.startedAt,
52
+ steps: job.steps,
53
+ validationResults: job.validationResults,
54
+ };
55
+ }
56
+ function calcAverageAccuracy(customer) {
57
+ const accuracy = customer.enrollment?.accuracy;
58
+ if (accuracy == null) {
59
+ return 0;
60
+ }
61
+ const values = Object.values(accuracy);
62
+ if (values.length === 0) {
63
+ return 0;
64
+ }
65
+ return values.reduce((sum, value) => sum + value, 0) / values.length;
66
+ }
@@ -0,0 +1,52 @@
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
+ }
@@ -0,0 +1,36 @@
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;
@@ -111,9 +111,9 @@ export interface BulkProcessingDetail {
111
111
  }
112
112
  declare const toBillStageCodeType: (v: string) => "paid" | "pending_approval" | "scheduled" | "draft";
113
113
  export type BillStageCodeType = ReturnType<typeof toBillStageCodeType>;
114
- declare const toBillPaymentStatusCodeType: (v: string) => "failed" | "paid" | "returned" | "processing" | "posted" | "cancelled" | "pending_vendor_action" | "awaiting_to_be_marked_as_paid" | "mark_as_paid";
114
+ declare const toBillPaymentStatusCodeType: (v: string) => "failed" | "cancelled" | "paid" | "returned" | "processing" | "posted" | "pending_vendor_action" | "awaiting_to_be_marked_as_paid" | "mark_as_paid";
115
115
  export type BillPaymentStatusCodeType = ReturnType<typeof toBillPaymentStatusCodeType>;
116
- declare const toBillPaymentRefundStatusCodeType: (v: string) => "failed" | "returned" | "processing" | "cancelled" | "completed";
116
+ declare const toBillPaymentRefundStatusCodeType: (v: string) => "failed" | "completed" | "cancelled" | "returned" | "processing";
117
117
  export type BillPaymentRefundStatusCodeType = ReturnType<typeof toBillPaymentRefundStatusCodeType>;
118
118
  declare const toBillStatusCodeType: (v: string) => "approved" | "rejected" | "pending_approval" | "initiated";
119
119
  export type BillStatusCodeType = ReturnType<typeof toBillStatusCodeType>;
@@ -54,7 +54,7 @@ export interface CardActivationOrPinChangeAttemptHistory {
54
54
  timestamp: ZeniDate;
55
55
  userId: ID;
56
56
  }
57
- export declare const toCardActivationOrPinUpdateEventCodeType: (v: string) => "success" | "failed";
57
+ export declare const toCardActivationOrPinUpdateEventCodeType: (v: string) => "failed" | "success";
58
58
  export type CardActivationOrPinUpdateEventCodeType = ReturnType<typeof toCardActivationOrPinUpdateEventCodeType>;
59
59
  export interface ChargeCardState {
60
60
  chargeCardByID: Record<ID, ChargeCard>;
@@ -28,6 +28,6 @@ export interface DepositAccountTransactionState {
28
28
  }
29
29
  export declare const toDepositAccountTransactionType: (v: string) => "wire" | "purchase" | "originated_ach" | "ach_originating" | "received_ach" | "returned_ach" | "dishonored_ach" | "book" | "atm" | "fee" | "reversal" | "card_transaction" | "batch_release" | "dispute" | "adjustment" | "interest" | "check_deposit" | "returned_check_deposit" | "payment_canceled";
30
30
  type DepositAccountTransactionType = ReturnType<typeof toDepositAccountTransactionType>;
31
- export declare const toDepositTransactionStatusCode: (v: string) => "rejected" | "pending" | "failed" | "returned" | "pending_review" | "canceled" | "clearing" | "sent" | undefined;
31
+ export declare const toDepositTransactionStatusCode: (v: string) => "pending" | "failed" | "rejected" | "returned" | "pending_review" | "canceled" | "clearing" | "sent" | undefined;
32
32
  export type DepositTransactionStatusCode = ReturnType<typeof toDepositTransactionStatusCode>;
33
33
  export {};
@@ -7,10 +7,10 @@ export declare const toEntityType: (v: string) => "bill_pay" | "reimbursement" |
7
7
  export type EntityType = ReturnType<typeof toEntityType>;
8
8
  export declare const toEntityTypeWithOtherConnection: (v: string) => "bill_pay" | "reimbursement" | "zeni_accounts" | "zeni_treasury" | "charge_cards" | "other_connection";
9
9
  export type EntityTypeWithOtherConnection = ReturnType<typeof toEntityTypeWithOtherConnection>;
10
- declare const toEntityApprovalStatusCode: (v: string) => "approved" | "rejected" | "pending";
10
+ declare const toEntityApprovalStatusCode: (v: string) => "pending" | "approved" | "rejected";
11
11
  type EntityApprovalStatusCode = ReturnType<typeof toEntityApprovalStatusCode>;
12
12
  export declare const toEntityApprovalStatusCodeStrict: (v: string | null) => EntityApprovalStatusCode | undefined;
13
- export declare const toActivityStatus: (v: string) => "approved" | "rejected" | "pending" | "notified";
13
+ export declare const toActivityStatus: (v: string) => "pending" | "approved" | "rejected" | "notified";
14
14
  export type ActivityStatus = ReturnType<typeof toActivityStatus>;
15
15
  export interface Actor {
16
16
  isImplicitActor: boolean;
@@ -25,28 +25,26 @@ export interface JEScheduleAISummariesPayload {
25
25
  debit_accounting_class?: JEScheduleAISummaryFieldPayload;
26
26
  period?: JEScheduleAISummaryFieldPayload;
27
27
  posting_date?: JEScheduleAISummaryFieldPayload;
28
- schedule_type?: JEScheduleAISummaryFieldPayload;
29
28
  }
30
29
  export interface JEScheduleRecommendationsPayload {
30
+ amortization_days?: number | null;
31
+ amortization_months_estimate?: number | null;
31
32
  credit_account_confidence?: number;
33
+ credit_account_id?: string | null;
34
+ credit_accounting_class_id?: string | null;
32
35
  credit_class_confidence?: number;
33
36
  debit_account_confidence?: number;
37
+ debit_account_id?: string | null;
38
+ debit_accounting_class_id?: string | null;
34
39
  debit_class_confidence?: number;
35
40
  end_date?: string | null;
36
- je_credit_account_id?: string | null;
37
- je_credit_accounting_class_id?: string | null;
38
- je_debit_account_id?: string | null;
39
- je_debit_accounting_class_id?: string | null;
40
41
  je_schedule_type?: string | null;
41
- je_schedule_type_confidence?: number;
42
42
  period?: number | null;
43
43
  period_confidence?: number;
44
44
  posting_date?: string | null;
45
- posting_date_confidence?: number;
46
45
  similar_transactions?: unknown[];
47
46
  start_date?: string | null;
48
47
  starting_month?: string | null;
49
- starting_month_confidence?: number;
50
48
  }
51
49
  export interface JEScheduledTransactionPayload {
52
50
  balance: number | null;
@@ -71,7 +69,6 @@ export interface JEScheduledTransactionPayload {
71
69
  updated_by: UserPayload;
72
70
  vendor: VendorPayload;
73
71
  ai_summaries?: JEScheduleAISummariesPayload;
74
- created_by?: UserPayload;
75
72
  end_date?: string | null;
76
73
  recommendations?: JEScheduleRecommendationsPayload;
77
74
  updated_at?: string | null;
@@ -146,7 +146,7 @@ function toJEScheduleOtherAttributes(payload) {
146
146
  assetId: payload.asset_id ?? undefined,
147
147
  };
148
148
  }
149
- function toJEScheduleAISummaries(payload) {
149
+ function toJEScheduleAIRecommendations(payload) {
150
150
  if (payload == null) {
151
151
  return undefined;
152
152
  }
@@ -187,40 +187,8 @@ function toJEScheduleAISummaries(payload) {
187
187
  reasoning: payload.posting_date.reasoning,
188
188
  };
189
189
  }
190
- if (payload.schedule_type != null) {
191
- result.scheduleType = {
192
- confidence: payload.schedule_type.confidence,
193
- reasoning: payload.schedule_type.reasoning,
194
- };
195
- }
196
190
  return Object.keys(result).length > 0 ? result : undefined;
197
191
  }
198
- function toJEScheduleRecommendations(payload) {
199
- if (payload == null) {
200
- return undefined;
201
- }
202
- return {
203
- creditAccountConfidence: payload.credit_account_confidence,
204
- creditClassConfidence: payload.credit_class_confidence,
205
- debitAccountConfidence: payload.debit_account_confidence,
206
- debitClassConfidence: payload.debit_class_confidence,
207
- endDate: payload.end_date ?? undefined,
208
- jeCreditAccountId: payload.je_credit_account_id ?? undefined,
209
- jeCreditAccountingClassId: payload.je_credit_accounting_class_id ?? undefined,
210
- jeDebitAccountId: payload.je_debit_account_id ?? undefined,
211
- jeDebitAccountingClassId: payload.je_debit_accounting_class_id ?? undefined,
212
- jeScheduleType: payload.je_schedule_type ?? undefined,
213
- jeScheduleTypeConfidence: payload.je_schedule_type_confidence,
214
- period: payload.period ?? undefined,
215
- periodConfidence: payload.period_confidence,
216
- postingDate: payload.posting_date ?? undefined,
217
- postingDateConfidence: payload.posting_date_confidence,
218
- similarTransactions: payload.similar_transactions,
219
- startDate: payload.start_date ?? undefined,
220
- startingMonth: payload.starting_month ?? undefined,
221
- startingMonthConfidence: payload.starting_month_confidence,
222
- };
223
- }
224
192
  function toJEScheduledTransaction(payload) {
225
193
  return {
226
194
  jeScheduleId: payload.je_schedule_id ?? undefined,
@@ -265,9 +233,7 @@ function toJEScheduledTransaction(payload) {
265
233
  ? toJEScheduleOtherAttributes(payload.other_attributes)
266
234
  : {},
267
235
  scheduledJournalEntry: [],
268
- aiSummaries: toJEScheduleAISummaries(payload.ai_summaries),
269
- createdByUserID: payload.created_by?.user_id ?? undefined,
270
- recommendations: toJEScheduleRecommendations(payload.recommendations),
236
+ aiRecommendations: toJEScheduleAIRecommendations(payload.ai_summaries),
271
237
  };
272
238
  }
273
239
  function toJEAccruedScheduledTransaction(payload) {
@@ -9,7 +9,7 @@ import { ScheduleTransaction } from '../transaction/stateTypes/scheduleTransacti
9
9
  import { TransactionID } from '../transaction/stateTypes/transaction';
10
10
  import { User } from '../user/userState';
11
11
  import { Vendor } from '../vendor/vendorState';
12
- import { JEScheduleAISummaries, JEScheduleOtherAttributes, JEScheduleRecommendations, ScheduleJournalStatusCode, ScheduleStatus } from './jeSchedulesState';
12
+ import { JEScheduleAIRecommendations, JEScheduleOtherAttributes, ScheduleJournalStatusCode, ScheduleStatus } from './jeSchedulesState';
13
13
  import { JEScheduleKey, JEScheduleTransactionKey, JournalEntryErrorCodeType, ScheduleTypes } from './jeSchedulesTypes';
14
14
  export interface ScheduledJournalEntry {
15
15
  error: JournalEntryErrorCodeType[];
@@ -59,16 +59,14 @@ export interface JEScheduledTransaction {
59
59
  scheduledJournalEntry: ScheduledJournalEntry[];
60
60
  status: ScheduleStatus;
61
61
  vendor: Vendor;
62
- aiSummaries?: JEScheduleAISummaries;
62
+ aiRecommendations?: JEScheduleAIRecommendations;
63
63
  balanceAsOfToday?: Amount;
64
- createdByUser?: User;
65
64
  dayOfPostingDate?: ScheduleDaysOfMonth;
66
65
  endDate?: ZeniDate;
67
66
  jeScheduleId?: ID;
68
67
  jeScheduleType?: ScheduleTypes;
69
68
  lastDayOfMonth?: boolean;
70
69
  period?: number;
71
- recommendations?: JEScheduleRecommendations;
72
70
  startDate?: ZeniDate;
73
71
  updatedAt?: ZeniDate;
74
72
  updatedByUser?: User;
@@ -77,13 +77,12 @@ exports.getJEAccruedScheduleByJEScheduleKey = getJEAccruedScheduleByJEScheduleKe
77
77
  const getJEScheduledTransactionByJEScheduleTransactionKey = (jeScheduleTransactionKey, state) => {
78
78
  const { jeSchedulesState, vendorState, accountState, userState, classState, transactionState, } = state;
79
79
  const jeScheduleTransactionState = (0, get_1.default)(jeSchedulesState.schedulesByTransactionKey, jeScheduleTransactionKey);
80
- const { period, updatedByUserID: updatedBy, createdByUserID: createdBy, vendorId, jeCredit, jeDebit, currencyCode, currencySymbol, balanceAsOfToday, baseTransaction, startDate, endDate, status, updatedAt, jeScheduleId, scheduledJournalEntry, dayOfPostingDate: postingDate, lastDayOfMonth, otherAttributes, jeScheduleType, aiSummaries, recommendations, } = jeScheduleTransactionState;
80
+ const { period, updatedByUserID: updatedBy, vendorId, jeCredit, jeDebit, currencyCode, currencySymbol, balanceAsOfToday, baseTransaction, startDate, endDate, status, updatedAt, jeScheduleId, scheduledJournalEntry, dayOfPostingDate: postingDate, lastDayOfMonth, otherAttributes, jeScheduleType, aiRecommendations, } = jeScheduleTransactionState;
81
81
  const vendorDetails = (0, vendorSelector_1.getVendorByVendorId)(vendorState, vendorId);
82
82
  if (vendorDetails == null) {
83
83
  throw new Error(`Vendor with ${vendorId} doesn't exist`);
84
84
  }
85
85
  const userDetails = updatedBy != null ? (0, userSelector_1.getUserByUserId)(userState, updatedBy) : undefined;
86
- const createdByUserDetails = createdBy != null ? (0, userSelector_1.getUserByUserId)(userState, createdBy) : undefined;
87
86
  const baseTransactionObject = (0, transactionSelector_1.getScheduleTransactionById)(transactionState, baseTransaction);
88
87
  if (baseTransactionObject == null) {
89
88
  throw Error('Base Schedule transaction cannot be null');
@@ -135,9 +134,7 @@ const getJEScheduledTransactionByJEScheduleTransactionKey = (jeScheduleTransacti
135
134
  account: accountDebit,
136
135
  },
137
136
  scheduledJournalEntry,
138
- aiSummaries,
139
- createdByUser: createdByUserDetails,
140
- recommendations,
137
+ aiRecommendations,
141
138
  };
142
139
  };
143
140
  exports.getJEScheduledTransactionByJEScheduleTransactionKey = getJEScheduledTransactionByJEScheduleTransactionKey;
@@ -16,35 +16,13 @@ export interface JEScheduleFieldRecommendation {
16
16
  confidence: number;
17
17
  reasoning: string;
18
18
  }
19
- export interface JEScheduleAISummaries {
19
+ export interface JEScheduleAIRecommendations {
20
20
  creditAccount?: JEScheduleFieldRecommendation;
21
21
  creditClass?: JEScheduleFieldRecommendation;
22
22
  debitAccount?: JEScheduleFieldRecommendation;
23
23
  debitClass?: JEScheduleFieldRecommendation;
24
24
  period?: JEScheduleFieldRecommendation;
25
25
  postingDate?: JEScheduleFieldRecommendation;
26
- scheduleType?: JEScheduleFieldRecommendation;
27
- }
28
- export interface JEScheduleRecommendations {
29
- creditAccountConfidence?: number;
30
- creditClassConfidence?: number;
31
- debitAccountConfidence?: number;
32
- debitClassConfidence?: number;
33
- endDate?: string;
34
- jeCreditAccountId?: string;
35
- jeCreditAccountingClassId?: string;
36
- jeDebitAccountId?: string;
37
- jeDebitAccountingClassId?: string;
38
- jeScheduleType?: string;
39
- jeScheduleTypeConfidence?: number;
40
- period?: number;
41
- periodConfidence?: number;
42
- postingDate?: string;
43
- postingDateConfidence?: number;
44
- similarTransactions?: unknown[];
45
- startDate?: string;
46
- startingMonth?: string;
47
- startingMonthConfidence?: number;
48
26
  }
49
27
  export interface JEScheduleOtherAttributes {
50
28
  assetId?: string;
@@ -90,16 +68,14 @@ export interface JEScheduledTransactionState {
90
68
  scheduledJournalEntry: ScheduledJournalEntryState[];
91
69
  status: ScheduleStatus;
92
70
  vendorId: ID;
93
- aiSummaries?: JEScheduleAISummaries;
71
+ aiRecommendations?: JEScheduleAIRecommendations;
94
72
  balanceAsOfToday?: number;
95
- createdByUserID?: ID;
96
73
  dayOfPostingDate?: ScheduleDaysOfMonth;
97
74
  endDate?: ZeniDate;
98
75
  jeScheduleId?: ID;
99
76
  jeScheduleType?: ScheduleTypes;
100
77
  lastDayOfMonth?: boolean;
101
78
  period?: number;
102
- recommendations?: JEScheduleRecommendations;
103
79
  startDate?: ZeniDate;
104
80
  updatedAt?: ZeniDate;
105
81
  updatedByUserID?: ID;
@@ -12,7 +12,7 @@ export type ScheduleTypes = ReturnType<typeof toScheduleTypesType>;
12
12
  export declare const toScheduleTypesTypeStrict: (v?: string) => "prepaid_expenses" | "fixed_assets" | "accrued_expenses" | "deferred_revenue" | undefined;
13
13
  export declare const toScheduleJournalEntryStatusCodeType: (v: string) => "pending" | "posted" | "unknown" | "canceled" | "recorded";
14
14
  export type ScheduleJournalEntryStatusCodeType = ReturnType<typeof toScheduleJournalEntryStatusCodeType>;
15
- export declare const toScheduleStatusCodeType: (v: string) => "draft" | "completed" | "new" | "ongoing" | "marked_as_completed";
15
+ export declare const toScheduleStatusCodeType: (v: string) => "completed" | "draft" | "new" | "ongoing" | "marked_as_completed";
16
16
  export type ScheduleStatusCodeType = ReturnType<typeof toScheduleStatusCodeType>;
17
17
  export declare const toJournalEntryErrorCodeType: (v: string) => "vendor_deleted" | "debit_category_deleted" | "credit_category_deleted" | "qbo_error" | "qbo_authorization_error" | "qbo_invalid_company_status_error" | "qbo_book_close_date_error";
18
18
  export type JournalEntryErrorCodeType = ReturnType<typeof toJournalEntryErrorCodeType>;