diff --git a/src/CONST/index.ts b/src/CONST/index.ts index c56be545e2d9..cc7a36c5e41e 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -7032,6 +7032,8 @@ const CONST = { SUBMITTER_USER_ID: this.TABLE_COLUMNS.SUBMITTER_USER_ID, SUBMITTER_PAYROLL_ID: this.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID, ORDER_DEAL_NUMBERS: this.TABLE_COLUMNS.ORDER_DEAL_NUMBERS, + AMOUNT_DEBITED: this.TABLE_COLUMNS.AMOUNT_DEBITED, + AMOUNT_REIMBURSED: this.TABLE_COLUMNS.AMOUNT_REIMBURSED, EXPORTED_ICON: this.TABLE_COLUMNS.EXPORTED_TO, ACTION: this.TABLE_COLUMNS.ACTION, }, @@ -7071,6 +7073,8 @@ const CONST = { BANK_ACCOUNT: this.TABLE_COLUMNS.GROUP_BANK_ACCOUNT, WITHDRAWAL_ID: this.TABLE_COLUMNS.GROUP_WITHDRAWAL_ID, EXPENSES: this.TABLE_COLUMNS.GROUP_EXPENSES, + AMOUNT_DEBITED: this.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED, + AMOUNT_REIMBURSED: this.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED, TOTAL: this.TABLE_COLUMNS.GROUP_TOTAL, }, CATEGORY: { @@ -7149,6 +7153,8 @@ const CONST = { this.TABLE_COLUMNS.GROUP_BANK_ACCOUNT, this.TABLE_COLUMNS.GROUP_WITHDRAWAL_ID, this.TABLE_COLUMNS.GROUP_EXPENSES, + this.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED, + this.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED, this.TABLE_COLUMNS.GROUP_TOTAL, ], CATEGORY: [this.TABLE_COLUMNS.GROUP_CATEGORY, this.TABLE_COLUMNS.GROUP_EXPENSES, this.TABLE_COLUMNS.GROUP_TOTAL], @@ -7240,6 +7246,8 @@ const CONST = { SUBMITTER_USER_ID: 'submitterUserID', SUBMITTER_PAYROLL_ID: 'submitterPayrollID', ORDER_DEAL_NUMBERS: 'orderDealNumbers', + AMOUNT_DEBITED: 'amountDebited', + AMOUNT_REIMBURSED: 'amountReimbursed', AVATAR: 'avatar', STATUS: 'status', PAID_STATUS: 'paidstatus', @@ -7269,6 +7277,8 @@ const CONST = { GROUP_YEAR: 'groupyear', GROUP_QUARTER: 'groupquarter', GROUP_WITHDRAWAL_STATUS: 'groupWithdrawalStatus', + GROUP_AMOUNT_DEBITED: 'groupAmountDebited', + GROUP_AMOUNT_REIMBURSED: 'groupAmountReimbursed', }, SYNTAX_OPERATORS: { AND: 'and', @@ -7331,6 +7341,8 @@ const CONST = { PAID_STATUS: 'paidStatus', WITHDRAWN: 'withdrawn', TOTAL: 'total', + AMOUNT_DEBITED: 'amountDebited', + AMOUNT_REIMBURSED: 'amountReimbursed', TITLE: 'title', ASSIGNEE: 'assignee', REIMBURSABLE: 'reimbursable', @@ -7383,6 +7395,8 @@ const CONST = { DATE: 'date', AMOUNT: 'amount', TOTAL: 'total', + AMOUNT_DEBITED: 'amount-debited', + AMOUNT_REIMBURSED: 'amount-reimbursed', EXPENSE_TYPE: 'expense-type', RECEIPT_TYPE: 'receipt-type', CURRENCY: 'currency', @@ -7494,6 +7508,10 @@ const CONST = { [this.TABLE_COLUMNS.GROUP_YEAR]: 'group-year', [this.TABLE_COLUMNS.GROUP_QUARTER]: 'group-quarter', [this.TABLE_COLUMNS.GROUP_WITHDRAWAL_STATUS]: 'group-withdrawal-status', + [this.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED]: 'group-amount-debited', + [this.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED]: 'group-amount-reimbursed', + [this.TABLE_COLUMNS.AMOUNT_DEBITED]: 'amount-debited', + [this.TABLE_COLUMNS.AMOUNT_REIMBURSED]: 'amount-reimbursed', }; }, NOT_PREFIX: '-', diff --git a/src/components/Search/FilterDropdowns/SortByPopup.tsx b/src/components/Search/FilterDropdowns/SortByPopup.tsx index 4fd70677e466..ab5d17990869 100644 --- a/src/components/Search/FilterDropdowns/SortByPopup.tsx +++ b/src/components/Search/FilterDropdowns/SortByPopup.tsx @@ -55,7 +55,7 @@ function SortByPopup({searchResults, queryJSON, groupBy, onSort, onSortOrderPres const searchDataType = shouldUseLiveData ? CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT : searchResults?.search?.type; const currentColumns = !searchResults?.data ? [] - : getColumnsToShow({currentAccountID: accountID, data: searchResults.data, visibleColumns, type: searchDataType, groupBy: groupBy?.value}); + : getColumnsToShow({currentAccountID: accountID, data: searchResults.data, visibleColumns, type: searchDataType, groupBy: groupBy?.value, sortBy: queryJSON.sortBy}); const sortableColumns = getSortByOptions(currentColumns, translate); const sortOrder = queryJSON.sortOrder; diff --git a/src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx b/src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx index 237dd323dfd3..1ecf5270792b 100644 --- a/src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx +++ b/src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx @@ -60,6 +60,7 @@ function ExpenseReportListItemRowWide({ const submitterUserID = item.submitterUserID; const submitterPayrollID = item.submitterPayrollID; const orderDealNumbers = item.orderDealNumbers; + const {debitedAmount, debitedCurrency, creditedAmount, creditedCurrency} = item; const columnComponents = { [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: ( @@ -234,6 +235,26 @@ function ExpenseReportListItemRowWide({ ), + [CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED]: ( + + {!!debitedAmount && !!debitedCurrency && ( + + )} + + ), + [CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED]: ( + + {!!creditedAmount && !!creditedCurrency && ( + + )} + + ), [CONST.SEARCH.TABLE_COLUMNS.REPORT_ID]: ( diff --git a/src/components/Search/SearchList/ListItem/WithdrawalIDListItemHeader.tsx b/src/components/Search/SearchList/ListItem/WithdrawalIDListItemHeader.tsx index 7327f9aa8b29..67f72a025cdc 100644 --- a/src/components/Search/SearchList/ListItem/WithdrawalIDListItemHeader.tsx +++ b/src/components/Search/SearchList/ListItem/WithdrawalIDListItemHeader.tsx @@ -93,6 +93,8 @@ function WithdrawalIDListItemHeaderImpl({ withdrawalIDItem.debitPosted, DateUtils.doesDateBelongToAPastYear(withdrawalIDItem.debitPosted) ? CONST.DATE.MONTH_DAY_YEAR_ABBR_FORMAT : CONST.DATE.MONTH_DAY_ABBR_FORMAT, ); + const {debitedAmount, debitedCurrency, creditedAmount, creditedCurrency} = withdrawalIDItem; + const badgeProps = getSettlementStatusBadgeProps(withdrawalIDItem.state, translate, theme); const settlementStatus = getSettlementStatus(withdrawalIDItem.state); const statusBadge = !!badgeProps && ( @@ -177,6 +179,33 @@ function WithdrawalIDListItemHeaderImpl({ ), + // A settlement that did not convert currencies reports neither amount, and an amount says nothing without the currency it moved in. + [CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED]: ( + + {!!debitedAmount && !!debitedCurrency && ( + + )} + + ), + [CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED]: ( + + {!!creditedAmount && !!creditedCurrency && ( + + )} + + ), [CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL]: ( { - const commonGroupHeaders: SearchColumnConfig[] = [ - { - columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES, - translationKey: 'common.expenses' as TranslationPaths, - isColumnSortable: true, - }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL, - translationKey: 'common.total' as TranslationPaths, - isColumnSortable: true, - }, - ]; + const groupExpensesHeader: SearchColumnConfig = { + columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES, + translationKey: 'common.expenses' as TranslationPaths, + isColumnSortable: true, + }; + const groupTotalHeader: SearchColumnConfig = { + columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL, + translationKey: 'common.total' as TranslationPaths, + isColumnSortable: true, + }; + const commonGroupHeaders: SearchColumnConfig[] = [groupExpensesHeader, groupTotalHeader]; switch (groupBy) { case CONST.SEARCH.GROUP_BY.FROM: return [ @@ -405,7 +412,18 @@ const getTransactionGroupHeaders = (groupBy: SearchGroupBy, icons: SearchHeaderI columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_WITHDRAWAL_ID, translationKey: 'common.withdrawalID', }, - ...commonGroupHeaders, + groupExpensesHeader, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED, + translationKey: 'common.amountDebited', + isColumnSortable: true, + }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED, + translationKey: 'common.amountReimbursed', + isColumnSortable: true, + }, + groupTotalHeader, ]; case CONST.SEARCH.GROUP_BY.CATEGORY: return [ diff --git a/src/components/Search/SortableTableHeader.tsx b/src/components/Search/SortableTableHeader.tsx index c535480b6d44..21daa1256854 100644 --- a/src/components/Search/SortableTableHeader.tsx +++ b/src/components/Search/SortableTableHeader.tsx @@ -80,9 +80,14 @@ function SortableTableHeader({ const sortByColumnName = sortColumnName ?? columnName; const isActive = sortBy === sortByColumnName; const isReimbursableOrBillableColumn = columnName === CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE || columnName === CONST.SEARCH.TABLE_COLUMNS.BILLABLE; + const isConversionAmountColumn = + columnName === CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED || + columnName === CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED || + columnName === CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED || + columnName === CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED; const textStyle = [ columnName === CONST.SEARCH.TABLE_COLUMNS.RECEIPT ? StyleUtils.getTextOverflowStyle('clip') : null, - isReimbursableOrBillableColumn ? styles.flexShrink1 : null, + isReimbursableOrBillableColumn || isConversionAmountColumn ? styles.flexShrink1 : null, ]; return ( diff --git a/src/components/Search/hooks/useSearchSnapshot.ts b/src/components/Search/hooks/useSearchSnapshot.ts index a6a8e82fa8ea..87db5d0a4b9d 100644 --- a/src/components/Search/hooks/useSearchSnapshot.ts +++ b/src/components/Search/hooks/useSearchSnapshot.ts @@ -377,6 +377,7 @@ function useSearchSnapshot({queryJSON, searchResults, newSearchResultKeys, trans groupBy: validGroupBy, shouldUseStrictDefaultExpenseColumns: currentSearchKey === CONST.SEARCH.SEARCH_KEYS.EXPENSES && isDefaultExpensesQuery(queryJSON), fallbackPolicyID: policyForMovingExpensesID, + sortBy: queryJSON.sortBy, }); })(); diff --git a/src/components/Search/types.ts b/src/components/Search/types.ts index a4b38f5c81be..6e10ba06b828 100644 --- a/src/components/Search/types.ts +++ b/src/components/Search/types.ts @@ -321,7 +321,12 @@ type SearchDateFilterKeys = type SearchDateKey = `${SearchDateFilterKeys}${ValueOf}` | ReportFieldDateKey; -type SearchAmountFilterKeys = typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT | typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL | typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT; +type SearchAmountFilterKeys = + | typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT + | typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL + | typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT + | typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED + | typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED; type SearchAmountValues = Record, string | undefined>; type SearchFilterKey = diff --git a/src/hooks/useAdvancedSearchFilters.ts b/src/hooks/useAdvancedSearchFilters.ts index 2577b21ae7aa..d25ea6615de5 100644 --- a/src/hooks/useAdvancedSearchFilters.ts +++ b/src/hooks/useAdvancedSearchFilters.ts @@ -86,6 +86,8 @@ const typeFiltersKeys = { [ CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE, CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL, + CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED, + CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED, CONST.SEARCH.SYNTAX_FILTER_KEYS.CURRENCY, CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID_STATUS, diff --git a/src/hooks/useSearchOverlay.tsx b/src/hooks/useSearchOverlay.tsx index 431b120011c8..e4d1a1cd387c 100644 --- a/src/hooks/useSearchOverlay.tsx +++ b/src/hooks/useSearchOverlay.tsx @@ -122,6 +122,7 @@ function useSearchOverlay({ groupBy: validGroupBy, shouldUseStrictDefaultExpenseColumns, fallbackPolicyID: policyForMovingExpensesID, + sortBy: queryJSON.sortBy, }); })(); diff --git a/src/languages/de.ts b/src/languages/de.ts index 90c12f77afa9..e7d6a105c8bb 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -405,6 +405,8 @@ const translations: TranslationDeepObject = { longReportID: 'Langer Bericht-ID', withdrawalID: 'Auszahlungs-ID', internationalReimbursementIDs: 'Internationale Erstattungs-IDs', + amountDebited: 'Belasteter Betrag', + amountReimbursed: 'Erstatteter Betrag', withdrawalStatus: 'Auszahlungsstatus', paidStatus: 'Status: Bezahlt', bankAccounts: 'Bankkonten', diff --git a/src/languages/el.ts b/src/languages/el.ts index bf92231ac01f..f610d0f60205 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -411,6 +411,8 @@ const translations: TranslationDeepObject = { longReportID: 'Μακρύ αναγνωριστικό αναφοράς', withdrawalID: 'Αναγνωριστικό ανάληψης', internationalReimbursementIDs: 'Διεθνή αναγνωριστικά αποζημιώσεων', + amountDebited: 'Ποσό χρέωσης', + amountReimbursed: 'Ποσό που αποζημιώθηκε', withdrawalStatus: 'Κατάσταση ανάληψης', paidStatus: 'Κατάσταση πληρωμής', bankAccounts: 'Τραπεζικοί λογαριασμοί', diff --git a/src/languages/en.ts b/src/languages/en.ts index 76b65c1ce7fc..3a0cd56def71 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -434,6 +434,8 @@ const translations = { longReportID: 'Long Report ID', withdrawalID: 'Withdrawal ID', internationalReimbursementIDs: 'International reimbursement IDs', + amountDebited: 'Amount debited', + amountReimbursed: 'Amount reimbursed', withdrawalStatus: 'Withdrawal status', paidStatus: 'Paid status', bankAccounts: 'Bank accounts', diff --git a/src/languages/es.ts b/src/languages/es.ts index efedd83a41f4..f85026c83fdc 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -464,6 +464,8 @@ const translations: TranslationDeepObject = { reimbursableTotal: 'Total reembolsable', nonReimbursableTotal: 'Total no reembolsable', internationalReimbursementIDs: 'IDs de reembolso internacional', + amountDebited: 'Importe debitado', + amountReimbursed: 'Importe reembolsado', opensInNewTab: 'Se abre en una nueva pestaña', locked: 'Bloqueado', month: 'Monat', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 6ff241adbee0..d5fb57201631 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -404,6 +404,8 @@ const translations: TranslationDeepObject = { longReportID: 'ID de note de frais longue', withdrawalID: 'ID de retrait', internationalReimbursementIDs: 'ID de remboursement international', + amountDebited: 'Montant débité', + amountReimbursed: 'Montant remboursé', withdrawalStatus: 'Statut de retrait', paidStatus: 'Statut payé', bankAccounts: 'Comptes bancaires', diff --git a/src/languages/it.ts b/src/languages/it.ts index 1c34234fac77..bc11b9e9092e 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -405,6 +405,8 @@ const translations: TranslationDeepObject = { longReportID: 'ID report dettagliato', withdrawalID: 'ID prelievo', internationalReimbursementIDs: 'ID di rimborso internazionale', + amountDebited: 'Importo addebitato', + amountReimbursed: 'Importo rimborsato', withdrawalStatus: 'Stato del prelievo', paidStatus: 'Stato di pagamento', bankAccounts: 'Conti bancari', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index ad527c2c3524..de0a702f0322 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -404,6 +404,8 @@ const translations: TranslationDeepObject = { longReportID: '長いレポートID', withdrawalID: '出金ID', internationalReimbursementIDs: '国際払い戻しID', + amountDebited: '引き落とし額', + amountReimbursed: '精算済み金額', withdrawalStatus: '出金ステータス', paidStatus: '支払済みステータス', bankAccounts: '銀行口座', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index c6f495885175..2891c3d1dd9f 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -404,6 +404,8 @@ const translations: TranslationDeepObject = { longReportID: 'Lang rapport-ID', withdrawalID: 'Opname-ID', internationalReimbursementIDs: 'Internationale terugbetalings-ID’s', + amountDebited: 'Afgeschreven bedrag', + amountReimbursed: 'Terugbetaald bedrag', withdrawalStatus: 'Opnamestatus', paidStatus: 'Betaald-status', bankAccounts: 'Bankrekeningen', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 4a171f78e0aa..e38d465843c6 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -404,6 +404,8 @@ const translations: TranslationDeepObject = { longReportID: 'Długi identyfikator raportu', withdrawalID: 'Identyfikator wypłaty', internationalReimbursementIDs: 'Identyfikatory zwrotów międzynarodowych', + amountDebited: 'Kwota obciążenia', + amountReimbursed: 'Kwota zwrócona', withdrawalStatus: 'Status wypłaty', paidStatus: 'Status: opłacono', bankAccounts: 'Konta bankowe', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index dea97fc1921e..64788f53a5d3 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -404,6 +404,8 @@ const translations: TranslationDeepObject = { longReportID: 'ID de relatório longo', withdrawalID: 'ID do saque', internationalReimbursementIDs: 'IDs de reembolso internacional', + amountDebited: 'Valor debitado', + amountReimbursed: 'Valor reembolsado', withdrawalStatus: 'Status do saque', paidStatus: 'Status pago', bankAccounts: 'Contas bancárias', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 7ce8b8c0ef09..21824aee2580 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -404,6 +404,8 @@ const translations: TranslationDeepObject = { longReportID: '长报表 ID', withdrawalID: '提现编号', internationalReimbursementIDs: '国际报销 ID', + amountDebited: '扣款金额', + amountReimbursed: '已报销金额', withdrawalStatus: '提现状态', paidStatus: '已付款状态', bankAccounts: '银行账户', diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 5d715ffccfec..6adc0db8e09f 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -461,6 +461,8 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa case 'submitterUserID': case 'submitterPayrollID': case 'orderDealNumbers': + case 'debitedCurrency': + case 'creditedCurrency': return validateString(value); case 'hasOutstandingChildRequest': case 'hasOutstandingChildTask': @@ -487,6 +489,8 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa case 'reimbursableTotal': case 'unheldReimbursableTotal': case 'transactionCount': + case 'debitedAmount': + case 'creditedAmount': return validateNumber(value); case 'chatType': return validateConstantEnum(value, CONST.REPORT.CHAT_TYPE); @@ -602,6 +606,10 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa submitterUserID: CONST.RED_BRICK_ROAD_PENDING_ACTION, submitterPayrollID: CONST.RED_BRICK_ROAD_PENDING_ACTION, orderDealNumbers: CONST.RED_BRICK_ROAD_PENDING_ACTION, + debitedAmount: CONST.RED_BRICK_ROAD_PENDING_ACTION, + debitedCurrency: CONST.RED_BRICK_ROAD_PENDING_ACTION, + creditedAmount: CONST.RED_BRICK_ROAD_PENDING_ACTION, + creditedCurrency: CONST.RED_BRICK_ROAD_PENDING_ACTION, avatarUrl: CONST.RED_BRICK_ROAD_PENDING_ACTION, chatType: CONST.RED_BRICK_ROAD_PENDING_ACTION, hasOutstandingChildRequest: CONST.RED_BRICK_ROAD_PENDING_ACTION, diff --git a/src/libs/SearchAutocompleteUtils.ts b/src/libs/SearchAutocompleteUtils.ts index 8ff1f0652540..dde15bc131df 100644 --- a/src/libs/SearchAutocompleteUtils.ts +++ b/src/libs/SearchAutocompleteUtils.ts @@ -252,6 +252,8 @@ function filterOutRangesWithCorrectValue( case CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL: case CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT: case CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT: + case CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED: + case CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED: // This uses the same regex as the AmountWithoutCurrencyInput component (allowing for 3 digit decimals as some currencies support that) return new RegExp(`^-?(?!.*[.,].*[.,])\\d{0,${CONST.IOU.AMOUNT_MAX_LENGTH}}(?:[.,]\\d{0,2})?$`).test(range.value); case CONST.SEARCH.SYNTAX_ROOT_KEYS.COLUMNS: diff --git a/src/libs/SearchParser/autocompleteParser.js b/src/libs/SearchParser/autocompleteParser.js index 3784d0666ce2..d68f3c39a7a6 100644 --- a/src/libs/SearchParser/autocompleteParser.js +++ b/src/libs/SearchParser/autocompleteParser.js @@ -261,42 +261,48 @@ function peg$parse(input, options) { var peg$c75 = "purchase-amount"; var peg$c76 = "purchasecurrency"; var peg$c77 = "purchase-currency"; - var peg$c78 = "columns"; - var peg$c79 = "view"; - var peg$c80 = "per-diem"; - var peg$c81 = "drafts"; - var peg$c82 = "draft"; - var peg$c83 = "tax"; - var peg$c84 = "policy-name"; - var peg$c85 = "long-report-id"; - var peg$c86 = "exported-to"; - var peg$c87 = "exportedto"; - var peg$c88 = "exchange-rate"; - var peg$c89 = "reimbursable-total"; - var peg$c90 = "non-reimbursable-total"; - var peg$c91 = "group-from"; - var peg$c92 = "group-expenses"; - var peg$c93 = "group-total"; - var peg$c94 = "group-card"; - var peg$c95 = "group-feed"; - var peg$c96 = "group-bank-account"; - var peg$c97 = "group-withdrawn"; - var peg$c98 = "group-withdrawal-id"; - var peg$c99 = "group-category"; - var peg$c100 = "group-tag"; - var peg$c101 = "group-merchant"; - var peg$c102 = "group-month"; - var peg$c103 = "group-week"; - var peg$c104 = "group-year"; - var peg$c105 = "group-quarter"; - var peg$c106 = "!="; - var peg$c107 = ">="; - var peg$c108 = ">"; - var peg$c109 = "<="; - var peg$c110 = "<"; - var peg$c111 = "\u201C"; - var peg$c112 = "\u201D"; - var peg$c113 = "\""; + var peg$c78 = "amountdebited"; + var peg$c79 = "amount-debited"; + var peg$c80 = "amountreimbursed"; + var peg$c81 = "amount-reimbursed"; + var peg$c82 = "columns"; + var peg$c83 = "view"; + var peg$c84 = "per-diem"; + var peg$c85 = "drafts"; + var peg$c86 = "draft"; + var peg$c87 = "tax"; + var peg$c88 = "policy-name"; + var peg$c89 = "long-report-id"; + var peg$c90 = "exported-to"; + var peg$c91 = "exportedto"; + var peg$c92 = "exchange-rate"; + var peg$c93 = "reimbursable-total"; + var peg$c94 = "non-reimbursable-total"; + var peg$c95 = "group-from"; + var peg$c96 = "group-expenses"; + var peg$c97 = "group-total"; + var peg$c98 = "group-card"; + var peg$c99 = "group-feed"; + var peg$c100 = "group-bank-account"; + var peg$c101 = "group-withdrawn"; + var peg$c102 = "group-withdrawal-id"; + var peg$c103 = "group-amount-debited"; + var peg$c104 = "group-amount-reimbursed"; + var peg$c105 = "group-category"; + var peg$c106 = "group-tag"; + var peg$c107 = "group-merchant"; + var peg$c108 = "group-month"; + var peg$c109 = "group-week"; + var peg$c110 = "group-year"; + var peg$c111 = "group-quarter"; + var peg$c112 = "!="; + var peg$c113 = ">="; + var peg$c114 = ">"; + var peg$c115 = "<="; + var peg$c116 = "<"; + var peg$c117 = "\u201C"; + var peg$c118 = "\u201D"; + var peg$c119 = "\""; var peg$r0 = /^[ \t\r\n\xA0,:=<>!]/; var peg$r1 = /^[:=]/; @@ -393,58 +399,64 @@ function peg$parse(input, options) { var peg$e78 = peg$literalExpectation("purchase-amount", true); var peg$e79 = peg$literalExpectation("purchaseCurrency", true); var peg$e80 = peg$literalExpectation("purchase-currency", true); - var peg$e81 = peg$literalExpectation("columns", true); - var peg$e82 = peg$literalExpectation("view", true); - var peg$e83 = peg$literalExpectation("per-diem", true); - var peg$e84 = peg$literalExpectation("drafts", true); - var peg$e85 = peg$literalExpectation("draft", true); - var peg$e86 = peg$literalExpectation("tax", true); - var peg$e87 = peg$literalExpectation("policy-name", true); - var peg$e88 = peg$literalExpectation("long-report-id", true); - var peg$e89 = peg$literalExpectation("exported-to", true); - var peg$e90 = peg$classExpectation([":", "="], false, false); - var peg$e91 = peg$literalExpectation("exportedTo", true); - var peg$e92 = peg$literalExpectation("exchange-rate", true); - var peg$e93 = peg$literalExpectation("reimbursable-total", true); - var peg$e94 = peg$literalExpectation("non-reimbursable-total", true); - var peg$e95 = peg$literalExpectation("group-from", true); - var peg$e96 = peg$literalExpectation("group-expenses", true); - var peg$e97 = peg$literalExpectation("group-total", true); - var peg$e98 = peg$literalExpectation("group-card", true); - var peg$e99 = peg$literalExpectation("group-feed", true); - var peg$e100 = peg$literalExpectation("group-bank-account", true); - var peg$e101 = peg$literalExpectation("group-withdrawn", true); - var peg$e102 = peg$literalExpectation("group-withdrawal-id", true); - var peg$e103 = peg$literalExpectation("group-category", true); - var peg$e104 = peg$literalExpectation("group-tag", true); - var peg$e105 = peg$literalExpectation("group-merchant", true); - var peg$e106 = peg$literalExpectation("group-month", true); - var peg$e107 = peg$literalExpectation("group-week", true); - var peg$e108 = peg$literalExpectation("group-year", true); - var peg$e109 = peg$literalExpectation("group-quarter", true); - var peg$e110 = peg$otherExpectation("operator"); - var peg$e111 = peg$literalExpectation("!=", false); - var peg$e112 = peg$literalExpectation(">=", false); - var peg$e113 = peg$literalExpectation(">", false); - var peg$e114 = peg$literalExpectation("<=", false); - var peg$e115 = peg$literalExpectation("<", false); - var peg$e116 = peg$otherExpectation("word"); - var peg$e117 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e118 = peg$otherExpectation("whitespace"); - var peg$e119 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e120 = peg$otherExpectation("quote"); - var peg$e121 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e122 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e123 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e124 = peg$literalExpectation("\u201C", false); - var peg$e125 = peg$literalExpectation("\u201D", false); - var peg$e126 = peg$literalExpectation("\"", false); - var peg$e127 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e128 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e129 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e130 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e131 = peg$classExpectation([","], false, false); - var peg$e132 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e81 = peg$literalExpectation("amountDebited", true); + var peg$e82 = peg$literalExpectation("amount-debited", true); + var peg$e83 = peg$literalExpectation("amountReimbursed", true); + var peg$e84 = peg$literalExpectation("amount-reimbursed", true); + var peg$e85 = peg$literalExpectation("columns", true); + var peg$e86 = peg$literalExpectation("view", true); + var peg$e87 = peg$literalExpectation("per-diem", true); + var peg$e88 = peg$literalExpectation("drafts", true); + var peg$e89 = peg$literalExpectation("draft", true); + var peg$e90 = peg$literalExpectation("tax", true); + var peg$e91 = peg$literalExpectation("policy-name", true); + var peg$e92 = peg$literalExpectation("long-report-id", true); + var peg$e93 = peg$literalExpectation("exported-to", true); + var peg$e94 = peg$classExpectation([":", "="], false, false); + var peg$e95 = peg$literalExpectation("exportedTo", true); + var peg$e96 = peg$literalExpectation("exchange-rate", true); + var peg$e97 = peg$literalExpectation("reimbursable-total", true); + var peg$e98 = peg$literalExpectation("non-reimbursable-total", true); + var peg$e99 = peg$literalExpectation("group-from", true); + var peg$e100 = peg$literalExpectation("group-expenses", true); + var peg$e101 = peg$literalExpectation("group-total", true); + var peg$e102 = peg$literalExpectation("group-card", true); + var peg$e103 = peg$literalExpectation("group-feed", true); + var peg$e104 = peg$literalExpectation("group-bank-account", true); + var peg$e105 = peg$literalExpectation("group-withdrawn", true); + var peg$e106 = peg$literalExpectation("group-withdrawal-id", true); + var peg$e107 = peg$literalExpectation("group-amount-debited", true); + var peg$e108 = peg$literalExpectation("group-amount-reimbursed", true); + var peg$e109 = peg$literalExpectation("group-category", true); + var peg$e110 = peg$literalExpectation("group-tag", true); + var peg$e111 = peg$literalExpectation("group-merchant", true); + var peg$e112 = peg$literalExpectation("group-month", true); + var peg$e113 = peg$literalExpectation("group-week", true); + var peg$e114 = peg$literalExpectation("group-year", true); + var peg$e115 = peg$literalExpectation("group-quarter", true); + var peg$e116 = peg$otherExpectation("operator"); + var peg$e117 = peg$literalExpectation("!=", false); + var peg$e118 = peg$literalExpectation(">=", false); + var peg$e119 = peg$literalExpectation(">", false); + var peg$e120 = peg$literalExpectation("<=", false); + var peg$e121 = peg$literalExpectation("<", false); + var peg$e122 = peg$otherExpectation("word"); + var peg$e123 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e124 = peg$otherExpectation("whitespace"); + var peg$e125 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e126 = peg$otherExpectation("quote"); + var peg$e127 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e128 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e129 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e130 = peg$literalExpectation("\u201C", false); + var peg$e131 = peg$literalExpectation("\u201D", false); + var peg$e132 = peg$literalExpectation("\"", false); + var peg$e133 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e134 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e135 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e136 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e137 = peg$classExpectation([","], false, false); + var peg$e138 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); var peg$f0 = function(ranges) { return { autocomplete, ranges }; }; var peg$f1 = function(filters) { return filters.filter(Boolean).flat(); }; @@ -561,69 +573,75 @@ function peg$parse(input, options) { var peg$f57 = function() {return "is"; }; var peg$f58 = function() {return "purchaseAmount"}; var peg$f59 = function() {return "purchaseCurrency"}; - var peg$f60 = function() { + var peg$f60 = function() {return "amountDebited"}; + var peg$f61 = function() {return "amountReimbursed"}; + var peg$f62 = function() { isColumnsContext = true; return "columns"; }; - var peg$f61 = function() {return "view"}; - var peg$f62 = function() { return isColumnsContext; }; - var peg$f63 = function() { return "perDiem"; }; - var peg$f64 = function() { return "drafts"; }; - var peg$f65 = function() { return "originalamount"; }; - var peg$f66 = function() { return "taxAmount"; }; - var peg$f67 = function() { return "taxrate"; }; - var peg$f68 = function() { return "policyname"; }; - var peg$f69 = function() { return "withdrawalID"; }; - var peg$f70 = function() { return "bankAccount"; }; - var peg$f71 = function() { return "reportID"; }; - var peg$f72 = function() { return "base62ReportID"; }; - var peg$f73 = function() { return "exportedto"; }; - var peg$f74 = function() { return "exportedTo"; }; - var peg$f75 = function() { return "exportedTo"; }; - var peg$f76 = function() { return "exchangeRate"; }; - var peg$f77 = function() { return "reimbursableTotal"; }; - var peg$f78 = function() { return "nonReimbursableTotal"; }; - var peg$f79 = function() { return "groupFrom"; }; - var peg$f80 = function() { return "groupExpenses"; }; - var peg$f81 = function() { return "groupTotal"; }; - var peg$f82 = function() { return "groupCard"; }; - var peg$f83 = function() { return "groupFeed"; }; - var peg$f84 = function() { return "groupBankAccount"; }; - var peg$f85 = function() { return "groupWithdrawn"; }; - var peg$f86 = function() { return "groupWithdrawalID"; }; - var peg$f87 = function() { return "groupCategory"; }; - var peg$f88 = function() { return "groupTag"; }; - var peg$f89 = function() { return "groupMerchant"; }; - var peg$f90 = function() { return "groupmonth"; }; - var peg$f91 = function() { return "groupweek"; }; - var peg$f92 = function() { return "groupyear"; }; - var peg$f93 = function() { return "groupquarter"; }; - var peg$f94 = function() { return "eq"; }; - var peg$f95 = function() { return "neq"; }; - var peg$f96 = function() { return "gte"; }; - var peg$f97 = function() { return "gt"; }; - var peg$f98 = function() { return "lte"; }; - var peg$f99 = function() { return "lt"; }; - var peg$f100 = function(o) { + var peg$f63 = function() {return "view"}; + var peg$f64 = function() { return isColumnsContext; }; + var peg$f65 = function() { return "perDiem"; }; + var peg$f66 = function() { return "drafts"; }; + var peg$f67 = function() { return "originalamount"; }; + var peg$f68 = function() { return "taxAmount"; }; + var peg$f69 = function() { return "taxrate"; }; + var peg$f70 = function() { return "policyname"; }; + var peg$f71 = function() { return "withdrawalID"; }; + var peg$f72 = function() { return "bankAccount"; }; + var peg$f73 = function() { return "reportID"; }; + var peg$f74 = function() { return "base62ReportID"; }; + var peg$f75 = function() { return "exportedto"; }; + var peg$f76 = function() { return "exportedTo"; }; + var peg$f77 = function() { return "exportedTo"; }; + var peg$f78 = function() { return "exchangeRate"; }; + var peg$f79 = function() { return "reimbursableTotal"; }; + var peg$f80 = function() { return "nonReimbursableTotal"; }; + var peg$f81 = function() { return "groupFrom"; }; + var peg$f82 = function() { return "groupExpenses"; }; + var peg$f83 = function() { return "groupTotal"; }; + var peg$f84 = function() { return "groupCard"; }; + var peg$f85 = function() { return "groupFeed"; }; + var peg$f86 = function() { return "groupBankAccount"; }; + var peg$f87 = function() { return "groupWithdrawn"; }; + var peg$f88 = function() { return "groupWithdrawalID"; }; + var peg$f89 = function() { return "groupAmountDebited"; }; + var peg$f90 = function() { return "groupAmountReimbursed"; }; + var peg$f91 = function() { return "amountDebited"; }; + var peg$f92 = function() { return "amountReimbursed"; }; + var peg$f93 = function() { return "groupCategory"; }; + var peg$f94 = function() { return "groupTag"; }; + var peg$f95 = function() { return "groupMerchant"; }; + var peg$f96 = function() { return "groupmonth"; }; + var peg$f97 = function() { return "groupweek"; }; + var peg$f98 = function() { return "groupyear"; }; + var peg$f99 = function() { return "groupquarter"; }; + var peg$f100 = function() { return "eq"; }; + var peg$f101 = function() { return "neq"; }; + var peg$f102 = function() { return "gte"; }; + var peg$f103 = function() { return "gt"; }; + var peg$f104 = function() { return "lte"; }; + var peg$f105 = function() { return "lt"; }; + var peg$f106 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } isColumnsContext = false; return o; }; - var peg$f101 = function(chars) { return chars.join("").trim(); }; - var peg$f102 = function() { + var peg$f107 = function(chars) { return chars.join("").trim(); }; + var peg$f108 = function() { isColumnsContext = false; return "and"; }; - var peg$f103 = function() { return expectingNestedQuote; }; - var peg$f104 = function(start, inner, end) { //handle no-breaking space + var peg$f109 = function() { return expectingNestedQuote; }; + var peg$f110 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f105 = function(start) {return "“"}; - var peg$f106 = function(start) {return "”"}; - var peg$f107 = function(start) {return "\""}; - var peg$f108 = function(start, inner, end) { + var peg$f111 = function(start) {return "“"}; + var peg$f112 = function(start) {return "”"}; + var peg$f113 = function(start) {return "\""}; + var peg$f114 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -1120,29 +1138,35 @@ function peg$parse(input, options) { if (s1 === peg$FAILED) { s1 = peg$parsepurchaseAmount(); if (s1 === peg$FAILED) { - s1 = peg$parseamount(); + s1 = peg$parseamountDebited(); if (s1 === peg$FAILED) { - s1 = peg$parsemerchant(); + s1 = peg$parseamountReimbursed(); if (s1 === peg$FAILED) { - s1 = peg$parsedescription(); + s1 = peg$parseamount(); if (s1 === peg$FAILED) { - s1 = peg$parsereportID(); + s1 = peg$parsemerchant(); if (s1 === peg$FAILED) { - s1 = peg$parsewithdrawalID(); + s1 = peg$parsedescription(); if (s1 === peg$FAILED) { - s1 = peg$parsetitle(); + s1 = peg$parsereportID(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitterUserID(); + s1 = peg$parsewithdrawalID(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitterPayrollID(); + s1 = peg$parsetitle(); if (s1 === peg$FAILED) { - s1 = peg$parseorderDealNumbers(); + s1 = peg$parsesubmitterUserID(); if (s1 === peg$FAILED) { - s1 = peg$parsereportFieldDynamic(); + s1 = peg$parsesubmitterPayrollID(); if (s1 === peg$FAILED) { - s1 = peg$parsecolumns(); + s1 = peg$parseorderDealNumbers(); if (s1 === peg$FAILED) { - s1 = peg$parselimit(); + s1 = peg$parsereportFieldDynamic(); + if (s1 === peg$FAILED) { + s1 = peg$parsecolumns(); + if (s1 === peg$FAILED) { + s1 = peg$parselimit(); + } + } } } } @@ -2536,20 +2560,78 @@ function peg$parse(input, options) { return s0; } + function peg$parseamountDebited() { + var s0, s1; + + s0 = input.substr(peg$currPos, 13); + if (s0.toLowerCase() === peg$c78) { + peg$currPos += 13; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e81); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 14); + if (s1.toLowerCase() === peg$c79) { + peg$currPos += 14; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e82); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f60(); + } + s0 = s1; + } + + return s0; + } + + function peg$parseamountReimbursed() { + var s0, s1; + + s0 = input.substr(peg$currPos, 16); + if (s0.toLowerCase() === peg$c80) { + peg$currPos += 16; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e83); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 17); + if (s1.toLowerCase() === peg$c81) { + peg$currPos += 17; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e84); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f61(); + } + s0 = s1; + } + + return s0; + } + function peg$parsecolumns() { var s0, s1; s0 = peg$currPos; s1 = input.substr(peg$currPos, 7); - if (s1.toLowerCase() === peg$c78) { + if (s1.toLowerCase() === peg$c82) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e81); } + if (peg$silentFails === 0) { peg$fail(peg$e85); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f60(); + s1 = peg$f62(); } s0 = s1; @@ -2561,15 +2643,15 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 4); - if (s1.toLowerCase() === peg$c79) { + if (s1.toLowerCase() === peg$c83) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e82); } + if (peg$silentFails === 0) { peg$fail(peg$e86); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f61(); + s1 = peg$f63(); } s0 = s1; @@ -2581,7 +2663,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f62(); + s1 = peg$f64(); if (s1) { s1 = undefined; } else { @@ -2653,19 +2735,31 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$parsegroupWithdrawalId(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupCategory(); + s0 = peg$parsegroupAmountDebited(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupTag(); + s0 = peg$parsegroupAmountReimbursed(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupMerchant(); + s0 = peg$parseamountDebitedColumn(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupMonth(); + s0 = peg$parseamountReimbursedColumn(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupWeek(); + s0 = peg$parsegroupCategory(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupYear(); + s0 = peg$parsegroupTag(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupQuarter(); + s0 = peg$parsegroupMerchant(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupMonth(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupWeek(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupYear(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupQuarter(); + } + } + } + } } } } @@ -2701,11 +2795,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 8); - if (s1.toLowerCase() === peg$c80) { + if (s1.toLowerCase() === peg$c84) { peg$currPos += 8; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e83); } + if (peg$silentFails === 0) { peg$fail(peg$e87); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2720,7 +2814,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f63(); + s0 = peg$f65(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2738,19 +2832,19 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 6); - if (s1.toLowerCase() === peg$c81) { + if (s1.toLowerCase() === peg$c85) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e84); } + if (peg$silentFails === 0) { peg$fail(peg$e88); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 5); - if (s1.toLowerCase() === peg$c82) { + if (s1.toLowerCase() === peg$c86) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e85); } + if (peg$silentFails === 0) { peg$fail(peg$e89); } } } if (s1 !== peg$FAILED) { @@ -2766,7 +2860,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f64(); + s0 = peg$f66(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2803,7 +2897,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f65(); + s0 = peg$f67(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2821,11 +2915,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 3); - if (s1.toLowerCase() === peg$c83) { + if (s1.toLowerCase() === peg$c87) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e86); } + if (peg$silentFails === 0) { peg$fail(peg$e90); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2840,7 +2934,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f66(); + s0 = peg$f68(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2877,7 +2971,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f67(); + s0 = peg$f69(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2895,11 +2989,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c84) { + if (s1.toLowerCase() === peg$c88) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e87); } + if (peg$silentFails === 0) { peg$fail(peg$e91); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2914,7 +3008,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f68(); + s0 = peg$f70(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2951,7 +3045,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f69(); + s0 = peg$f71(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2988,7 +3082,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f70(); + s0 = peg$f72(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3006,11 +3100,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c85) { + if (s1.toLowerCase() === peg$c89) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e88); } + if (peg$silentFails === 0) { peg$fail(peg$e92); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3025,7 +3119,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f71(); + s0 = peg$f73(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3062,7 +3156,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f72(); + s0 = peg$f74(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3080,11 +3174,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c86) { + if (s1.toLowerCase() === peg$c90) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e89); } + if (peg$silentFails === 0) { peg$fail(peg$e93); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3099,7 +3193,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f73(); + s0 = peg$f75(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3124,7 +3218,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e90); } + if (peg$silentFails === 0) { peg$fail(peg$e94); } } if (s2 !== peg$FAILED) { s1 = [s1, s2]; @@ -3143,11 +3237,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c87) { + if (s1.toLowerCase() === peg$c91) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e91); } + if (peg$silentFails === 0) { peg$fail(peg$e95); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3162,7 +3256,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f74(); + s0 = peg$f76(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3174,11 +3268,11 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c86) { + if (s1.toLowerCase() === peg$c90) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e89); } + if (peg$silentFails === 0) { peg$fail(peg$e93); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3193,7 +3287,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f75(); + s0 = peg$f77(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3212,11 +3306,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 13); - if (s1.toLowerCase() === peg$c88) { + if (s1.toLowerCase() === peg$c92) { peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e92); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3231,7 +3325,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f76(); + s0 = peg$f78(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3249,11 +3343,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c89) { + if (s1.toLowerCase() === peg$c93) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e93); } + if (peg$silentFails === 0) { peg$fail(peg$e97); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3268,7 +3362,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f77(); + s0 = peg$f79(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3286,11 +3380,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 22); - if (s1.toLowerCase() === peg$c90) { + if (s1.toLowerCase() === peg$c94) { peg$currPos += 22; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } + if (peg$silentFails === 0) { peg$fail(peg$e98); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3305,7 +3399,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f78(); + s0 = peg$f80(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3323,11 +3417,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c91) { + if (s1.toLowerCase() === peg$c95) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { peg$fail(peg$e99); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3342,7 +3436,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f79(); + s0 = peg$f81(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3360,11 +3454,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c92) { + if (s1.toLowerCase() === peg$c96) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3379,7 +3473,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f80(); + s0 = peg$f82(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3397,11 +3491,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c93) { + if (s1.toLowerCase() === peg$c97) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3416,7 +3510,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f81(); + s0 = peg$f83(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3434,11 +3528,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c94) { + if (s1.toLowerCase() === peg$c98) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3453,7 +3547,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f82(); + s0 = peg$f84(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3471,11 +3565,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c95) { + if (s1.toLowerCase() === peg$c99) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3490,7 +3584,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f83(); + s0 = peg$f85(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3508,11 +3602,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c96) { + if (s1.toLowerCase() === peg$c100) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3527,7 +3621,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f84(); + s0 = peg$f86(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3545,11 +3639,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 15); - if (s1.toLowerCase() === peg$c97) { + if (s1.toLowerCase() === peg$c101) { peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3564,7 +3658,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f85(); + s0 = peg$f87(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3582,11 +3676,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 19); - if (s1.toLowerCase() === peg$c98) { + if (s1.toLowerCase() === peg$c102) { peg$currPos += 19; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3601,7 +3695,155 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f86(); + s0 = peg$f88(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsegroupAmountDebited() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 20); + if (s1.toLowerCase() === peg$c103) { + peg$currPos += 20; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e107); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f89(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsegroupAmountReimbursed() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 23); + if (s1.toLowerCase() === peg$c104) { + peg$currPos += 23; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e108); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f90(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseamountDebitedColumn() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 14); + if (s1.toLowerCase() === peg$c79) { + peg$currPos += 14; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e82); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f91(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseamountReimbursedColumn() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 17); + if (s1.toLowerCase() === peg$c81) { + peg$currPos += 17; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e84); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f92(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3619,11 +3861,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c99) { + if (s1.toLowerCase() === peg$c105) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3638,7 +3880,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f87(); + s0 = peg$f93(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3656,11 +3898,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 9); - if (s1.toLowerCase() === peg$c100) { + if (s1.toLowerCase() === peg$c106) { peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3675,7 +3917,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f88(); + s0 = peg$f94(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3693,11 +3935,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c101) { + if (s1.toLowerCase() === peg$c107) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3712,7 +3954,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f89(); + s0 = peg$f95(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3730,11 +3972,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c102) { + if (s1.toLowerCase() === peg$c108) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3749,7 +3991,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f90(); + s0 = peg$f96(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3767,11 +4009,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c103) { + if (s1.toLowerCase() === peg$c109) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3786,7 +4028,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f91(); + s0 = peg$f97(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3804,11 +4046,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c104) { + if (s1.toLowerCase() === peg$c110) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3823,7 +4065,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f92(); + s0 = peg$f98(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3841,11 +4083,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 13); - if (s1.toLowerCase() === peg$c105) { + if (s1.toLowerCase() === peg$c111) { peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3860,7 +4102,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f93(); + s0 = peg$f99(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3883,81 +4125,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e90); } + if (peg$silentFails === 0) { peg$fail(peg$e94); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f94(); + s1 = peg$f100(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c106) { - s1 = peg$c106; + if (input.substr(peg$currPos, 2) === peg$c112) { + s1 = peg$c112; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e117); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f95(); + s1 = peg$f101(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c107) { - s1 = peg$c107; + if (input.substr(peg$currPos, 2) === peg$c113) { + s1 = peg$c113; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e118); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f96(); + s1 = peg$f102(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c108; + s1 = peg$c114; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e119); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f97(); + s1 = peg$f103(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c109) { - s1 = peg$c109; + if (input.substr(peg$currPos, 2) === peg$c115) { + s1 = peg$c115; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e120); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f98(); + s1 = peg$f104(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c110; + s1 = peg$c116; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e121); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f99(); + s1 = peg$f105(); } s0 = s1; } @@ -3968,7 +4210,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } return s0; @@ -3981,7 +4223,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f100(s1); + s1 = peg$f106(s1); } s0 = s1; @@ -3999,7 +4241,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } + if (peg$silentFails === 0) { peg$fail(peg$e123); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -4009,7 +4251,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } + if (peg$silentFails === 0) { peg$fail(peg$e123); } } } } else { @@ -4017,13 +4259,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f101(s1); + s1 = peg$f107(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } + if (peg$silentFails === 0) { peg$fail(peg$e122); } } return s0; @@ -4035,7 +4277,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f102(); + s1 = peg$f108(); s0 = s1; return s0; @@ -4051,7 +4293,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e119); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -4060,12 +4302,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e119); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e118); } + if (peg$silentFails === 0) { peg$fail(peg$e124); } return s0; } @@ -4075,7 +4317,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f103(); + s1 = peg$f109(); if (s1) { s1 = undefined; } else { @@ -4112,7 +4354,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { peg$fail(peg$e127); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4121,7 +4363,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { peg$fail(peg$e127); } } } s2 = input.charAt(peg$currPos); @@ -4129,7 +4371,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e122); } + if (peg$silentFails === 0) { peg$fail(peg$e128); } } if (s2 !== peg$FAILED) { s3 = []; @@ -4138,7 +4380,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4147,7 +4389,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } } s4 = input.charAt(peg$currPos); @@ -4155,7 +4397,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e122); } + if (peg$silentFails === 0) { peg$fail(peg$e128); } } if (s4 !== peg$FAILED) { s5 = []; @@ -4164,7 +4406,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } + if (peg$silentFails === 0) { peg$fail(peg$e123); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -4173,11 +4415,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } + if (peg$silentFails === 0) { peg$fail(peg$e123); } } } peg$savedPos = s0; - s0 = peg$f104(s1, s3, s5); + s0 = peg$f110(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4189,7 +4431,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e120); } + if (peg$silentFails === 0) { peg$fail(peg$e126); } } return s0; @@ -4206,7 +4448,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { peg$fail(peg$e127); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4215,7 +4457,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { peg$fail(peg$e127); } } } s2 = input.charAt(peg$currPos); @@ -4223,7 +4465,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e122); } + if (peg$silentFails === 0) { peg$fail(peg$e128); } } if (s2 !== peg$FAILED) { s3 = []; @@ -4232,7 +4474,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -4248,15 +4490,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c111; + s6 = peg$c117; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } + if (peg$silentFails === 0) { peg$fail(peg$e130); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f105(s1); + s4 = peg$f111(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4279,15 +4521,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c112; + s6 = peg$c118; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { peg$fail(peg$e131); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f106(s1); + s4 = peg$f112(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4310,15 +4552,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c113; + s6 = peg$c119; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e126); } + if (peg$silentFails === 0) { peg$fail(peg$e132); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f107(s1); + s4 = peg$f113(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4337,7 +4579,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -4353,15 +4595,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c111; + s6 = peg$c117; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } + if (peg$silentFails === 0) { peg$fail(peg$e130); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f105(s1); + s4 = peg$f111(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4384,15 +4626,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c112; + s6 = peg$c118; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { peg$fail(peg$e131); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f106(s1); + s4 = peg$f112(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4415,15 +4657,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c113; + s6 = peg$c119; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e126); } + if (peg$silentFails === 0) { peg$fail(peg$e132); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f107(s1); + s4 = peg$f113(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4439,7 +4681,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f108(s1, s3, s4); + s0 = peg$f114(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4451,7 +4693,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e120); } + if (peg$silentFails === 0) { peg$fail(peg$e126); } } return s0; @@ -4466,7 +4708,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e122); } + if (peg$silentFails === 0) { peg$fail(peg$e128); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4504,7 +4746,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e127); } + if (peg$silentFails === 0) { peg$fail(peg$e133); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4513,7 +4755,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e127); } + if (peg$silentFails === 0) { peg$fail(peg$e133); } } } s2 = []; @@ -4522,7 +4764,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e128); } + if (peg$silentFails === 0) { peg$fail(peg$e134); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -4531,7 +4773,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e128); } + if (peg$silentFails === 0) { peg$fail(peg$e134); } } } s3 = []; @@ -4540,7 +4782,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e129); } + if (peg$silentFails === 0) { peg$fail(peg$e135); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4549,7 +4791,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e129); } + if (peg$silentFails === 0) { peg$fail(peg$e135); } } } s4 = peg$parseoperator(); @@ -4568,7 +4810,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e130); } + if (peg$silentFails === 0) { peg$fail(peg$e136); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4577,7 +4819,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e130); } + if (peg$silentFails === 0) { peg$fail(peg$e136); } } } s2 = peg$currPos; @@ -4624,7 +4866,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e131); } + if (peg$silentFails === 0) { peg$fail(peg$e137); } } } } @@ -4640,7 +4882,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e132); } + if (peg$silentFails === 0) { peg$fail(peg$e138); } } if (s0 === peg$FAILED) { s0 = peg$currPos; diff --git a/src/libs/SearchParser/autocompleteParser.peggy b/src/libs/SearchParser/autocompleteParser.peggy index 885f0cf30bfa..1218bb74a26f 100644 --- a/src/libs/SearchParser/autocompleteParser.peggy +++ b/src/libs/SearchParser/autocompleteParser.peggy @@ -117,6 +117,9 @@ autocompleteKey "key" / is / purchaseCurrency / purchaseAmount + // Both must precede `amount`, which would otherwise match their prefix. + / amountDebited + / amountReimbursed / amount / merchant / description diff --git a/src/libs/SearchParser/baseRules.peggy b/src/libs/SearchParser/baseRules.peggy index 60e1c33290fa..d4b8746f4014 100644 --- a/src/libs/SearchParser/baseRules.peggy +++ b/src/libs/SearchParser/baseRules.peggy @@ -95,6 +95,8 @@ has = "has"i {return "has"; } is = "is"i {return "is"; } purchaseAmount = "purchaseAmount"i / "purchase-amount"i {return "purchaseAmount"} purchaseCurrency = "purchaseCurrency"i / "purchase-currency"i {return "purchaseCurrency"} +amountDebited = "amountDebited"i / "amount-debited"i {return "amountDebited"} +amountReimbursed = "amountReimbursed"i / "amount-reimbursed"i {return "amountReimbursed"} columns = "columns"i { isColumnsContext = true; return "columns"; @@ -128,6 +130,10 @@ columnsValues / groupBankAccount / groupWithdrawn / groupWithdrawalId + / groupAmountDebited + / groupAmountReimbursed + / amountDebitedColumn + / amountReimbursedColumn / groupCategory / groupTag / groupMerchant @@ -162,6 +168,10 @@ groupFeed = "group-feed"i &wordBoundary { return "gr groupBankAccount = "group-bank-account"i &wordBoundary { return "groupBankAccount"; } groupWithdrawn = "group-withdrawn"i &wordBoundary { return "groupWithdrawn"; } groupWithdrawalId = "group-withdrawal-id"i &wordBoundary { return "groupWithdrawalID"; } +groupAmountDebited = "group-amount-debited"i &wordBoundary { return "groupAmountDebited"; } +groupAmountReimbursed = "group-amount-reimbursed"i &wordBoundary { return "groupAmountReimbursed"; } +amountDebitedColumn = "amount-debited"i &wordBoundary { return "amountDebited"; } +amountReimbursedColumn = "amount-reimbursed"i &wordBoundary { return "amountReimbursed"; } groupCategory = "group-category"i &wordBoundary { return "groupCategory"; } groupTag = "group-tag"i &wordBoundary { return "groupTag"; } groupMerchant = "group-merchant"i &wordBoundary { return "groupMerchant"; } diff --git a/src/libs/SearchParser/searchParser.js b/src/libs/SearchParser/searchParser.js index 5fd114076e1c..be719c9c663b 100644 --- a/src/libs/SearchParser/searchParser.js +++ b/src/libs/SearchParser/searchParser.js @@ -262,42 +262,48 @@ function peg$parse(input, options) { var peg$c75 = "purchase-amount"; var peg$c76 = "purchasecurrency"; var peg$c77 = "purchase-currency"; - var peg$c78 = "columns"; - var peg$c79 = "view"; - var peg$c80 = "per-diem"; - var peg$c81 = "drafts"; - var peg$c82 = "draft"; - var peg$c83 = "tax"; - var peg$c84 = "policy-name"; - var peg$c85 = "long-report-id"; - var peg$c86 = "exported-to"; - var peg$c87 = "exportedto"; - var peg$c88 = "exchange-rate"; - var peg$c89 = "reimbursable-total"; - var peg$c90 = "non-reimbursable-total"; - var peg$c91 = "group-from"; - var peg$c92 = "group-expenses"; - var peg$c93 = "group-total"; - var peg$c94 = "group-card"; - var peg$c95 = "group-feed"; - var peg$c96 = "group-bank-account"; - var peg$c97 = "group-withdrawn"; - var peg$c98 = "group-withdrawal-id"; - var peg$c99 = "group-category"; - var peg$c100 = "group-tag"; - var peg$c101 = "group-merchant"; - var peg$c102 = "group-month"; - var peg$c103 = "group-week"; - var peg$c104 = "group-year"; - var peg$c105 = "group-quarter"; - var peg$c106 = "!="; - var peg$c107 = ">="; - var peg$c108 = ">"; - var peg$c109 = "<="; - var peg$c110 = "<"; - var peg$c111 = "\u201C"; - var peg$c112 = "\u201D"; - var peg$c113 = "\""; + var peg$c78 = "amountdebited"; + var peg$c79 = "amount-debited"; + var peg$c80 = "amountreimbursed"; + var peg$c81 = "amount-reimbursed"; + var peg$c82 = "columns"; + var peg$c83 = "view"; + var peg$c84 = "per-diem"; + var peg$c85 = "drafts"; + var peg$c86 = "draft"; + var peg$c87 = "tax"; + var peg$c88 = "policy-name"; + var peg$c89 = "long-report-id"; + var peg$c90 = "exported-to"; + var peg$c91 = "exportedto"; + var peg$c92 = "exchange-rate"; + var peg$c93 = "reimbursable-total"; + var peg$c94 = "non-reimbursable-total"; + var peg$c95 = "group-from"; + var peg$c96 = "group-expenses"; + var peg$c97 = "group-total"; + var peg$c98 = "group-card"; + var peg$c99 = "group-feed"; + var peg$c100 = "group-bank-account"; + var peg$c101 = "group-withdrawn"; + var peg$c102 = "group-withdrawal-id"; + var peg$c103 = "group-amount-debited"; + var peg$c104 = "group-amount-reimbursed"; + var peg$c105 = "group-category"; + var peg$c106 = "group-tag"; + var peg$c107 = "group-merchant"; + var peg$c108 = "group-month"; + var peg$c109 = "group-week"; + var peg$c110 = "group-year"; + var peg$c111 = "group-quarter"; + var peg$c112 = "!="; + var peg$c113 = ">="; + var peg$c114 = ">"; + var peg$c115 = "<="; + var peg$c116 = "<"; + var peg$c117 = "\u201C"; + var peg$c118 = "\u201D"; + var peg$c119 = "\""; var peg$r0 = /^[^ \t\r\n\xA0]/; var peg$r1 = /^[ \t\r\n\xA0,:=<>!]/; @@ -397,58 +403,64 @@ function peg$parse(input, options) { var peg$e80 = peg$literalExpectation("purchase-amount", true); var peg$e81 = peg$literalExpectation("purchaseCurrency", true); var peg$e82 = peg$literalExpectation("purchase-currency", true); - var peg$e83 = peg$literalExpectation("columns", true); - var peg$e84 = peg$literalExpectation("view", true); - var peg$e85 = peg$literalExpectation("per-diem", true); - var peg$e86 = peg$literalExpectation("drafts", true); - var peg$e87 = peg$literalExpectation("draft", true); - var peg$e88 = peg$literalExpectation("tax", true); - var peg$e89 = peg$literalExpectation("policy-name", true); - var peg$e90 = peg$literalExpectation("long-report-id", true); - var peg$e91 = peg$literalExpectation("exported-to", true); - var peg$e92 = peg$classExpectation([":", "="], false, false); - var peg$e93 = peg$literalExpectation("exportedTo", true); - var peg$e94 = peg$literalExpectation("exchange-rate", true); - var peg$e95 = peg$literalExpectation("reimbursable-total", true); - var peg$e96 = peg$literalExpectation("non-reimbursable-total", true); - var peg$e97 = peg$literalExpectation("group-from", true); - var peg$e98 = peg$literalExpectation("group-expenses", true); - var peg$e99 = peg$literalExpectation("group-total", true); - var peg$e100 = peg$literalExpectation("group-card", true); - var peg$e101 = peg$literalExpectation("group-feed", true); - var peg$e102 = peg$literalExpectation("group-bank-account", true); - var peg$e103 = peg$literalExpectation("group-withdrawn", true); - var peg$e104 = peg$literalExpectation("group-withdrawal-id", true); - var peg$e105 = peg$literalExpectation("group-category", true); - var peg$e106 = peg$literalExpectation("group-tag", true); - var peg$e107 = peg$literalExpectation("group-merchant", true); - var peg$e108 = peg$literalExpectation("group-month", true); - var peg$e109 = peg$literalExpectation("group-week", true); - var peg$e110 = peg$literalExpectation("group-year", true); - var peg$e111 = peg$literalExpectation("group-quarter", true); - var peg$e112 = peg$otherExpectation("operator"); - var peg$e113 = peg$literalExpectation("!=", false); - var peg$e114 = peg$literalExpectation(">=", false); - var peg$e115 = peg$literalExpectation(">", false); - var peg$e116 = peg$literalExpectation("<=", false); - var peg$e117 = peg$literalExpectation("<", false); - var peg$e118 = peg$otherExpectation("word"); - var peg$e119 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e120 = peg$otherExpectation("whitespace"); - var peg$e121 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e122 = peg$otherExpectation("quote"); - var peg$e123 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e124 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e125 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e126 = peg$literalExpectation("\u201C", false); - var peg$e127 = peg$literalExpectation("\u201D", false); - var peg$e128 = peg$literalExpectation("\"", false); - var peg$e129 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e130 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e131 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e132 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e133 = peg$classExpectation([","], false, false); - var peg$e134 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e83 = peg$literalExpectation("amountDebited", true); + var peg$e84 = peg$literalExpectation("amount-debited", true); + var peg$e85 = peg$literalExpectation("amountReimbursed", true); + var peg$e86 = peg$literalExpectation("amount-reimbursed", true); + var peg$e87 = peg$literalExpectation("columns", true); + var peg$e88 = peg$literalExpectation("view", true); + var peg$e89 = peg$literalExpectation("per-diem", true); + var peg$e90 = peg$literalExpectation("drafts", true); + var peg$e91 = peg$literalExpectation("draft", true); + var peg$e92 = peg$literalExpectation("tax", true); + var peg$e93 = peg$literalExpectation("policy-name", true); + var peg$e94 = peg$literalExpectation("long-report-id", true); + var peg$e95 = peg$literalExpectation("exported-to", true); + var peg$e96 = peg$classExpectation([":", "="], false, false); + var peg$e97 = peg$literalExpectation("exportedTo", true); + var peg$e98 = peg$literalExpectation("exchange-rate", true); + var peg$e99 = peg$literalExpectation("reimbursable-total", true); + var peg$e100 = peg$literalExpectation("non-reimbursable-total", true); + var peg$e101 = peg$literalExpectation("group-from", true); + var peg$e102 = peg$literalExpectation("group-expenses", true); + var peg$e103 = peg$literalExpectation("group-total", true); + var peg$e104 = peg$literalExpectation("group-card", true); + var peg$e105 = peg$literalExpectation("group-feed", true); + var peg$e106 = peg$literalExpectation("group-bank-account", true); + var peg$e107 = peg$literalExpectation("group-withdrawn", true); + var peg$e108 = peg$literalExpectation("group-withdrawal-id", true); + var peg$e109 = peg$literalExpectation("group-amount-debited", true); + var peg$e110 = peg$literalExpectation("group-amount-reimbursed", true); + var peg$e111 = peg$literalExpectation("group-category", true); + var peg$e112 = peg$literalExpectation("group-tag", true); + var peg$e113 = peg$literalExpectation("group-merchant", true); + var peg$e114 = peg$literalExpectation("group-month", true); + var peg$e115 = peg$literalExpectation("group-week", true); + var peg$e116 = peg$literalExpectation("group-year", true); + var peg$e117 = peg$literalExpectation("group-quarter", true); + var peg$e118 = peg$otherExpectation("operator"); + var peg$e119 = peg$literalExpectation("!=", false); + var peg$e120 = peg$literalExpectation(">=", false); + var peg$e121 = peg$literalExpectation(">", false); + var peg$e122 = peg$literalExpectation("<=", false); + var peg$e123 = peg$literalExpectation("<", false); + var peg$e124 = peg$otherExpectation("word"); + var peg$e125 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e126 = peg$otherExpectation("whitespace"); + var peg$e127 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e128 = peg$otherExpectation("quote"); + var peg$e129 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e130 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e131 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e132 = peg$literalExpectation("\u201C", false); + var peg$e133 = peg$literalExpectation("\u201D", false); + var peg$e134 = peg$literalExpectation("\"", false); + var peg$e135 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e136 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e137 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e138 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e139 = peg$classExpectation([","], false, false); + var peg$e140 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); var peg$f0 = function(filters) { return applyDefaults(filters); }; var peg$f1 = function(head, tail) { @@ -588,69 +600,75 @@ function peg$parse(input, options) { var peg$f58 = function() {return "is"; }; var peg$f59 = function() {return "purchaseAmount"}; var peg$f60 = function() {return "purchaseCurrency"}; - var peg$f61 = function() { + var peg$f61 = function() {return "amountDebited"}; + var peg$f62 = function() {return "amountReimbursed"}; + var peg$f63 = function() { isColumnsContext = true; return "columns"; }; - var peg$f62 = function() {return "view"}; - var peg$f63 = function() { return isColumnsContext; }; - var peg$f64 = function() { return "perDiem"; }; - var peg$f65 = function() { return "drafts"; }; - var peg$f66 = function() { return "originalamount"; }; - var peg$f67 = function() { return "taxAmount"; }; - var peg$f68 = function() { return "taxrate"; }; - var peg$f69 = function() { return "policyname"; }; - var peg$f70 = function() { return "withdrawalID"; }; - var peg$f71 = function() { return "bankAccount"; }; - var peg$f72 = function() { return "reportID"; }; - var peg$f73 = function() { return "base62ReportID"; }; - var peg$f74 = function() { return "exportedto"; }; - var peg$f75 = function() { return "exportedTo"; }; - var peg$f76 = function() { return "exportedTo"; }; - var peg$f77 = function() { return "exchangeRate"; }; - var peg$f78 = function() { return "reimbursableTotal"; }; - var peg$f79 = function() { return "nonReimbursableTotal"; }; - var peg$f80 = function() { return "groupFrom"; }; - var peg$f81 = function() { return "groupExpenses"; }; - var peg$f82 = function() { return "groupTotal"; }; - var peg$f83 = function() { return "groupCard"; }; - var peg$f84 = function() { return "groupFeed"; }; - var peg$f85 = function() { return "groupBankAccount"; }; - var peg$f86 = function() { return "groupWithdrawn"; }; - var peg$f87 = function() { return "groupWithdrawalID"; }; - var peg$f88 = function() { return "groupCategory"; }; - var peg$f89 = function() { return "groupTag"; }; - var peg$f90 = function() { return "groupMerchant"; }; - var peg$f91 = function() { return "groupmonth"; }; - var peg$f92 = function() { return "groupweek"; }; - var peg$f93 = function() { return "groupyear"; }; - var peg$f94 = function() { return "groupquarter"; }; - var peg$f95 = function() { return "eq"; }; - var peg$f96 = function() { return "neq"; }; - var peg$f97 = function() { return "gte"; }; - var peg$f98 = function() { return "gt"; }; - var peg$f99 = function() { return "lte"; }; - var peg$f100 = function() { return "lt"; }; - var peg$f101 = function(o) { + var peg$f64 = function() {return "view"}; + var peg$f65 = function() { return isColumnsContext; }; + var peg$f66 = function() { return "perDiem"; }; + var peg$f67 = function() { return "drafts"; }; + var peg$f68 = function() { return "originalamount"; }; + var peg$f69 = function() { return "taxAmount"; }; + var peg$f70 = function() { return "taxrate"; }; + var peg$f71 = function() { return "policyname"; }; + var peg$f72 = function() { return "withdrawalID"; }; + var peg$f73 = function() { return "bankAccount"; }; + var peg$f74 = function() { return "reportID"; }; + var peg$f75 = function() { return "base62ReportID"; }; + var peg$f76 = function() { return "exportedto"; }; + var peg$f77 = function() { return "exportedTo"; }; + var peg$f78 = function() { return "exportedTo"; }; + var peg$f79 = function() { return "exchangeRate"; }; + var peg$f80 = function() { return "reimbursableTotal"; }; + var peg$f81 = function() { return "nonReimbursableTotal"; }; + var peg$f82 = function() { return "groupFrom"; }; + var peg$f83 = function() { return "groupExpenses"; }; + var peg$f84 = function() { return "groupTotal"; }; + var peg$f85 = function() { return "groupCard"; }; + var peg$f86 = function() { return "groupFeed"; }; + var peg$f87 = function() { return "groupBankAccount"; }; + var peg$f88 = function() { return "groupWithdrawn"; }; + var peg$f89 = function() { return "groupWithdrawalID"; }; + var peg$f90 = function() { return "groupAmountDebited"; }; + var peg$f91 = function() { return "groupAmountReimbursed"; }; + var peg$f92 = function() { return "amountDebited"; }; + var peg$f93 = function() { return "amountReimbursed"; }; + var peg$f94 = function() { return "groupCategory"; }; + var peg$f95 = function() { return "groupTag"; }; + var peg$f96 = function() { return "groupMerchant"; }; + var peg$f97 = function() { return "groupmonth"; }; + var peg$f98 = function() { return "groupweek"; }; + var peg$f99 = function() { return "groupyear"; }; + var peg$f100 = function() { return "groupquarter"; }; + var peg$f101 = function() { return "eq"; }; + var peg$f102 = function() { return "neq"; }; + var peg$f103 = function() { return "gte"; }; + var peg$f104 = function() { return "gt"; }; + var peg$f105 = function() { return "lte"; }; + var peg$f106 = function() { return "lt"; }; + var peg$f107 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } isColumnsContext = false; return o; }; - var peg$f102 = function(chars) { return chars.join("").trim(); }; - var peg$f103 = function() { + var peg$f108 = function(chars) { return chars.join("").trim(); }; + var peg$f109 = function() { isColumnsContext = false; return "and"; }; - var peg$f104 = function() { return expectingNestedQuote; }; - var peg$f105 = function(start, inner, end) { //handle no-breaking space + var peg$f110 = function() { return expectingNestedQuote; }; + var peg$f111 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f106 = function(start) {return "“"}; - var peg$f107 = function(start) {return "”"}; - var peg$f108 = function(start) {return "\""}; - var peg$f109 = function(start, inner, end) { + var peg$f112 = function(start) {return "“"}; + var peg$f113 = function(start) {return "”"}; + var peg$f114 = function(start) {return "\""}; + var peg$f115 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -1134,103 +1152,109 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parsedate(); if (s1 === peg$FAILED) { - s1 = peg$parseamount(); + s1 = peg$parseamountDebited(); if (s1 === peg$FAILED) { - s1 = peg$parsetotal(); + s1 = peg$parseamountReimbursed(); if (s1 === peg$FAILED) { - s1 = peg$parsemerchant(); + s1 = peg$parseamount(); if (s1 === peg$FAILED) { - s1 = peg$parsedescription(); + s1 = peg$parsetotal(); if (s1 === peg$FAILED) { - s1 = peg$parsereportID(); + s1 = peg$parsemerchant(); if (s1 === peg$FAILED) { - s1 = peg$parsekeyword(); + s1 = peg$parsedescription(); if (s1 === peg$FAILED) { - s1 = peg$parsein(); + s1 = peg$parsereportID(); if (s1 === peg$FAILED) { - s1 = peg$parsecurrency(); + s1 = peg$parsekeyword(); if (s1 === peg$FAILED) { - s1 = peg$parsegroupCurrency(); + s1 = peg$parsein(); if (s1 === peg$FAILED) { - s1 = peg$parsetag(); + s1 = peg$parsecurrency(); if (s1 === peg$FAILED) { - s1 = peg$parsecategory(); + s1 = peg$parsegroupCurrency(); if (s1 === peg$FAILED) { - s1 = peg$parseto(); + s1 = peg$parsetag(); if (s1 === peg$FAILED) { - s1 = peg$parsetaxRate(); + s1 = peg$parsecategory(); if (s1 === peg$FAILED) { - s1 = peg$parsecardID(); + s1 = peg$parseto(); if (s1 === peg$FAILED) { - s1 = peg$parsebankAccount(); + s1 = peg$parsetaxRate(); if (s1 === peg$FAILED) { - s1 = peg$parsefrom(); + s1 = peg$parsecardID(); if (s1 === peg$FAILED) { - s1 = peg$parseattendee(); + s1 = peg$parsebankAccount(); if (s1 === peg$FAILED) { - s1 = peg$parsepayer(); + s1 = peg$parsefrom(); if (s1 === peg$FAILED) { - s1 = peg$parseexporter(); + s1 = peg$parseattendee(); if (s1 === peg$FAILED) { - s1 = peg$parseexpenseType(); + s1 = peg$parsepayer(); if (s1 === peg$FAILED) { - s1 = peg$parsereceiptType(); + s1 = peg$parseexporter(); if (s1 === peg$FAILED) { - s1 = peg$parsewithdrawalType(); + s1 = peg$parseexpenseType(); if (s1 === peg$FAILED) { - s1 = peg$parsewithdrawalStatus(); + s1 = peg$parsereceiptType(); if (s1 === peg$FAILED) { - s1 = peg$parsepaidStatus(); + s1 = peg$parsewithdrawalType(); if (s1 === peg$FAILED) { - s1 = peg$parsewithdrawalID(); + s1 = peg$parsewithdrawalStatus(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitted(); + s1 = peg$parsepaidStatus(); if (s1 === peg$FAILED) { - s1 = peg$parseapproved(); + s1 = peg$parsewithdrawalID(); if (s1 === peg$FAILED) { - s1 = peg$parsepaid(); + s1 = peg$parsesubmitted(); if (s1 === peg$FAILED) { - s1 = peg$parseexportedTo(); + s1 = peg$parseapproved(); if (s1 === peg$FAILED) { - s1 = peg$parseexported(); + s1 = peg$parsepaid(); if (s1 === peg$FAILED) { - s1 = peg$parseposted(); + s1 = peg$parseexportedTo(); if (s1 === peg$FAILED) { - s1 = peg$parsewithdrawn(); + s1 = peg$parseexported(); if (s1 === peg$FAILED) { - s1 = peg$parsefeed(); + s1 = peg$parseposted(); if (s1 === peg$FAILED) { - s1 = peg$parsetitle(); + s1 = peg$parsewithdrawn(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitterUserID(); + s1 = peg$parsefeed(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitterPayrollID(); + s1 = peg$parsetitle(); if (s1 === peg$FAILED) { - s1 = peg$parseorderDealNumbers(); + s1 = peg$parsesubmitterUserID(); if (s1 === peg$FAILED) { - s1 = peg$parseassignee(); + s1 = peg$parsesubmitterPayrollID(); if (s1 === peg$FAILED) { - s1 = peg$parsecreatedBy(); + s1 = peg$parseorderDealNumbers(); if (s1 === peg$FAILED) { - s1 = peg$parsereimbursable(); + s1 = peg$parseassignee(); if (s1 === peg$FAILED) { - s1 = peg$parsebillable(); + s1 = peg$parsecreatedBy(); if (s1 === peg$FAILED) { - s1 = peg$parseaction(); + s1 = peg$parsereimbursable(); if (s1 === peg$FAILED) { - s1 = peg$parsehas(); + s1 = peg$parsebillable(); if (s1 === peg$FAILED) { - s1 = peg$parseis(); + s1 = peg$parseaction(); if (s1 === peg$FAILED) { - s1 = peg$parsepurchaseCurrency(); + s1 = peg$parsehas(); if (s1 === peg$FAILED) { - s1 = peg$parsepurchaseAmount(); + s1 = peg$parseis(); if (s1 === peg$FAILED) { - s1 = peg$parsepolicyID(); + s1 = peg$parsepurchaseCurrency(); if (s1 === peg$FAILED) { - s1 = peg$parsestatus(); + s1 = peg$parsepurchaseAmount(); if (s1 === peg$FAILED) { - s1 = peg$parsereportFieldDynamic(); + s1 = peg$parsepolicyID(); + if (s1 === peg$FAILED) { + s1 = peg$parsestatus(); + if (s1 === peg$FAILED) { + s1 = peg$parsereportFieldDynamic(); + } + } } } } @@ -2720,20 +2744,78 @@ function peg$parse(input, options) { return s0; } + function peg$parseamountDebited() { + var s0, s1; + + s0 = input.substr(peg$currPos, 13); + if (s0.toLowerCase() === peg$c78) { + peg$currPos += 13; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e83); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 14); + if (s1.toLowerCase() === peg$c79) { + peg$currPos += 14; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e84); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f61(); + } + s0 = s1; + } + + return s0; + } + + function peg$parseamountReimbursed() { + var s0, s1; + + s0 = input.substr(peg$currPos, 16); + if (s0.toLowerCase() === peg$c80) { + peg$currPos += 16; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e85); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 17); + if (s1.toLowerCase() === peg$c81) { + peg$currPos += 17; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e86); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f62(); + } + s0 = s1; + } + + return s0; + } + function peg$parsecolumns() { var s0, s1; s0 = peg$currPos; s1 = input.substr(peg$currPos, 7); - if (s1.toLowerCase() === peg$c78) { + if (s1.toLowerCase() === peg$c82) { peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e83); } + if (peg$silentFails === 0) { peg$fail(peg$e87); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f61(); + s1 = peg$f63(); } s0 = s1; @@ -2745,15 +2827,15 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 4); - if (s1.toLowerCase() === peg$c79) { + if (s1.toLowerCase() === peg$c83) { peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e84); } + if (peg$silentFails === 0) { peg$fail(peg$e88); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f62(); + s1 = peg$f64(); } s0 = s1; @@ -2765,7 +2847,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f63(); + s1 = peg$f65(); if (s1) { s1 = undefined; } else { @@ -2837,19 +2919,31 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$parsegroupWithdrawalId(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupCategory(); + s0 = peg$parsegroupAmountDebited(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupTag(); + s0 = peg$parsegroupAmountReimbursed(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupMerchant(); + s0 = peg$parseamountDebitedColumn(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupMonth(); + s0 = peg$parseamountReimbursedColumn(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupWeek(); + s0 = peg$parsegroupCategory(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupYear(); + s0 = peg$parsegroupTag(); if (s0 === peg$FAILED) { - s0 = peg$parsegroupQuarter(); + s0 = peg$parsegroupMerchant(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupMonth(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupWeek(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupYear(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupQuarter(); + } + } + } + } } } } @@ -2885,11 +2979,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 8); - if (s1.toLowerCase() === peg$c80) { + if (s1.toLowerCase() === peg$c84) { peg$currPos += 8; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e85); } + if (peg$silentFails === 0) { peg$fail(peg$e89); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2904,7 +2998,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f64(); + s0 = peg$f66(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2922,19 +3016,19 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 6); - if (s1.toLowerCase() === peg$c81) { + if (s1.toLowerCase() === peg$c85) { peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e86); } + if (peg$silentFails === 0) { peg$fail(peg$e90); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 5); - if (s1.toLowerCase() === peg$c82) { + if (s1.toLowerCase() === peg$c86) { peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e87); } + if (peg$silentFails === 0) { peg$fail(peg$e91); } } } if (s1 !== peg$FAILED) { @@ -2950,7 +3044,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f65(); + s0 = peg$f67(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2987,7 +3081,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f66(); + s0 = peg$f68(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3005,11 +3099,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 3); - if (s1.toLowerCase() === peg$c83) { + if (s1.toLowerCase() === peg$c87) { peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e88); } + if (peg$silentFails === 0) { peg$fail(peg$e92); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3024,7 +3118,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f67(); + s0 = peg$f69(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3061,7 +3155,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f68(); + s0 = peg$f70(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3079,11 +3173,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c84) { + if (s1.toLowerCase() === peg$c88) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e89); } + if (peg$silentFails === 0) { peg$fail(peg$e93); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3098,7 +3192,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f69(); + s0 = peg$f71(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3135,7 +3229,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f70(); + s0 = peg$f72(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3172,7 +3266,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f71(); + s0 = peg$f73(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3190,11 +3284,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c85) { + if (s1.toLowerCase() === peg$c89) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e90); } + if (peg$silentFails === 0) { peg$fail(peg$e94); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3209,7 +3303,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f72(); + s0 = peg$f74(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3246,7 +3340,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f73(); + s0 = peg$f75(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3264,11 +3358,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c86) { + if (s1.toLowerCase() === peg$c90) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e91); } + if (peg$silentFails === 0) { peg$fail(peg$e95); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3283,7 +3377,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f74(); + s0 = peg$f76(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3308,7 +3402,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e92); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } if (s2 !== peg$FAILED) { s1 = [s1, s2]; @@ -3327,11 +3421,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c87) { + if (s1.toLowerCase() === peg$c91) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e93); } + if (peg$silentFails === 0) { peg$fail(peg$e97); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3346,7 +3440,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f75(); + s0 = peg$f77(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3358,11 +3452,11 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c86) { + if (s1.toLowerCase() === peg$c90) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e91); } + if (peg$silentFails === 0) { peg$fail(peg$e95); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3377,7 +3471,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f76(); + s0 = peg$f78(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3396,11 +3490,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 13); - if (s1.toLowerCase() === peg$c88) { + if (s1.toLowerCase() === peg$c92) { peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } + if (peg$silentFails === 0) { peg$fail(peg$e98); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3415,7 +3509,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f77(); + s0 = peg$f79(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3433,11 +3527,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c89) { + if (s1.toLowerCase() === peg$c93) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { peg$fail(peg$e99); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3452,7 +3546,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f78(); + s0 = peg$f80(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3470,11 +3564,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 22); - if (s1.toLowerCase() === peg$c90) { + if (s1.toLowerCase() === peg$c94) { peg$currPos += 22; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3489,7 +3583,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f79(); + s0 = peg$f81(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3507,11 +3601,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c91) { + if (s1.toLowerCase() === peg$c95) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3526,7 +3620,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f80(); + s0 = peg$f82(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3544,11 +3638,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c92) { + if (s1.toLowerCase() === peg$c96) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3563,7 +3657,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f81(); + s0 = peg$f83(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3581,11 +3675,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c93) { + if (s1.toLowerCase() === peg$c97) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3600,7 +3694,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f82(); + s0 = peg$f84(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3618,11 +3712,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c94) { + if (s1.toLowerCase() === peg$c98) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3637,7 +3731,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f83(); + s0 = peg$f85(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3655,11 +3749,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c95) { + if (s1.toLowerCase() === peg$c99) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3674,7 +3768,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f84(); + s0 = peg$f86(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3692,11 +3786,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c96) { + if (s1.toLowerCase() === peg$c100) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3711,7 +3805,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f85(); + s0 = peg$f87(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3729,11 +3823,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 15); - if (s1.toLowerCase() === peg$c97) { + if (s1.toLowerCase() === peg$c101) { peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3748,7 +3842,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f86(); + s0 = peg$f88(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3766,11 +3860,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 19); - if (s1.toLowerCase() === peg$c98) { + if (s1.toLowerCase() === peg$c102) { peg$currPos += 19; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3785,7 +3879,155 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f87(); + s0 = peg$f89(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsegroupAmountDebited() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 20); + if (s1.toLowerCase() === peg$c103) { + peg$currPos += 20; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e109); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f90(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsegroupAmountReimbursed() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 23); + if (s1.toLowerCase() === peg$c104) { + peg$currPos += 23; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e110); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f91(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseamountDebitedColumn() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 14); + if (s1.toLowerCase() === peg$c79) { + peg$currPos += 14; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e84); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f92(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseamountReimbursedColumn() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 17); + if (s1.toLowerCase() === peg$c81) { + peg$currPos += 17; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e86); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f93(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3803,11 +4045,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c99) { + if (s1.toLowerCase() === peg$c105) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3822,7 +4064,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f88(); + s0 = peg$f94(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3840,11 +4082,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 9); - if (s1.toLowerCase() === peg$c100) { + if (s1.toLowerCase() === peg$c106) { peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3859,7 +4101,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f89(); + s0 = peg$f95(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3877,11 +4119,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c101) { + if (s1.toLowerCase() === peg$c107) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3896,7 +4138,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f90(); + s0 = peg$f96(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3914,11 +4156,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c102) { + if (s1.toLowerCase() === peg$c108) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3933,7 +4175,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f91(); + s0 = peg$f97(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3951,11 +4193,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c103) { + if (s1.toLowerCase() === peg$c109) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3970,7 +4212,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f92(); + s0 = peg$f98(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3988,11 +4230,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c104) { + if (s1.toLowerCase() === peg$c110) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4007,7 +4249,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f93(); + s0 = peg$f99(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4025,11 +4267,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 13); - if (s1.toLowerCase() === peg$c105) { + if (s1.toLowerCase() === peg$c111) { peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e117); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4044,7 +4286,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f94(); + s0 = peg$f100(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4067,81 +4309,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e92); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f95(); + s1 = peg$f101(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c106) { - s1 = peg$c106; + if (input.substr(peg$currPos, 2) === peg$c112) { + s1 = peg$c112; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e119); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f96(); + s1 = peg$f102(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c107) { - s1 = peg$c107; + if (input.substr(peg$currPos, 2) === peg$c113) { + s1 = peg$c113; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e120); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f97(); + s1 = peg$f103(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c108; + s1 = peg$c114; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e121); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f98(); + s1 = peg$f104(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c109) { - s1 = peg$c109; + if (input.substr(peg$currPos, 2) === peg$c115) { + s1 = peg$c115; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } + if (peg$silentFails === 0) { peg$fail(peg$e122); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f99(); + s1 = peg$f105(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c110; + s1 = peg$c116; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } + if (peg$silentFails === 0) { peg$fail(peg$e123); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f100(); + s1 = peg$f106(); } s0 = s1; } @@ -4152,7 +4394,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e118); } } return s0; @@ -4165,7 +4407,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f101(s1); + s1 = peg$f107(s1); } s0 = s1; @@ -4183,7 +4425,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e119); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -4193,7 +4435,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e119); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } } } else { @@ -4201,13 +4443,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f102(s1); + s1 = peg$f108(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e118); } + if (peg$silentFails === 0) { peg$fail(peg$e124); } } return s0; @@ -4219,7 +4461,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f103(); + s1 = peg$f109(); s0 = s1; return s0; @@ -4235,7 +4477,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { peg$fail(peg$e127); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -4244,12 +4486,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { peg$fail(peg$e127); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e120); } + if (peg$silentFails === 0) { peg$fail(peg$e126); } return s0; } @@ -4259,7 +4501,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f104(); + s1 = peg$f110(); if (s1) { s1 = undefined; } else { @@ -4296,7 +4538,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4305,7 +4547,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } } s2 = input.charAt(peg$currPos); @@ -4313,7 +4555,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } + if (peg$silentFails === 0) { peg$fail(peg$e130); } } if (s2 !== peg$FAILED) { s3 = []; @@ -4322,7 +4564,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { peg$fail(peg$e131); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4331,7 +4573,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { peg$fail(peg$e131); } } } s4 = input.charAt(peg$currPos); @@ -4339,7 +4581,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } + if (peg$silentFails === 0) { peg$fail(peg$e130); } } if (s4 !== peg$FAILED) { s5 = []; @@ -4348,7 +4590,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e119); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -4357,11 +4599,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e119); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } } peg$savedPos = s0; - s0 = peg$f105(s1, s3, s5); + s0 = peg$f111(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4373,7 +4615,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e122); } + if (peg$silentFails === 0) { peg$fail(peg$e128); } } return s0; @@ -4390,7 +4632,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4399,7 +4641,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } } s2 = input.charAt(peg$currPos); @@ -4407,7 +4649,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } + if (peg$silentFails === 0) { peg$fail(peg$e130); } } if (s2 !== peg$FAILED) { s3 = []; @@ -4416,7 +4658,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { peg$fail(peg$e131); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -4432,15 +4674,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c111; + s6 = peg$c117; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e126); } + if (peg$silentFails === 0) { peg$fail(peg$e132); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f106(s1); + s4 = peg$f112(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4463,15 +4705,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c112; + s6 = peg$c118; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e127); } + if (peg$silentFails === 0) { peg$fail(peg$e133); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f107(s1); + s4 = peg$f113(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4494,15 +4736,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c113; + s6 = peg$c119; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e128); } + if (peg$silentFails === 0) { peg$fail(peg$e134); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f108(s1); + s4 = peg$f114(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4521,7 +4763,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { peg$fail(peg$e131); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -4537,15 +4779,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c111; + s6 = peg$c117; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e126); } + if (peg$silentFails === 0) { peg$fail(peg$e132); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f106(s1); + s4 = peg$f112(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4568,15 +4810,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c112; + s6 = peg$c118; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e127); } + if (peg$silentFails === 0) { peg$fail(peg$e133); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f107(s1); + s4 = peg$f113(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4599,15 +4841,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c113; + s6 = peg$c119; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e128); } + if (peg$silentFails === 0) { peg$fail(peg$e134); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f108(s1); + s4 = peg$f114(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4623,7 +4865,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f109(s1, s3, s4); + s0 = peg$f115(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4635,7 +4877,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e122); } + if (peg$silentFails === 0) { peg$fail(peg$e128); } } return s0; @@ -4650,7 +4892,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } + if (peg$silentFails === 0) { peg$fail(peg$e130); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4688,7 +4930,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e129); } + if (peg$silentFails === 0) { peg$fail(peg$e135); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4697,7 +4939,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e129); } + if (peg$silentFails === 0) { peg$fail(peg$e135); } } } s2 = []; @@ -4706,7 +4948,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e130); } + if (peg$silentFails === 0) { peg$fail(peg$e136); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -4715,7 +4957,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e130); } + if (peg$silentFails === 0) { peg$fail(peg$e136); } } } s3 = []; @@ -4724,7 +4966,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e131); } + if (peg$silentFails === 0) { peg$fail(peg$e137); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4733,7 +4975,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e131); } + if (peg$silentFails === 0) { peg$fail(peg$e137); } } } s4 = peg$parseoperator(); @@ -4752,7 +4994,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e132); } + if (peg$silentFails === 0) { peg$fail(peg$e138); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4761,7 +5003,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e132); } + if (peg$silentFails === 0) { peg$fail(peg$e138); } } } s2 = peg$currPos; @@ -4808,7 +5050,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e133); } + if (peg$silentFails === 0) { peg$fail(peg$e139); } } } } @@ -4824,7 +5066,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e134); } + if (peg$silentFails === 0) { peg$fail(peg$e140); } } if (s0 === peg$FAILED) { s0 = peg$currPos; diff --git a/src/libs/SearchParser/searchParser.peggy b/src/libs/SearchParser/searchParser.peggy index 7a48b0da4e3a..4022a286ad3a 100644 --- a/src/libs/SearchParser/searchParser.peggy +++ b/src/libs/SearchParser/searchParser.peggy @@ -256,6 +256,9 @@ reportFieldDynamic key "key" = @( date + // Both must precede `amount`, which would otherwise match their prefix. + / amountDebited + / amountReimbursed / amount / total / merchant diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts index 891d7d4a48ea..21396efe0a68 100644 --- a/src/libs/SearchQueryUtils.ts +++ b/src/libs/SearchQueryUtils.ts @@ -1721,7 +1721,13 @@ function getFilterDisplayValue({ if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.IN) { return deprecatedGetReportName(reports?.[`${ONYXKEYS.COLLECTION.REPORT}${filterValue}`], reportAttributes) || filterValue; } - if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT || filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL || filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT) { + if ( + filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT || + filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL || + filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT || + filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED || + filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED + ) { // Added 2 here as this is the maximum number of decimals an amount can have. So, we can run a search with 2 decimals here. const frontendAmount = convertToFrontendAmountAsInteger(Number(filterValue), 2); return Number.isNaN(frontendAmount) ? filterValue : frontendAmount.toString(); diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 9c5d8ff0b497..97d8fdfcfe50 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -340,6 +340,10 @@ const expenseReportColumnNamesToSortingProperty: ExpenseReportSorting = { [CONST.SEARCH.TABLE_COLUMNS.FROM]: 'formattedFrom' as const, [CONST.SEARCH.TABLE_COLUMNS.TO]: 'formattedTo' as const, [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: 'total' as const, + // Both the backend page selection and this local sort rank the amounts as stored, without converting between + // currencies, so a report can outrank one that is worth more in another currency. + [CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED]: 'debitedAmount' as const, + [CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED]: 'creditedAmount' as const, [CONST.SEARCH.TABLE_COLUMNS.ACTION]: 'action' as const, }; @@ -371,6 +375,10 @@ const transactionWithdrawalIDGroupColumnNamesToSortingProperty: TransactionWithd [CONST.SEARCH.TABLE_COLUMNS.WITHDRAWN]: 'debitPosted' as const, [CONST.SEARCH.TABLE_COLUMNS.GROUP_WITHDRAWAL_STATUS]: 'state' as const, [CONST.SEARCH.TABLE_COLUMNS.GROUP_WITHDRAWAL_ID]: 'formattedWithdrawalID' as const, + // Both the backend page selection and this local sort rank the amounts as stored, without converting between + // currencies, so a group can outrank one that is worth more in another currency. + [CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED]: 'debitedAmount' as const, + [CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED]: 'creditedAmount' as const, ...transactionGroupBaseSortingProperties, }; @@ -4526,6 +4534,10 @@ function getSearchColumnTranslationKey(column: SearchSortBy): TranslationPaths { return 'common.expenses'; case CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL: return 'common.total'; + case CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED: + return 'common.amountDebited'; + case CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED: + return 'common.amountReimbursed'; case CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID: return 'common.withdrawalID'; case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID: @@ -4534,6 +4546,10 @@ function getSearchColumnTranslationKey(column: SearchSortBy): TranslationPaths { return 'workspace.common.customField2'; case CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS: return 'common.internationalReimbursementIDs'; + case CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED: + return 'common.amountDebited'; + case CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED: + return 'common.amountReimbursed'; case CONST.SEARCH.TABLE_COLUMNS.GROUP_WITHDRAWAL_ID: return 'common.withdrawalID'; case CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH: @@ -5216,6 +5232,14 @@ const FILTER_TO_SYNTAX_KEY = { [FILTER_KEYS.PURCHASE_AMOUNT_EQUAL_TO]: CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT, [FILTER_KEYS.PURCHASE_AMOUNT_LESS_THAN]: CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT, [FILTER_KEYS.PURCHASE_AMOUNT_GREATER_THAN]: CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT, + + [FILTER_KEYS.AMOUNT_DEBITED_EQUAL_TO]: CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED, + [FILTER_KEYS.AMOUNT_DEBITED_LESS_THAN]: CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED, + [FILTER_KEYS.AMOUNT_DEBITED_GREATER_THAN]: CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED, + + [FILTER_KEYS.AMOUNT_REIMBURSED_EQUAL_TO]: CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED, + [FILTER_KEYS.AMOUNT_REIMBURSED_LESS_THAN]: CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED, + [FILTER_KEYS.AMOUNT_REIMBURSED_GREATER_THAN]: CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED, }; function isGroupedFilterKey(key: SearchAdvancedFiltersKey): key is keyof typeof FILTER_TO_SYNTAX_KEY { @@ -5376,6 +5400,14 @@ const FILTER_VIEW_MAP = { labelKey: 'common.purchaseAmount', icon: 'Coins', }, + [CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED]: { + labelKey: 'common.amountDebited', + icon: 'Coins', + }, + [CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED]: { + labelKey: 'common.amountReimbursed', + icon: 'Coins', + }, [CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL]: { labelKey: 'common.total', icon: 'Coins', @@ -5894,6 +5926,30 @@ function getPolicyTagsForPolicyID(policyTags: PolicyTagsLookup | undefined, poli return policyTagsKey ? policyTags[policyTagsKey] : undefined; } +// Only settlements that converted currencies carry these amounts, so each column stays hidden until a group reports one. +const conversionAmountGroupColumns = { + [CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED]: {amount: 'debitedAmount', currency: 'debitedCurrency'}, + [CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED]: {amount: 'creditedAmount', currency: 'creditedCurrency'}, +} as const satisfies Partial>; + +function isConversionAmountGroupColumn(column: SearchColumnType): column is keyof typeof conversionAmountGroupColumns { + return column in conversionAmountGroupColumns; +} + +function hasGroupWithConversionAmount(column: keyof typeof conversionAmountGroupColumns, data: OnyxTypes.SearchResults['data']): boolean { + const {amount, currency} = conversionAmountGroupColumns[column]; + return Object.keys(data).some((key) => { + if (!isGroupEntry(key)) { + return false; + } + + const group: Partial = data[key]; + + // getWithdrawalIDSections drops groups without an account number, so a column keyed off one would have no row to fill it. + return !!group.accountNumber && !!group[amount] && !!group[currency]; + }); +} + /** * Determines what columns to show based on available data * @param isExpenseReportView: true when we are inside an expense report view, false if we're in the Reports page. @@ -5915,6 +5971,7 @@ function getColumnsToShow({ shouldUseStrictDefaultExpenseColumns = false, isPolicyTaxEnabled = false, fallbackPolicyID, + sortBy, }: { currentAccountID: number | undefined; data: OnyxTypes.SearchResults['data'] | OnyxTypes.Transaction[]; @@ -5931,14 +5988,26 @@ function getColumnsToShow({ shouldUseStrictDefaultExpenseColumns?: boolean; isPolicyTaxEnabled?: boolean; fallbackPolicyID?: string; + sortBy?: SearchSortBy; }): SearchColumnType[] { const reportCustomColumns = new Set([ CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID, CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID, CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS, + CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED, + CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED, ]); - const hasReportCustomColumnValue = (column: SearchColumnType, reportToCheck: OnyxEntry): boolean => !!getReportCustomColumnValue(column, reportToCheck); + const hasReportCustomColumnValue = (column: SearchColumnType, reportToCheck: OnyxEntry): boolean => { + // The cell needs both the amount and the currency it moved in, so treat either one alone as no value. + if (column === CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED) { + return !!reportToCheck?.debitedAmount && !!reportToCheck?.debitedCurrency; + } + if (column === CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED) { + return !!reportToCheck?.creditedAmount && !!reportToCheck?.creditedCurrency; + } + return !!getReportCustomColumnValue(column, reportToCheck); + }; if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { const defaultReportColumns: SearchColumnType[] = [ @@ -5984,6 +6053,12 @@ function getColumnsToShow({ return true; } + // The column the results are sorted by has to stay, even with nothing to show in it. Both the header and the + // Sort by option come from this list, so dropping it would leave the sort applied with no way to change it. + if (column === sortBy) { + return true; + } + return Object.keys(data).some((key) => { if (!isReportEntry(key)) { return false; @@ -6052,7 +6127,13 @@ function getColumnsToShow({ result.push(col); } - return result; + if (Array.isArray(data)) { + return result; + } + + // The column the results are sorted by has to stay, even with nothing to show in it. Both the header and the + // Sort by option come from this list, so dropping it would leave the sort applied with no way to change it. + return result.filter((column) => !isConversionAmountGroupColumn(column) || column === sortBy || hasGroupWithConversionAmount(column, data)); } } diff --git a/src/selectors/Report.ts b/src/selectors/Report.ts index cfa0b41246ba..8fbf1484c35f 100644 --- a/src/selectors/Report.ts +++ b/src/selectors/Report.ts @@ -147,6 +147,10 @@ function getStableReportSelector(report: OnyxEntry) { submitterUserID: report.submitterUserID, submitterPayrollID: report.submitterPayrollID, orderDealNumbers: report.orderDealNumbers, + debitedAmount: report.debitedAmount, + debitedCurrency: report.debitedCurrency, + creditedAmount: report.creditedAmount, + creditedCurrency: report.creditedCurrency, chatType: report.chatType, hasOutstandingChildRequest: report.hasOutstandingChildRequest, hasOutstandingChildTask: report.hasOutstandingChildTask, diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index b62a7e633c85..6547d1ef3d77 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -2014,6 +2014,13 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ case CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES: columnWidth = {...getWidthStyle(variables.w130)}; break; + case CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED: + case CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED: + case CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED: + case CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED: + // Fixed width: wide enough for the long headers these columns carry, so no amount-based widening is needed. + columnWidth = {...getWidthStyle(variables.w130), ...styles.alignItemsEnd}; + break; case CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE_TOTAL: case CONST.SEARCH.TABLE_COLUMNS.NON_REIMBURSABLE_TOTAL: case CONST.SEARCH.TABLE_COLUMNS.ORIGINAL_AMOUNT: diff --git a/src/types/form/SearchAdvancedFiltersForm.ts b/src/types/form/SearchAdvancedFiltersForm.ts index 6d8c2a5556c5..a50b916706e6 100644 --- a/src/types/form/SearchAdvancedFiltersForm.ts +++ b/src/types/form/SearchAdvancedFiltersForm.ts @@ -44,7 +44,13 @@ const DATE_FILTER_KEYS: SearchDateFilterKeys[] = [ CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN, ]; -const AMOUNT_FILTER_KEYS: SearchAmountFilterKeys[] = [CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT, CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL, CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT]; +const AMOUNT_FILTER_KEYS: SearchAmountFilterKeys[] = [ + CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT, + CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL, + CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT, + CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_DEBITED, + CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT_REIMBURSED, +]; const NEGATABLE_FILTER_KEYS = [ CONST.SEARCH.SYNTAX_FILTER_KEYS.TO, @@ -160,6 +166,16 @@ const FILTER_KEYS = { TOTAL_LESS_THAN: 'totalLessThan', TOTAL_GREATER_THAN: 'totalGreaterThan', + AMOUNT_DEBITED_NOT: 'amountDebitedNot', + AMOUNT_DEBITED_EQUAL_TO: 'amountDebitedEqualTo', + AMOUNT_DEBITED_LESS_THAN: 'amountDebitedLessThan', + AMOUNT_DEBITED_GREATER_THAN: 'amountDebitedGreaterThan', + + AMOUNT_REIMBURSED_NOT: 'amountReimbursedNot', + AMOUNT_REIMBURSED_EQUAL_TO: 'amountReimbursedEqualTo', + AMOUNT_REIMBURSED_LESS_THAN: 'amountReimbursedLessThan', + AMOUNT_REIMBURSED_GREATER_THAN: 'amountReimbursedGreaterThan', + TAX_RATE_NOT: 'taxRateNot', TAX_RATE: 'taxRate', @@ -384,6 +400,14 @@ const ALLOWED_TYPE_FILTERS: Record> = { FILTER_KEYS.TOTAL_NOT, FILTER_KEYS.TOTAL_GREATER_THAN, FILTER_KEYS.TOTAL_LESS_THAN, + FILTER_KEYS.AMOUNT_DEBITED_EQUAL_TO, + FILTER_KEYS.AMOUNT_DEBITED_NOT, + FILTER_KEYS.AMOUNT_DEBITED_GREATER_THAN, + FILTER_KEYS.AMOUNT_DEBITED_LESS_THAN, + FILTER_KEYS.AMOUNT_REIMBURSED_EQUAL_TO, + FILTER_KEYS.AMOUNT_REIMBURSED_NOT, + FILTER_KEYS.AMOUNT_REIMBURSED_GREATER_THAN, + FILTER_KEYS.AMOUNT_REIMBURSED_LESS_THAN, FILTER_KEYS.CURRENCY, FILTER_KEYS.CURRENCY_NOT, FILTER_KEYS.GROUP_CURRENCY, @@ -781,6 +805,16 @@ type SearchAdvancedFiltersForm = Form< [FILTER_KEYS.TOTAL_LESS_THAN]: string; [FILTER_KEYS.TOTAL_GREATER_THAN]: string; + [FILTER_KEYS.AMOUNT_DEBITED_EQUAL_TO]: string; + [FILTER_KEYS.AMOUNT_DEBITED_NOT]: string; + [FILTER_KEYS.AMOUNT_DEBITED_LESS_THAN]: string; + [FILTER_KEYS.AMOUNT_DEBITED_GREATER_THAN]: string; + + [FILTER_KEYS.AMOUNT_REIMBURSED_EQUAL_TO]: string; + [FILTER_KEYS.AMOUNT_REIMBURSED_NOT]: string; + [FILTER_KEYS.AMOUNT_REIMBURSED_LESS_THAN]: string; + [FILTER_KEYS.AMOUNT_REIMBURSED_GREATER_THAN]: string; + [FILTER_KEYS.KEYWORD]: string; [FILTER_KEYS.TAX_RATE]: string[]; diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 65949a422984..097e327ce81a 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -109,6 +109,18 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** International reimbursement IDs associated with the report */ orderDealNumbers?: string; + /** Amount taken from the payer's account for this report's cross-border reimbursement */ + debitedAmount?: number; + + /** Currency of `debitedAmount` */ + debitedCurrency?: string; + + /** Amount delivered to the recipient by this report's cross-border reimbursement */ + creditedAmount?: number; + + /** Currency of `creditedAmount` */ + creditedCurrency?: string; + /** The specific type of chat */ chatType?: ValueOf; diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index e48db2a3a640..4ee77a699e9f 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -194,6 +194,18 @@ type SearchWithdrawalIDGroup = { /** Settlement state (5/6/7=failed, 8=cleared, others=pending) */ state: number; + /** What the company was debited, when the settlement converted currencies */ + debitedAmount?: number; + + /** Currency the company was debited in */ + debitedCurrency?: string; + + /** What the employee was credited, when the settlement converted currencies */ + creditedAmount?: number; + + /** Currency the employee was credited in */ + creditedCurrency?: string; + /** Workspace ID for the grouped settlement */ policyID?: string; diff --git a/src/types/utils/whitelistedReportKeys.ts b/src/types/utils/whitelistedReportKeys.ts index 8a05d84e0893..6aee1edc8a70 100644 --- a/src/types/utils/whitelistedReportKeys.ts +++ b/src/types/utils/whitelistedReportKeys.ts @@ -37,6 +37,10 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback< submitterUserID: unknown; submitterPayrollID: unknown; orderDealNumbers: unknown; + debitedAmount: unknown; + debitedCurrency: unknown; + creditedAmount: unknown; + creditedCurrency: unknown; visibility: unknown; invoiceReceiver: unknown; parentReportID: unknown; diff --git a/tests/unit/Search/ColumnAvailabilityTest.ts b/tests/unit/Search/ColumnAvailabilityTest.ts index fa1578228a41..d960b00b2de0 100644 --- a/tests/unit/Search/ColumnAvailabilityTest.ts +++ b/tests/unit/Search/ColumnAvailabilityTest.ts @@ -33,6 +33,8 @@ describe('Column availability single source of truth', () => { TABLE_COLUMNS.FIRST_APPROVER, TABLE_COLUMNS.FIRST_APPROVED, TABLE_COLUMNS.PAID_STATUS, + TABLE_COLUMNS.AMOUNT_DEBITED, + TABLE_COLUMNS.AMOUNT_REIMBURSED, // Grouped search views. TABLE_COLUMNS.EXPENSES, TABLE_COLUMNS.FEED, @@ -54,6 +56,8 @@ describe('Column availability single source of truth', () => { TABLE_COLUMNS.GROUP_YEAR, TABLE_COLUMNS.GROUP_QUARTER, TABLE_COLUMNS.GROUP_WITHDRAWAL_STATUS, + TABLE_COLUMNS.GROUP_AMOUNT_DEBITED, + TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED, ]); test('every TABLE_COLUMNS value is classified in COLUMN_AVAILABILITY or owned by another surface', () => { diff --git a/tests/unit/Search/SearchQueryUtilsTest.ts b/tests/unit/Search/SearchQueryUtilsTest.ts index fcf960cfa13b..4299e929c808 100644 --- a/tests/unit/Search/SearchQueryUtilsTest.ts +++ b/tests/unit/Search/SearchQueryUtilsTest.ts @@ -594,6 +594,29 @@ describe('SearchQueryUtils', () => { expect(result).toEqual('type:expense total>1 total<1000'); }); + test('conversion amount filter values', () => { + const filterValues: Partial = { + type: 'expense-report', + amountDebitedGreaterThan: '1', + amountDebitedLessThan: '1000', + amountReimbursedEqualTo: '500', + }; + const result = buildQueryStringFromFilterFormValues(filterValues); + + expect(result).toEqual('type:expense-report amountDebited>1 amountDebited<1000 amountReimbursed:500'); + }); + + test('conversion amount filters are dropped on an expense search, since a payment pays a whole report', () => { + const filterValues: Partial = { + type: 'expense', + amountDebitedEqualTo: '1694', + amountReimbursedGreaterThan: '1000', + }; + const result = buildQueryStringFromFilterFormValues(filterValues); + + expect(result).toEqual('type:expense'); + }); + test('equal to filter values', () => { const filterValues: Partial = { type: 'expense', @@ -1182,6 +1205,22 @@ describe('SearchQueryUtils', () => { }); }); + test('conversion amount filters parse from either spelling of the key', () => { + const queryJSON = buildSearchQueryJSON('type:expense-report amount-debited>1000 amountReimbursed<2000'); + + if (!queryJSON) { + throw new Error('Failed to parse query string'); + } + + const result = buildFilterFormValuesFromQuery(queryJSON, {}, {}, {}, {}, {}, {}, {}); + + expect(result).toMatchObject({ + type: 'expense-report', + amountDebitedGreaterThan: '1000', + amountReimbursedLessThan: '2000', + }); + }); + test('withdrawal status filter parses valid values and drops invalid ones', () => { const policyCategories = {}; const policyTags = {}; diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index c85a6e273d91..5dcb016316bb 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -16,7 +16,7 @@ import type { TransactionYearGroupListItemType, } from '@components/Search/SearchList/ListItem/types'; import {getExpenseHeaders} from '@components/Search/SearchTableHeader'; -import type {SelectedTransactionInfo} from '@components/Search/types'; +import type {SearchColumnType, SelectedTransactionInfo, SortOrder} from '@components/Search/types'; import Navigation from '@navigation/Navigation'; @@ -6920,6 +6920,84 @@ describe('SearchUIUtils', () => { ).toStrictEqual(transactionWithdrawalIDGroupListItemsSorted); }); + it('should sort withdrawal-id groups by each conversion amount, leaving the settlements that did not convert at the empty end', () => { + const withConversion = (keyForList: string, debitedAmount?: number, creditedAmount?: number): TransactionWithdrawalIDGroupListItemType => ({ + bankName: CONST.BANK_NAMES.CHASE, + entryID, + accountNumber, + debitPosted: '2025-08-12 17:11:22', + count: 4, + currency: 'USD', + total: 40, + state: 8, + groupedBy: CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID, + formattedWithdrawalID: '5', + transactions: [], + transactionsQueryJSON: undefined, + shouldShowYearWithdrawn: true, + keyForList, + ...(debitedAmount ? {debitedAmount, debitedCurrency: 'USD'} : {}), + ...(creditedAmount ? {creditedAmount, creditedCurrency: 'GBP'} : {}), + }); + const domestic = withConversion('group_domestic'); + const smallConversion = withConversion('group_small', 1694, 1340); + const largeConversion = withConversion('group_large', 32200, 26886); + const groups = [smallConversion, domestic, largeConversion]; + + const sortGroups = (sortBy: SearchColumnType, sortOrder: SortOrder) => + SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.EXPENSE, [...groups], localeCompare, translateLocal, sortBy, sortOrder, CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID).map( + (group) => group.keyForList, + ); + + expect(sortGroups(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED, CONST.SEARCH.SORT_ORDER.ASC)).toStrictEqual(['group_domestic', 'group_small', 'group_large']); + expect(sortGroups(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED, CONST.SEARCH.SORT_ORDER.DESC)).toStrictEqual(['group_large', 'group_small', 'group_domestic']); + expect(sortGroups(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED, CONST.SEARCH.SORT_ORDER.ASC)).toStrictEqual(['group_domestic', 'group_small', 'group_large']); + expect(sortGroups(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED, CONST.SEARCH.SORT_ORDER.DESC)).toStrictEqual(['group_large', 'group_small', 'group_domestic']); + }); + + it('should sort expense reports by each conversion amount, leaving the reports that did not convert at the empty end', () => { + const withConversion = (keyForList: string, debitedAmount?: number, creditedAmount?: number) => + createMock({ + groupedBy: 'expense-report', + keyForList, + reportID: keyForList, + created: '2025-08-12 17:11:22', + currency: 'USD', + transactions: [], + ...(debitedAmount ? {debitedAmount, debitedCurrency: 'GBP'} : {}), + ...(creditedAmount ? {creditedAmount, creditedCurrency: 'USD'} : {}), + }); + const domestic = withConversion('report_domestic'); + const smallConversion = withConversion('report_small', 1694, 2000); + const largeConversion = withConversion('report_large', 32200, 40000); + // Debited the most but reimbursed the least, so the two sides rank the reports differently + const reversedConversion = withConversion('report_reversed', 90000, 100); + const reports = [smallConversion, domestic, largeConversion, reversedConversion]; + + const sortReports = (sortBy: SearchColumnType, sortOrder: SortOrder) => + SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, [...reports], localeCompare, translateLocal, sortBy, sortOrder).map((report) => report.keyForList); + + expect(sortReports(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED, CONST.SEARCH.SORT_ORDER.ASC)).toStrictEqual(['report_domestic', 'report_small', 'report_large', 'report_reversed']); + expect(sortReports(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED, CONST.SEARCH.SORT_ORDER.DESC)).toStrictEqual([ + 'report_reversed', + 'report_large', + 'report_small', + 'report_domestic', + ]); + expect(sortReports(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED, CONST.SEARCH.SORT_ORDER.ASC)).toStrictEqual([ + 'report_domestic', + 'report_reversed', + 'report_small', + 'report_large', + ]); + expect(sortReports(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED, CONST.SEARCH.SORT_ORDER.DESC)).toStrictEqual([ + 'report_large', + 'report_small', + 'report_reversed', + 'report_domestic', + ]); + }); + it('should sort category group data when type is EXPENSE and groupBy is category', () => { expect( SearchUIUtils.getSortedSections( @@ -9654,6 +9732,143 @@ describe('SearchUIUtils', () => { expect(result).toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_FROM); }); + test('Should only show the conversion amount columns for reports whose reimbursement converted currencies', () => { + const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED, CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED]; + const domesticReport = {reportID: '1', type: CONST.REPORT.TYPE.EXPENSE, total: -10000, currency: 'USD'}; + const crossBorderReport = { + ...domesticReport, + reportID: '2', + debitedAmount: 30000, + debitedCurrency: 'GBP', + creditedAmount: 37250, + creditedCurrency: 'USD', + }; + + // @ts-expect-error minimal dataset for getColumnsToShow + const domesticData: OnyxTypes.SearchResults['data'] = {[`${ONYXKEYS.COLLECTION.REPORT}${domesticReport.reportID}`]: domesticReport}; + const crossBorderData: OnyxTypes.SearchResults['data'] = {...domesticData, [`${ONYXKEYS.COLLECTION.REPORT}${crossBorderReport.reportID}`]: crossBorderReport}; + + const domesticColumns = SearchUIUtils.getColumnsToShow({currentAccountID: 1, data: domesticData, visibleColumns, type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT}); + expect(domesticColumns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED); + expect(domesticColumns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED); + + const crossBorderColumns = SearchUIUtils.getColumnsToShow({currentAccountID: 1, data: crossBorderData, visibleColumns, type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT}); + expect(crossBorderColumns).toContain(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED); + expect(crossBorderColumns).toContain(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED); + + // Without a currency the amount cannot be rendered, so that column stays hidden. + const missingCurrencyData: OnyxTypes.SearchResults['data'] = { + ...domesticData, + [`${ONYXKEYS.COLLECTION.REPORT}${crossBorderReport.reportID}`]: {...crossBorderReport, creditedCurrency: undefined}, + }; + const missingCurrencyColumns = SearchUIUtils.getColumnsToShow({ + currentAccountID: 1, + data: missingCurrencyData, + visibleColumns, + type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, + }); + expect(missingCurrencyColumns).toContain(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED); + expect(missingCurrencyColumns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED); + + const sortedColumns = SearchUIUtils.getColumnsToShow({ + currentAccountID: 1, + data: domesticData, + visibleColumns, + type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, + sortBy: CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED, + }); + expect(sortedColumns).toContain(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_DEBITED); + expect(sortedColumns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.AMOUNT_REIMBURSED); + }); + + test('Should only show the conversion amount columns for withdrawal groups that converted currencies', () => { + const domesticGroup = { + entryID: 1, + count: 1, + total: -10000, + currency: 'USD', + accountNumber: '1234', + bankName: CONST.BANK_NAMES.CHASE, + debitPosted: '2026-01-02', + state: 8, + }; + const crossBorderGroup = { + ...domesticGroup, + entryID: 2, + debitedAmount: 10000, + debitedCurrency: 'USD', + creditedAmount: 9200, + creditedCurrency: 'EUR', + }; + + // @ts-expect-error minimal dataset for getColumnsToShow + const domesticData: OnyxTypes.SearchResults['data'] = {[`group_${domesticGroup.entryID}`]: domesticGroup}; + const crossBorderData: OnyxTypes.SearchResults['data'] = {...domesticData, [`group_${crossBorderGroup.entryID}`]: crossBorderGroup}; + + const domesticColumns = SearchUIUtils.getColumnsToShow({currentAccountID: 1, data: domesticData, visibleColumns: [], groupBy: CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID}); + expect(domesticColumns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED); + expect(domesticColumns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED); + + const crossBorderColumns = SearchUIUtils.getColumnsToShow({currentAccountID: 1, data: crossBorderData, visibleColumns: [], groupBy: CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID}); + expect(crossBorderColumns).toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED); + expect(crossBorderColumns).toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED); + + // A group with no account number never reaches the list, so its amounts must not open a column either. + const unrenderedData: OnyxTypes.SearchResults['data'] = {...domesticData, [`group_${crossBorderGroup.entryID}`]: {...crossBorderGroup, accountNumber: ''}}; + const unrenderedColumns = SearchUIUtils.getColumnsToShow({currentAccountID: 1, data: unrenderedData, visibleColumns: [], groupBy: CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID}); + expect(unrenderedColumns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED); + expect(unrenderedColumns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED); + }); + + test('Should hide a conversion amount column when its currency is missing', () => { + const groupMissingCreditedCurrency = { + entryID: 3, + count: 1, + total: -10000, + currency: 'USD', + accountNumber: '1234', + bankName: CONST.BANK_NAMES.CHASE, + debitPosted: '2026-01-02', + state: 8, + debitedAmount: 10000, + debitedCurrency: 'USD', + creditedAmount: 9200, + }; + + // @ts-expect-error minimal dataset for getColumnsToShow + const data: OnyxTypes.SearchResults['data'] = {[`group_${groupMissingCreditedCurrency.entryID}`]: groupMissingCreditedCurrency}; + + const columns = SearchUIUtils.getColumnsToShow({currentAccountID: 1, data, visibleColumns: [], groupBy: CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID}); + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED); + expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED); + }); + + test('Should keep the conversion amount column the groups are sorted by', () => { + const domesticGroup = { + entryID: 4, + count: 1, + total: -10000, + currency: 'USD', + accountNumber: '1234', + bankName: CONST.BANK_NAMES.CHASE, + debitPosted: '2026-01-02', + state: 8, + }; + + // @ts-expect-error minimal dataset for getColumnsToShow + const data: OnyxTypes.SearchResults['data'] = {[`group_${domesticGroup.entryID}`]: domesticGroup}; + + const columns = SearchUIUtils.getColumnsToShow({ + currentAccountID: 1, + data, + visibleColumns: [], + groupBy: CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID, + sortBy: CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED, + }); + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_DEBITED); + expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.GROUP_AMOUNT_REIMBURSED); + }); + test('Should hide To for strict default expense columns', () => { const baseTransaction = searchResults.data[`transactions_${transactionID}`]; const tx = {