@zeniai/client-epic-state 4.19.99-betaRD10 → 4.19.99-betaRD2
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/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.d.ts +1 -2
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +5 -16
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -2
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -12
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.d.ts +2 -2
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +6 -9
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +2 -36
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -4
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +2 -5
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +2 -26
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +1 -4
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -1
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -1
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +5 -16
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -12
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +2 -36
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -5
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -1
- package/lib/esm/view/aiAccountantView/aiAccountantViewReducer.js +10 -14
- package/lib/esm/view/aiAccountantView/aiAccountantViewSelector.js +12 -12
- package/lib/esm/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +4 -24
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +7 -17
- package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +17 -30
- package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -10
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +3 -13
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +3 -11
- package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +9 -22
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +6 -12
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +0 -1
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +8 -3
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +59 -140
- package/lib/index.d.ts +2 -2
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
- package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +5 -7
- package/lib/view/aiAccountantView/aiAccountantViewReducer.js +10 -14
- package/lib/view/aiAccountantView/aiAccountantViewSelector.d.ts +0 -1
- package/lib/view/aiAccountantView/aiAccountantViewSelector.js +12 -12
- package/lib/view/aiAccountantView/aiAccountantViewState.d.ts +0 -1
- package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.d.ts +1 -14
- package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +3 -23
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.d.ts +3 -10
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +6 -16
- package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.d.ts +1 -14
- package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +16 -29
- package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +1 -0
- package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -10
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +3 -13
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +3 -11
- package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +9 -22
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +5 -11
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +0 -1
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +8 -3
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +59 -140
- package/package.json +1 -1
|
@@ -7,9 +7,7 @@ const aiAccountantCustomerState_1 = require("./aiAccountantCustomerState");
|
|
|
7
7
|
const toAiAccountantEnrollment = (payload) => ({
|
|
8
8
|
status: (0, aiAccountantCustomerState_1.toAiAccountantEnrollmentStatus)(payload.status),
|
|
9
9
|
accuracy: payload.accuracy,
|
|
10
|
-
latestTraining: payload.latest_training
|
|
11
|
-
? (0, zeniDayJS_1.date)(payload.latest_training)
|
|
12
|
-
: undefined,
|
|
10
|
+
latestTraining: payload.latest_training,
|
|
13
11
|
latestTransactionSync: payload.latest_transaction_sync != null
|
|
14
12
|
? (0, zeniDayJS_1.date)(payload.latest_transaction_sync)
|
|
15
13
|
: undefined,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { AiAccountantCustomerPayload, AiAccountantJobPayload } from './aiAccountantCustomerPayload';
|
|
2
2
|
import { AiAccountantCustomerState } from './aiAccountantCustomerState';
|
|
3
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[]
|
|
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[]], {
|
|
5
5
|
tenantId: string;
|
|
6
6
|
jobs: AiAccountantJobPayload[];
|
|
7
|
-
append: boolean;
|
|
8
7
|
}, "aiAccountantCustomer/updateAiAccountantJobs", never, never>;
|
|
9
8
|
declare const _default: import("redux").Reducer<AiAccountantCustomerState>;
|
|
10
9
|
export default _default;
|
|
@@ -13,12 +13,10 @@ const aiAccountantCustomer = (0, toolkit_1.createSlice)({
|
|
|
13
13
|
initialState: exports.initialAiAccountantCustomerState,
|
|
14
14
|
reducers: {
|
|
15
15
|
updateAiAccountantCustomers(draft, action) {
|
|
16
|
-
const newCustomerByTenantId = {};
|
|
17
16
|
action.payload.forEach((payload) => {
|
|
18
17
|
const customer = (0, aiAccountantCustomerPayload_1.toAiAccountantCustomer)(payload);
|
|
19
|
-
|
|
18
|
+
draft.customerByTenantId[customer.tenantId] = customer;
|
|
20
19
|
});
|
|
21
|
-
draft.customerByTenantId = newCustomerByTenantId;
|
|
22
20
|
},
|
|
23
21
|
updateAiAccountantCustomer(draft, action) {
|
|
24
22
|
const customer = (0, aiAccountantCustomerPayload_1.toAiAccountantCustomer)(action.payload);
|
|
@@ -26,20 +24,11 @@ const aiAccountantCustomer = (0, toolkit_1.createSlice)({
|
|
|
26
24
|
},
|
|
27
25
|
updateAiAccountantJobs: {
|
|
28
26
|
reducer(draft, action) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const existing = draft.jobsByTenantId[action.payload.tenantId] ?? [];
|
|
32
|
-
const jobMap = new Map(existing.map((job) => [job.jobId, job]));
|
|
33
|
-
mappedJobs.forEach((job) => jobMap.set(job.jobId, job));
|
|
34
|
-
draft.jobsByTenantId[action.payload.tenantId] =
|
|
35
|
-
Array.from(jobMap.values());
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
draft.jobsByTenantId[action.payload.tenantId] = mappedJobs;
|
|
39
|
-
}
|
|
27
|
+
draft.jobsByTenantId[action.payload.tenantId] =
|
|
28
|
+
action.payload.jobs.map(aiAccountantCustomerPayload_1.toAiAccountantJob);
|
|
40
29
|
},
|
|
41
|
-
prepare(tenantId, jobs
|
|
42
|
-
return { payload: { tenantId, jobs
|
|
30
|
+
prepare(tenantId, jobs) {
|
|
31
|
+
return { payload: { tenantId, jobs } };
|
|
43
32
|
},
|
|
44
33
|
},
|
|
45
34
|
clearAllAiAccountantCustomers(draft) {
|
|
@@ -6,7 +6,7 @@ import { AiAccountantCustomerState, AiAccountantEnrollmentStatus, AiAccountantJo
|
|
|
6
6
|
export interface AiAccountantEnrollmentView {
|
|
7
7
|
status: AiAccountantEnrollmentStatus;
|
|
8
8
|
accuracy?: Record<string, number>;
|
|
9
|
-
latestTraining?:
|
|
9
|
+
latestTraining?: string;
|
|
10
10
|
latestTransactionSync?: ZeniDate;
|
|
11
11
|
offboardedAt?: ZeniDate;
|
|
12
12
|
offboardedBy?: User;
|
|
@@ -20,7 +20,6 @@ export interface AiAccountantEnrollmentView {
|
|
|
20
20
|
}>;
|
|
21
21
|
}
|
|
22
22
|
export interface AiAccountantCustomerView {
|
|
23
|
-
averageAccuracy: number;
|
|
24
23
|
companyId: ID;
|
|
25
24
|
companyName: string;
|
|
26
25
|
tenantId: ID;
|
|
@@ -14,7 +14,6 @@ function getAiAccountantJobsByTenantId(customerState, userState, tenantId) {
|
|
|
14
14
|
// ── Helpers ──
|
|
15
15
|
function toCustomerView(customer, userState) {
|
|
16
16
|
return {
|
|
17
|
-
averageAccuracy: calcAverageAccuracy(customer),
|
|
18
17
|
companyId: customer.companyId,
|
|
19
18
|
companyName: customer.companyName,
|
|
20
19
|
tenantId: customer.tenantId,
|
|
@@ -53,14 +52,3 @@ function toJobView(job, userState) {
|
|
|
53
52
|
validationResults: job.validationResults,
|
|
54
53
|
};
|
|
55
54
|
}
|
|
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
|
-
}
|
|
@@ -4,12 +4,12 @@ export declare const toAiAccountantOperationType: (v: string) => "onboard" | "of
|
|
|
4
4
|
export type AiAccountantOperationType = ReturnType<typeof toAiAccountantOperationType>;
|
|
5
5
|
export declare const toAiAccountantEnrollmentStatus: (v: string) => "onboarding" | "error" | "active" | "pending" | "offboarding" | "offboarded" | "failed";
|
|
6
6
|
export type AiAccountantEnrollmentStatus = ReturnType<typeof toAiAccountantEnrollmentStatus>;
|
|
7
|
-
export declare const toAiAccountantJobStatus: (v: string) => "failed" | "queued" | "running" | "completed" | "cancelled"
|
|
7
|
+
export declare const toAiAccountantJobStatus: (v: string) => "failed" | "queued" | "running" | "completed" | "cancelled";
|
|
8
8
|
export type AiAccountantJobStatus = ReturnType<typeof toAiAccountantJobStatus>;
|
|
9
9
|
export interface AiAccountantEnrollment {
|
|
10
10
|
status: AiAccountantEnrollmentStatus;
|
|
11
11
|
accuracy?: Record<string, number>;
|
|
12
|
-
latestTraining?:
|
|
12
|
+
latestTraining?: string;
|
|
13
13
|
latestTransactionSync?: ZeniDate;
|
|
14
14
|
offboardedAt?: ZeniDate;
|
|
15
15
|
offboardedBy?: ID;
|
|
@@ -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
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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;
|
|
@@ -2,15 +2,12 @@ import { AccountBasePayload } from '../../account/accountPayload';
|
|
|
2
2
|
import { ClassBasePayload } from '../../class/classPayload';
|
|
3
3
|
import { ScheduleTransaction } from '../stateTypes/scheduleTransaction';
|
|
4
4
|
import { TransactionIDPayload } from './transactionIDPayload';
|
|
5
|
-
export interface ScheduleTransactionPayload extends TransactionIDPayload, Omit<AccountBasePayload, 'qbo_id'
|
|
5
|
+
export interface ScheduleTransactionPayload extends TransactionIDPayload, Omit<AccountBasePayload, 'qbo_id'>, Omit<ClassBasePayload, 'qbo_id' | 'labels'> {
|
|
6
6
|
line_id: string;
|
|
7
7
|
third_party_transaction_id: string;
|
|
8
8
|
total_amount: number;
|
|
9
9
|
transaction_date: string;
|
|
10
10
|
transaction_memo: string;
|
|
11
11
|
transaction_type_name: string;
|
|
12
|
-
labels?: string[];
|
|
13
|
-
sync_token?: number;
|
|
14
|
-
transaction_description?: string | null;
|
|
15
12
|
}
|
|
16
13
|
export declare const toScheduleTransaction: (payload: ScheduleTransactionPayload, currency_code: string, currency_symbol: string) => ScheduleTransaction;
|
|
@@ -32,7 +32,6 @@ const toScheduleTransaction = (payload, currency_code, currency_symbol) => {
|
|
|
32
32
|
currencyCode: currency_code,
|
|
33
33
|
currencySymbol: currency_symbol,
|
|
34
34
|
},
|
|
35
|
-
description: payload.transaction_description ?? undefined,
|
|
36
35
|
};
|
|
37
36
|
};
|
|
38
37
|
exports.toScheduleTransaction = toScheduleTransaction;
|
|
@@ -4,9 +4,7 @@ import { toAiAccountantEnrollmentStatus, toAiAccountantJobStatus, toAiAccountant
|
|
|
4
4
|
export const toAiAccountantEnrollment = (payload) => ({
|
|
5
5
|
status: toAiAccountantEnrollmentStatus(payload.status),
|
|
6
6
|
accuracy: payload.accuracy,
|
|
7
|
-
latestTraining: payload.latest_training
|
|
8
|
-
? date(payload.latest_training)
|
|
9
|
-
: undefined,
|
|
7
|
+
latestTraining: payload.latest_training,
|
|
10
8
|
latestTransactionSync: payload.latest_transaction_sync != null
|
|
11
9
|
? date(payload.latest_transaction_sync)
|
|
12
10
|
: undefined,
|
|
@@ -9,12 +9,10 @@ const aiAccountantCustomer = createSlice({
|
|
|
9
9
|
initialState: initialAiAccountantCustomerState,
|
|
10
10
|
reducers: {
|
|
11
11
|
updateAiAccountantCustomers(draft, action) {
|
|
12
|
-
const newCustomerByTenantId = {};
|
|
13
12
|
action.payload.forEach((payload) => {
|
|
14
13
|
const customer = toAiAccountantCustomer(payload);
|
|
15
|
-
|
|
14
|
+
draft.customerByTenantId[customer.tenantId] = customer;
|
|
16
15
|
});
|
|
17
|
-
draft.customerByTenantId = newCustomerByTenantId;
|
|
18
16
|
},
|
|
19
17
|
updateAiAccountantCustomer(draft, action) {
|
|
20
18
|
const customer = toAiAccountantCustomer(action.payload);
|
|
@@ -22,20 +20,11 @@ const aiAccountantCustomer = createSlice({
|
|
|
22
20
|
},
|
|
23
21
|
updateAiAccountantJobs: {
|
|
24
22
|
reducer(draft, action) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const existing = draft.jobsByTenantId[action.payload.tenantId] ?? [];
|
|
28
|
-
const jobMap = new Map(existing.map((job) => [job.jobId, job]));
|
|
29
|
-
mappedJobs.forEach((job) => jobMap.set(job.jobId, job));
|
|
30
|
-
draft.jobsByTenantId[action.payload.tenantId] =
|
|
31
|
-
Array.from(jobMap.values());
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
draft.jobsByTenantId[action.payload.tenantId] = mappedJobs;
|
|
35
|
-
}
|
|
23
|
+
draft.jobsByTenantId[action.payload.tenantId] =
|
|
24
|
+
action.payload.jobs.map(toAiAccountantJob);
|
|
36
25
|
},
|
|
37
|
-
prepare(tenantId, jobs
|
|
38
|
-
return { payload: { tenantId, jobs
|
|
26
|
+
prepare(tenantId, jobs) {
|
|
27
|
+
return { payload: { tenantId, jobs } };
|
|
39
28
|
},
|
|
40
29
|
},
|
|
41
30
|
clearAllAiAccountantCustomers(draft) {
|
|
@@ -10,7 +10,6 @@ export function getAiAccountantJobsByTenantId(customerState, userState, tenantId
|
|
|
10
10
|
// ── Helpers ──
|
|
11
11
|
function toCustomerView(customer, userState) {
|
|
12
12
|
return {
|
|
13
|
-
averageAccuracy: calcAverageAccuracy(customer),
|
|
14
13
|
companyId: customer.companyId,
|
|
15
14
|
companyName: customer.companyName,
|
|
16
15
|
tenantId: customer.tenantId,
|
|
@@ -49,14 +48,3 @@ function toJobView(job, userState) {
|
|
|
49
48
|
validationResults: job.validationResults,
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
|
-
function calcAverageAccuracy(customer) {
|
|
53
|
-
const accuracy = customer.enrollment?.accuracy;
|
|
54
|
-
if (accuracy == null) {
|
|
55
|
-
return 0;
|
|
56
|
-
}
|
|
57
|
-
const values = Object.values(accuracy);
|
|
58
|
-
if (values.length === 0) {
|
|
59
|
-
return 0;
|
|
60
|
-
}
|
|
61
|
-
return values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
62
|
-
}
|
|
@@ -136,7 +136,7 @@ function toJEScheduleOtherAttributes(payload) {
|
|
|
136
136
|
assetId: payload.asset_id ?? undefined,
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function toJEScheduleAIRecommendations(payload) {
|
|
140
140
|
if (payload == null) {
|
|
141
141
|
return undefined;
|
|
142
142
|
}
|
|
@@ -177,40 +177,8 @@ function toJEScheduleAISummaries(payload) {
|
|
|
177
177
|
reasoning: payload.posting_date.reasoning,
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
-
if (payload.schedule_type != null) {
|
|
181
|
-
result.scheduleType = {
|
|
182
|
-
confidence: payload.schedule_type.confidence,
|
|
183
|
-
reasoning: payload.schedule_type.reasoning,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
180
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
187
181
|
}
|
|
188
|
-
function toJEScheduleRecommendations(payload) {
|
|
189
|
-
if (payload == null) {
|
|
190
|
-
return undefined;
|
|
191
|
-
}
|
|
192
|
-
return {
|
|
193
|
-
creditAccountConfidence: payload.credit_account_confidence,
|
|
194
|
-
creditClassConfidence: payload.credit_class_confidence,
|
|
195
|
-
debitAccountConfidence: payload.debit_account_confidence,
|
|
196
|
-
debitClassConfidence: payload.debit_class_confidence,
|
|
197
|
-
endDate: payload.end_date ?? undefined,
|
|
198
|
-
jeCreditAccountId: payload.je_credit_account_id ?? undefined,
|
|
199
|
-
jeCreditAccountingClassId: payload.je_credit_accounting_class_id ?? undefined,
|
|
200
|
-
jeDebitAccountId: payload.je_debit_account_id ?? undefined,
|
|
201
|
-
jeDebitAccountingClassId: payload.je_debit_accounting_class_id ?? undefined,
|
|
202
|
-
jeScheduleType: payload.je_schedule_type ?? undefined,
|
|
203
|
-
jeScheduleTypeConfidence: payload.je_schedule_type_confidence,
|
|
204
|
-
period: payload.period ?? undefined,
|
|
205
|
-
periodConfidence: payload.period_confidence,
|
|
206
|
-
postingDate: payload.posting_date ?? undefined,
|
|
207
|
-
postingDateConfidence: payload.posting_date_confidence,
|
|
208
|
-
similarTransactions: payload.similar_transactions,
|
|
209
|
-
startDate: payload.start_date ?? undefined,
|
|
210
|
-
startingMonth: payload.starting_month ?? undefined,
|
|
211
|
-
startingMonthConfidence: payload.starting_month_confidence,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
182
|
export function toJEScheduledTransaction(payload) {
|
|
215
183
|
return {
|
|
216
184
|
jeScheduleId: payload.je_schedule_id ?? undefined,
|
|
@@ -255,9 +223,7 @@ export function toJEScheduledTransaction(payload) {
|
|
|
255
223
|
? toJEScheduleOtherAttributes(payload.other_attributes)
|
|
256
224
|
: {},
|
|
257
225
|
scheduledJournalEntry: [],
|
|
258
|
-
|
|
259
|
-
createdByUserID: payload.created_by?.user_id ?? undefined,
|
|
260
|
-
recommendations: toJEScheduleRecommendations(payload.recommendations),
|
|
226
|
+
aiRecommendations: toJEScheduleAIRecommendations(payload.ai_summaries),
|
|
261
227
|
};
|
|
262
228
|
}
|
|
263
229
|
export function toJEAccruedScheduledTransaction(payload) {
|
|
@@ -70,13 +70,12 @@ export const getJEAccruedScheduleByJEScheduleKey = (JEScheduleKey, state) => {
|
|
|
70
70
|
export const getJEScheduledTransactionByJEScheduleTransactionKey = (jeScheduleTransactionKey, state) => {
|
|
71
71
|
const { jeSchedulesState, vendorState, accountState, userState, classState, transactionState, } = state;
|
|
72
72
|
const jeScheduleTransactionState = recordGet(jeSchedulesState.schedulesByTransactionKey, jeScheduleTransactionKey);
|
|
73
|
-
const { period, updatedByUserID: updatedBy,
|
|
73
|
+
const { period, updatedByUserID: updatedBy, vendorId, jeCredit, jeDebit, currencyCode, currencySymbol, balanceAsOfToday, baseTransaction, startDate, endDate, status, updatedAt, jeScheduleId, scheduledJournalEntry, dayOfPostingDate: postingDate, lastDayOfMonth, otherAttributes, jeScheduleType, aiRecommendations, } = jeScheduleTransactionState;
|
|
74
74
|
const vendorDetails = getVendorByVendorId(vendorState, vendorId);
|
|
75
75
|
if (vendorDetails == null) {
|
|
76
76
|
throw new Error(`Vendor with ${vendorId} doesn't exist`);
|
|
77
77
|
}
|
|
78
78
|
const userDetails = updatedBy != null ? getUserByUserId(userState, updatedBy) : undefined;
|
|
79
|
-
const createdByUserDetails = createdBy != null ? getUserByUserId(userState, createdBy) : undefined;
|
|
80
79
|
const baseTransactionObject = getScheduleTransactionById(transactionState, baseTransaction);
|
|
81
80
|
if (baseTransactionObject == null) {
|
|
82
81
|
throw Error('Base Schedule transaction cannot be null');
|
|
@@ -128,8 +127,6 @@ export const getJEScheduledTransactionByJEScheduleTransactionKey = (jeScheduleTr
|
|
|
128
127
|
account: accountDebit,
|
|
129
128
|
},
|
|
130
129
|
scheduledJournalEntry,
|
|
131
|
-
|
|
132
|
-
createdByUser: createdByUserDetails,
|
|
133
|
-
recommendations,
|
|
130
|
+
aiRecommendations,
|
|
134
131
|
};
|
|
135
132
|
};
|
|
@@ -21,7 +21,7 @@ const aiAccountantView = createSlice({
|
|
|
21
21
|
draft.customersFetchStatus = { fetchState: 'In-Progress' };
|
|
22
22
|
},
|
|
23
23
|
updateAiAccountantCustomers(draft, action) {
|
|
24
|
-
draft.customersByTenantId = toCustomersByTenantId(action.payload
|
|
24
|
+
draft.customersByTenantId = toCustomersByTenantId(action.payload);
|
|
25
25
|
draft.customersFetchStatus = { fetchState: 'Completed' };
|
|
26
26
|
},
|
|
27
27
|
updateAiAccountantCustomersFailure(draft, action) {
|
|
@@ -38,8 +38,8 @@ const aiAccountantView = createSlice({
|
|
|
38
38
|
customerView.jobsFetchStatus = { fetchState: 'In-Progress' };
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
prepare(tenantId
|
|
42
|
-
return { payload: { tenantId
|
|
41
|
+
prepare(tenantId) {
|
|
42
|
+
return { payload: { tenantId } };
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
updateAiAccountantJobs: {
|
|
@@ -47,11 +47,10 @@ const aiAccountantView = createSlice({
|
|
|
47
47
|
const customerView = draft.customersByTenantId[action.payload.tenantId];
|
|
48
48
|
if (customerView != null) {
|
|
49
49
|
customerView.jobsFetchStatus = { fetchState: 'Completed' };
|
|
50
|
-
customerView.jobsPageToken = action.payload.nextPageToken;
|
|
51
50
|
}
|
|
52
51
|
},
|
|
53
|
-
prepare(tenantId
|
|
54
|
-
return { payload: { tenantId
|
|
52
|
+
prepare(tenantId) {
|
|
53
|
+
return { payload: { tenantId } };
|
|
55
54
|
},
|
|
56
55
|
},
|
|
57
56
|
updateAiAccountantJobsFailure(draft, action) {
|
|
@@ -73,8 +72,8 @@ const aiAccountantView = createSlice({
|
|
|
73
72
|
_action) {
|
|
74
73
|
draft.triggerJobStatus = { fetchState: 'In-Progress' };
|
|
75
74
|
},
|
|
76
|
-
prepare(operationType,
|
|
77
|
-
return { payload: { operationType,
|
|
75
|
+
prepare(operationType, params, triggeredBy) {
|
|
76
|
+
return { payload: { operationType, params, triggeredBy } };
|
|
78
77
|
},
|
|
79
78
|
},
|
|
80
79
|
triggerAiAccountantJobSuccess(draft) {
|
|
@@ -133,16 +132,13 @@ const aiAccountantView = createSlice({
|
|
|
133
132
|
export const { cancelAiAccountantOnboarding, cancelAiAccountantOnboardingFailure, cancelAiAccountantOnboardingSuccess, clearAiAccountantView, fetchAiAccountantCustomers, fetchAiAccountantJobs, setSelectedTenantIdsForJobTrigger, triggerAiAccountantJob, triggerAiAccountantJobFailure, triggerAiAccountantJobSuccess, updateAiAccountantCustomers, updateAiAccountantCustomersFailure, updateAiAccountantJobs, updateAiAccountantJobsFailure, updateAiAccountantUIState, } = aiAccountantView.actions;
|
|
134
133
|
export default aiAccountantView.reducer;
|
|
135
134
|
// ── Helpers ──
|
|
136
|
-
const toCustomersByTenantId = (customers
|
|
135
|
+
const toCustomersByTenantId = (customers) => {
|
|
137
136
|
const result = {};
|
|
138
137
|
for (const payload of customers) {
|
|
139
|
-
|
|
140
|
-
const existingState = existing[tenantId];
|
|
141
|
-
result[tenantId] = existingState ?? {
|
|
138
|
+
result[payload.tenant_id] = {
|
|
142
139
|
cancelOnboardingStatus: { fetchState: 'Not-Started' },
|
|
143
140
|
jobsFetchStatus: { fetchState: 'Not-Started' },
|
|
144
|
-
|
|
145
|
-
tenantId,
|
|
141
|
+
tenantId: payload.tenant_id,
|
|
146
142
|
};
|
|
147
143
|
}
|
|
148
144
|
return result;
|