@zeniai/client-epic-state 5.0.4-betaJK1 → 5.0.4

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 (18) hide show
  1. package/lib/entity/accountRecon/accountReconState.d.ts +1 -1
  2. package/lib/entity/accountRecon/accountReconState.js +0 -1
  3. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.d.ts +9 -1
  4. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +16 -1
  5. package/lib/esm/entity/accountRecon/accountReconState.js +0 -1
  6. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +16 -1
  7. package/lib/esm/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +0 -2
  8. package/lib/esm/view/expenseAutomationView/epics/accountRecon/initialiseLocalDataForSelectedAccountIdEpic.js +0 -1
  9. package/lib/esm/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +2 -29
  10. package/lib/esm/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.js +1 -2
  11. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  12. package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +0 -2
  13. package/lib/view/expenseAutomationView/epics/accountRecon/initialiseLocalDataForSelectedAccountIdEpic.js +0 -1
  14. package/lib/view/expenseAutomationView/epics/accountRecon/saveReconciliationReviewEpic.js +2 -29
  15. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.d.ts +1 -1
  16. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.js +1 -2
  17. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -4
  18. package/package.json +1 -1
@@ -4,7 +4,7 @@ import { MonthYearPeriod } from '../../commonStateTypes/timePeriod';
4
4
  import { ZeniDate } from '../../zeniDayJS';
5
5
  import { MerchantType, TransactionDirectionType } from '../transaction/stateTypes/reconciliationTransaction';
6
6
  import { TransactionType } from '../transaction/stateTypes/transactionType';
7
- export declare const toRecommendedActionCodeType: (v: string) => "record_expense" | "record_deposit" | "record_transfer" | "record_bill_payment" | "record_cc_payment" | "record_cc_credit" | "record_journal_entry";
7
+ export declare const toRecommendedActionCodeType: (v: string) => "record_expense" | "record_deposit" | "record_transfer" | "record_bill_payment" | "record_cc_payment" | "record_cc_credit";
8
8
  export type RecommendedActionCodeType = ReturnType<typeof toRecommendedActionCodeType>;
9
9
  export declare const toReconciliationStatusCodeType: (v: string) => "pending" | "failed" | "in_progress" | "save_for_later" | "reconciled" | "reconciled_on_qbo";
10
10
  export type ReconciliationStatusCodeType = ReturnType<typeof toReconciliationStatusCodeType>;
@@ -10,7 +10,6 @@ const RECOMMENDED_ACTION_CODE = [
10
10
  'record_bill_payment', // Match
11
11
  'record_cc_payment', // Categorize
12
12
  'record_cc_credit', // Categorize
13
- 'record_journal_entry', // Journal Entry
14
13
  ];
15
14
  const toRecommendedActionCodeType = (v) => (0, stringToUnion_1.stringToUnion)(v, RECOMMENDED_ACTION_CODE);
16
15
  exports.toRecommendedActionCodeType = toRecommendedActionCodeType;
@@ -1,7 +1,15 @@
1
1
  import { AiAccountantCustomer, AiAccountantEnrollment, AiAccountantJob } from './aiAccountantCustomerState';
