@zeniai/client-epic-state 4.19.99-betaRD9 → 4.19.99-betaSS2

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 (72) 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/jeSchedulesTypes.d.ts +1 -1
  6. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  7. package/lib/entity/tenant/clearAllEpic.d.ts +1 -3
  8. package/lib/entity/tenant/clearAllEpic.js +0 -4
  9. package/lib/entity/userRole/userRoleType.d.ts +2 -2
  10. package/lib/epic.d.ts +1 -5
  11. package/lib/epic.js +1 -5
  12. package/lib/esm/entity/tenant/clearAllEpic.js +0 -4
  13. package/lib/esm/epic.js +1 -5
  14. package/lib/esm/index.js +0 -7
  15. package/lib/esm/reducer.js +0 -6
  16. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +8 -3
  17. package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +59 -140
  18. package/lib/index.d.ts +0 -8
  19. package/lib/index.js +2 -30
  20. package/lib/reducer.d.ts +0 -6
  21. package/lib/reducer.js +0 -6
  22. package/lib/view/aiCfoView/aiCfoViewState.d.ts +1 -1
  23. package/lib/view/companyView/types/cockpitTypes.d.ts +5 -6
  24. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  25. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -1
  26. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +8 -3
  27. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +59 -140
  28. package/lib/view/reviewCompanyView/reviewCompanyViewState.d.ts +1 -1
  29. package/lib/view/spendManagement/billPay/billList/billListReducer.d.ts +1 -1
  30. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  31. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +4 -4
  32. package/lib/view/spendManagement/reimbursement/remiListView/remiListReducer.d.ts +1 -1
  33. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +3 -3
  34. package/lib/view/subscriptionView/types/subscriptionTypes.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.d.ts +0 -44
  37. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +0 -55
  38. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.d.ts +0 -10
  39. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +0 -51
  40. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +0 -48
  41. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -66
  42. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.d.ts +0 -52
  43. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -37
  44. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +0 -49
  45. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +0 -47
  46. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerSelector.js +0 -62
  47. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerState.js +0 -31
  48. package/lib/esm/view/aiAccountantView/aiAccountantViewPayload.js +0 -2
  49. package/lib/esm/view/aiAccountantView/aiAccountantViewReducer.js +0 -149
  50. package/lib/esm/view/aiAccountantView/aiAccountantViewSelector.js +0 -72
  51. package/lib/esm/view/aiAccountantView/aiAccountantViewState.js +0 -11
  52. package/lib/esm/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +0 -46
  53. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +0 -27
  54. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +0 -47
  55. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +0 -52
  56. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  57. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +0 -32
  58. package/lib/view/aiAccountantView/aiAccountantViewPayload.js +0 -8
  59. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +0 -29
  60. package/lib/view/aiAccountantView/aiAccountantViewReducer.js +0 -153
  61. package/lib/view/aiAccountantView/aiAccountantViewSelector.d.ts +0 -14
  62. package/lib/view/aiAccountantView/aiAccountantViewSelector.js +0 -78
  63. package/lib/view/aiAccountantView/aiAccountantViewState.d.ts +0 -27
  64. package/lib/view/aiAccountantView/aiAccountantViewState.js +0 -13
  65. package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.d.ts +0 -33
  66. package/lib/view/aiAccountantView/epics/cancelAiAccountantOnboardingEpic.js +0 -50
  67. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.d.ts +0 -23
  68. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +0 -31
  69. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.d.ts +0 -33
  70. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +0 -51
  71. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.d.ts +0 -28
  72. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +0 -56
@@ -1,13 +1,12 @@
1
1
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
2
2
  import { ZeniDate } from '../../../zeniDayJS';
3
- import { AiAccountantFilterCategoryField } from '../../aiAccountantView/aiAccountantViewState';
4
3
  import { SubscriptionViewSortKey } from '../../subscriptionView/types/subscriptionTypes';
5
4
  import { FilterCategoryValueType } from '../helpers/cockpitHelpers';
6
5
  import { CockpitDownloadTabsID, CockpitTabsFileType } from './cockpitTabsID';
