@zeniai/client-epic-state 5.2.11-betaAM4 → 5.2.11-betaAM6

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.
@@ -139,7 +139,9 @@ export interface JEOneTimeAccrualClearedPayload {
139
139
  reversed_at?: string | null;
140
140
  }
141
141
  export interface JEOneTimeAccrualMatchSuggestionPayload {
142
+ match_tier?: string | null;
142
143
  matched_amount?: number | null;
144
+ matched_line_id?: string | null;
143
145
  matched_transaction_id?: string | null;
144
146
  matched_transaction_integration_id?: string | null;
145
147
  matched_transaction_type?: string | null;
@@ -476,9 +476,11 @@ function toJEOneTimeAccrualMatchSuggestion(payload, currencyCode) {
476
476
  }
477
477
  return {
478
478
  resolution: payload.resolution ?? undefined,
479
+ matchTier: payload.match_tier ?? undefined,
479
480
  matchedTransactionIntegrationId: payload.matched_transaction_integration_id ?? undefined,
480
481
  matchedTransactionId: payload.matched_transaction_id ?? undefined,
481
482
  matchedTransactionType: payload.matched_transaction_type ?? undefined,
483
+ matchedLineId: payload.matched_line_id ?? undefined,
482
484
  matchedAmount: payload.matched_amount != null
483
485
  ? toOneTimeAccrualAmount(payload.matched_amount, currencyCode)
484
486
  : undefined,
@@ -212,9 +212,11 @@ export interface JEOneTimeAccrualCleared {
212
212
  /** AI match suggestion on a posted on-bill-match accrual awaiting review. */
213
213
  export interface JEOneTimeAccrualMatchSuggestion {
214
214
  matchedAmount?: Amount;
215
+ matchedLineId?: string;
215
216
  matchedTransactionId?: string;
216
217
  matchedTransactionIntegrationId?: string;
217
218
  matchedTransactionType?: string;
219
+ matchTier?: string;
218
220
  resolution?: string;
219
221
  }
220
222
  export interface JEOneTimeAccrualState {
@@ -465,9 +465,11 @@ function toJEOneTimeAccrualMatchSuggestion(payload, currencyCode) {
465
465
  }
466
466
  return {
467
467
  resolution: payload.resolution ?? undefined,
468
+ matchTier: payload.match_tier ?? undefined,
468
469
  matchedTransactionIntegrationId: payload.matched_transaction_integration_id ?? undefined,
469
470
  matchedTransactionId: payload.matched_transaction_id ?? undefined,
470
471
  matchedTransactionType: payload.matched_transaction_type ?? undefined,
472
+ matchedLineId: payload.matched_line_id ?? undefined,
471
473
  matchedAmount: payload.matched_amount != null
472
474
  ? toOneTimeAccrualAmount(payload.matched_amount, currencyCode)
473
475
  : undefined,
package/lib/esm/index.js CHANGED
@@ -871,4 +871,4 @@ export { getInvoicingOnboardingGateView } from './view/invoicing/invoicingConfig
871
871
  // Accrued JE schedules are not a discriminated union member, so consumers need this guard to
872
872
  // narrow a JEScheduleRow before reading baseTransaction / recurringAmount.
873
873
  export { getExpenseAutomationJEOneTimeAccrualDetailView, getJEScheduleRowType, isAccruedScheduleRow, isAiAccountantSchedule, isExistingTabRow, isOneTimeAccrualRow, isRenderableOneTimeAccrual, isPendingReviewRow, } from './view/expenseAutomationView/selectors/jeSchedulesViewSelector';
874
- export { getActualMatchingAmount, getActualMatchingReversalDate, getExpenseAutomationActualMatchingView, isAutoReversedAccrual, isPendingReviewAccrual, } from './view/expenseAutomationView/selectors/actualMatchingViewSelector';
874
+ export { getActualMatchingAmount, getActualMatchingReversalDate, getExpenseAutomationActualMatchingView, isAutoReversedAccrual, isManuallyReversedAccrual, isPendingReviewAccrual, } from './view/expenseAutomationView/selectors/actualMatchingViewSelector';
@@ -5,8 +5,31 @@ export function toServiceMonthFromPeriod(period) {
5
5
  }
6
6
  const DEFAULT_CURRENCY_CODE = 'USD';
7
7
  const DEFAULT_CURRENCY_SYMBOL = '$';
8
+ function resolveMatchSearchAmount(payload) {
9
+ const raw = payload.total_amount ?? payload.amount;
10
+ if (typeof raw === 'number' && Number.isFinite(raw)) {
11
+ return raw;
12
+ }
13
+ if (typeof raw === 'string' && raw !== '') {
14
+ const parsed = Number(raw);
15
+ if (Number.isFinite(parsed)) {
16
+ return parsed;
17
+ }
18
+ }
19
+ return 0;
20
+ }
21
+ function resolveMatchSearchCurrencySymbol(payload, currencyCode) {
22
+ if (payload.currency_symbol != null && payload.currency_symbol !== '') {
23
+ return payload.currency_symbol;
24
+ }
25
+ return currencyCode === DEFAULT_CURRENCY_CODE
26
+ ? DEFAULT_CURRENCY_SYMBOL
27
+ : currencyCode;
28
+ }
8
29
  export function toActualMatchingTransactionSearchResult(payload) {
9
- const currencyCode = payload.currency_code ?? DEFAULT_CURRENCY_CODE;
30
+ const currencyCode = payload.currency_code != null && payload.currency_code !== ''
31
+ ? payload.currency_code
32
+ : DEFAULT_CURRENCY_CODE;
10
33
  return {
11
34
  transactionId: payload.transaction_id,
12
35
  transactionIntegrationId: payload.transaction_integration_id,
@@ -14,7 +37,7 @@ export function toActualMatchingTransactionSearchResult(payload) {
14
37
  lineId: payload.line_id,
15
38
  vendorId: payload.vendor_id ?? undefined,
16
39
  vendorName: payload.vendor_name ?? '',
17
- amount: payload.total_amount,
40
+ amount: resolveMatchSearchAmount(payload),
18
41
  transactionDate: payload.transaction_date,
19
42
  accountId: payload.account_id ?? undefined,
20
43
  accountName: payload.account_name ?? undefined,
@@ -22,10 +45,7 @@ export function toActualMatchingTransactionSearchResult(payload) {
22
45
  accountingClassId: payload.accounting_class_id ?? undefined,
23
46
  accountingClassName: payload.accounting_class_name ?? undefined,
24
47
  currencyCode,
25
- currencySymbol: payload.currency_symbol ??
26
- (currencyCode === DEFAULT_CURRENCY_CODE
27
- ? DEFAULT_CURRENCY_SYMBOL
28
- : currencyCode),
48
+ currencySymbol: resolveMatchSearchCurrencySymbol(payload, currencyCode),
29
49
  transactionMemo: payload.transaction_memo ?? undefined,
30
50
  transactionDescription: payload.transaction_description ?? undefined,
31
51
  transactionTypeName: payload.transaction_type_name ?? undefined,
@@ -6,6 +6,10 @@ export function isAutoReversedAccrual(accrual) {
6
6
  return (accrual.accrualStatus === 'reversed' &&
7
7
  accrual.reversalTrigger === 'bill_match');
8
8
  }
9
+ export function isManuallyReversedAccrual(accrual) {
10
+ return (accrual.accrualStatus === 'reversed' &&
11
+ accrual.reversalTrigger === 'manual_reverse');
12
+ }
9
13
  export function isPendingReviewAccrual(accrual) {
10
14
  if (accrual.accrualStatus !== 'posted' || accrual.matchSuggestion == null) {
11
15
  return false;
@@ -14,10 +18,12 @@ export function isPendingReviewAccrual(accrual) {
14
18
  return resolution == null || resolution.length === 0;
15
19
  }
16
20
  export function getActualMatchingAmount(accrual) {
17
- return (accrual.cleared?.matchedAmount?.amount ?? accrual.estimatedAmount.amount);
21
+ return (accrual.cleared?.matchedAmount?.amount ??
22
+ accrual.matchSuggestion?.matchedAmount?.amount ??
23
+ accrual.estimatedAmount.amount);
18
24
  }
19
25
  export function getActualMatchingReversalDate(accrual) {
20
- if (!isAutoReversedAccrual(accrual)) {
26
+ if (!isAutoReversedAccrual(accrual) && !isManuallyReversedAccrual(accrual)) {
21
27
  return undefined;
22
28
  }
23
29
  return accrual.actualReversalPostDate ?? accrual.cleared?.reversedAt;
@@ -26,9 +32,9 @@ function toActualMatchingRow(accrual, kind) {
26
32
  return {
27
33
  ...accrual,
28
34
  kind,
29
- reversalDate: kind === 'auto_reversed'
30
- ? getActualMatchingReversalDate(accrual)
31
- : undefined,
35
+ reversalDate: kind === 'pending_review'
36
+ ? undefined
37
+ : getActualMatchingReversalDate(accrual),
32
38
  };
33
39
  }
34
40
  function matchesSearch(accrual, searchString) {
@@ -92,32 +98,37 @@ export function getExpenseAutomationActualMatchingView(state) {
92
98
  const pendingReview = sortActualMatchingRows(filtered
93
99
  .filter(isPendingReviewAccrual)
94
100
  .map((accrual) => toActualMatchingRow(accrual, 'pending_review')), uiState);
95
- const kpiSource = accruals;
96
- const kpiSummary = kpiSource.length === 0
101
+ const manuallyReversed = sortActualMatchingRows(filtered
102
+ .filter(isManuallyReversedAccrual)
103
+ .map((accrual) => toActualMatchingRow(accrual, 'manually_reversed')), uiState);
104
+ const listedAccruals = accruals.filter((accrual) => isAutoReversedAccrual(accrual) ||
105
+ isPendingReviewAccrual(accrual) ||
106
+ isManuallyReversedAccrual(accrual));
107
+ const kpiSummary = listedAccruals.length === 0
97
108
  ? emptyKpiSummary()
98
109
  : {
99
110
  autoReversed: {
100
- count: kpiSource.filter(isAutoReversedAccrual).length,
101
- amount: kpiSource
111
+ count: listedAccruals.filter(isAutoReversedAccrual).length,
112
+ amount: listedAccruals
102
113
  .filter(isAutoReversedAccrual)
103
114
  .reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
104
115
  },
105
116
  pendingReview: {
106
- count: kpiSource.filter(isPendingReviewAccrual).length,
107
- amount: kpiSource
117
+ count: listedAccruals.filter(isPendingReviewAccrual).length,
118
+ amount: listedAccruals
108
119
  .filter(isPendingReviewAccrual)
109
120
  .reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
110
121
  },
111
122
  totalThisClose: {
112
- count: kpiSource.length,
113
- amount: kpiSource.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
123
+ count: listedAccruals.length,
124
+ amount: listedAccruals.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
114
125
  },
115
126
  ai: {
116
- count: kpiSource.filter((accrual) => accrual.origin === 'agent')
127
+ count: listedAccruals.filter((accrual) => accrual.origin === 'agent')
117
128
  .length,
118
129
  },
119
130
  manual: {
120
- count: kpiSource.filter((accrual) => accrual.origin === 'human')
131
+ count: listedAccruals.filter((accrual) => accrual.origin === 'human')
121
132
  .length,
122
133
  },
123
134
  };
@@ -129,6 +140,7 @@ export function getExpenseAutomationActualMatchingView(state) {
129
140
  error,
130
141
  autoReversed,
131
142
  pendingReview,
143
+ manuallyReversed,
132
144
  kpiSummary,
133
145
  uiState,
134
146
  refreshStatus,
package/lib/index.d.ts CHANGED
@@ -1265,4 +1265,4 @@ export type { InvoicingOnboardingGateView } from './view/invoicing/invoicingConf
1265
1265
  export type { InvoicingConfigView } from './view/invoicing/invoicingConfigView/invoicingConfigViewSelector';
1266
1266
  export type { InvoicingOnboardingStatus } from './view/invoicing/invoicingConfigView/invoicingConfigViewPayload';
1267
1267
  export { getExpenseAutomationJEOneTimeAccrualDetailView, getJEScheduleRowType, isAccruedScheduleRow, isAiAccountantSchedule, isExistingTabRow, isOneTimeAccrualRow, isRenderableOneTimeAccrual, isPendingReviewRow, } from './view/expenseAutomationView/selectors/jeSchedulesViewSelector';
1268
- export { getActualMatchingAmount, getActualMatchingReversalDate, getExpenseAutomationActualMatchingView, isAutoReversedAccrual, isPendingReviewAccrual, } from './view/expenseAutomationView/selectors/actualMatchingViewSelector';
1268
+ export { getActualMatchingAmount, getActualMatchingReversalDate, getExpenseAutomationActualMatchingView, isAutoReversedAccrual, isManuallyReversedAccrual, isPendingReviewAccrual, } from './view/expenseAutomationView/selectors/actualMatchingViewSelector';
package/lib/index.js CHANGED
@@ -84,7 +84,7 @@ exports.getInvoicingDiscountActionState = exports.runInvoicingDiscountAction = e
84
84
  exports.updateInvoicingSubscriptions = exports.removeInvoicingSubscription = exports.resetPromotionalCreditAction = exports.submitAddPromotionalCredits = exports.getInvoicingSetupIntentFetchState = exports.getInvoicingSetupIntent = exports.getInvoicingSentPaymentLinkMagicUrl = exports.getInvoicingSentPaymentLinkEmail = exports.getInvoicingPlaidLinkTokenFetchState = exports.getInvoicingPlaidLinkToken = exports.getInvoicingPaymentMethodSaveState = exports.getInvoicingPaymentLinkSendState = exports.sendInvoicingPaymentLink = exports.saveInvoicingPaymentMethod = exports.resetInvoicingCustomerPaymentMethod = exports.fetchInvoicingPlaidLinkToken = exports.createInvoicingSetupIntent = exports.getInvoicingCustomerDetail = exports.fetchInvoicingCustomerDetailPage = exports.fetchInvoicingCustomerDetail = exports.getInvoicingCustomerListView = exports.INVOICING_CUSTOMER_COLUMNS = exports.ALL_INVOICING_CUSTOMER_TAB_IDS = exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = exports.updateInvoicingCustomerFilters = exports.setInvoicingCustomerActiveTab = exports.fetchInvoicingCustomerListPage = exports.fetchInvoicingCustomerList = exports.fetchInvoicingCustomerCounts = exports.updateInvoicingCustomers = exports.removeInvoicingCustomer = exports.INVOICING_LIST_PAGE_SIZE = exports.getInvoicingDataImportActionState = exports.uploadInvoicingMigrationFiles = exports.startInvoicingMigration = exports.rollbackInvoicingMigration = exports.retryInvoicingMigration = exports.connectInvoicingChargebee = exports.getInvoicingDataImportView = exports.setInvoicingActiveMigrationSessionId = exports.fetchInvoicingMigrationSessions = exports.fetchInvoicingMigrationSession = exports.fetchInvoicingMigrationDiagnostics = exports.fetchInvoicingDataImportStatus = exports.getInvoicingPaymentActionState = exports.runInvoicingPaymentAction = exports.getInvoicingDunningActionState = exports.runInvoicingDunningAction = exports.getInvoicingSubscriptionActionState = exports.runInvoicingSubscriptionAction = void 0;
85
85
  exports.getInvoicingCouponCounts = exports.INVOICING_COUPON_COLUMNS = exports.ALL_INVOICING_COUPON_TAB_IDS = exports.ALL_INVOICING_COUPON_SORT_KEYS = exports.updateInvoicingCouponFilters = exports.setInvoicingCouponActiveTab = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.fetchInvoicingCouponCounts = exports.updateInvoicingCoupons = exports.removeInvoicingCoupon = exports.getInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteById = exports.fetchInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteListView = exports.INVOICING_CREDIT_NOTE_COLUMNS = exports.ALL_INVOICING_CREDIT_NOTE_TAB_IDS = exports.ALL_INVOICING_CREDIT_NOTE_SORT_KEYS = exports.updateInvoicingCreditNoteFilters = exports.setInvoicingCreditNoteActiveTab = exports.fetchInvoicingCreditNoteListPage = exports.fetchInvoicingCreditNoteList = exports.fetchInvoicingCreditNoteCounts = exports.updateInvoicingCreditNotes = exports.removeInvoicingCreditNote = exports.getInvoicingTransactionDetail = exports.getInvoicingTransactionById = exports.fetchInvoicingTransactionDetail = exports.getInvoicingTransactionListView = exports.INVOICING_TRANSACTION_COLUMNS = exports.ALL_INVOICING_TRANSACTION_TAB_IDS = exports.ALL_INVOICING_TRANSACTION_SORT_KEYS = exports.updateInvoicingTransactionFilters = exports.setInvoicingTransactionActiveTab = exports.fetchInvoicingTransactionListPage = exports.fetchInvoicingTransactionList = exports.updateInvoicingTransactions = exports.removeInvoicingTransaction = exports.getInvoicingSubscriptionDetail = exports.getInvoicingSubscriptionById = exports.fetchInvoicingSubscriptionDetail = exports.getInvoicingSubscriptionListView = exports.INVOICING_SUBSCRIPTION_COLUMNS = exports.ALL_INVOICING_SUBSCRIPTION_TAB_IDS = exports.ALL_INVOICING_SUBSCRIPTION_SORT_KEYS = exports.updateInvoicingSubscriptionFilters = exports.setInvoicingSubscriptionActiveTab = exports.fetchInvoicingSubscriptionListPage = exports.fetchInvoicingSubscriptionList = exports.fetchInvoicingSubscriptionCounts = void 0;
86
86
  exports.resetSaveInvoicingSettings = exports.resetInvoicingBrandingFormDraft = exports.fetchInvoicingSettings = exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.getInvoicingProductById = exports.getInvoicingPlanById = exports.getInvoicingCatalogItemDetail = exports.fetchInvoicingCatalogItemDetail = exports.getInvoicingCatalogListView = exports.INVOICING_PRODUCT_COLUMNS = exports.ALL_INVOICING_PRODUCT_SORT_KEYS = exports.updateInvoicingCatalogProductFilters = exports.updateInvoicingCatalogPlanFilters = exports.fetchInvoicingCatalogProductList = exports.fetchInvoicingCatalogPlanList = exports.fetchInvoicingCatalogListPage = exports.fetchInvoicingCatalogCounts = exports.updateInvoicingProducts = exports.removeInvoicingProduct = exports.updateInvoicingPlans = exports.removeInvoicingPlan = exports.mergeInvoicingPlanSubFamily = exports.getInvoicingDunningEmailPreview = exports.getInvoicingDunningCaseDetail = exports.getInvoicingDunningCaseById = exports.invalidateInvoicingDunningEmailPreview = exports.fetchInvoicingDunningEmailPreviewPage = exports.fetchInvoicingDunningCaseDetail = exports.clearInvoicingDunningCaseDetailView = exports.getInvoicingDunningCaseListView = exports.INVOICING_DUNNING_CASE_COLUMNS = exports.ALL_INVOICING_DUNNING_CASE_TAB_IDS = exports.ALL_INVOICING_DUNNING_CASE_SORT_KEYS = exports.updateInvoicingDunningCaseFilters = exports.setInvoicingDunningCaseActiveTab = exports.fetchInvoicingDunningCaseListPage = exports.fetchInvoicingDunningCaseList = exports.fetchInvoicingDunningCaseCounts = exports.updateInvoicingDunningCases = exports.removeInvoicingDunningCase = exports.getInvoicingCouponDetail = exports.fetchInvoicingCouponDetail = exports.getInvoicingCouponById = exports.getInvoicingCouponListView = exports.getInvoicingCouponListNextCursor = exports.getInvoicingCouponListItems = exports.getInvoicingCouponListHasMore = exports.getInvoicingCouponListFilters = exports.getInvoicingCouponListFetchState = void 0;
87
- exports.isPendingReviewAccrual = exports.isAutoReversedAccrual = exports.getExpenseAutomationActualMatchingView = exports.getActualMatchingReversalDate = exports.getActualMatchingAmount = exports.isPendingReviewRow = exports.isRenderableOneTimeAccrual = exports.isOneTimeAccrualRow = exports.isExistingTabRow = exports.isAiAccountantSchedule = exports.isAccruedScheduleRow = exports.getJEScheduleRowType = exports.getExpenseAutomationJEOneTimeAccrualDetailView = exports.getInvoicingOnboardingGateView = exports.getInvoicingConfigView = exports.updateInvoicingConfig = exports.resetInvoicingConfigActionStates = exports.fetchInvoicingConfig = exports.enableInvoicing = exports.acceptInvoicingTerms = exports.withInvoicingQboAccountMappingId = exports.toInvoicingQboCustomerMatchingMode = exports.toInvoicingNamedOptionsByKey = exports.getInvoicingQboAccountMappingId = exports.INVOICING_QBO_CUSTOMER_MATCHING_MODES = exports.getInvoicingQboView = exports.invoicingAccountsForQboAccountTypes = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.startInvoicingQboBackfill = exports.retryInvoicingQboSyncTask = exports.fetchInvoicingQboSyncHealth = exports.fetchInvoicingQboConnection = exports.fetchInvoicingAccountingPickers = exports.isStripeConnectedFromSettings = exports.initialInvoicingBrandingFormLocalData = exports.entityToInvoicingBrandingFormLocalData = exports.INVOICING_BUSINESS_ADDRESS_TYPE = exports.getInvoicingSettingsView = exports.getInvoicingSettingsHubView = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = exports.getInvoicingBrandingFormView = exports.updateInvoicingSettings = exports.updateInvoicingBrandingFormDraft = exports.submitInvoicingBrandingForm = exports.saveInvoicingSettings = void 0;
87
+ exports.isPendingReviewAccrual = exports.isManuallyReversedAccrual = exports.isAutoReversedAccrual = exports.getExpenseAutomationActualMatchingView = exports.getActualMatchingReversalDate = exports.getActualMatchingAmount = exports.isPendingReviewRow = exports.isRenderableOneTimeAccrual = exports.isOneTimeAccrualRow = exports.isExistingTabRow = exports.isAiAccountantSchedule = exports.isAccruedScheduleRow = exports.getJEScheduleRowType = exports.getExpenseAutomationJEOneTimeAccrualDetailView = exports.getInvoicingOnboardingGateView = exports.getInvoicingConfigView = exports.updateInvoicingConfig = exports.resetInvoicingConfigActionStates = exports.fetchInvoicingConfig = exports.enableInvoicing = exports.acceptInvoicingTerms = exports.withInvoicingQboAccountMappingId = exports.toInvoicingQboCustomerMatchingMode = exports.toInvoicingNamedOptionsByKey = exports.getInvoicingQboAccountMappingId = exports.INVOICING_QBO_CUSTOMER_MATCHING_MODES = exports.getInvoicingQboView = exports.invoicingAccountsForQboAccountTypes = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.startInvoicingQboBackfill = exports.retryInvoicingQboSyncTask = exports.fetchInvoicingQboSyncHealth = exports.fetchInvoicingQboConnection = exports.fetchInvoicingAccountingPickers = exports.isStripeConnectedFromSettings = exports.initialInvoicingBrandingFormLocalData = exports.entityToInvoicingBrandingFormLocalData = exports.INVOICING_BUSINESS_ADDRESS_TYPE = exports.getInvoicingSettingsView = exports.getInvoicingSettingsHubView = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = exports.getInvoicingBrandingFormView = exports.updateInvoicingSettings = exports.updateInvoicingBrandingFormDraft = exports.submitInvoicingBrandingForm = exports.saveInvoicingSettings = void 0;
88
88
  const allowedValue_1 = require("./commonStateTypes/allowedValue");
89
89
  Object.defineProperty(exports, "isAllowedValueWithCode", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithCode; } });
90
90
  Object.defineProperty(exports, "isAllowedValueWithID", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithID; } });
@@ -3204,4 +3204,5 @@ Object.defineProperty(exports, "getActualMatchingAmount", { enumerable: true, ge
3204
3204
  Object.defineProperty(exports, "getActualMatchingReversalDate", { enumerable: true, get: function () { return actualMatchingViewSelector_1.getActualMatchingReversalDate; } });
3205
3205
  Object.defineProperty(exports, "getExpenseAutomationActualMatchingView", { enumerable: true, get: function () { return actualMatchingViewSelector_1.getExpenseAutomationActualMatchingView; } });
3206
3206
  Object.defineProperty(exports, "isAutoReversedAccrual", { enumerable: true, get: function () { return actualMatchingViewSelector_1.isAutoReversedAccrual; } });
3207
+ Object.defineProperty(exports, "isManuallyReversedAccrual", { enumerable: true, get: function () { return actualMatchingViewSelector_1.isManuallyReversedAccrual; } });
3207
3208
  Object.defineProperty(exports, "isPendingReviewAccrual", { enumerable: true, get: function () { return actualMatchingViewSelector_1.isPendingReviewAccrual; } });
@@ -25,7 +25,6 @@ export interface MatchTransactionSearchQueryPayload {
25
25
  }
26
26
  export interface MatchTransactionSearchResultPayload {
27
27
  line_id: string;
28
- total_amount: number;
29
28
  transaction_date: string;
30
29
  transaction_id: ID;
31
30
  transaction_integration_id: string;
@@ -35,8 +34,10 @@ export interface MatchTransactionSearchResultPayload {
35
34
  account_name?: string | null;
36
35
  accounting_class_id?: ID | null;
37
36
  accounting_class_name?: string | null;
37
+ amount?: number | null;
38
38
  currency_code?: string | null;
39
39
  currency_symbol?: string | null;
40
+ total_amount?: number | null;
40
41
  transaction_description?: string | null;
41
42
  transaction_memo?: string | null;
42
43
  transaction_type_name?: string | null;
@@ -10,8 +10,31 @@ function toServiceMonthFromPeriod(period) {
10
10
  }
11
11
  const DEFAULT_CURRENCY_CODE = 'USD';
12
12
  const DEFAULT_CURRENCY_SYMBOL = '$';
13
+ function resolveMatchSearchAmount(payload) {
14
+ const raw = payload.total_amount ?? payload.amount;
15
+ if (typeof raw === 'number' && Number.isFinite(raw)) {
16
+ return raw;
17
+ }
18
+ if (typeof raw === 'string' && raw !== '') {
19
+ const parsed = Number(raw);
20
+ if (Number.isFinite(parsed)) {
21
+ return parsed;
22
+ }
23
+ }
24
+ return 0;
25
+ }
26
+ function resolveMatchSearchCurrencySymbol(payload, currencyCode) {
27
+ if (payload.currency_symbol != null && payload.currency_symbol !== '') {
28
+ return payload.currency_symbol;
29
+ }
30
+ return currencyCode === DEFAULT_CURRENCY_CODE
31
+ ? DEFAULT_CURRENCY_SYMBOL
32
+ : currencyCode;
33
+ }
13
34
  function toActualMatchingTransactionSearchResult(payload) {
14
- const currencyCode = payload.currency_code ?? DEFAULT_CURRENCY_CODE;
35
+ const currencyCode = payload.currency_code != null && payload.currency_code !== ''
36
+ ? payload.currency_code
37
+ : DEFAULT_CURRENCY_CODE;
15
38
  return {
16
39
  transactionId: payload.transaction_id,
17
40
  transactionIntegrationId: payload.transaction_integration_id,
@@ -19,7 +42,7 @@ function toActualMatchingTransactionSearchResult(payload) {
19
42
  lineId: payload.line_id,
20
43
  vendorId: payload.vendor_id ?? undefined,
21
44
  vendorName: payload.vendor_name ?? '',
22
- amount: payload.total_amount,
45
+ amount: resolveMatchSearchAmount(payload),
23
46
  transactionDate: payload.transaction_date,
24
47
  accountId: payload.account_id ?? undefined,
25
48
  accountName: payload.account_name ?? undefined,
@@ -27,10 +50,7 @@ function toActualMatchingTransactionSearchResult(payload) {
27
50
  accountingClassId: payload.accounting_class_id ?? undefined,
28
51
  accountingClassName: payload.accounting_class_name ?? undefined,
29
52
  currencyCode,
30
- currencySymbol: payload.currency_symbol ??
31
- (currencyCode === DEFAULT_CURRENCY_CODE
32
- ? DEFAULT_CURRENCY_SYMBOL
33
- : currencyCode),
53
+ currencySymbol: resolveMatchSearchCurrencySymbol(payload, currencyCode),
34
54
  transactionMemo: payload.transaction_memo ?? undefined,
35
55
  transactionDescription: payload.transaction_description ?? undefined,
36
56
  transactionTypeName: payload.transaction_type_name ?? undefined,
@@ -3,7 +3,7 @@ import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndRep
3
3
  import { JEOneTimeAccrual } from '../../../entity/jeSchedules/jeSchedulesSelector';
4
4
  import { ZeniDate } from '../../../zeniDayJS';
5
5
  import { ActualMatchingTransactionSearchResult, ActualMatchingViewUIState, MatchAndReverseResult } from '../types/actualMatchingViewState';
6
- export type ActualMatchingRowKind = 'auto_reversed' | 'pending_review';
6
+ export type ActualMatchingRowKind = 'auto_reversed' | 'pending_review' | 'manually_reversed';
7
7
  export interface ActualMatchingRow extends JEOneTimeAccrual {
8
8
  kind: ActualMatchingRowKind;
9
9
  reversalDate?: ZeniDate;
@@ -51,6 +51,7 @@ export interface ExpenseAutomationActualMatchingViewSelector extends SelectorVie
51
51
  autoReversed: ActualMatchingRow[];
52
52
  hasLoadedForSelectedPeriod: boolean;
53
53
  kpiSummary: ActualMatchingKpiSummary;
54
+ manuallyReversed: ActualMatchingRow[];
54
55
  matchModal: ActualMatchingMatchModalView;
55
56
  pendingReview: ActualMatchingRow[];
56
57
  refreshStatus: FetchStateAndError;
@@ -3,6 +3,7 @@ import { RootState } from '../../../rootStateTypes';
3
3
  import { ZeniDate } from '../../../zeniDayJS';
4
4
  import { ExpenseAutomationActualMatchingViewSelector } from '../selectorTypes/actualMatchingViewSelectorTypes';
5
5
  export declare function isAutoReversedAccrual(accrual: JEOneTimeAccrual): boolean;
6
+ export declare function isManuallyReversedAccrual(accrual: JEOneTimeAccrual): boolean;
6
7
  export declare function isPendingReviewAccrual(accrual: JEOneTimeAccrual): boolean;
7
8
  export declare function getActualMatchingAmount(accrual: JEOneTimeAccrual): number;
8
9
  export declare function getActualMatchingReversalDate(accrual: JEOneTimeAccrual): ZeniDate | undefined;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isAutoReversedAccrual = isAutoReversedAccrual;
7
+ exports.isManuallyReversedAccrual = isManuallyReversedAccrual;
7
8
  exports.isPendingReviewAccrual = isPendingReviewAccrual;
8
9
  exports.getActualMatchingAmount = getActualMatchingAmount;
9
10
  exports.getActualMatchingReversalDate = getActualMatchingReversalDate;
@@ -16,6 +17,10 @@ function isAutoReversedAccrual(accrual) {
16
17
  return (accrual.accrualStatus === 'reversed' &&
17
18
  accrual.reversalTrigger === 'bill_match');
18
19
  }
20
+ function isManuallyReversedAccrual(accrual) {
21
+ return (accrual.accrualStatus === 'reversed' &&
22
+ accrual.reversalTrigger === 'manual_reverse');
23
+ }
19
24
  function isPendingReviewAccrual(accrual) {
20
25
  if (accrual.accrualStatus !== 'posted' || accrual.matchSuggestion == null) {
21
26
  return false;
@@ -24,10 +29,12 @@ function isPendingReviewAccrual(accrual) {
24
29
  return resolution == null || resolution.length === 0;
25
30
  }
26
31
  function getActualMatchingAmount(accrual) {
27
- return (accrual.cleared?.matchedAmount?.amount ?? accrual.estimatedAmount.amount);
32
+ return (accrual.cleared?.matchedAmount?.amount ??
33
+ accrual.matchSuggestion?.matchedAmount?.amount ??
34
+ accrual.estimatedAmount.amount);
28
35
  }
29
36
  function getActualMatchingReversalDate(accrual) {
30
- if (!isAutoReversedAccrual(accrual)) {
37
+ if (!isAutoReversedAccrual(accrual) && !isManuallyReversedAccrual(accrual)) {
31
38
  return undefined;
32
39
  }
33
40
  return accrual.actualReversalPostDate ?? accrual.cleared?.reversedAt;
@@ -36,9 +43,9 @@ function toActualMatchingRow(accrual, kind) {
36
43
  return {
37
44
  ...accrual,
38
45
  kind,
39
- reversalDate: kind === 'auto_reversed'
40
- ? getActualMatchingReversalDate(accrual)
41
- : undefined,
46
+ reversalDate: kind === 'pending_review'
47
+ ? undefined
48
+ : getActualMatchingReversalDate(accrual),
42
49
  };
43
50
  }
44
51
  function matchesSearch(accrual, searchString) {
@@ -102,32 +109,37 @@ function getExpenseAutomationActualMatchingView(state) {
102
109
  const pendingReview = sortActualMatchingRows(filtered
103
110
  .filter(isPendingReviewAccrual)
104
111
  .map((accrual) => toActualMatchingRow(accrual, 'pending_review')), uiState);
105
- const kpiSource = accruals;
106
- const kpiSummary = kpiSource.length === 0
112
+ const manuallyReversed = sortActualMatchingRows(filtered
113
+ .filter(isManuallyReversedAccrual)
114
+ .map((accrual) => toActualMatchingRow(accrual, 'manually_reversed')), uiState);
115
+ const listedAccruals = accruals.filter((accrual) => isAutoReversedAccrual(accrual) ||
116
+ isPendingReviewAccrual(accrual) ||
117
+ isManuallyReversedAccrual(accrual));
118
+ const kpiSummary = listedAccruals.length === 0
107
119
  ? emptyKpiSummary()
108
120
  : {
109
121
  autoReversed: {
110
- count: kpiSource.filter(isAutoReversedAccrual).length,
111
- amount: kpiSource
122
+ count: listedAccruals.filter(isAutoReversedAccrual).length,
123
+ amount: listedAccruals
112
124
  .filter(isAutoReversedAccrual)
113
125
  .reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
114
126
  },
115
127
  pendingReview: {
116
- count: kpiSource.filter(isPendingReviewAccrual).length,
117
- amount: kpiSource
128
+ count: listedAccruals.filter(isPendingReviewAccrual).length,
129
+ amount: listedAccruals
118
130
  .filter(isPendingReviewAccrual)
119
131
  .reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
120
132
  },
121
133
  totalThisClose: {
122
- count: kpiSource.length,
123
- amount: kpiSource.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
134
+ count: listedAccruals.length,
135
+ amount: listedAccruals.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
124
136
  },
125
137
  ai: {
126
- count: kpiSource.filter((accrual) => accrual.origin === 'agent')
138
+ count: listedAccruals.filter((accrual) => accrual.origin === 'agent')
127
139
  .length,
128
140
  },
129
141
  manual: {
130
- count: kpiSource.filter((accrual) => accrual.origin === 'human')
142
+ count: listedAccruals.filter((accrual) => accrual.origin === 'human')
131
143
  .length,
132
144
  },
133
145
  };
@@ -139,6 +151,7 @@ function getExpenseAutomationActualMatchingView(state) {
139
151
  error,
140
152
  autoReversed,
141
153
  pendingReview,
154
+ manuallyReversed,
142
155
  kpiSummary,
143
156
  uiState,
144
157
  refreshStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.11-betaAM4",
3
+ "version": "5.2.11-betaAM6",
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",