@zeniai/client-epic-state 5.0.31-betaAR10 → 5.0.31-betaAR2

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.
@@ -1,9 +1,9 @@
1
1
  import { AccountsViewParentID } from '../../commonStateTypes/accountView/nestedAccountID';
2
2
  import { ClassesViewParentID } from '../../commonStateTypes/classesView/nestedClassID';
3
+ import { ProjectsViewParentID } from '../../commonStateTypes/projectView/projectViewParentID';
3
4
  import { AdditionalBalancesOptions } from '../../commonStateTypes/coaBalance/additionalBalances/getAdditionalBalances';
4
5
  import { COABalancesFilter } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
5
6
  import { ID } from '../../commonStateTypes/common';
6
- import { ProjectsViewParentID } from '../../commonStateTypes/projectView/projectViewParentID';
7
7
  import { EntityOrder } from '../../commonStateTypes/selectorTypes/selectorTypes';
8
8
  import { ReportIDPlusForecastID } from '../../commonStateTypes/viewAndReport/viewAndReport';
9
9
  import { Account, AccountBase, AccountState, AccountType } from './accountState';
@@ -132,16 +132,16 @@ export declare const getAllAccounts: (accountState: AccountState) => Account[];
132
132
  export interface AccountFilterOption {
133
133
  accountId: ID;
134
134
  accountName: string;
135
- accountType: AccountType;
135
+ /**
136
+ * Account type for the underlying account (e.g. 'bank', 'credit_card', 'expenses').
137
+ * Required by the Payment Account Type filter dropdown so it can show only the
138
+ * types actually present on the tenant rather than the full ALL_ACCOUNT_TYPES list.
139
+ */
140
+ accountType: AccountType | undefined;
136
141
  }
137
142
  /**
138
143
  * Partitions accounts for transaction filter dropdowns: bank/credit_card → paymentAccountNames,
139
144
  * all other account types → categoryOptions. Use for payment_account_name and category filter options.
140
- *
141
- * Note: payment_account_type dropdown options come from transaction-level
142
- * `paymentType`/`paymentTypeName` fields, not account-level — account records
143
- * rarely carry those values. See ExpenseAutomationPage.filterOptions for
144
- * the source of those options.
145
145
  */