7
- export declare const toPortfolioSortKeyType: (v: string) => "companyName" | "expenses" | "runway" | "cashBalance" | "revenues" | "netIncome";
8
- export declare const toManagementSortKeyType: (v: string) => "status" | "bookCloseDate" | "companyName" | "group" | "controller" | "plans" | "monthlyRecurringRevenue" | "notes" | "taxStatus" | "preparer" | "reviewer" | "annualRecurringRevenue" | "task" | "customerSuccessManager" | "apAnalyst" | "reportSent" | "taxLead" | "satisfaction";
9
- export declare const toOnboardingSortKeyType: (v: string) => "companyName" | "notes" | "businessVerified" | "identityVerified" | "bankAccountLinked" | "customerCreated" | "groupCreated" | "qboLinked" | "enroller" | "invite" | "latestCreated";
10
- export declare const toHealthSortKeyType: (v: string) => "companyName" | "group" | "controller" | "monthlyRecurringRevenue" | "runway" | "companyEngagementMetricsUpdatedAt" | "customerSatisfactionScore" | "externalProductServiceExposure" | "netPromoterScore" | "customerSuccessManager" | "issues" | "productVerticals" | "churnProbability" | "lastReportSent" | "subscriptionDate" | "renewalDate" | "dashboardLastSeen" | "lastEngagement";
6
+ export declare const toPortfolioSortKeyType: (v: string) => "expenses" | "runway" | "companyName" | "cashBalance" | "revenues" | "netIncome";
7
+ export declare const toManagementSortKeyType: (v: string) => "status" | "bookCloseDate" | "group" | "taxStatus" | "controller" | "preparer" | "reviewer" | "annualRecurringRevenue" | "companyName" | "monthlyRecurringRevenue" | "task" | "notes" | "plans" | "customerSuccessManager" | "apAnalyst" | "reportSent" | "taxLead" | "satisfaction";
8
+ export declare const toOnboardingSortKeyType: (v: string) => "companyName" | "businessVerified" | "identityVerified" | "bankAccountLinked" | "customerCreated" | "groupCreated" | "qboLinked" | "notes" | "enroller" | "invite" | "latestCreated";
9
+ export declare const toHealthSortKeyType: (v: string) => "group" | "runway" | "controller" | "companyName" | "monthlyRecurringRevenue" | "companyEngagementMetricsUpdatedAt" | "customerSatisfactionScore" | "externalProductServiceExposure" | "netPromoterScore" | "customerSuccessManager" | "lastReportSent" | "issues" | "productVerticals" | "churnProbability" | "subscriptionDate" | "renewalDate" | "dashboardLastSeen" | "lastEngagement";
11
10
  export declare const toTaskManagerSortKeyType: (v: string) => "status" | "name" | "tags" | "createdBy" | "dueDate" | "priority" | "assignee" | "taskName";
12
11
  export type PortfolioViewSortKey = ReturnType<typeof toPortfolioSortKeyType>;
13
12
  export type ManagementViewSortKey = ReturnType<typeof toManagementSortKeyType>;
@@ -22,7 +21,7 @@ export interface CockpitFilterCategory {
22
21
  matchingOperator: 'equal' | 'not-equal';
23
22
  values: FilterCategoryValueType[];
24
23
  valuesCombinationOperator: 'ANY' | 'ALL';
25
- field?: AiAccountantFilterCategoryField | ManagementViewFilterCategoryField | SubscriptionViewFilterCategoryField | PortfolioViewFilterCategoryField | HealthMonitorViewFilterCategoryField;
24
+ field?: ManagementViewFilterCategoryField | SubscriptionViewFilterCategoryField | PortfolioViewFilterCategoryField | HealthMonitorViewFilterCategoryField;
26
25
  }