2
+ export interface AiAccountantModelAccuracyPayload {
3
+ accuracy: number;
4
+ model_id: string;
5
+ passed: boolean;
6
+ threshold: number;
7
+ training_status: string;
8
+ validated_at: string;
9
+ }
2
10
  export interface AiAccountantEnrollmentPayload {
3
11
  status: string;
4
- accuracy?: Record<string, number>;
12
+ accuracy?: Record<string, AiAccountantModelAccuracyPayload> | null;
5
13
  latest_training?: string;
6
14
  latest_transaction_sync?: string;
7
15
  offboarded_at?: string;
@@ -4,9 +4,24 @@ exports.toAiAccountantJob = exports.toAiAccountantCustomer = exports.toAiAccount
4
4
  const zeniDayJS_1 = require("../../zeniDayJS");
5
5
  const aiAccountantCustomerState_1 = require("./aiAccountantCustomerState");
6
6
  // ── Mapping functions (payload → state) ──
7
+ // Backend returns accuracy as a percent (0–100) inside a nested object; the UI
8
+ // layer treats it as a 0–1 fraction. Normalize here and drop malformed entries.
9
+ const toAccuracyByModel = (accuracyPayload) => {
10
+ if (accuracyPayload == null) {
11
+ return undefined;
12
+ }
13
+ const result = {};
14
+ Object.entries(accuracyPayload).forEach(([model, entry]) => {
15
+ const percent = entry?.accuracy;
16
+ if (typeof percent === 'number' && Number.isFinite(percent)) {
17
+ result[model] = percent / 100;
18
+ }
19
+ });
20
+ return Object.keys(result).length > 0 ? result : undefined;
21
+ };
7
22
  const toAiAccountantEnrollment = (payload) => ({
8
23
  status: (0, aiAccountantCustomerState_1.toAiAccountantEnrollmentStatus)(payload.status),
9
- accuracy: payload.accuracy,
24
+ accuracy: toAccuracyByModel(payload.accuracy),
10
25
  latestTraining: payload.latest_training != null
11
26
  ? (0, zeniDayJS_1.date)(payload.latest_training)
12
27
  : undefined,
@@ -7,7 +7,6 @@ const RECOMMENDED_ACTION_CODE = [
7
7
  'record_bill_payment', // Match
8
8
  'record_cc_payment', // Categorize
9
9
  'record_cc_credit', // Categorize
10
- 'record_journal_entry', // Journal Entry
11
10
  ];
12
11
  export const toRecommendedActionCodeType = (v) => stringToUnion(v, RECOMMENDED_ACTION_CODE);
13
12
  const RECONCILIATION_STATUS_CODE = [
@@ -1,9 +1,24 @@
1
1
  import { date } from '../../zeniDayJS';
2
2
  import { toAiAccountantEnrollmentStatus, toAiAccountantJobStatus, toAiAccountantOperationType, } from './aiAccountantCustomerState';
3
3
  // ── Mapping functions (payload → state) ──
4
+ // Backend returns accuracy as a percent (0–100) inside a nested object; the UI
5
+ // layer treats it as a 0–1 fraction. Normalize here and drop malformed entries.
6
+ const toAccuracyByModel = (accuracyPayload) => {
7
+ if (accuracyPayload == null) {
8
+ return undefined;
9
+ }
10
+ const result = {};
11
+ Object.entries(accuracyPayload).forEach(([model, entry]) => {
12
+ const percent = entry?.accuracy;
13
+ if (typeof percent === 'number' && Number.isFinite(percent)) {
14
+ result[model] = percent / 100;
15
+ }
16
+ });
17
+ return Object.keys(result).length > 0 ? result : undefined;
18
+ };
4
19
  export const toAiAccountantEnrollment = (payload) => ({
5
20
  status: toAiAccountantEnrollmentStatus(payload.status),
6
- accuracy: payload.accuracy,
21
+ accuracy: toAccuracyByModel(payload.accuracy),
7
22
  latestTraining: payload.latest_training != null
8
23
  ? date(payload.latest_training)
9
24
  : undefined,
@@ -2,7 +2,6 @@ import { from, of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { convertToPeriod, toMonthYearPeriodId, } from '../../../../commonStateTypes/timePeriod';
4
4
  import { updateAccounts } from '../../../../entity/account/accountReducer';
5
- import { toRecommendedActionCodeType } from '../../../../entity/accountRecon/accountReconState';
6
5
  import { updateAccountRecon } from '../../../../entity/accountRecon/accountReconReducer';
7
6
  import { getAccountReconByAccountIdAndSelectedPeriod } from '../../../../entity/accountRecon/accountReconSelector';
8
7
  import { updateFiles } from '../../../../entity/file/fileReducer';
@@ -117,7 +116,6 @@ export const prepareReviewTabLocalData = (transactionsToReview) => {
117
116
  .recommended_transactions[0].merchant_name,
118
117
  }
119
118
  : undefined,
120
- recommendedActionType: toRecommendedActionCodeType(currentTransaction.recommended_action.recommended_actions),
121
119
  };
122
120
  return {
123
121
  ...prev,
@@ -45,7 +45,6 @@ export const prepareReviewTabLocalData = (transactionsToReview) => {
45
45
  .recommendedTransactions[0].merchantName,
46
46
  }
47
47
  : undefined,
48
- recommendedActionType: currentTransaction.recommendedAction.action,
49
48
  };
50
49
  return {
51
50
  ...prev,
@@ -30,10 +30,8 @@ export const saveReconciliationReviewEpic = (actions$, state$, zeniAPI) => actio
30
30
  reconciliationId = reconciliationData?.reconciliationId;
31
31
  updatedTransaction = reconciliationData?.transactionsToReview.find((transaction) => transaction.transactionId === transactionId);
32
32
  }
33
- const reviewAction = localData?.recommendedActionType ??
34
- updatedTransaction?.recommendedAction.action;
35
33
  const queryParam = {
36
- review_action: reviewAction,
34
+ review_action: updatedTransaction?.recommendedAction.action,
37
35
  reconciliation_id: reconciliationId ?? '',
38
36
  ref_account_id: selectedAccountId,
39
37
  ref_account_name: reconciliationData?.account.accountName,
@@ -43,7 +41,7 @@ export const saveReconciliationReviewEpic = (actions$, state$, zeniAPI) => actio
43
41
  if (reconciliationData != null &&
44
42
  updatedTransaction != null &&
45
43
  localData != null) {
46
- switch (reviewAction) {
44
+ switch (updatedTransaction.recommendedAction.action) {
47
45
  case 'record_expense':
48
46
  payload = getPayloadForExpenseRecord(updatedTransaction, localData);
49
47
  break;
@@ -65,9 +63,6 @@ export const saveReconciliationReviewEpic = (actions$, state$, zeniAPI) => actio
65
63
  case 'record_deposit':
66
64
  payload = getPayloadForDeposit(updatedTransaction, localData, entityState);
67
65
  break;
68
- case 'record_journal_entry':
69
- payload = getPayloadForJournalEntry(updatedTransaction, localData);
70
- break;
71
66
  }
72
67
  }
73
68
  payload = {
@@ -225,28 +220,6 @@ const getPayloadForBillPayment = (updatedTransaction, linkedTransaction, localDa
225
220
  vendor_name: linkedTransaction?.merchantName,
226
221
  };
227
222
  };
228
- function getPayloadForJournalEntry(updatedTransaction, localData) {
229
- return {
230
- transaction_id: updatedTransaction.transactionId,
231
- transaction_date: updatedTransaction.transactionDate.format(DEFAULT_DATE_FORMAT),
232
- transaction_memo: updatedTransaction.memo,
233
- amount: updatedTransaction.amount.amount,
234
- currency_code: updatedTransaction.amount.currencyCode,
235
- transaction_direction: updatedTransaction.transactionDirection,
236
- lines: [
237
- {
238
- class_id: localData.jeDebitClassId,
239
- posting_type: 'Debit',
240
- amount: updatedTransaction.amount.amount,
241
- },
242
- {
243
- class_id: localData.jeCreditClassId,
244
- posting_type: 'Credit',
245
- amount: updatedTransaction.amount.amount,
246
- },
247
- ],
248
- };
249
- }
250
223
  const getToastMessageSection = (updatedTransaction) => {
251
224
  if (updatedTransaction?.recommendedAction.action === 'record_bill_payment') {
252
225
  return 'recon_transaction_match';
@@ -1,6 +1,6 @@
1
1
  import fetch from 'cross-fetch';
2
2
  import { zeniAPI } from '../../../../init';
3
- export default async function uploadAccountStatementIntoDocumentAI(accountType, fileBlob, authParams, accountName) {
3
+ export default async function uploadAccountStatementIntoDocumentAI(accountType, fileBlob, authParams) {
4
4
  let statementUpload;
5
5
  const urlEndPoint = `${zeniAPI.apiEndPoints.documentAIMicroServiceBaseUrl}/1.0/processors/statement`;
6
6
  const data = new FormData();
@@ -10,7 +10,6 @@ export default async function uploadAccountStatementIntoDocumentAI(accountType,
10
10
  ? 'reconciliation_card_statement_upload'
11
11
  : 'reconciliation_bank_statement_upload',
12
12
  purpose_id: 'reconciliation',
13
- ...(accountName != null && { account_name: accountName }),
14
13
  });
15
14
  data.append('attachment_json_0', attachment_json);
16
15
  try {