146
146
  export declare const getTransactionFilterAccountOptions: (accountState: AccountState) => {
147
147
  categoryOptions: AccountFilterOption[];
@@ -202,20 +202,12 @@ exports.getAllAccounts = getAllAccounts;
202
202
  /**
203
203
  * Partitions accounts for transaction filter dropdowns: bank/credit_card → paymentAccountNames,
204
204
  * all other account types → categoryOptions. Use for payment_account_name and category filter options.
205
- *
206
- * Note: payment_account_type dropdown options come from transaction-level
207
- * `paymentType`/`paymentTypeName` fields, not account-level — account records
208
- * rarely carry those values. See ExpenseAutomationPage.filterOptions for
209
- * the source of those options.
210
205
  */
211
206
  const getTransactionFilterAccountOptions = (accountState) => {
212
207
  const accounts = (0, exports.getAllAccounts)(accountState);
213
208
  const paymentAccountNames = [];
214
209
  const categoryOptions = [];
215
210
  for (const account of accounts) {
216
- if (account.accountType == null) {
217
- continue;
218
- }
219
211
  const option = {
220
212
  accountId: account.accountId,
221
213
  accountName: account.accountName,
@@ -188,20 +188,12 @@ export const getAllAccounts = (accountState) => Object.values(accountState.accou
188
188
  /**
189
189
  * Partitions accounts for transaction filter dropdowns: bank/credit_card → paymentAccountNames,
190
190
  * all other account types → categoryOptions. Use for payment_account_name and category filter options.
191
- *
192
- * Note: payment_account_type dropdown options come from transaction-level
193
- * `paymentType`/`paymentTypeName` fields, not account-level — account records
194
- * rarely carry those values. See ExpenseAutomationPage.filterOptions for
195
- * the source of those options.
196
191
  */
197
192
  export const getTransactionFilterAccountOptions = (accountState) => {
198
193
  const accounts = getAllAccounts(accountState);
199
194
  const paymentAccountNames = [];
200
195
  const categoryOptions = [];
201
196
  for (const account of accounts) {
202
- if (account.accountType == null) {
203
- continue;
204
- }
205
197
  const option = {
206
198
  accountId: account.accountId,
207
199
  accountName: account.accountName,
@@ -24,11 +24,6 @@ export const fetchTransactionCategorizationEpic = (actions$, state$, zeniAPI) =>
24
24
  page_size: 25,
25
25
  search_text: uiState.searchString,
26
26
  };
27
- // .getJSON<TransactionCategorizationResponse>(
28
- // `https://qa.api.zeni.ai/version/accounting/amitesh/1.0/expense-automation/transactions?query=${encodeURIComponent(
29
- // JSON.stringify(queryParam)
30
- // )}`
31
- // )
32
27
  return zeniAPI
33
28
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
34
29
  .pipe(mergeMap((response) => {
@@ -332,20 +332,33 @@ const getCategoryValueForTransaction = (key, transaction) => {
332
332
  return undefined;
333
333
  }
334
334
  case 'payment_account_name': {
335
- // Match the value the row renders: TransactionCategorizationListRow reads
336
- // `currentTransaction?.account?.accountName` for the Payment Account Name
337
- // column. Returning the same field here keeps filter-match parity with the
338
- // visible cell, so any row a user can see is also a row the filter can match.
339
- return transaction.transaction.account?.accountName;
335
+ // Get from transaction.account or from lines
336
+ if (transaction.transaction.account?.accountName) {
337
+ return transaction.transaction.account.accountName;
338
+ }
339
+ // Get from first line's account
340
+ const firstLine = transaction.transaction.lines?.[0];
341
+ if (firstLine?.type === 'transaction_with_account_and_class_line' ||
342
+ firstLine?.type === 'transaction_with_product_or_service_line' ||
343
+ firstLine?.type === 'journal_entry_transaction_line') {
344
+ const accountLine = firstLine;
345
+ return accountLine.account?.accountName;
346
+ }
347
+ return undefined;
340
348
  }
341
349
  case 'payment_account_type': {
342
- // Compare against the raw `paymentType` enum (e.g. "credit_card", "check",
343
- // "cash"). The same enum is what TransactionCategorizationListRow uses for
344
- // its icon switch on line ~1675, and it's what the dropdown options emit
345
- // as `value`. Display labels come from each account's `paymentTypeName`
346
- // field (populated by mapAccountBasePayloadToAccountBase from the backend
347
- // payload) no client-side label map required.
348
- return transaction.transaction.paymentType;
350
+ // Similar to payment_account_name but for type
351
+ if (transaction.transaction.account?.accountType) {
352
+ return transaction.transaction.account.accountType;
353
+ }
354
+ const firstLineForType = transaction.transaction.lines?.[0];
355
+ if (firstLineForType?.type === 'transaction_with_account_and_class_line' ||
356
+ firstLineForType?.type === 'transaction_with_product_or_service_line' ||
357
+ firstLineForType?.type === 'journal_entry_transaction_line') {
358
+ const accountLineForType = firstLineForType;
359
+ return accountLineForType.account?.accountType;
360
+ }
361
+ return undefined;
349
362
  }
350
363
  case 'category': {
351
364
  // Get from transactionLocalData (preferred) or from transaction lines
package/lib/index.d.ts CHANGED
@@ -38,7 +38,7 @@ import { AgingDateSelectionType, AgingDetailReportInvoice, AgingDetailReportUISt
38
38
  import { isAgingReport, isCashFlowOrBalanceSheetReport, isDashboardClassesViewReport, isDashboardReport, isFluxAnalysisOpExReport, isOpExByVendorReport, isPAndLClassesViewReport, isPAndLProjectViewReport, isPAndLReport } from './commonStateTypes/viewAndReport/reportIDHelper';
39
39
  import { PageToken, Report, ReportFormat, ReportID, ReportIDPlusForecastID, SelectorReport, SelectorView, View, toReportFormatStrict, toReportID } from './commonStateTypes/viewAndReport/viewAndReport';
40
40
  import { PAYMENT_BUSINESS_DAYS, filterDays, getNextNthWorkingDay, getPreviousNthWorkingDay, getYearsList, holidaysFormatted, isHoliday, isHolidayToday } from './commonStateTypes/workingDayHelper';
41
- import { AccountFilterOption, AccountReport, AccountWithBalanceReport, getAllAccounts, getTransactionFilterAccountOptions } from './entity/account/accountSelector';
41
+ import { AccountReport, AccountWithBalanceReport, getAllAccounts, getTransactionFilterAccountOptions } from './entity/account/accountSelector';
42
42
  import { ALL_ACCOUNT_TYPES, Account, AccountBase, AccountType, RecommendedAccountBase, ReconciliationAccountSourceType, StatementCloseDay, toAccountType, toReconciliationAccountSource } from './entity/account/accountState';
43
43
  import { NestedAccountReport } from './entity/account/subAccountSelector';
44
44
  import { AccountGroupReport } from './entity/accountGroup/accountGroupSelector';
@@ -647,7 +647,7 @@ export { VendorSpendTrendFilterTabType, toVendorSpendTrendFilterTabsTypeStrict,
647
647
  export { getNumberOfPeriods };
648
648
  export { SCHEDULE_DAYS_OF_MONTH, ScheduleDaysOfMonth, toScheduleDaysOfMonth, Day, Month, toMonth, toMonthStrict, Quarter, toQuarter, toQuarterStrict, AbsoluteDay, TimePeriod, };
649
649
  export { Tenant, TenantView, LoggedInUser, TenantBaseView, CurrentTenant, TenantProductSettings, getTenantBaseById, getCurrentTenant, getIsAccountingClassesEnabled, getIsAccountingProjectsEnabled, getTenantsByCheckInDateSelector, getTenantsBaseByCheckInDateSelector, getTenantsCoreDetailsByCheckInDateSelector, toTenantCoreDetailsView, getTenantBaseViewForTenantView, getTenantBaseViewForTenantId, isZeniDomainTenant, isTenantUsingZeniCOA, TenantsBaseOrdered, TenantsOrdered, TenantCoreDetailsView, fetchActiveTenant, fetchAllTenants, updateCurrentTenant, clearAll, doMagicLinkSignIn, verifyDeviceWithTwoFA, resendVerifyDeviceOTP, sendEmailMagicLinkToUser, doSignIn, updateSignInState, DoSignInPayload, doSignOut, sendSessionHeartbeat, resetSignInState, RoleResource, Connection, fetchExcludedResourcesForTenant, fetchExternalConnectionsForTenant, saveExternalConnectionForTenant, fetchSubscriptionSummaryForTenant, isTenantBankingOnly, isTenantCardsOnly, isTenantBookkeepingEnabled, isOtherProductsEnabledForTenant, };
650
- export { Account, ALL_ACCOUNT_TYPES, AccountType, AccountBase, StatementCloseDay, toAccountType, AccountReport, AccountFilterOption, getAllAccounts, getTransactionFilterAccountOptions, NestedAccountReport, AccountWithBalanceReport, AccountGroup, AccountGroupReportV2, AccountGroupType, toAccountGroupType, AccountGroupReport, getAccountGroupKey, AccountGroupKey, RecommendedAccountBase, };
650
+ export { Account, ALL_ACCOUNT_TYPES, AccountType, AccountBase, StatementCloseDay, toAccountType, AccountReport, getAllAccounts, getTransactionFilterAccountOptions, NestedAccountReport, AccountWithBalanceReport, AccountGroup, AccountGroupReportV2, AccountGroupType, toAccountGroupType, AccountGroupReport, getAccountGroupKey, AccountGroupKey, RecommendedAccountBase, };
651
651
  export { Class, ClassBase, RecommendedClassBase, } from './entity/class/classState';
652
652
  export { getAllClasses, getClassById } from './entity/class/classSelector';
653
653
  export { ClassReport } from './entity/class/classSelectorTypes';