27
26
  export interface CockpitFilters {
28
27
  categories?: CockpitFilterCategory[];
@@ -38,7 +38,7 @@ export declare const getLineItemsByTransactionIdsFromLocalData: (transactionLoca
38
38
  export declare const mergeTabSpecificLineItems: (currentTabSpecificLineItems: TabSpecificLineItems, selectedTab: TransactionsTab, newLineItems: TabSpecificLineItems) => TabSpecificLineItems;
39
39
  export declare const getSnackbarMessageForTransactionReview: (updatedCount: number, failedCount: number, categorizedCount: number) => {
40
40
  messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed";
41
- messageText: "notification" | "failed" | "success";
41
+ messageText: "notification" | "success" | "failed";
42
42
  type: "error" | "success" | "info";
43
43
  variables: {
44
44
  variableName: string;
@@ -17,7 +17,7 @@ export interface MissingReceiptsViewUIState {
17
17
  * Kept in sync with `ManualSearchInput` in web-components (fires search only when length ≥ this).
18
18
  */
19
19
  export declare const MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = 2;
20
- export declare const toBatchStatusValue: (v: string) => "pending" | "completed" | "processing";
20
+ export declare const toBatchStatusValue: (v: string) => "pending" | "processing" | "completed";
21
21
  export type BatchStatusValue = ReturnType<typeof toBatchStatusValue>;
22
22
  /** Canonical batch file statuses (API ingress may use aliases; see `parseBatchFileStatus`). */
23
23
  export declare const BATCH_FILE_STATUSES: readonly ["exact_match", "possible_matches", "no_match", "failed"];
@@ -52,11 +52,16 @@ const getProfitAndLossClassesHorizontalView = (filter, accountState, classState,
52
52
  const calculatedSections = {};
53
53
  let reportCurrency = currencyHelper_1.defaultCustomerCurrency;
54
54
  if (fetchState.fetchState === 'Completed' && selectedPeriod != null) {
55
+ // Get section reports using existing selector infrastructure
56
+ const sectionReports = {};
57
+ HORIZONTAL_PANDL_SECTION_IDS.forEach((sectionId) => {
58
+ sectionReports[sectionId] = (0, sectionClassesViewSelector_1.getSectionClassesViewReport)(accountState, classState, sectionsState, { reportId, sectionId }, filter);
59
+ });
55
60
  reportCurrency =
56
61
  profitAndLossClassesViewState.currency ?? currencyHelper_1.defaultCustomerCurrency;
57
- // Fetch each section and pivot class→account to account→class in one pass
62
+ // Pivot each section from class→account to account→class
58
63
  HORIZONTAL_PANDL_SECTION_IDS.forEach((sectionId) => {
59
- const sectionReport = (0, sectionClassesViewSelector_1.getSectionClassesViewReport)(accountState, classState, sectionsState, { reportId, sectionId }, filter);
64
+ const sectionReport = sectionReports[sectionId];
60
65
  if (sectionReport != null) {
61
66
  sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns, SECTION_TITLES[sectionId] ?? sectionId, reportCurrency);
62
67
  }
@@ -260,7 +265,7 @@ function sumBalancesInSlice(balances) {
260
265
  if (balances.length === 0) {
261
266
  return 0;
262
267
  }
263
- const summed = (0, getSummationBalance_1.getSummationFreeRangeTotalBalance)(balances);
268
+ const summed = (0, getSummationBalance_1.getSummationFreeRangeTotalBalance)([...balances]);
264
269
  return summed?.balance.amount ?? 0;
265
270
  }
266
271
  /**
@@ -28,31 +28,30 @@ function enrichHorizontalSection(report, section) {
28
28
  return total?.balance.amount ?? 0;
29
29
  });
30
30
  section.sectionHeaderBalancesSlice = buildHorizontalClassColumnBalancesSlice(report, classAmounts, section.sectionTotal.amount);
31
- const parentIndices = computeHorizontalAccountParentIndices(section.accounts);
32
- const childrenRowIndicesByParent = buildHorizontalAccountChildIndicesByParent(parentIndices);
31
+ const childrenRowIndicesByParent = buildHorizontalAccountChildIndicesByParent(section.accounts);
33
32
  const childrenRecord = {};
34
33
  childrenRowIndicesByParent.forEach((childIndices, parentIndex) => {
35
34
  childrenRecord[parentIndex] = childIndices;
36
35
  });
37
36
  section.treeLayout = {
38
37
  rootAccountRowIndices: section.accounts
39
- .map((_, i) => (parentIndices[i] === -1 ? i : -1))
38
+ .map((_, i) => findHorizontalAccountParentIndex(section.accounts, i) === -1 ? i : -1)
40
39
  .filter((i) => i >= 0),
41
40
  childrenRowIndicesByParent: childrenRecord,
42
41
  };
43
- const siblingsPerRow = buildSiblingIndicesPerRow(section.accounts, parentIndices);
44
- const hasChildFlags = computeHorizontalHasChildFlags(parentIndices);
45
42
  for (let i = 0; i < section.accounts.length; i++) {
46
43
  const row = section.accounts[i];
47
- // Same column order as `report.classColumns` (see `pivotSectionToHorizontal`).
48
- const classRowAmounts = row.classBalances.map((b) => b.balance.amount);
44
+ const classRowAmounts = report.classColumns.map((col) => {
45
+ const cb = row.classBalances.find((b) => b.classId === col.classId);
46
+ return cb?.balance.amount ?? 0;
47
+ });
49
48
  row.accountReportData = {
50
49
  accountId: row.accountId,
51
50
  accountName: row.accountName,
52
51
  accountType: row.accountType,
53
52
  depth: row.depth,
54
53
  balancesInTimeframe: buildHorizontalClassColumnBalancesSlice(report, classRowAmounts, row.rowTotal.amount),
55
- horizontalTreeView: buildHorizontalTreeViewFromPrecomputed(section.accounts, i, parentIndices, siblingsPerRow, hasChildFlags),
54
+ horizontalTreeView: buildHorizontalTreeView(section.accounts, i),
56
55
  };
57
56
  }
58
57
  }
@@ -124,157 +123,64 @@ function buildHorizontalClassColumnBalancesSlice(report, classAmounts, totalAmou
124
123
  },
125
124
  };
126
125
  }
127
- /**
128
- * Parent index per DFS row — O(n). Matches the scan in the former
129
- * `findHorizontalAccountParentIndex` (depth &lt;= 2 rows have no parent).
130
- */
131
- function computeHorizontalAccountParentIndices(rows) {
132
- const accountRowCount = rows.length;
133
- const parentIndex = new Array(accountRowCount).fill(-1);
134
- const stack = [];
135
- for (let rowIndex = 0; rowIndex < accountRowCount; rowIndex++) {
136
- const accountRow = rows[rowIndex];
137
- if (accountRow == null) {
138
- continue;
139
- }
140
- const d = accountRow.depth;
141
- while (stack.length > 0) {
142
- const topIdx = stack[stack.length - 1];
143
- if (topIdx == null) {
144
- break;
145
- }
146
- const topRow = rows[topIdx];
147
- if (topRow == null) {
148
- stack.pop();
149
- continue;
150
- }
151
- if (topRow.depth < d) {
152
- break;
153
- }
154
- stack.pop();
155
- }
156
- if (d <= 2) {
157
- parentIndex[rowIndex] = -1;
158
- }
159
- else if (stack.length === 0) {
160
- parentIndex[rowIndex] = -1;
161
- }
162
- else {
163
- const peek = stack[stack.length - 1];
164
- if (peek == null) {
165
- parentIndex[rowIndex] = -1;
166
- }
167
- else {
168
- const parentRow = rows[peek];
169
- parentIndex[rowIndex] =
170
- parentRow != null && parentRow.depth === d - 1 ? peek : -1;
126
+ function findHorizontalAccountParentIndex(dfsOrderedAccountRows, childRowIndex) {
127
+ const childDepth = dfsOrderedAccountRows[childRowIndex].depth;
128
+ if (childDepth <= 2) {
129
+ return -1;
130
+ }
131
+ for (let earlierRowIndex = childRowIndex - 1; earlierRowIndex >= 0; earlierRowIndex--) {
132
+ const earlierDepth = dfsOrderedAccountRows[earlierRowIndex].depth;
133
+ if (earlierDepth < childDepth) {
134
+ if (earlierDepth === childDepth - 1) {
135
+ return earlierRowIndex;
171
136
  }
137
+ return -1;
172
138
  }
173
- stack.push(rowIndex);
174
139
  }
175
- return parentIndex;
140
+ return -1;
176
141
  }
177
- /** Sibling row indices (same parent + depth), in traversal order — O(n). */
178
- function buildSiblingIndicesPerRow(rows, parentIndices) {
179
- const accountRowCount = rows.length;
180
- const keyToIndices = new Map();
181
- for (let rowIndex = 0; rowIndex < accountRowCount; rowIndex++) {
182
- const parentRowIndex = parentIndices[rowIndex];
183
- const accountRow = rows[rowIndex];
184
- if (parentRowIndex == null || accountRow == null) {
185
- continue;
186
- }
187
- const key = `${parentRowIndex}:${accountRow.depth}`;
188
- let g = keyToIndices.get(key);
189
- if (g == null) {
190
- g = [];
191
- keyToIndices.set(key, g);
142
+ function getHorizontalAccountSiblingIndices(dfsOrderedAccountRows, rowIndex) {
143
+ const parentRowIndex = findHorizontalAccountParentIndex(dfsOrderedAccountRows, rowIndex);
144
+ const rowDepth = dfsOrderedAccountRows[rowIndex].depth;
145
+ const siblings = [];
146
+ for (let i = 0; i < dfsOrderedAccountRows.length; i++) {
147
+ if (dfsOrderedAccountRows[i].depth === rowDepth &&
148
+ findHorizontalAccountParentIndex(dfsOrderedAccountRows, i) ===
149
+ parentRowIndex) {
150
+ siblings.push(i);
192
151
  }
193
- g.push(rowIndex);
194
152
  }
195
- const siblingsPerRow = new Array(accountRowCount);
196
- for (let rowIndex = 0; rowIndex < accountRowCount; rowIndex++) {
197
- const parentRowIndex = parentIndices[rowIndex];
198
- const accountRow = rows[rowIndex];
199
- if (parentRowIndex == null || accountRow == null) {
200
- siblingsPerRow[rowIndex] = [rowIndex];
201
- continue;
202
- }
203
- const key = `${parentRowIndex}:${accountRow.depth}`;
204
- const group = keyToIndices.get(key);
205
- siblingsPerRow[rowIndex] = group != null ? group : [rowIndex];
206
- }
207
- return siblingsPerRow;
153
+ return siblings;
208
154
  }
209
- function computeHorizontalHasChildFlags(parentIndices) {
210
- const rowCount = parentIndices.length;
211
- const flags = new Array(rowCount).fill(false);
212
- for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
213
- const parentRowIndex = parentIndices[rowIndex];
214
- if (parentRowIndex != null &&
215
- parentRowIndex >= 0 &&
216
- parentRowIndex < rowCount) {
217
- flags[parentRowIndex] = true;
218
- }
219
- }
220
- return flags;
155
+ function horizontalAccountHasChildRows(dfsOrderedAccountRows, parentRowIndex) {
156
+ return dfsOrderedAccountRows.some((_, rowIndex) => findHorizontalAccountParentIndex(dfsOrderedAccountRows, rowIndex) ===
157
+ parentRowIndex);
221
158
  }
222
- function buildHorizontalSubAccountAncestorMetadataFromPrecomputed(dfsOrderedAccountRows, currentRowIndex, parentIndices, siblingsPerRow, hasChildFlags) {
223
- const chain = [];
159
+ function buildHorizontalSubAccountAncestorMetadata(dfsOrderedAccountRows, currentRowIndex) {
160
+ const ancestorRowIndicesRootToLeaf = [];
224
161
  let walkRowIndex = currentRowIndex;
225
162
  while (walkRowIndex >= 0) {
226
- chain.unshift(walkRowIndex);
227
- const parentRowIndex = parentIndices[walkRowIndex];
228
- if (parentRowIndex == null) {
229
- break;
230
- }
231
- walkRowIndex = parentRowIndex;
163
+ ancestorRowIndicesRootToLeaf.unshift(walkRowIndex);
164
+ walkRowIndex = findHorizontalAccountParentIndex(dfsOrderedAccountRows, walkRowIndex);
232
165
  }
233
- return chain.map((rowIndex) => {
234
- const accountRow = dfsOrderedAccountRows[rowIndex];
235
- const siblingIndices = siblingsPerRow[rowIndex];
236
- const hasChild = hasChildFlags[rowIndex];
237
- if (accountRow == null || siblingIndices == null) {
238
- return {
239
- depth: 0,
240
- hasSibling: false,
241
- hasChildren: hasChild === true,
242
- isLastNode: true,
243
- name: '',
244
- };
245
- }
166
+ return ancestorRowIndicesRootToLeaf.map((rowIndex) => {
167
+ const siblingIndices = getHorizontalAccountSiblingIndices(dfsOrderedAccountRows, rowIndex);
246
168
  return {
247
- depth: accountRow.depth - 2,
169
+ depth: dfsOrderedAccountRows[rowIndex].depth - 2,
248
170
  hasSibling: siblingIndices.length > 1,
249
- hasChildren: hasChild === true,
171
+ hasChildren: horizontalAccountHasChildRows(dfsOrderedAccountRows, rowIndex),
250
172
  isLastNode: rowIndex === siblingIndices[siblingIndices.length - 1],
251
- name: accountRow.accountName,
173
+ name: dfsOrderedAccountRows[rowIndex].accountName,
252
174
  };
253
175
  });
254
176
  }
255
- function buildHorizontalTreeViewFromPrecomputed(dfsOrderedAccountRows, currentRowIndex, parentIndices, siblingsPerRow, hasChildFlags) {
256
- const siblingIndices = siblingsPerRow[currentRowIndex];
257
- const accountRow = dfsOrderedAccountRows[currentRowIndex];
258
- const hasChildrenFlag = hasChildFlags[currentRowIndex];
259
- const treeDepth = accountRow != null ? Math.max(0, accountRow.depth - 2) : 0;
260
- const hasChildren = hasChildrenFlag === true;
261
- const sibs = siblingIndices ?? [currentRowIndex];
262
- return {
263
- subAccountAncestorMetadata: buildHorizontalSubAccountAncestorMetadataFromPrecomputed(dfsOrderedAccountRows, currentRowIndex, parentIndices, siblingsPerRow, hasChildFlags),
264
- treeDepth,
265
- hasChildren,
266
- hasSiblings: sibs.length > 1,
267
- isLeaf: !hasChildren,
268
- isLastNode: currentRowIndex === sibs[sibs.length - 1],
269
- };
270
- }
271
- function buildHorizontalAccountChildIndicesByParent(parentIndices) {
177
+ function buildHorizontalAccountChildIndicesByParent(dfsOrderedAccountRows) {
272
178
  const childIndicesByParentRowIndex = new Map();
273
- for (let rowIndex = 0; rowIndex < parentIndices.length; rowIndex++) {
274
- const parentRowIndex = parentIndices[rowIndex];
275
- if (parentRowIndex != null && parentRowIndex >= 0) {
179
+ for (let rowIndex = 0; rowIndex < dfsOrderedAccountRows.length; rowIndex++) {
180
+ const parentRowIndex = findHorizontalAccountParentIndex(dfsOrderedAccountRows, rowIndex);
181
+ if (parentRowIndex >= 0) {
276
182
  let childRowIndices = childIndicesByParentRowIndex.get(parentRowIndex);
277
- if (childRowIndices == null) {
183
+ if (childRowIndices === undefined) {
278
184
  childRowIndices = [];
279
185
  childIndicesByParentRowIndex.set(parentRowIndex, childRowIndices);
280
186
  }
@@ -283,3 +189,16 @@ function buildHorizontalAccountChildIndicesByParent(parentIndices) {
283
189
  }
284
190
  return childIndicesByParentRowIndex;
285
191
  }
192
+ function buildHorizontalTreeView(dfsOrderedAccountRows, currentRowIndex) {
193
+ const treeDepth = Math.max(0, dfsOrderedAccountRows[currentRowIndex].depth - 2);
194
+ const siblingIndices = getHorizontalAccountSiblingIndices(dfsOrderedAccountRows, currentRowIndex);
195
+ const hasChildren = horizontalAccountHasChildRows(dfsOrderedAccountRows, currentRowIndex);
196
+ return {
197
+ subAccountAncestorMetadata: buildHorizontalSubAccountAncestorMetadata(dfsOrderedAccountRows, currentRowIndex),
198
+ treeDepth,
199
+ hasChildren,
200
+ hasSiblings: siblingIndices.length > 1,
201
+ isLeaf: !hasChildren,
202
+ isLastNode: currentRowIndex === siblingIndices[siblingIndices.length - 1],
203
+ };
204
+ }
@@ -3,7 +3,7 @@ import { SortOrder } from '../../commonStateTypes/selectorTypes/sortOrderTypes';
3
3
  import { OnboardingInfo } from '../../entity/company/companyStateTypes';
4
4
  import { ZeniDate } from '../../zeniDayJS';
5
5
  import { AuditSummaryPayload, ReviewCompanyPayload } from './reviewCompanyPayload';
6
- export declare const toReviewColumnKeyType: (v: string) => "companyName" | "notes" | "uncategorized" | "auditScore" | "miscategorized" | "warnings" | "vendorReview" | "reviewVendor";
6
+ export declare const toReviewColumnKeyType: (v: string) => "uncategorized" | "companyName" | "auditScore" | "miscategorized" | "notes" | "warnings" | "vendorReview" | "reviewVendor";
7
7
  export type ReviewCompanyColumnKey = ReturnType<typeof toReviewColumnKeyType>;
8
8
  export type ReviewTransactionsType = 'income' | 'expense';
9
9
  export interface AuditSummary {
@@ -21,7 +21,7 @@ export declare const fetchBillList: import("@reduxjs/toolkit").ActionCreatorWith
21
21
  period: TimePeriod;
22
22
  tab: "paid" | "pending_approval" | "scheduled" | "draft";
23
23
  error: ZeniAPIStatus<Record<string, unknown>>;
24
- }, "billList/updateBillListFailure", never, never>, updateTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"paid" | "pending_approval" | "scheduled" | "draft", "billList/updateTab">, updateSubTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"failed" | "cancelled" | "rejected" | "ach" | "wire" | "deleted" | "overdue" | "all" | "awaiting_approval" | "awaiting_my_approval" | "offline", "billList/updateSubTab">, updateSelectedBillId: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "billList/updateSelectedBillId">, clearBillList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"billList/clearBillList">, updateBillDetailSaveBillCode: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<SaveBillStageCode, "billList/updateBillDetailSaveBillCode">, updateBillListUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
24
+ }, "billList/updateBillListFailure", never, never>, updateTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"paid" | "pending_approval" | "scheduled" | "draft", "billList/updateTab">, updateSubTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"rejected" | "failed" | "ach" | "wire" | "cancelled" | "deleted" | "overdue" | "all" | "awaiting_approval" | "awaiting_my_approval" | "offline", "billList/updateSubTab">, updateSelectedBillId: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "billList/updateSelectedBillId">, clearBillList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"billList/clearBillList">, updateBillDetailSaveBillCode: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<SaveBillStageCode, "billList/updateBillDetailSaveBillCode">, updateBillListUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
25
25
  period: TimePeriod;
26
26
  uiState: Partial<BillListUIState>;
27
27
  }, "billList/updateBillListUIState">, updateSearchResult: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "billList/updateSearchResult">, updateFilterResult: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
@@ -35,7 +35,7 @@ export type SaveBillStageCode = 'draft' | 'pending_approval' | undefined;
35
35
  export declare const ALL_BILL_TABS: readonly ["paid", "pending_approval", "scheduled", "draft"];
36
36
  declare const toBillTabType: (v: string) => "paid" | "pending_approval" | "scheduled" | "draft";
37
37
  export type BillTab = ReturnType<typeof toBillTabType>;
38
- declare const toBillsSubTabType: (v: string) => "failed" | "cancelled" | "rejected" | "ach" | "wire" | "deleted" | "overdue" | "all" | "awaiting_approval" | "awaiting_my_approval" | "offline";
38
+ declare const toBillsSubTabType: (v: string) => "rejected" | "failed" | "ach" | "wire" | "cancelled" | "deleted" | "overdue" | "all" | "awaiting_approval" | "awaiting_my_approval" | "offline";
39
39
  export type BillsSubTabType = ReturnType<typeof toBillsSubTabType>;
40
40
  declare const toBillPaySortKeyType: (v: string) => "amount" | "status" | "name" | "dueDate" | "paymentMethod" | "invoiceNumber" | "invoiceDate";
41
41
  export declare type BillPayViewSortKey = ReturnType<typeof toBillPaySortKeyType>;
@@ -52,12 +52,12 @@ export declare const fetchChargeCardDetailPage: import("@reduxjs/toolkit").Actio
52
52
  chargeCardId: ID;
53
53
  fetchState: FetchState;
54
54
  error?: ZeniAPIStatus;
55
- }, "chargeCardDetail/updatePhysicalChargeCardAttemptSuccessOrFailure">, updatePhysicalChargeCardAttempt: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCardId: string, statusCode: "failed" | "success"], {
55
+ }, "chargeCardDetail/updatePhysicalChargeCardAttemptSuccessOrFailure">, updatePhysicalChargeCardAttempt: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCardId: string, statusCode: "success" | "failed"], {
56
56
  chargeCardId: string;
57
- statusCode: "failed" | "success";
58
- }, "chargeCardDetail/updatePhysicalChargeCardAttempt", never, never>, updateDebitCardPinAttempt: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCardId: string, statusCode: "failed" | "success"], {
57
+ statusCode: "success" | "failed";
58
+ }, "chargeCardDetail/updatePhysicalChargeCardAttempt", never, never>, updateDebitCardPinAttempt: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[chargeCardId: string, statusCode: "success" | "failed"], {
59
59
  chargeCardId: string;
60
- statusCode: "failed" | "success";
60
+ statusCode: "success" | "failed";
61
61
  }, "chargeCardDetail/updateDebitCardPinAttempt", never, never>, updateDebitCardPinAttemptSuccessOrFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
62
62
  chargeCardId: ID;
63
63
  fetchState: FetchState;
@@ -27,7 +27,7 @@ export declare const fetchRemiList: import("@reduxjs/toolkit").ActionCreatorWith
27
27
  }, "remiList/updateRemiListFailure", never, never>, updateRemiListUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
28
28
  period: TimePeriod;
29
29
  uiState: Partial<RemiListUIState>;
30
- }, "remiList/updateRemiListUIState">, updateTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"paid" | "pending_approval" | "scheduled" | "draft", "remiList/updateTab">, updateSubTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"failed" | "cancelled" | "rejected" | "ach" | "wire" | "deleted" | "overdue" | "all" | "myDrafts" | "awaitingApproval" | "awaitingMyApproval" | "awaitingAllApproval", "remiList/updateSubTab">, updateSelectedRemiId: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "remiList/updateSelectedRemiId">, clearRemiList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"remiList/clearRemiList">, updateRemiDetailSaveRemiCode: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<SaveRemiStageCode, "remiList/updateRemiDetailSaveRemiCode">, updateSearchResult: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "remiList/updateSearchResult">, updateFilterResult: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
30
+ }, "remiList/updateRemiListUIState">, updateTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"paid" | "pending_approval" | "scheduled" | "draft", "remiList/updateTab">, updateSubTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<"rejected" | "failed" | "ach" | "wire" | "cancelled" | "deleted" | "overdue" | "all" | "myDrafts" | "awaitingApproval" | "awaitingMyApproval" | "awaitingAllApproval", "remiList/updateSubTab">, updateSelectedRemiId: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "remiList/updateSelectedRemiId">, clearRemiList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"remiList/clearRemiList">, updateRemiDetailSaveRemiCode: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<SaveRemiStageCode, "remiList/updateRemiDetailSaveRemiCode">, updateSearchResult: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "remiList/updateSearchResult">, updateFilterResult: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
31
31
  filters: ReimbursementFilters;
32
32
  }, "remiList/updateFilterResult">, updateRemiListDownloadUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
33
33
  uiState: Partial<RemiListDownloadUIState>;
@@ -33,10 +33,10 @@ export declare const ALL_REMI_TABS: readonly ["paid", "pending_approval", "sched
33
33
  export declare const toRemiTabType: (v: string) => "paid" | "pending_approval" | "scheduled" | "draft";
34
34
  export declare const toRemiTabTypeStrict: (v: string) => "paid" | "pending_approval" | "scheduled" | "draft" | undefined;
35
35
  export type RemiTabType = ReturnType<typeof toRemiTabType>;
36
- export declare const toRemiSubTabType: (v: string) => "failed" | "cancelled" | "rejected" | "ach" | "wire" | "deleted" | "overdue" | "all" | "myDrafts" | "awaitingApproval" | "awaitingMyApproval" | "awaitingAllApproval";
37
- export declare const toRemiSubTabTypeStrict: (v: string) => "failed" | "cancelled" | "rejected" | "ach" | "wire" | "deleted" | "overdue" | "all" | "myDrafts" | "awaitingApproval" | "awaitingMyApproval" | "awaitingAllApproval" | undefined;
36
+ export declare const toRemiSubTabType: (v: string) => "rejected" | "failed" | "ach" | "wire" | "cancelled" | "deleted" | "overdue" | "all" | "myDrafts" | "awaitingApproval" | "awaitingMyApproval" | "awaitingAllApproval";
37
+ export declare const toRemiSubTabTypeStrict: (v: string) => "rejected" | "failed" | "ach" | "wire" | "cancelled" | "deleted" | "overdue" | "all" | "myDrafts" | "awaitingApproval" | "awaitingMyApproval" | "awaitingAllApproval" | undefined;
38
38
  export type RemiSubTabType = ReturnType<typeof toRemiSubTabType>;
39
- export declare const toRemiSubTabUnderScoreType: (v: string) => "failed" | "cancelled" | "rejected" | "ach" | "wire" | "deleted" | "overdue" | "all" | "awaiting_approval" | "awaiting_my_approval" | "my_drafts" | "awaiting_all_approval";
39
+ export declare const toRemiSubTabUnderScoreType: (v: string) => "rejected" | "failed" | "ach" | "wire" | "cancelled" | "deleted" | "overdue" | "all" | "awaiting_approval" | "awaiting_my_approval" | "my_drafts" | "awaiting_all_approval";
40
40
  export type RemiSubTabUnderScoreType = ReturnType<typeof toRemiSubTabUnderScoreType>;
41
41
  declare const toReimbursementSortKeyType: (v: string) => "amount" | "status" | "type" | "createdBy" | "submittedOn" | "reportName";
42
42
  export type ReimbursementViewSortKey = ReturnType<typeof toReimbursementSortKeyType>;
@@ -1,4 +1,4 @@
1
- export declare const toSubscriptionSortKeyType: (v: string) => "status" | "companyName" | "controller" | "plans" | "planLowerLimit" | "planHigherLimit" | "avg2MonthExpenses" | "addons" | "upgradeStatus" | "monthlyRecurringRevenue" | "notes";
1
+ export declare const toSubscriptionSortKeyType: (v: string) => "status" | "controller" | "avg2MonthExpenses" | "companyName" | "monthlyRecurringRevenue" | "notes" | "plans" | "planLowerLimit" | "planHigherLimit" | "addons" | "upgradeStatus";
2
2
  export type SubscriptionViewSortKey = ReturnType<typeof toSubscriptionSortKeyType>;
3
3
  export declare const SUBSCRIPTION_STATUS_CODES: string[];
4
4
  declare const toSubscriptionStatusCodeType: (v: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.99-betaRD9",
3
+ "version": "4.19.99-betaSS2",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -1,44 +0,0 @@
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;
@@ -1,55 +0,0 @@
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 != null
11
- ? (0, zeniDayJS_1.date)(payload.latest_training)
12
- : undefined,
13
- latestTransactionSync: payload.latest_transaction_sync != null
14
- ? (0, zeniDayJS_1.date)(payload.latest_transaction_sync)
15
- : undefined,
16
- offboardedAt: payload.offboarded_at != null ? (0, zeniDayJS_1.date)(payload.offboarded_at) : undefined,
17
- offboardedBy: payload.offboarded_by,
18
- onboardedAt: payload.onboarded_at != null ? (0, zeniDayJS_1.date)(payload.onboarded_at) : undefined,
19
- onboardedBy: payload.onboarded_by,
20
- validationResults: payload.validation_results?.map((vr) => ({
21
- accuracy: vr.accuracy,
22
- modelType: vr.model_type,
23
- passed: vr.passed,
24
- threshold: vr.threshold,
25
- })),
26
- });
27
- exports.toAiAccountantEnrollment = toAiAccountantEnrollment;
28
- const toAiAccountantCustomer = (payload) => ({
29
- companyId: payload.company_id,
30
- companyName: payload.company_name,
31
- tenantId: payload.tenant_id,
32
- bookcloseDate: payload.bookclose_date != null ? (0, zeniDayJS_1.date)(payload.bookclose_date) : undefined,
33
- enrollment: payload.enrollment != null
34
- ? (0, exports.toAiAccountantEnrollment)(payload.enrollment)
35
- : undefined,
36
- });
37
- exports.toAiAccountantCustomer = toAiAccountantCustomer;
38
- const toAiAccountantJob = (payload) => ({
39
- companyId: payload.company_id,
40
- createdAt: (0, zeniDayJS_1.date)(payload.created_at),
41
- jobId: payload.job_id,
42
- operationType: (0, aiAccountantCustomerState_1.toAiAccountantOperationType)(payload.operation_type),
43
- status: (0, aiAccountantCustomerState_1.toAiAccountantJobStatus)(payload.status),
44
- tenantId: payload.tenant_id,
45
- triggeredBy: payload.triggered_by,
46
- companyNamespace: payload.company_namespace,
47
- completedAt: payload.completed_at != null ? (0, zeniDayJS_1.date)(payload.completed_at) : undefined,
48
- errorMessage: payload.error_message,
49
- parameters: payload.parameters,
50
- retryCount: payload.retry_count,
51
- startedAt: payload.started_at != null ? (0, zeniDayJS_1.date)(payload.started_at) : undefined,
52
- steps: payload.steps,
53
- validationResults: payload.validation_results,
54
- });
55
- exports.toAiAccountantJob = toAiAccountantJob;
@@ -1,10 +0,0 @@
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;
@@ -1,51 +0,0 @@
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
- const newCustomerByTenantId = {};
17
- action.payload.forEach((payload) => {
18
- const customer = (0, aiAccountantCustomerPayload_1.toAiAccountantCustomer)(payload);
19
- newCustomerByTenantId[customer.tenantId] = customer;
20
- });
21
- draft.customerByTenantId = newCustomerByTenantId;
22
- },
23
- updateAiAccountantCustomer(draft, action) {
24
- const customer = (0, aiAccountantCustomerPayload_1.toAiAccountantCustomer)(action.payload);
25
- draft.customerByTenantId[customer.tenantId] = customer;
26
- },
27
- updateAiAccountantJobs: {
28
- reducer(draft, action) {
29
- const mappedJobs = action.payload.jobs.map(aiAccountantCustomerPayload_1.toAiAccountantJob);
30
- if (action.payload.append) {
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
- }
40
- },
41
- prepare(tenantId, jobs, append = false) {
42
- return { payload: { tenantId, jobs, append } };
43
- },
44
- },
45
- clearAllAiAccountantCustomers(draft) {
46
- Object.assign(draft, exports.initialAiAccountantCustomerState);
47
- },
48
- },
49
- });
50
- _a = aiAccountantCustomer.actions, exports.clearAllAiAccountantCustomers = _a.clearAllAiAccountantCustomers, exports.updateAiAccountantCustomers = _a.updateAiAccountantCustomers, exports.updateAiAccountantCustomer = _a.updateAiAccountantCustomer, exports.updateAiAccountantJobs = _a.updateAiAccountantJobs;
51
- exports.default = aiAccountantCustomer.reducer;