diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 81eb9e25b8ea..fc8822b04438 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -743,6 +743,8 @@ const CONST = { EXPORT_LABELS: { NETSUITE: 'NetSuite', + NETSUITE_QUICKSTART: 'NetSuite QuickStart', + SAGE_ACCOUNTING: 'Sage Accounting', INTUIT_ENTERPRISE_SUITE: 'Intuit Enterprise Suite', QBO: 'QuickBooks Online', QBD: 'QuickBooks Desktop', @@ -9448,6 +9450,8 @@ const CONST = { EXPENSE: 'expense', REPORT: 'report', }, + // Auth supports COUNT exports even though App does not list the connection. + COUNT_EXPORT_LABEL: 'COUNT', SYNTAX_FILTER_KEYS: { TYPE: 'type', STATUS: 'status', @@ -9510,6 +9514,7 @@ const CONST = { IS: 'is', REPORT_FIELD: 'reportField', EXPORTED_TO: 'exportedTo', + EXPORTED_TO_TEMPLATE: 'exportedToTemplate', SUBMITTER_USER_ID: 'submitterUserID', SUBMITTER_PAYROLL_ID: 'submitterPayrollID', ORDER_DEAL_NUMBERS: 'orderDealNumbers', @@ -9610,6 +9615,7 @@ const CONST = { IS: 'is', REPORT_FIELD: 'report-field', EXPORTED_TO: 'exported-to', + EXPORTED_TO_TEMPLATE: 'exported-to-template', SUBMITTER_USER_ID: 'submitter-user-id', SUBMITTER_PAYROLL_ID: 'submitter-payroll-id', ORDER_DEAL_NUMBERS: 'order-deal-numbers', diff --git a/src/components/Search/FilterComponents/ExportedToSelector.tsx b/src/components/Search/FilterComponents/ExportedToSelector.tsx index 2273addfd4f3..a5cdab05efa3 100644 --- a/src/components/Search/FilterComponents/ExportedToSelector.tsx +++ b/src/components/Search/FilterComponents/ExportedToSelector.tsx @@ -9,7 +9,15 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import {getExportLabelsForConnection, getStandardExportTemplateDisplayName, isStandardExportTemplate} from '@libs/AccountingUtils'; +import { + EXPORT_TEMPLATE_SEARCH_PREFIX, + getConnectionNameFromExportLabel, + getExportLabelsForConnection, + getExportedToDisplayName, + getExportTemplateSearchValue, + getStandardExportTemplateDisplayName, + isStandardExportTemplate, +} from '@libs/AccountingUtils'; import {getIntegrationIcon} from '@libs/ReportUtils'; import {getAllPolicyValues, getConnectedIntegrationNamesForPolicies} from '@libs/SearchQueryUtils'; @@ -17,6 +25,7 @@ import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import type {ConnectionName} from '@src/types/onyx/Policy'; import type IconAsset from '@src/types/utils/IconAsset'; import React from 'react'; @@ -24,13 +33,15 @@ import {View} from 'react-native'; import MultiSelect from './MultiSelect'; +const integrationConnectionNames = CONST.POLICY.CONNECTIONS.ACCOUNTING_CONNECTION_NAMES; + type ExportedToSelectorProps = SearchFilterCommonProps & { policyID: Filter | undefined; }; function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, selectionListStyle, autoFocus, footer, onChange}: ExportedToSelectorProps) { const styles = useThemeStyles(); - const {localeCompare} = useLocalize(); + const {localeCompare, translate} = useLocalize(); const StyleUtils = useStyleUtils(); const theme = useTheme(); const expensifyIcons = useMemoizedLazyExpensifyIcons([ @@ -49,6 +60,7 @@ function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, 'BusinessCentralSquare', 'OdooSquare', 'GustoSquare', + 'Export', 'Table', 'TablePencil', ]); @@ -59,18 +71,33 @@ function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, const policiesToLoadTemplatesFrom = getAllPolicyValues(policyID, ONYXKEYS.COLLECTION.POLICY, policies); const exportTemplates = useCombinedExportTemplates(policiesToLoadTemplatesFrom); - const integrationConnectionNames = CONST.POLICY.CONNECTIONS.ACCOUNTING_CONNECTION_NAMES; - - const tableIconForExportOption = (tableIcon: IconAsset) => ( + const getSmallIconForExportOption = (icon: IconAsset) => ( ); + const getIntegrationIconForExportOption = (label: string, connectionName?: ConnectionName) => { + const isIntuitEnterpriseSuite = label.toLowerCase() === CONST.EXPORT_LABELS.INTUIT_ENTERPRISE_SUITE.toLowerCase(); + const icon = isIntuitEnterpriseSuite ? expensifyIcons.IntuitSquare : getIntegrationIcon(connectionName ?? getConnectionNameFromExportLabel(label), expensifyIcons); + return icon ? ( + + + + ) : ( + getSmallIconForExportOption(expensifyIcons.Export) + ); + }; + const exportedToPickerOptions = (() => { const integrationConnectionNamesSet = new Set(integrationConnectionNames); @@ -78,26 +105,12 @@ function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, .filter((connectionName) => connectedIntegrationNames.has(connectionName)) .flatMap((connectionName) => { const searchValues = getExportLabelsForConnection(connectionName, policiesToLoadTemplatesFrom); - return searchValues.map((searchValue) => { - const isIntuitEnterpriseSuite = searchValue === CONST.EXPORT_LABELS.INTUIT_ENTERPRISE_SUITE; - const icon = isIntuitEnterpriseSuite ? expensifyIcons.IntuitSquare : getIntegrationIcon(connectionName, expensifyIcons); - return { - text: searchValue, - value: searchValue, - leftElement: icon ? ( - - - - ) : ( - tableIconForExportOption(expensifyIcons.Table) - ), - }; - }); + return searchValues.map((searchValue) => ({ + text: searchValue, + accessibilityLabel: translate('search.exportIntegrationAccessibilityLabel', searchValue), + value: searchValue, + leftElement: getIntegrationIconForExportOption(searchValue, connectionName), + })); }); const usedPickerValueKeys = new Set(connectedIntegrationPickerItems.map((item) => item.value)); @@ -113,7 +126,8 @@ function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, // Standard templates are filtered on by the label the backend records for them, while custom templates are filtered on by their display name const isStandardTemplate = isStandardExportTemplate(template.templateName); - const filterValue = isStandardTemplate ? getStandardExportTemplateDisplayName(template.templateName) : displayName; + const templateLabel = isStandardTemplate ? getStandardExportTemplateDisplayName(template.templateName) : displayName; + const filterValue = getExportTemplateSearchValue(templateLabel); if (usedPickerValueKeys.has(filterValue)) { continue; } @@ -121,8 +135,24 @@ function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, usedPickerValueKeys.add(filterValue); standardAndIntegrationCustomTemplatePickerItems.push({ text: displayName, + accessibilityLabel: translate('search.exportTemplateAccessibilityLabel', displayName), value: filterValue, - leftElement: tableIconForExportOption(isStandardTemplate ? expensifyIcons.Table : expensifyIcons.TablePencil), + leftElement: getSmallIconForExportOption(isStandardTemplate ? expensifyIcons.Table : expensifyIcons.TablePencil), + }); + } + + // Saved destinations can outlive connections and cached templates. + for (const selectedValue of value) { + if (usedPickerValueKeys.has(selectedValue)) { + continue; + } + const displayName = getExportedToDisplayName(selectedValue); + const isTemplate = selectedValue.startsWith(EXPORT_TEMPLATE_SEARCH_PREFIX); + standardAndIntegrationCustomTemplatePickerItems.push({ + text: displayName, + accessibilityLabel: translate(isTemplate ? 'search.exportTemplateAccessibilityLabel' : 'search.exportIntegrationAccessibilityLabel', displayName), + value: selectedValue, + leftElement: isTemplate ? getSmallIconForExportOption(expensifyIcons.TablePencil) : getIntegrationIconForExportOption(displayName), }); } diff --git a/src/components/Search/FilterComponents/MultiSelect.tsx b/src/components/Search/FilterComponents/MultiSelect.tsx index e239e315a7b7..be7dbbc69257 100644 --- a/src/components/Search/FilterComponents/MultiSelect.tsx +++ b/src/components/Search/FilterComponents/MultiSelect.tsx @@ -31,6 +31,9 @@ type MultiSelectItem = { leftElement?: ReactNode; searchableText?: string; + /** Overrides the row's spoken label without changing its visible text. */ + accessibilityLabel?: string; + /** Optional supporting text rendered on a second line beneath `text` */ alternateText?: string; }; @@ -124,6 +127,7 @@ function MultiSelect({ const listData: ListItem[] = filteredItems.map((item) => ({ text: item.text, alternateText: item.alternateText, + accessibilityLabel: item.accessibilityLabel, keyForList: item.value, isSelected: !!selectedItems.find((i) => i.value === item.value), icons: item.icons, diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index d3b42cc34ef1..ee4c48c824d7 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -25,6 +25,7 @@ import useSortedReportActionsData from '@hooks/useSortedReportActionsData'; import useThemeStyles from '@hooks/useThemeStyles'; import useTransactionsByID from '@hooks/useTransactionsByID'; +import {EXPORT_TEMPLATE_SEARCH_PREFIX, getExportedToDisplayName} from '@libs/AccountingUtils'; import FS from '@libs/Fullstory'; import type {Options, SearchOption} from '@libs/OptionsListUtils'; import {combineOrderingOfReportsAndPersonalDetails, getSearchOptions} from '@libs/OptionsListUtils'; @@ -131,7 +132,9 @@ const setPerformanceTimersEnd = () => { }; function getAutocompleteDisplayText(filterKey: UserFriendlyKey, value: string) { - return `${filterKey}:${value}`; + const isEncodedTemplate = filterKey === CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO && value.startsWith(EXPORT_TEMPLATE_SEARCH_PREFIX); + const displayKey = isEncodedTemplate ? CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO_TEMPLATE : filterKey; + return `${displayKey}:${isEncodedTemplate ? getExportedToDisplayName(value) : value}`; } function SearchRouterItem({ @@ -255,7 +258,7 @@ function SearchAutocompleteList({ const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const currentUserEmail = currentUserPersonalDetails.email ?? ''; const currentUserAccountID = currentUserPersonalDetails.accountID; - const expensifyIcons = useMemoizedLazyExpensifyIcons(['History', 'MagnifyingGlass']); + const expensifyIcons = useMemoizedLazyExpensifyIcons(['History', 'MagnifyingGlass', 'TablePencil']); const taxRates = getAllTaxRates(policies); const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector}); @@ -734,7 +737,11 @@ function SearchAutocompleteList({ return { text: getAutocompleteDisplayText(filterKey, text), mapKey: mapKey ? getSubstitutionMapKey(mapKey, text) : undefined, - singleIcon: expensifyIcons.MagnifyingGlass, + singleIcon: + filterKey === CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO_TEMPLATE || + (filterKey === CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO && text.startsWith(EXPORT_TEMPLATE_SEARCH_PREFIX)) + ? expensifyIcons.TablePencil + : expensifyIcons.MagnifyingGlass, searchQuery: text, autocompleteID, keyForList: autocompleteID ?? text, diff --git a/src/components/Search/SearchRouter/SearchRouter.tsx b/src/components/Search/SearchRouter/SearchRouter.tsx index 6d59e51d2391..0107dad2a86a 100644 --- a/src/components/Search/SearchRouter/SearchRouter.tsx +++ b/src/components/Search/SearchRouter/SearchRouter.tsx @@ -39,9 +39,9 @@ import Parser from '@libs/Parser'; import {getAllTaxRates} from '@libs/PolicyUtils'; import {isHiddenForCurrentUser, isInvoiceReport, isMoneyRequestReport, isOneOnOneChat} from '@libs/ReportUtils'; import type {OptionData} from '@libs/ReportUtils'; -import {getAutocompleteQueryWithComma, getTrimmedUserSearchQueryPreservingComma} from '@libs/SearchAutocompleteUtils'; +import {getAutocompleteQueryWithComma, getQueryWithAutocompleteSelection} from '@libs/SearchAutocompleteUtils'; import {searchKeyToSavedSearchID} from '@libs/SearchKeyUtils'; -import {buildSearchQueryJSON, buildUserReadableQueryString, getQueryWithPreservedSort, getQueryWithUpdatedValues, sanitizeSearchValue} from '@libs/SearchQueryUtils'; +import {buildSearchQueryJSON, buildUserReadableQueryString, getQueryWithPreservedSort, getQueryWithUpdatedValues} from '@libs/SearchQueryUtils'; import StringUtils from '@libs/StringUtils'; import { beginSearchRouterQuerySession, @@ -486,8 +486,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla setFocusAndScrollToRight(); } else if (item.searchItemType === CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.AUTOCOMPLETE_SUGGESTION && textInputValue) { const fieldKey = item.mapKey?.includes(':') ? item.mapKey.split(':').at(0) : item.mapKey; - const trimmedUserSearchQuery = getTrimmedUserSearchQueryPreservingComma(textInputValue, fieldKey); - const newSearchQuery = `${trimmedUserSearchQuery}${sanitizeSearchValue(item.searchQuery)}\u00A0`; + const newSearchQuery = getQueryWithAutocompleteSelection(textInputValue, fieldKey, item.searchQuery); onSearchQueryChange(newSearchQuery, true, undefined, false); setSelection({start: newSearchQuery.length, end: newSearchQuery.length}); diff --git a/src/hooks/useAutocompleteSuggestions.ts b/src/hooks/useAutocompleteSuggestions.ts index bb67f9a78de2..d9b90240d258 100644 --- a/src/hooks/useAutocompleteSuggestions.ts +++ b/src/hooks/useAutocompleteSuggestions.ts @@ -2,6 +2,7 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider'; import type {SubstitutionMap} from '@components/Search/SearchRouter/getQueryWithSubstitutions'; import type {SearchFilterKey, UserFriendlyKey} from '@components/Search/types'; +import {EXPORT_TEMPLATE_SEARCH_PREFIX, getExportedToDisplayName, getExportedToPickerValue} from '@libs/AccountingUtils'; import {getBankAccountSearchLabel, isFilterableBankAccount} from '@libs/BankAccountUtils'; import {getCardFeedsForDisplay} from '@libs/CardFeedUtils'; import {getCardDescription, isCard, isCardHiddenFromSearch} from '@libs/CardUtils'; @@ -668,18 +669,26 @@ function useAutocompleteSuggestions({ return filteredIsValues.map((isValue) => ({filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.IS, text: isValue})); } + case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE: case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO: { + const isTemplateFilter = autocompleteKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE; + const selectedExports = new Set( + ranges + .filter((range) => range.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO || range.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE) + .map((range) => getExportedToPickerValue(range.value, range.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE).toLowerCase()), + ); const filteredExportedTo = exportedToFilterOptions + .filter((value) => !isTemplateFilter || value.startsWith(EXPORT_TEMPLATE_SEARCH_PREFIX)) .filter((value) => { const lowerValue = value.toLowerCase(); - return lowerValue.includes(autocompleteValue.toLowerCase()) && !alreadyAutocompletedKeys.has(lowerValue); + return getExportedToDisplayName(value).toLowerCase().includes(autocompleteValue.toLowerCase()) && !selectedExports.has(lowerValue); }) .sort() .slice(0, 10); return filteredExportedTo.map((value) => ({ - filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO, - text: value, - mapKey: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, + filterKey: isTemplateFilter ? CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO_TEMPLATE : CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO, + text: isTemplateFilter ? getExportedToDisplayName(value) : value, + mapKey: isTemplateFilter ? CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE : CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, })); } case CONST.SEARCH.SYNTAX_FILTER_KEYS.ANY_APPROVAL: diff --git a/src/hooks/useExportedToFilterOptions.ts b/src/hooks/useExportedToFilterOptions.ts index 2c5193b082c4..5a361a9b77ee 100644 --- a/src/hooks/useExportedToFilterOptions.ts +++ b/src/hooks/useExportedToFilterOptions.ts @@ -1,7 +1,7 @@ import {useSearchQueryContext} from '@components/Search/SearchContext'; import type {Filter} from '@components/Search/types'; -import {getExportLabelsForConnection, getStandardExportTemplateDisplayName} from '@libs/AccountingUtils'; +import {getExportLabelsForConnection, getExportTemplateSearchValue, getStandardExportTemplateDisplayName} from '@libs/AccountingUtils'; import {getAllPolicyValues, getConnectedIntegrationNamesForPolicies, getFilterFromQuery} from '@libs/SearchQueryUtils'; import CONST from '@src/CONST'; @@ -51,7 +51,9 @@ function exportedToPoliciesSelector(policies: OnyxCollection): OnyxColle */ export default function useExportedToFilterOptions(policyIDsOverride?: Filter): UseExportedToFilterDataResult { const {currentSearchQueryJSON} = useSearchQueryContext(); - const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: exportedToPoliciesSelector}); + const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, { + selector: exportedToPoliciesSelector, + }); // When search is scoped to workspaces, use only those policies otherwise use all. const policiesToUse = getAllPolicyValues( @@ -71,7 +73,7 @@ export default function useExportedToFilterOptions(policyIDsOverride?: Filter): const standardExportTemplateDisplayName = getStandardExportTemplateDisplayName(template.templateName); const filterValue = standardExportTemplateDisplayName !== template.templateName ? standardExportTemplateDisplayName : (template.name ?? template.templateName); - standardAndCustomExportTemplates.push(filterValue); + standardAndCustomExportTemplates.push(getExportTemplateSearchValue(filterValue)); } // React Compiler stops memoizing a value made before a hook call and passed to a function after it, unless the hook also received it, so the policy IDs are read again here. diff --git a/src/hooks/useFilterFormValues.tsx b/src/hooks/useFilterFormValues.tsx index 4238f42c13f1..1181faa34f5a 100644 --- a/src/hooks/useFilterFormValues.tsx +++ b/src/hooks/useFilterFormValues.tsx @@ -15,7 +15,6 @@ import type {OnyxCollection} from 'react-native-onyx'; import {useCurrencyListState} from './useCurrencyList'; import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; -import useExportedToFilterOptions from './useExportedToFilterOptions'; import useOnyx from './useOnyx'; function policiesSelector(policies: OnyxCollection): OnyxCollection> { @@ -67,21 +66,9 @@ const useFilterFormValues = (queryJSON?: SearchQueryJSON) => { // Helps to avoid unnecessary recalculations when user open report details screen. React Compiler does not provide same result. const taxRates = getAllTaxRates(policies); const allCards = mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList); - const {exportedToFilterOptions} = useExportedToFilterOptions(); const formValues = queryJSON - ? buildFilterFormValuesFromQuery( - queryJSON, - policyCategories, - currencyList, - personalDetails, - allCards, - allReports, - taxRates, - exportedToFilterOptions, - currentUserPersonalDetails.accountID, - bankAccountList, - ) + ? buildFilterFormValuesFromQuery(queryJSON, policyCategories, currencyList, personalDetails, allCards, allReports, taxRates, currentUserPersonalDetails.accountID, bankAccountList) : getEmptyObject>(); return formValues; diff --git a/src/languages/de.ts b/src/languages/de.ts index 263e7e84dc84..f9489b4cdd32 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -11721,6 +11721,8 @@ Fügen Sie weitere Ausgabelimits hinzu, um den Cashflow Ihres Unternehmens zu sc description: 'Wow, das sind aber viele Elemente! Wir bündeln sie, und Concierge schickt dir in Kürze eine Datei.', }, exportedTo: 'Exportiert nach', + exportIntegrationAccessibilityLabel: (name: string) => `${name}, Integration`, + exportTemplateAccessibilityLabel: (name: string) => `${name}, Exportvorlage`, exportAll: { selectAllMatchingItems: 'Alle passenden Einträge auswählen', allMatchingItemsSelected: 'Alle passenden Elemente ausgewählt', diff --git a/src/languages/el.ts b/src/languages/el.ts index f9448d5688eb..dcb9fee6df70 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -11940,6 +11940,8 @@ ${reportName}`, description: 'Ουάου, αυτά είναι πολλά στοιχεία! Θα τα συγκεντρώσουμε και ο Concierge θα σας στείλει σύντομα ένα αρχείο.', }, exportedTo: 'Εξήχθη σε', + exportIntegrationAccessibilityLabel: (name: string) => `${name}, ενσωμάτωση`, + exportTemplateAccessibilityLabel: (name: string) => `${name}, πρότυπο εξαγωγής`, exportAll: { selectAllMatchingItems: 'Επιλέξτε όλα τα στοιχεία που ταιριάζουν', allMatchingItemsSelected: 'Έχουν επιλεγεί όλα τα στοιχεία που ταιριάζουν', diff --git a/src/languages/en.ts b/src/languages/en.ts index d4b3df17acc2..b751b333a365 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -12139,6 +12139,10 @@ const translations = { description: "Whoa, that's a lot of items! We'll bundle them up, and Concierge will send you a file shortly.", }, exportedTo: 'Exported to', + // @context Screen reader label for an accounting integration destination. The name is a product name such as NetSuite. + exportIntegrationAccessibilityLabel: (name: string) => `${name}, integration`, + // @context Screen reader label for a saved CSV export template. “Export template” is the noun for a reusable file format, never an instruction to export a template. + exportTemplateAccessibilityLabel: (name: string) => `${name}, export template`, exportAll: { selectAllMatchingItems: 'Select all matching items', allMatchingItemsSelected: 'All matching items selected', diff --git a/src/languages/es.ts b/src/languages/es.ts index 3660b73c7595..7d2904b5764d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -11638,6 +11638,8 @@ ${reportName}`, description: '¡Wow, esos son muchos elementos! Los agruparemos y Concierge te enviará un archivo en breve.', }, exportedTo: 'Exported to', + exportIntegrationAccessibilityLabel: (name: string) => `${name}, integración`, + exportTemplateAccessibilityLabel: (name: string) => `${name}, plantilla de exportación`, exportAll: { selectAllMatchingItems: 'Seleccionar todos los elementos coincidentes', allMatchingItemsSelected: 'Todos los elementos coincidentes seleccionados', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 439d2c810f0d..1bdb11c1f586 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -11751,6 +11751,8 @@ Ajoutez davantage de règles de dépenses pour protéger la trésorerie de l’e description: 'Ouah, ça fait beaucoup d’éléments ! Nous allons les regrouper et Concierge vous enverra un fichier sous peu.', }, exportedTo: 'Exporté vers', + exportIntegrationAccessibilityLabel: (name: string) => `${name}, intégration`, + exportTemplateAccessibilityLabel: (name: string) => `${name}, modèle d’export csv`, exportAll: { selectAllMatchingItems: 'Sélectionnez tous les éléments correspondants', allMatchingItemsSelected: 'Tous les éléments correspondants sont sélectionnés', diff --git a/src/languages/it.ts b/src/languages/it.ts index c837a24a05e7..39f43a376cac 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -11667,6 +11667,8 @@ Aggiungi altre regole di spesa per proteggere il flusso di cassa aziendale.`, description: 'Wow, sono davvero tanti elementi! Li raggrupperemo e Concierge ti invierà un file a breve.', }, exportedTo: 'Esportato in', + exportIntegrationAccessibilityLabel: (name: string) => `${name}, integrazione`, + exportTemplateAccessibilityLabel: (name: string) => `${name}, modello di esportazione`, exportAll: { selectAllMatchingItems: 'Seleziona tutti gli elementi corrispondenti', allMatchingItemsSelected: 'Tutti gli elementi corrispondenti selezionati', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index d2504ebe0824..a3acfa8ea3f1 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -11479,6 +11479,8 @@ ${reportName}`, description: 'おっと、アイテムがたくさんありますね!まとめて整理して、間もなくConciergeからファイルをお送りします。', }, exportedTo: 'エクスポート先', + exportIntegrationAccessibilityLabel: (name: string) => `${name}、インテグレーション`, + exportTemplateAccessibilityLabel: (name: string) => `${name}、エクスポートテンプレート`, exportAll: {selectAllMatchingItems: '一致する項目をすべて選択', allMatchingItemsSelected: '一致する項目をすべて選択済み', selectAllOnThisPage: 'このページのすべてを選択'}, errors: { pleaseSelectDatesForBothFromAndTo: '開始日と終了日の両方を選択してください', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index b7d284ceab95..a015cc2f075f 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -11615,6 +11615,8 @@ er bestedingsregels toe om de kasstroom van het bedrijf te beschermen.`, description: 'Wow, dat zijn veel items! We bundelen ze, en Concierge stuurt je binnenkort een bestand.', }, exportedTo: 'Geëxporteerd naar', + exportIntegrationAccessibilityLabel: (name: string) => `${name}, integratie`, + exportTemplateAccessibilityLabel: (name: string) => `${name}, exportsjabloon`, exportAll: { selectAllMatchingItems: 'Selecteer alle overeenkomende items', allMatchingItemsSelected: 'Alle overeenkomende items geselecteerd', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index bb58cc0c1ed5..719f945c6936 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -11693,6 +11693,8 @@ Dodaj więcej zasad wydatków, żeby chronić płynność finansową firmy.`, description: 'Wow, ale dużo pozycji! Spakujemy je, a Concierge wkrótce wyśle Ci plik.', }, exportedTo: 'Wyeksportowano do', + exportIntegrationAccessibilityLabel: (name: string) => `${name}, integracja`, + exportTemplateAccessibilityLabel: (name: string) => `${name}, szablon eksportu`, exportAll: { selectAllMatchingItems: 'Zaznacz wszystkie pasujące elementy', allMatchingItemsSelected: 'Zaznaczono wszystkie pasujące elementy', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 84fbb4e4a56a..1f45b907c71d 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -11623,6 +11623,8 @@ Adicione mais regras de gasto para proteger o fluxo de caixa da empresa.`, description: 'Uau, são muitos itens! Vamos agrupá-los e o Concierge enviará um arquivo para você em breve.', }, exportedTo: 'Exportado para', + exportIntegrationAccessibilityLabel: (name: string) => `${name}, integração`, + exportTemplateAccessibilityLabel: (name: string) => `${name}, modelo de exportação`, exportAll: { selectAllMatchingItems: 'Selecionar todos os itens correspondentes', allMatchingItemsSelected: 'Todos os itens correspondentes selecionados', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 83c6aa53e4ed..8f0cafa0db62 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -11182,6 +11182,8 @@ ${reportName}`, description: '哇,项目真不少!我们会把它们打包好,Concierge 很快就会给你发送一个文件。', }, exportedTo: '已导出到', + exportIntegrationAccessibilityLabel: (name: string) => `${name},集成`, + exportTemplateAccessibilityLabel: (name: string) => `${name},导出模板`, exportAll: {selectAllMatchingItems: '选择所有匹配的项目', allMatchingItemsSelected: '已选择所有匹配的项目', selectAllOnThisPage: '选择本页全部内容'}, errors: { pleaseSelectDatesForBothFromAndTo: '请选择起始和结束日期', diff --git a/src/libs/AccountingUtils.ts b/src/libs/AccountingUtils.ts index a110a77ac0a6..8b90940a9d73 100644 --- a/src/libs/AccountingUtils.ts +++ b/src/libs/AccountingUtils.ts @@ -58,6 +58,34 @@ const STANDARD_EXPORT_TEMPLATE_NAME_MAPPING = { const STANDARD_EXPORT_TEMPLATE_LABELS = new Set(Object.values(STANDARD_EXPORT_TEMPLATE_NAME_MAPPING)); +const CONNECTION_NAME_BY_EXPORT_LABEL = new Map([ + ...CONST.POLICY.CONNECTIONS.ACCOUNTING_CONNECTION_NAMES.map((name) => [getExportLabelForConnection(name).toLowerCase(), name] as const), + [CONST.EXPORT_LABELS.NETSUITE_QUICKSTART.toLowerCase(), CONST.POLICY.CONNECTIONS.NAME.NETSUITE], + [CONST.EXPORT_LABELS.INTACCT.toLowerCase(), CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT], + [CONST.EXPORT_LABELS.CERTINIA.toLowerCase(), CONST.POLICY.CONNECTIONS.NAME.CERTINIA], + [CONST.EXPORT_LABELS.INTUIT_ENTERPRISE_SUITE.toLowerCase(), CONST.POLICY.CONNECTIONS.NAME.QBO], +]); + +const EXPORT_TEMPLATE_SEARCH_PREFIX = 'template:'; +const ACCOUNTING_EXPORT_SEARCH_VALUES = new Set( + [...Object.values(CONST.EXPORT_LABELS), ...CONST.POLICY.CONNECTIONS.EXPORTED_TO_INTEGRATION_DISPLAY_NAMES, CONST.SEARCH.COUNT_EXPORT_LABEL].map((label) => label.toLowerCase()), +); + +/** Returns a picker ID distinct from accounting destinations, even for identical names. */ +function getExportTemplateSearchValue(label: string): string { + return `${EXPORT_TEMPLATE_SEARCH_PREFIX}${label}`; +} + +/** Maps a query destination to its picker ID, preserving literal names in existing searches. */ +function getExportedToPickerValue(label: string, isTemplate: boolean): string { + return !isTemplate && ACCOUNTING_EXPORT_SEARCH_VALUES.has(label.toLowerCase()) ? label : getExportTemplateSearchValue(label); +} + +/** Returns the recorded template name without its Search discriminator. */ +function getExportedToDisplayName(value: string): string { + return value.startsWith(EXPORT_TEMPLATE_SEARCH_PREFIX) ? value.slice(EXPORT_TEMPLATE_SEARCH_PREFIX.length) : value; +} + function getConnectionNameFromRouteParam(routeParam: ValueOf) { return ROUTE_NAME_MAPPING[routeParam]; } @@ -73,6 +101,10 @@ function getExportLabelForConnection(connectionName: ConnectionName, policy?: On return CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]; } +function getConnectionNameFromExportLabel(label: string): ConnectionName | undefined { + return CONNECTION_NAME_BY_EXPORT_LABEL.get(label.toLowerCase()); +} + function getExportLabelsForConnection(connectionName: ConnectionName, policies: Array>): string[] { const connectionPolicies = policies.filter((policy) => !!policy?.connections?.[connectionName]); if (connectionPolicies.length === 0) { @@ -142,7 +174,12 @@ function isStandardExportTemplateLabel(label: string): boolean { } export { + EXPORT_TEMPLATE_SEARCH_PREFIX, + getExportTemplateSearchValue, + getExportedToDisplayName, + getExportedToPickerValue, getAccountingIntegrationDisplayName, + getConnectionNameFromExportLabel, getConnectionNameFromRouteParam, getExportLabelForConnection, getExportLabelsForConnection, diff --git a/src/libs/SearchAutocompleteUtils.ts b/src/libs/SearchAutocompleteUtils.ts index eb1c854c214d..f164f33ff8cf 100644 --- a/src/libs/SearchAutocompleteUtils.ts +++ b/src/libs/SearchAutocompleteUtils.ts @@ -8,11 +8,18 @@ import type {Policy, PolicyCategories, PolicyTagLists, RecentlyUsedCategories, R import type {MarkdownRange} from '@expensify/react-native-live-markdown'; import type {OnyxCollection} from 'react-native-onyx'; +import {EXPORT_TEMPLATE_SEARCH_PREFIX, getExportedToDisplayName} from './AccountingUtils'; import {getTagNamesFromTagsLists} from './PolicyUtils'; import {parse} from './SearchParser/autocompleteParser'; -import {getUserFriendlyKey, getUserFriendlyValue, isGroupBySupportedBySearch, resolvePolicyIDFromName} from './SearchQueryUtils'; +import {getUserFriendlyKey, getUserFriendlyValue, isGroupBySupportedBySearch, resolvePolicyIDFromName, sanitizeSearchValue} from './SearchQueryUtils'; +import StringUtils from './StringUtils'; + +const exportedToKeyPattern = [CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO, CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO].map(StringUtils.escapeRegExp).join('|'); +const EXPORTED_TO_HEADER = new RegExp(String.raw`(?:${exportedToKeyPattern})\s*(!=|[:=])\s*$`, 'i'); const CONTINUATION_DETECTION_SEARCH_FILTER_KEYS: SearchFilterKey[] = [ + CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, + CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE, CONST.SEARCH.SYNTAX_FILTER_KEYS.TO, CONST.SEARCH.SYNTAX_FILTER_KEYS.FROM, CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVER, @@ -369,8 +376,10 @@ function filterOutRangesWithCorrectValue( case CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE: case CONST.SEARCH.SYNTAX_FILTER_KEYS.VENDOR: return range.value.length > 0; + case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE: + return range.value.length > 0; case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO: - return knownValues.exportedTo.has(range.value); + return knownValues.exportedTo.has(range.value) || knownValues.exportedTo.has(`${EXPORT_TEMPLATE_SEARCH_PREFIX}${range.value}`); case CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID: case CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_ID: case CONST.SEARCH.SYNTAX_FILTER_KEYS.TRANSACTION_ID: @@ -438,6 +447,14 @@ function getTrimmedUserSearchQueryPreservingComma(textInputValue: string, fieldK return getQueryWithoutAutocompletedPart(textInputValue); } + if (fieldKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO || fieldKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE) { + const parsedQuery = parseForAutocomplete(textInputValue); + const activeRange = parsedQuery?.autocomplete ?? parsedQuery?.ranges.at(-1); + + // Parser ranges distinguish commas inside quoted template names from value separators. + return activeRange?.key === fieldKey ? textInputValue.slice(0, activeRange.start) : getQueryWithoutAutocompletedPart(textInputValue); + } + const nameFieldKey = CONTINUATION_DETECTION_SEARCH_FILTER_KEYS.find((key) => key === fieldKey); if (nameFieldKey) { @@ -468,7 +485,44 @@ function getTrimmedUserSearchQueryPreservingComma(textInputValue: string, fieldK return keyIndex !== -1 ? textInputValue.substring(0, keyIndex + fieldKey.length + 1) : getQueryWithoutAutocompletedPart(textInputValue); } +/** Builds the query after choosing an autocomplete destination, preserving literal template names. */ +function getQueryWithAutocompleteSelection(textInputValue: string, fieldKey: string | undefined, selectedValue: string): string { + let queryPrefix = getTrimmedUserSearchQueryPreservingComma(textInputValue, fieldKey); + let value = selectedValue; + if (fieldKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO && selectedValue.startsWith(EXPORT_TEMPLATE_SEARCH_PREFIX)) { + value = getExportedToDisplayName(selectedValue); + const templateKey = CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO_TEMPLATE; + const headerMatch = queryPrefix.match(EXPORTED_TO_HEADER); + // Template values use a separate key so an existing name beginning with "template:" stays literal. + if (headerMatch) { + queryPrefix = queryPrefix.replace(EXPORTED_TO_HEADER, `${templateKey}${headerMatch[1] === '!=' ? '!=' : ':'}`); + } else { + const parsedQuery = parseForAutocomplete(textInputValue); + const activeRange = parsedQuery?.autocomplete ?? parsedQuery?.ranges.at(-1); + const ranges = parsedQuery?.ranges ?? []; + let firstValueStart = activeRange?.start ?? queryPrefix.length; + + // Comma-separated destinations share the operator before the first value. + for (let index = ranges.length - 1; index >= 0; index--) { + const range = ranges[index]; + if (!range || range.start >= firstValueStart) { + continue; + } + if (range.key !== fieldKey || textInputValue.slice(range.start + range.length, firstValueStart).trim() !== ',') { + break; + } + firstValueStart = range.start; + } + const operator = textInputValue.slice(0, firstValueStart).match(EXPORTED_TO_HEADER)?.[1] === '!=' ? '!=' : ':'; + const negation = activeRange?.negated ? CONST.SEARCH.NOT_PREFIX : ''; + queryPrefix = `${queryPrefix.replace(/,\s*$/, '')} ${negation}${templateKey}${operator}`; + } + } + return `${queryPrefix}${sanitizeSearchValue(value)}\u00A0`; +} + export { + getQueryWithAutocompleteSelection, CONTINUATION_DETECTION_SEARCH_FILTER_KEYS, getAutocompleteCategories, getAutocompletePolicyData, diff --git a/src/libs/SearchParser/autocompleteParser.js b/src/libs/SearchParser/autocompleteParser.js index 057eae0d34ed..575a2dc619c2 100644 --- a/src/libs/SearchParser/autocompleteParser.js +++ b/src/libs/SearchParser/autocompleteParser.js @@ -301,52 +301,54 @@ function peg$parse(input, options) { var peg$c115 = "category-gl-code"; var peg$c116 = "tag-gl-code"; var peg$c117 = "long-report-id"; - var peg$c118 = "exported-to"; - var peg$c119 = "exportedto"; - var peg$c120 = "exchange-rate"; - var peg$c121 = "reimbursable-total"; - var peg$c122 = "non-reimbursable-total"; - var peg$c123 = "group-from"; - var peg$c124 = "group-expenses"; - var peg$c125 = "group-total"; - var peg$c126 = "group-card"; - var peg$c127 = "group-feed"; - var peg$c128 = "group-bank-account"; - var peg$c129 = "group-withdrawn"; - var peg$c130 = "group-withdrawal-id"; - var peg$c131 = "group-withdrawal-status"; - var peg$c132 = "group-amount-debited"; - var peg$c133 = "group-amount-reimbursed"; - var peg$c134 = "group-category"; - var peg$c135 = "group-tag"; - var peg$c136 = "group-merchant"; - var peg$c137 = "group-day"; - var peg$c138 = "group-month"; - var peg$c139 = "group-week"; - var peg$c140 = "group-year"; - var peg$c141 = "group-quarter"; - var peg$c142 = "group-approver"; - var peg$c143 = "group-violation"; - var peg$c144 = "*:"; - var peg$c145 = "!="; - var peg$c146 = ">="; - var peg$c147 = ">"; - var peg$c148 = "<="; - var peg$c149 = "<"; - var peg$c150 = "\\"; - var peg$c151 = "\u201C"; - var peg$c152 = "\u201D"; - var peg$c153 = "\""; - var peg$c154 = "footercount"; - var peg$c155 = "footer-count"; - var peg$c156 = "footercurrency"; - var peg$c157 = "footer-currency"; - var peg$c158 = "footertotal"; - var peg$c159 = "footer-total"; - var peg$c160 = "leftpinnedcolumns"; - var peg$c161 = "left-pinned-columns"; - var peg$c162 = "rightpinnedcolumns"; - var peg$c163 = "right-pinned-columns"; + var peg$c118 = "exportedtotemplate"; + var peg$c119 = "exported-to-template"; + var peg$c120 = "exported-to"; + var peg$c121 = "!="; + var peg$c122 = "exportedto"; + var peg$c123 = "exchange-rate"; + var peg$c124 = "reimbursable-total"; + var peg$c125 = "non-reimbursable-total"; + var peg$c126 = "group-from"; + var peg$c127 = "group-expenses"; + var peg$c128 = "group-total"; + var peg$c129 = "group-card"; + var peg$c130 = "group-feed"; + var peg$c131 = "group-bank-account"; + var peg$c132 = "group-withdrawn"; + var peg$c133 = "group-withdrawal-id"; + var peg$c134 = "group-withdrawal-status"; + var peg$c135 = "group-amount-debited"; + var peg$c136 = "group-amount-reimbursed"; + var peg$c137 = "group-category"; + var peg$c138 = "group-tag"; + var peg$c139 = "group-merchant"; + var peg$c140 = "group-day"; + var peg$c141 = "group-month"; + var peg$c142 = "group-week"; + var peg$c143 = "group-year"; + var peg$c144 = "group-quarter"; + var peg$c145 = "group-approver"; + var peg$c146 = "group-violation"; + var peg$c147 = "*:"; + var peg$c148 = ">="; + var peg$c149 = ">"; + var peg$c150 = "<="; + var peg$c151 = "<"; + var peg$c152 = "\\"; + var peg$c153 = "\u201C"; + var peg$c154 = "\u201D"; + var peg$c155 = "\""; + var peg$c156 = "footercount"; + var peg$c157 = "footer-count"; + var peg$c158 = "footercurrency"; + var peg$c159 = "footer-currency"; + var peg$c160 = "footertotal"; + var peg$c161 = "footer-total"; + var peg$c162 = "leftpinnedcolumns"; + var peg$c163 = "left-pinned-columns"; + var peg$c164 = "rightpinnedcolumns"; + var peg$c165 = "right-pinned-columns"; var peg$r0 = /^[ \t\r\n\xA0,:=<>!]/; var peg$r1 = /^[:=]/; @@ -484,69 +486,71 @@ function peg$parse(input, options) { var peg$e118 = peg$literalExpectation("category-gl-code", true); var peg$e119 = peg$literalExpectation("tag-gl-code", true); var peg$e120 = peg$literalExpectation("long-report-id", true); - var peg$e121 = peg$literalExpectation("exported-to", true); - var peg$e122 = peg$classExpectation([":", "="], false, false); - var peg$e123 = peg$literalExpectation("exportedTo", true); - var peg$e124 = peg$literalExpectation("exchange-rate", true); - var peg$e125 = peg$literalExpectation("reimbursable-total", true); - var peg$e126 = peg$literalExpectation("non-reimbursable-total", true); - var peg$e127 = peg$literalExpectation("group-from", true); - var peg$e128 = peg$literalExpectation("group-expenses", true); - var peg$e129 = peg$literalExpectation("group-total", true); - var peg$e130 = peg$literalExpectation("group-card", true); - var peg$e131 = peg$literalExpectation("group-feed", true); - var peg$e132 = peg$literalExpectation("group-bank-account", true); - var peg$e133 = peg$literalExpectation("group-withdrawn", true); - var peg$e134 = peg$literalExpectation("group-withdrawal-id", true); - var peg$e135 = peg$literalExpectation("group-withdrawal-status", true); - var peg$e136 = peg$literalExpectation("group-amount-debited", true); - var peg$e137 = peg$literalExpectation("group-amount-reimbursed", true); - var peg$e138 = peg$literalExpectation("group-category", true); - var peg$e139 = peg$literalExpectation("group-tag", true); - var peg$e140 = peg$literalExpectation("group-merchant", true); - var peg$e141 = peg$literalExpectation("group-day", true); - var peg$e142 = peg$literalExpectation("group-month", true); - var peg$e143 = peg$literalExpectation("group-week", true); - var peg$e144 = peg$literalExpectation("group-year", true); - var peg$e145 = peg$literalExpectation("group-quarter", true); - var peg$e146 = peg$literalExpectation("group-approver", true); - var peg$e147 = peg$literalExpectation("group-violation", true); - var peg$e148 = peg$otherExpectation("operator"); - var peg$e149 = peg$literalExpectation("*:", false); - var peg$e150 = peg$literalExpectation("!=", false); - var peg$e151 = peg$literalExpectation(">=", false); - var peg$e152 = peg$literalExpectation(">", false); - var peg$e153 = peg$literalExpectation("<=", false); - var peg$e154 = peg$literalExpectation("<", false); - var peg$e155 = peg$literalExpectation("\\", false); - var peg$e156 = peg$classExpectation([",", "\"", "\u201D", "\u201C", "\\"], false, false); - var peg$e157 = peg$otherExpectation("word"); - var peg$e158 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e159 = peg$otherExpectation("whitespace"); - var peg$e160 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e161 = peg$otherExpectation("quote"); - var peg$e162 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e163 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e164 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e165 = peg$literalExpectation("\u201C", false); - var peg$e166 = peg$literalExpectation("\u201D", false); - var peg$e167 = peg$literalExpectation("\"", false); - var peg$e168 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e169 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e170 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e171 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e172 = peg$classExpectation([","], false, false); - var peg$e173 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); - var peg$e174 = peg$literalExpectation("footerCount", true); - var peg$e175 = peg$literalExpectation("footer-count", true); - var peg$e176 = peg$literalExpectation("footerCurrency", true); - var peg$e177 = peg$literalExpectation("footer-currency", true); - var peg$e178 = peg$literalExpectation("footerTotal", true); - var peg$e179 = peg$literalExpectation("footer-total", true); - var peg$e180 = peg$literalExpectation("leftPinnedColumns", true); - var peg$e181 = peg$literalExpectation("left-pinned-columns", true); - var peg$e182 = peg$literalExpectation("rightPinnedColumns", true); - var peg$e183 = peg$literalExpectation("right-pinned-columns", true); + var peg$e121 = peg$literalExpectation("exportedToTemplate", true); + var peg$e122 = peg$literalExpectation("exported-to-template", true); + var peg$e123 = peg$literalExpectation("exported-to", true); + var peg$e124 = peg$classExpectation([":", "="], false, false); + var peg$e125 = peg$literalExpectation("!=", false); + var peg$e126 = peg$literalExpectation("exportedTo", true); + var peg$e127 = peg$literalExpectation("exchange-rate", true); + var peg$e128 = peg$literalExpectation("reimbursable-total", true); + var peg$e129 = peg$literalExpectation("non-reimbursable-total", true); + var peg$e130 = peg$literalExpectation("group-from", true); + var peg$e131 = peg$literalExpectation("group-expenses", true); + var peg$e132 = peg$literalExpectation("group-total", true); + var peg$e133 = peg$literalExpectation("group-card", true); + var peg$e134 = peg$literalExpectation("group-feed", true); + var peg$e135 = peg$literalExpectation("group-bank-account", true); + var peg$e136 = peg$literalExpectation("group-withdrawn", true); + var peg$e137 = peg$literalExpectation("group-withdrawal-id", true); + var peg$e138 = peg$literalExpectation("group-withdrawal-status", true); + var peg$e139 = peg$literalExpectation("group-amount-debited", true); + var peg$e140 = peg$literalExpectation("group-amount-reimbursed", true); + var peg$e141 = peg$literalExpectation("group-category", true); + var peg$e142 = peg$literalExpectation("group-tag", true); + var peg$e143 = peg$literalExpectation("group-merchant", true); + var peg$e144 = peg$literalExpectation("group-day", true); + var peg$e145 = peg$literalExpectation("group-month", true); + var peg$e146 = peg$literalExpectation("group-week", true); + var peg$e147 = peg$literalExpectation("group-year", true); + var peg$e148 = peg$literalExpectation("group-quarter", true); + var peg$e149 = peg$literalExpectation("group-approver", true); + var peg$e150 = peg$literalExpectation("group-violation", true); + var peg$e151 = peg$otherExpectation("operator"); + var peg$e152 = peg$literalExpectation("*:", false); + var peg$e153 = peg$literalExpectation(">=", false); + var peg$e154 = peg$literalExpectation(">", false); + var peg$e155 = peg$literalExpectation("<=", false); + var peg$e156 = peg$literalExpectation("<", false); + var peg$e157 = peg$literalExpectation("\\", false); + var peg$e158 = peg$classExpectation([",", "\"", "\u201D", "\u201C", "\\"], false, false); + var peg$e159 = peg$otherExpectation("word"); + var peg$e160 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e161 = peg$otherExpectation("whitespace"); + var peg$e162 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e163 = peg$otherExpectation("quote"); + var peg$e164 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e165 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e166 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e167 = peg$literalExpectation("\u201C", false); + var peg$e168 = peg$literalExpectation("\u201D", false); + var peg$e169 = peg$literalExpectation("\"", false); + var peg$e170 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e171 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e172 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e173 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e174 = peg$classExpectation([","], false, false); + var peg$e175 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e176 = peg$literalExpectation("footerCount", true); + var peg$e177 = peg$literalExpectation("footer-count", true); + var peg$e178 = peg$literalExpectation("footerCurrency", true); + var peg$e179 = peg$literalExpectation("footer-currency", true); + var peg$e180 = peg$literalExpectation("footerTotal", true); + var peg$e181 = peg$literalExpectation("footer-total", true); + var peg$e182 = peg$literalExpectation("leftPinnedColumns", true); + var peg$e183 = peg$literalExpectation("left-pinned-columns", true); + var peg$e184 = peg$literalExpectation("rightPinnedColumns", true); + var peg$e185 = peg$literalExpectation("right-pinned-columns", true); var peg$f0 = function(ranges) { return { autocomplete, ranges }; }; var peg$f1 = function(filters) { return filters.filter(Boolean).flat(); }; @@ -717,76 +721,78 @@ function peg$parse(input, options) { var peg$f96 = function() { return "bankAccount"; }; var peg$f97 = function() { return "reportID"; }; var peg$f98 = function() { return "base62ReportID"; }; - var peg$f99 = function() { return "transactionID"; }; - var peg$f100 = function() { return "exportedto"; }; - var peg$f101 = function() { return "exportedTo"; }; - var peg$f102 = function() { return "exportedTo"; }; - var peg$f103 = function() { return "exchangeRate"; }; - var peg$f104 = function() { return "reimbursableTotal"; }; - var peg$f105 = function() { return "nonReimbursableTotal"; }; - var peg$f106 = function() { return "groupFrom"; }; - var peg$f107 = function() { return "groupExpenses"; }; - var peg$f108 = function() { return "groupTotal"; }; - var peg$f109 = function() { return "groupCard"; }; - var peg$f110 = function() { return "groupFeed"; }; - var peg$f111 = function() { return "groupBankAccount"; }; - var peg$f112 = function() { return "groupWithdrawn"; }; - var peg$f113 = function() { return "groupWithdrawalID"; }; - var peg$f114 = function() { return "groupWithdrawalStatus"; }; - var peg$f115 = function() { return "groupAmountDebited"; }; - var peg$f116 = function() { return "groupAmountReimbursed"; }; - var peg$f117 = function() { return "amountDebited"; }; - var peg$f118 = function() { return "amountReimbursed"; }; - var peg$f119 = function() { return "groupCategory"; }; - var peg$f120 = function() { return "groupTag"; }; - var peg$f121 = function() { return "groupMerchant"; }; - var peg$f122 = function() { return "groupday"; }; - var peg$f123 = function() { return "groupmonth"; }; - var peg$f124 = function() { return "groupweek"; }; - var peg$f125 = function() { return "groupyear"; }; - var peg$f126 = function() { return "groupquarter"; }; - var peg$f127 = function() { return "groupApprover"; }; - var peg$f128 = function() { return "groupViolation"; }; - var peg$f129 = function() { return "contains"; }; - var peg$f130 = function() { return "eq"; }; - var peg$f131 = function() { return "neq"; }; - var peg$f132 = function() { return "gte"; }; - var peg$f133 = function() { return "gt"; }; - var peg$f134 = function() { return "lte"; }; - var peg$f135 = function() { return "lt"; }; - var peg$f136 = function(o) { + var peg$f99 = function() { return "exportedToTemplate"; }; + var peg$f100 = function() { return "exportedToTemplate"; }; + var peg$f101 = function() { return "transactionID"; }; + var peg$f102 = function() { return "exportedto"; }; + var peg$f103 = function() { return "exportedTo"; }; + var peg$f104 = function() { return "exportedTo"; }; + var peg$f105 = function() { return "exchangeRate"; }; + var peg$f106 = function() { return "reimbursableTotal"; }; + var peg$f107 = function() { return "nonReimbursableTotal"; }; + var peg$f108 = function() { return "groupFrom"; }; + var peg$f109 = function() { return "groupExpenses"; }; + var peg$f110 = function() { return "groupTotal"; }; + var peg$f111 = function() { return "groupCard"; }; + var peg$f112 = function() { return "groupFeed"; }; + var peg$f113 = function() { return "groupBankAccount"; }; + var peg$f114 = function() { return "groupWithdrawn"; }; + var peg$f115 = function() { return "groupWithdrawalID"; }; + var peg$f116 = function() { return "groupWithdrawalStatus"; }; + var peg$f117 = function() { return "groupAmountDebited"; }; + var peg$f118 = function() { return "groupAmountReimbursed"; }; + var peg$f119 = function() { return "amountDebited"; }; + var peg$f120 = function() { return "amountReimbursed"; }; + var peg$f121 = function() { return "groupCategory"; }; + var peg$f122 = function() { return "groupTag"; }; + var peg$f123 = function() { return "groupMerchant"; }; + var peg$f124 = function() { return "groupday"; }; + var peg$f125 = function() { return "groupmonth"; }; + var peg$f126 = function() { return "groupweek"; }; + var peg$f127 = function() { return "groupyear"; }; + var peg$f128 = function() { return "groupquarter"; }; + var peg$f129 = function() { return "groupApprover"; }; + var peg$f130 = function() { return "groupViolation"; }; + var peg$f131 = function() { return "contains"; }; + var peg$f132 = function() { return "eq"; }; + var peg$f133 = function() { return "neq"; }; + var peg$f134 = function() { return "gte"; }; + var peg$f135 = function() { return "gt"; }; + var peg$f136 = function() { return "lte"; }; + var peg$f137 = function() { return "lt"; }; + var peg$f138 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq" || o === "contains"); } isColumnsContext = false; return o; }; - var peg$f137 = function(c) { return c; }; - var peg$f138 = function(chars) { return chars.join("").trim(); }; - var peg$f139 = function() { + var peg$f139 = function(c) { return c; }; + var peg$f140 = function(chars) { return chars.join("").trim(); }; + var peg$f141 = function() { isColumnsContext = false; isExpenseTypeContext = false; isStatusContext = false; return "and"; }; - var peg$f140 = function() { return expectingNestedQuote; }; - var peg$f141 = function(start, inner, end) { //handle no-breaking space + var peg$f142 = function() { return expectingNestedQuote; }; + var peg$f143 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f142 = function(start) {return "“"}; - var peg$f143 = function(start) {return "”"}; - var peg$f144 = function(start) {return "\""}; - var peg$f145 = function(start, inner, end) { + var peg$f144 = function(start) {return "“"}; + var peg$f145 = function(start) {return "”"}; + var peg$f146 = function(start) {return "\""}; + var peg$f147 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; - var peg$f146 = function() { return "footerCount"; }; - var peg$f147 = function() { return "footerCurrency"; }; - var peg$f148 = function() { return "footerTotal"; }; - var peg$f149 = function() { + var peg$f148 = function() { return "footerCount"; }; + var peg$f149 = function() { return "footerCurrency"; }; + var peg$f150 = function() { return "footerTotal"; }; + var peg$f151 = function() { isColumnsContext = true; return "leftPinnedColumns"; }; - var peg$f150 = function() { + var peg$f152 = function() { isColumnsContext = true; return "rightPinnedColumns"; }; @@ -1284,65 +1290,68 @@ function peg$parse(input, options) { if (s1 === peg$FAILED) { s1 = peg$parsepaid(); if (s1 === peg$FAILED) { - s1 = peg$parseexportedTo(); + s1 = peg$parseexportedToTemplate(); if (s1 === peg$FAILED) { - s1 = peg$parseexported(); + s1 = peg$parseexportedTo(); if (s1 === peg$FAILED) { - s1 = peg$parsewithdrawn(); + s1 = peg$parseexported(); if (s1 === peg$FAILED) { - s1 = peg$parseposted(); + s1 = peg$parsewithdrawn(); if (s1 === peg$FAILED) { - s1 = peg$parsehas(); + s1 = peg$parseposted(); if (s1 === peg$FAILED) { - s1 = peg$parseis(); + s1 = peg$parsehas(); if (s1 === peg$FAILED) { - s1 = peg$parsepurchaseCurrency(); + s1 = peg$parseis(); if (s1 === peg$FAILED) { - s1 = peg$parseconvertedAmount(); + s1 = peg$parsepurchaseCurrency(); if (s1 === peg$FAILED) { - s1 = peg$parsepurchaseAmount(); + s1 = peg$parseconvertedAmount(); if (s1 === peg$FAILED) { - s1 = peg$parseamountDebited(); + s1 = peg$parsepurchaseAmount(); if (s1 === peg$FAILED) { - s1 = peg$parseamountReimbursed(); + s1 = peg$parseamountDebited(); if (s1 === peg$FAILED) { - s1 = peg$parseamount(); + s1 = peg$parseamountReimbursed(); if (s1 === peg$FAILED) { - s1 = peg$parsemerchant(); + s1 = peg$parseamount(); if (s1 === peg$FAILED) { - s1 = peg$parsedescription(); + s1 = peg$parsemerchant(); if (s1 === peg$FAILED) { - s1 = peg$parsereportID(); + s1 = peg$parsedescription(); if (s1 === peg$FAILED) { - s1 = peg$parsetransactionID(); + s1 = peg$parsereportID(); if (s1 === peg$FAILED) { - s1 = peg$parsewithdrawalID(); + s1 = peg$parsetransactionID(); if (s1 === peg$FAILED) { - s1 = peg$parsetitle(); + s1 = peg$parsewithdrawalID(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitterUserID(); + s1 = peg$parsetitle(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitterPayrollID(); + s1 = peg$parsesubmitterUserID(); if (s1 === peg$FAILED) { - s1 = peg$parseorderDealNumbers(); + s1 = peg$parsesubmitterPayrollID(); if (s1 === peg$FAILED) { - s1 = peg$parseapprover(); + s1 = peg$parseorderDealNumbers(); if (s1 === peg$FAILED) { - s1 = peg$parsereportFieldDynamic(); + s1 = peg$parseapprover(); if (s1 === peg$FAILED) { - s1 = peg$parsecolumns(); + s1 = peg$parsereportFieldDynamic(); if (s1 === peg$FAILED) { - s1 = peg$parselimit(); + s1 = peg$parsecolumns(); if (s1 === peg$FAILED) { - s1 = peg$parsefooterCount(); + s1 = peg$parselimit(); if (s1 === peg$FAILED) { - s1 = peg$parsefooterCurrency(); + s1 = peg$parsefooterCount(); if (s1 === peg$FAILED) { - s1 = peg$parsefooterTotal(); + s1 = peg$parsefooterCurrency(); if (s1 === peg$FAILED) { - s1 = peg$parseleftPinnedColumns(); + s1 = peg$parsefooterTotal(); if (s1 === peg$FAILED) { - s1 = peg$parserightPinnedColumns(); + s1 = peg$parseleftPinnedColumns(); + if (s1 === peg$FAILED) { + s1 = peg$parserightPinnedColumns(); + } } } } @@ -3991,6 +4000,75 @@ function peg$parse(input, options) { return s0; } + function peg$parseexportedToTemplate() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 18); + if (s1.toLowerCase() === peg$c118) { + peg$currPos += 18; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e121); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseexportedToKeyEnd(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f99(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 20); + if (s1.toLowerCase() === peg$c119) { + peg$currPos += 20; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e122); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseexportedToKeyEnd(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f100(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + function peg$parsetransactionId() { var s0, s1, s2, s3; @@ -4015,7 +4093,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f99(); + s0 = peg$f101(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4033,11 +4111,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c118) { + if (s1.toLowerCase() === peg$c120) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { peg$fail(peg$e123); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4052,7 +4130,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f100(); + s0 = peg$f102(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4077,7 +4155,16 @@ 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$e124); } + } + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c121) { + s2 = peg$c121; + peg$currPos += 2; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e125); } + } } if (s2 !== peg$FAILED) { s1 = [s1, s2]; @@ -4096,11 +4183,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c119) { + if (s1.toLowerCase() === peg$c122) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e126); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4115,7 +4202,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f101(); + s0 = peg$f103(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4127,11 +4214,11 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c118) { + if (s1.toLowerCase() === peg$c120) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } + if (peg$silentFails === 0) { peg$fail(peg$e123); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4146,7 +4233,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f102(); + s0 = peg$f104(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4165,11 +4252,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 13); - if (s1.toLowerCase() === peg$c120) { + if (s1.toLowerCase() === peg$c123) { peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } + if (peg$silentFails === 0) { peg$fail(peg$e127); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4184,7 +4271,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f103(); + s0 = peg$f105(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4202,11 +4289,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c121) { + if (s1.toLowerCase() === peg$c124) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { peg$fail(peg$e128); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4221,7 +4308,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f104(); + s0 = peg$f106(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4239,11 +4326,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 22); - if (s1.toLowerCase() === peg$c122) { + if (s1.toLowerCase() === peg$c125) { peg$currPos += 22; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e126); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4258,7 +4345,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f105(); + s0 = peg$f107(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4276,11 +4363,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c123) { + if (s1.toLowerCase() === peg$c126) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e127); } + if (peg$silentFails === 0) { peg$fail(peg$e130); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4295,7 +4382,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f106(); + s0 = peg$f108(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4313,11 +4400,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c124) { + if (s1.toLowerCase() === peg$c127) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e128); } + if (peg$silentFails === 0) { peg$fail(peg$e131); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4332,7 +4419,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f107(); + s0 = peg$f109(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4350,11 +4437,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c125) { + if (s1.toLowerCase() === peg$c128) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e129); } + if (peg$silentFails === 0) { peg$fail(peg$e132); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4369,7 +4456,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f108(); + s0 = peg$f110(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4387,11 +4474,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c126) { + if (s1.toLowerCase() === peg$c129) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e130); } + if (peg$silentFails === 0) { peg$fail(peg$e133); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4406,7 +4493,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f109(); + s0 = peg$f111(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4424,11 +4511,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c127) { + if (s1.toLowerCase() === peg$c130) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e131); } + if (peg$silentFails === 0) { peg$fail(peg$e134); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4443,7 +4530,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f110(); + s0 = peg$f112(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4461,11 +4548,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c128) { + if (s1.toLowerCase() === peg$c131) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e132); } + if (peg$silentFails === 0) { peg$fail(peg$e135); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4480,7 +4567,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f111(); + s0 = peg$f113(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4498,11 +4585,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 15); - if (s1.toLowerCase() === peg$c129) { + if (s1.toLowerCase() === peg$c132) { peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e133); } + if (peg$silentFails === 0) { peg$fail(peg$e136); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4517,7 +4604,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f112(); + s0 = peg$f114(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4535,11 +4622,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 19); - if (s1.toLowerCase() === peg$c130) { + if (s1.toLowerCase() === peg$c133) { peg$currPos += 19; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e134); } + if (peg$silentFails === 0) { peg$fail(peg$e137); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4554,7 +4641,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f113(); + s0 = peg$f115(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4572,11 +4659,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 23); - if (s1.toLowerCase() === peg$c131) { + if (s1.toLowerCase() === peg$c134) { peg$currPos += 23; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e135); } + if (peg$silentFails === 0) { peg$fail(peg$e138); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4591,7 +4678,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f114(); + s0 = peg$f116(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4609,11 +4696,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 20); - if (s1.toLowerCase() === peg$c132) { + if (s1.toLowerCase() === peg$c135) { peg$currPos += 20; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e136); } + if (peg$silentFails === 0) { peg$fail(peg$e139); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4628,7 +4715,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f115(); + s0 = peg$f117(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4646,11 +4733,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 23); - if (s1.toLowerCase() === peg$c133) { + if (s1.toLowerCase() === peg$c136) { peg$currPos += 23; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e137); } + if (peg$silentFails === 0) { peg$fail(peg$e140); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4665,7 +4752,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f116(); + s0 = peg$f118(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4702,7 +4789,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f117(); + s0 = peg$f119(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4739,7 +4826,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f118(); + s0 = peg$f120(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4757,11 +4844,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c134) { + if (s1.toLowerCase() === peg$c137) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e138); } + if (peg$silentFails === 0) { peg$fail(peg$e141); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4776,7 +4863,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f119(); + s0 = peg$f121(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4794,11 +4881,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 9); - if (s1.toLowerCase() === peg$c135) { + if (s1.toLowerCase() === peg$c138) { peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e139); } + if (peg$silentFails === 0) { peg$fail(peg$e142); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4813,7 +4900,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f120(); + s0 = peg$f122(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4831,11 +4918,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c136) { + if (s1.toLowerCase() === peg$c139) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e140); } + if (peg$silentFails === 0) { peg$fail(peg$e143); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4850,7 +4937,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f121(); + s0 = peg$f123(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4868,11 +4955,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 9); - if (s1.toLowerCase() === peg$c137) { + if (s1.toLowerCase() === peg$c140) { peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e141); } + if (peg$silentFails === 0) { peg$fail(peg$e144); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4887,7 +4974,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f122(); + s0 = peg$f124(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4905,11 +4992,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c138) { + if (s1.toLowerCase() === peg$c141) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e142); } + if (peg$silentFails === 0) { peg$fail(peg$e145); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4924,7 +5011,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f123(); + s0 = peg$f125(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4942,11 +5029,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c139) { + if (s1.toLowerCase() === peg$c142) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e143); } + if (peg$silentFails === 0) { peg$fail(peg$e146); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4961,7 +5048,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f124(); + s0 = peg$f126(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4979,11 +5066,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c140) { + if (s1.toLowerCase() === peg$c143) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e144); } + if (peg$silentFails === 0) { peg$fail(peg$e147); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4998,7 +5085,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f125(); + s0 = peg$f127(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5016,11 +5103,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 13); - if (s1.toLowerCase() === peg$c141) { + if (s1.toLowerCase() === peg$c144) { peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e145); } + if (peg$silentFails === 0) { peg$fail(peg$e148); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5035,7 +5122,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f126(); + s0 = peg$f128(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5053,11 +5140,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c142) { + if (s1.toLowerCase() === peg$c145) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e146); } + if (peg$silentFails === 0) { peg$fail(peg$e149); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5072,7 +5159,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f127(); + s0 = peg$f129(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5090,11 +5177,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 15); - if (s1.toLowerCase() === peg$c143) { + if (s1.toLowerCase() === peg$c146) { peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e147); } + if (peg$silentFails === 0) { peg$fail(peg$e150); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5109,7 +5196,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f128(); + s0 = peg$f130(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5127,16 +5214,16 @@ function peg$parse(input, options) { peg$silentFails++; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c144) { - s1 = peg$c144; + if (input.substr(peg$currPos, 2) === peg$c147) { + s1 = peg$c147; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e149); } + if (peg$silentFails === 0) { peg$fail(peg$e152); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f129(); + s1 = peg$f131(); } s0 = s1; if (s0 === peg$FAILED) { @@ -5146,81 +5233,81 @@ 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$e124); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f130(); + s1 = peg$f132(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c145) { - s1 = peg$c145; + if (input.substr(peg$currPos, 2) === peg$c121) { + s1 = peg$c121; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e150); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f131(); + s1 = peg$f133(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c146) { - s1 = peg$c146; + if (input.substr(peg$currPos, 2) === peg$c148) { + s1 = peg$c148; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e151); } + if (peg$silentFails === 0) { peg$fail(peg$e153); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f132(); + s1 = peg$f134(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c147; + s1 = peg$c149; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e152); } + if (peg$silentFails === 0) { peg$fail(peg$e154); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f133(); + s1 = peg$f135(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c148) { - s1 = peg$c148; + if (input.substr(peg$currPos, 2) === peg$c150) { + s1 = peg$c150; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e153); } + if (peg$silentFails === 0) { peg$fail(peg$e155); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f134(); + s1 = peg$f136(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c149; + s1 = peg$c151; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e154); } + if (peg$silentFails === 0) { peg$fail(peg$e156); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f135(); + s1 = peg$f137(); } s0 = s1; } @@ -5232,7 +5319,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e148); } + if (peg$silentFails === 0) { peg$fail(peg$e151); } } return s0; @@ -5245,7 +5332,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f136(s1); + s1 = peg$f138(s1); } s0 = s1; @@ -5257,11 +5344,11 @@ function peg$parse(input, options) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c150; + s1 = peg$c152; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e155); } + if (peg$silentFails === 0) { peg$fail(peg$e157); } } if (s1 !== peg$FAILED) { s2 = input.charAt(peg$currPos); @@ -5269,11 +5356,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e156); } + if (peg$silentFails === 0) { peg$fail(peg$e158); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f137(s2); + s0 = peg$f139(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5299,7 +5386,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e158); } + if (peg$silentFails === 0) { peg$fail(peg$e160); } } } if (s2 !== peg$FAILED) { @@ -5312,7 +5399,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e158); } + if (peg$silentFails === 0) { peg$fail(peg$e160); } } } } @@ -5321,13 +5408,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f138(s1); + s1 = peg$f140(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e157); } + if (peg$silentFails === 0) { peg$fail(peg$e159); } } return s0; @@ -5339,7 +5426,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f139(); + s1 = peg$f141(); s0 = s1; return s0; @@ -5355,7 +5442,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e160); } + if (peg$silentFails === 0) { peg$fail(peg$e162); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -5364,12 +5451,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e160); } + if (peg$silentFails === 0) { peg$fail(peg$e162); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e159); } + if (peg$silentFails === 0) { peg$fail(peg$e161); } return s0; } @@ -5379,7 +5466,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f140(); + s1 = peg$f142(); if (s1) { s1 = undefined; } else { @@ -5416,7 +5503,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e162); } + if (peg$silentFails === 0) { peg$fail(peg$e164); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -5425,7 +5512,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e162); } + if (peg$silentFails === 0) { peg$fail(peg$e164); } } } s2 = input.charAt(peg$currPos); @@ -5433,7 +5520,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e163); } + if (peg$silentFails === 0) { peg$fail(peg$e165); } } if (s2 !== peg$FAILED) { s3 = []; @@ -5444,7 +5531,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e164); } + if (peg$silentFails === 0) { peg$fail(peg$e166); } } } while (s4 !== peg$FAILED) { @@ -5456,7 +5543,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e164); } + if (peg$silentFails === 0) { peg$fail(peg$e166); } } } } @@ -5465,7 +5552,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e163); } + if (peg$silentFails === 0) { peg$fail(peg$e165); } } if (s4 !== peg$FAILED) { s5 = []; @@ -5474,7 +5561,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e158); } + if (peg$silentFails === 0) { peg$fail(peg$e160); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -5483,11 +5570,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e158); } + if (peg$silentFails === 0) { peg$fail(peg$e160); } } } peg$savedPos = s0; - s0 = peg$f141(s1, s3, s5); + s0 = peg$f143(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5499,7 +5586,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e161); } + if (peg$silentFails === 0) { peg$fail(peg$e163); } } return s0; @@ -5516,7 +5603,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e162); } + if (peg$silentFails === 0) { peg$fail(peg$e164); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -5525,7 +5612,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e162); } + if (peg$silentFails === 0) { peg$fail(peg$e164); } } } s2 = input.charAt(peg$currPos); @@ -5533,7 +5620,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e163); } + if (peg$silentFails === 0) { peg$fail(peg$e165); } } if (s2 !== peg$FAILED) { s3 = []; @@ -5544,7 +5631,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e164); } + if (peg$silentFails === 0) { peg$fail(peg$e166); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -5560,15 +5647,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c151; + s6 = peg$c153; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e165); } + if (peg$silentFails === 0) { peg$fail(peg$e167); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f142(s1); + s4 = peg$f144(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5591,15 +5678,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c152; + s6 = peg$c154; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e166); } + if (peg$silentFails === 0) { peg$fail(peg$e168); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f143(s1); + s4 = peg$f145(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5622,15 +5709,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c153; + s6 = peg$c155; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e167); } + if (peg$silentFails === 0) { peg$fail(peg$e169); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f144(s1); + s4 = peg$f146(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5652,7 +5739,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e164); } + if (peg$silentFails === 0) { peg$fail(peg$e166); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -5668,15 +5755,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c151; + s6 = peg$c153; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e165); } + if (peg$silentFails === 0) { peg$fail(peg$e167); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f142(s1); + s4 = peg$f144(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5699,15 +5786,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c152; + s6 = peg$c154; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e166); } + if (peg$silentFails === 0) { peg$fail(peg$e168); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f143(s1); + s4 = peg$f145(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5730,15 +5817,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c153; + s6 = peg$c155; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e167); } + if (peg$silentFails === 0) { peg$fail(peg$e169); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f144(s1); + s4 = peg$f146(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5755,7 +5842,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f145(s1, s3, s4); + s0 = peg$f147(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5767,7 +5854,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e161); } + if (peg$silentFails === 0) { peg$fail(peg$e163); } } return s0; @@ -5782,7 +5869,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e163); } + if (peg$silentFails === 0) { peg$fail(peg$e165); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5820,7 +5907,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e168); } + if (peg$silentFails === 0) { peg$fail(peg$e170); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -5829,7 +5916,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e168); } + if (peg$silentFails === 0) { peg$fail(peg$e170); } } } s2 = []; @@ -5838,7 +5925,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e169); } + if (peg$silentFails === 0) { peg$fail(peg$e171); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -5847,7 +5934,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e169); } + if (peg$silentFails === 0) { peg$fail(peg$e171); } } } s3 = []; @@ -5856,7 +5943,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e170); } + if (peg$silentFails === 0) { peg$fail(peg$e172); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -5865,7 +5952,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e170); } + if (peg$silentFails === 0) { peg$fail(peg$e172); } } } s4 = peg$parseoperator(); @@ -5884,7 +5971,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e171); } + if (peg$silentFails === 0) { peg$fail(peg$e173); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -5893,7 +5980,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e171); } + if (peg$silentFails === 0) { peg$fail(peg$e173); } } } s2 = peg$currPos; @@ -5940,7 +6027,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e172); } + if (peg$silentFails === 0) { peg$fail(peg$e174); } } } } @@ -5956,7 +6043,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e173); } + if (peg$silentFails === 0) { peg$fail(peg$e175); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -5985,24 +6072,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c154) { + if (s1.toLowerCase() === peg$c156) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e174); } + if (peg$silentFails === 0) { peg$fail(peg$e176); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 12); - if (s1.toLowerCase() === peg$c155) { + if (s1.toLowerCase() === peg$c157) { peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e175); } + if (peg$silentFails === 0) { peg$fail(peg$e177); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f146(); + s1 = peg$f148(); } s0 = s1; @@ -6014,24 +6101,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c156) { + if (s1.toLowerCase() === peg$c158) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e176); } + if (peg$silentFails === 0) { peg$fail(peg$e178); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 15); - if (s1.toLowerCase() === peg$c157) { + if (s1.toLowerCase() === peg$c159) { peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e177); } + if (peg$silentFails === 0) { peg$fail(peg$e179); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f147(); + s1 = peg$f149(); } s0 = s1; @@ -6043,24 +6130,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c158) { + if (s1.toLowerCase() === peg$c160) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e178); } + if (peg$silentFails === 0) { peg$fail(peg$e180); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 12); - if (s1.toLowerCase() === peg$c159) { + if (s1.toLowerCase() === peg$c161) { peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e179); } + if (peg$silentFails === 0) { peg$fail(peg$e181); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f148(); + s1 = peg$f150(); } s0 = s1; @@ -6072,24 +6159,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 17); - if (s1.toLowerCase() === peg$c160) { + if (s1.toLowerCase() === peg$c162) { peg$currPos += 17; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e180); } + if (peg$silentFails === 0) { peg$fail(peg$e182); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 19); - if (s1.toLowerCase() === peg$c161) { + if (s1.toLowerCase() === peg$c163) { peg$currPos += 19; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e181); } + if (peg$silentFails === 0) { peg$fail(peg$e183); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f149(); + s1 = peg$f151(); } s0 = s1; @@ -6101,24 +6188,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c162) { + if (s1.toLowerCase() === peg$c164) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e182); } + if (peg$silentFails === 0) { peg$fail(peg$e184); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 20); - if (s1.toLowerCase() === peg$c163) { + if (s1.toLowerCase() === peg$c165) { peg$currPos += 20; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e183); } + if (peg$silentFails === 0) { peg$fail(peg$e185); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f150(); + s1 = peg$f152(); } s0 = s1; diff --git a/src/libs/SearchParser/autocompleteParser.peggy b/src/libs/SearchParser/autocompleteParser.peggy index 391d130e61fd..52dce25f5f3d 100644 --- a/src/libs/SearchParser/autocompleteParser.peggy +++ b/src/libs/SearchParser/autocompleteParser.peggy @@ -123,6 +123,7 @@ autocompleteKey "key" / anySubmission / approved / paid + / exportedToTemplate / exportedTo / exported / withdrawn diff --git a/src/libs/SearchParser/baseRules.peggy b/src/libs/SearchParser/baseRules.peggy index ca8deb205749..7829a2a2ee75 100644 --- a/src/libs/SearchParser/baseRules.peggy +++ b/src/libs/SearchParser/baseRules.peggy @@ -197,9 +197,12 @@ withdrawalId = "withdrawal-id"i &wordBoundary { return "wi bankAccountColumn = "bank-account"i &wordBoundary { return "bankAccount"; } reportId = "long-report-id"i &wordBoundary { return "reportID"; } base62ReportId = "report-id"i &wordBoundary { return "base62ReportID"; } +exportedToTemplate + = "exportedToTemplate"i &exportedToKeyEnd { return "exportedToTemplate"; } + / "exported-to-template"i &exportedToKeyEnd { return "exportedToTemplate"; } transactionId = "transaction-id"i &wordBoundary { return "transactionID"; } exportedToColumnValue = "exported-to"i &wordBoundary { return "exportedto"; } -exportedToKeyEnd = wordBoundary / _ (":" / "=") +exportedToKeyEnd = wordBoundary / _ (":" / "=" / "!=") exportedTo = "exportedTo"i &exportedToKeyEnd { return "exportedTo"; } / "exported-to"i &exportedToKeyEnd { return "exportedTo"; } diff --git a/src/libs/SearchParser/searchParser.js b/src/libs/SearchParser/searchParser.js index 84d58bb232c5..f2658f4e4b02 100644 --- a/src/libs/SearchParser/searchParser.js +++ b/src/libs/SearchParser/searchParser.js @@ -302,52 +302,54 @@ function peg$parse(input, options) { var peg$c115 = "category-gl-code"; var peg$c116 = "tag-gl-code"; var peg$c117 = "long-report-id"; - var peg$c118 = "exported-to"; - var peg$c119 = "exportedto"; - var peg$c120 = "exchange-rate"; - var peg$c121 = "reimbursable-total"; - var peg$c122 = "non-reimbursable-total"; - var peg$c123 = "group-from"; - var peg$c124 = "group-expenses"; - var peg$c125 = "group-total"; - var peg$c126 = "group-card"; - var peg$c127 = "group-feed"; - var peg$c128 = "group-bank-account"; - var peg$c129 = "group-withdrawn"; - var peg$c130 = "group-withdrawal-id"; - var peg$c131 = "group-withdrawal-status"; - var peg$c132 = "group-amount-debited"; - var peg$c133 = "group-amount-reimbursed"; - var peg$c134 = "group-category"; - var peg$c135 = "group-tag"; - var peg$c136 = "group-merchant"; - var peg$c137 = "group-day"; - var peg$c138 = "group-month"; - var peg$c139 = "group-week"; - var peg$c140 = "group-year"; - var peg$c141 = "group-quarter"; - var peg$c142 = "group-approver"; - var peg$c143 = "group-violation"; - var peg$c144 = "*:"; - var peg$c145 = "!="; - var peg$c146 = ">="; - var peg$c147 = ">"; - var peg$c148 = "<="; - var peg$c149 = "<"; - var peg$c150 = "\\"; - var peg$c151 = "\u201C"; - var peg$c152 = "\u201D"; - var peg$c153 = "\""; - var peg$c154 = "footercount"; - var peg$c155 = "footer-count"; - var peg$c156 = "footercurrency"; - var peg$c157 = "footer-currency"; - var peg$c158 = "footertotal"; - var peg$c159 = "footer-total"; - var peg$c160 = "leftpinnedcolumns"; - var peg$c161 = "left-pinned-columns"; - var peg$c162 = "rightpinnedcolumns"; - var peg$c163 = "right-pinned-columns"; + var peg$c118 = "exportedtotemplate"; + var peg$c119 = "exported-to-template"; + var peg$c120 = "exported-to"; + var peg$c121 = "!="; + var peg$c122 = "exportedto"; + var peg$c123 = "exchange-rate"; + var peg$c124 = "reimbursable-total"; + var peg$c125 = "non-reimbursable-total"; + var peg$c126 = "group-from"; + var peg$c127 = "group-expenses"; + var peg$c128 = "group-total"; + var peg$c129 = "group-card"; + var peg$c130 = "group-feed"; + var peg$c131 = "group-bank-account"; + var peg$c132 = "group-withdrawn"; + var peg$c133 = "group-withdrawal-id"; + var peg$c134 = "group-withdrawal-status"; + var peg$c135 = "group-amount-debited"; + var peg$c136 = "group-amount-reimbursed"; + var peg$c137 = "group-category"; + var peg$c138 = "group-tag"; + var peg$c139 = "group-merchant"; + var peg$c140 = "group-day"; + var peg$c141 = "group-month"; + var peg$c142 = "group-week"; + var peg$c143 = "group-year"; + var peg$c144 = "group-quarter"; + var peg$c145 = "group-approver"; + var peg$c146 = "group-violation"; + var peg$c147 = "*:"; + var peg$c148 = ">="; + var peg$c149 = ">"; + var peg$c150 = "<="; + var peg$c151 = "<"; + var peg$c152 = "\\"; + var peg$c153 = "\u201C"; + var peg$c154 = "\u201D"; + var peg$c155 = "\""; + var peg$c156 = "footercount"; + var peg$c157 = "footer-count"; + var peg$c158 = "footercurrency"; + var peg$c159 = "footer-currency"; + var peg$c160 = "footertotal"; + var peg$c161 = "footer-total"; + var peg$c162 = "leftpinnedcolumns"; + var peg$c163 = "left-pinned-columns"; + var peg$c164 = "rightpinnedcolumns"; + var peg$c165 = "right-pinned-columns"; var peg$r0 = /^[^ \t\r\n\xA0]/; var peg$r1 = /^[ \t\r\n\xA0,:=<>!]/; @@ -488,69 +490,71 @@ function peg$parse(input, options) { var peg$e120 = peg$literalExpectation("category-gl-code", true); var peg$e121 = peg$literalExpectation("tag-gl-code", true); var peg$e122 = peg$literalExpectation("long-report-id", true); - var peg$e123 = peg$literalExpectation("exported-to", true); - var peg$e124 = peg$classExpectation([":", "="], false, false); - var peg$e125 = peg$literalExpectation("exportedTo", true); - var peg$e126 = peg$literalExpectation("exchange-rate", true); - var peg$e127 = peg$literalExpectation("reimbursable-total", true); - var peg$e128 = peg$literalExpectation("non-reimbursable-total", true); - var peg$e129 = peg$literalExpectation("group-from", true); - var peg$e130 = peg$literalExpectation("group-expenses", true); - var peg$e131 = peg$literalExpectation("group-total", true); - var peg$e132 = peg$literalExpectation("group-card", true); - var peg$e133 = peg$literalExpectation("group-feed", true); - var peg$e134 = peg$literalExpectation("group-bank-account", true); - var peg$e135 = peg$literalExpectation("group-withdrawn", true); - var peg$e136 = peg$literalExpectation("group-withdrawal-id", true); - var peg$e137 = peg$literalExpectation("group-withdrawal-status", true); - var peg$e138 = peg$literalExpectation("group-amount-debited", true); - var peg$e139 = peg$literalExpectation("group-amount-reimbursed", true); - var peg$e140 = peg$literalExpectation("group-category", true); - var peg$e141 = peg$literalExpectation("group-tag", true); - var peg$e142 = peg$literalExpectation("group-merchant", true); - var peg$e143 = peg$literalExpectation("group-day", true); - var peg$e144 = peg$literalExpectation("group-month", true); - var peg$e145 = peg$literalExpectation("group-week", true); - var peg$e146 = peg$literalExpectation("group-year", true); - var peg$e147 = peg$literalExpectation("group-quarter", true); - var peg$e148 = peg$literalExpectation("group-approver", true); - var peg$e149 = peg$literalExpectation("group-violation", true); - var peg$e150 = peg$otherExpectation("operator"); - var peg$e151 = peg$literalExpectation("*:", false); - var peg$e152 = peg$literalExpectation("!=", false); - var peg$e153 = peg$literalExpectation(">=", false); - var peg$e154 = peg$literalExpectation(">", false); - var peg$e155 = peg$literalExpectation("<=", false); - var peg$e156 = peg$literalExpectation("<", false); - var peg$e157 = peg$literalExpectation("\\", false); - var peg$e158 = peg$classExpectation([",", "\"", "\u201D", "\u201C", "\\"], false, false); - var peg$e159 = peg$otherExpectation("word"); - var peg$e160 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e161 = peg$otherExpectation("whitespace"); - var peg$e162 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e163 = peg$otherExpectation("quote"); - var peg$e164 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e165 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e166 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e167 = peg$literalExpectation("\u201C", false); - var peg$e168 = peg$literalExpectation("\u201D", false); - var peg$e169 = peg$literalExpectation("\"", false); - var peg$e170 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e171 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e172 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e173 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e174 = peg$classExpectation([","], false, false); - var peg$e175 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); - var peg$e176 = peg$literalExpectation("footerCount", true); - var peg$e177 = peg$literalExpectation("footer-count", true); - var peg$e178 = peg$literalExpectation("footerCurrency", true); - var peg$e179 = peg$literalExpectation("footer-currency", true); - var peg$e180 = peg$literalExpectation("footerTotal", true); - var peg$e181 = peg$literalExpectation("footer-total", true); - var peg$e182 = peg$literalExpectation("leftPinnedColumns", true); - var peg$e183 = peg$literalExpectation("left-pinned-columns", true); - var peg$e184 = peg$literalExpectation("rightPinnedColumns", true); - var peg$e185 = peg$literalExpectation("right-pinned-columns", true); + var peg$e123 = peg$literalExpectation("exportedToTemplate", true); + var peg$e124 = peg$literalExpectation("exported-to-template", true); + var peg$e125 = peg$literalExpectation("exported-to", true); + var peg$e126 = peg$classExpectation([":", "="], false, false); + var peg$e127 = peg$literalExpectation("!=", false); + var peg$e128 = peg$literalExpectation("exportedTo", true); + var peg$e129 = peg$literalExpectation("exchange-rate", true); + var peg$e130 = peg$literalExpectation("reimbursable-total", true); + var peg$e131 = peg$literalExpectation("non-reimbursable-total", true); + var peg$e132 = peg$literalExpectation("group-from", true); + var peg$e133 = peg$literalExpectation("group-expenses", true); + var peg$e134 = peg$literalExpectation("group-total", true); + var peg$e135 = peg$literalExpectation("group-card", true); + var peg$e136 = peg$literalExpectation("group-feed", true); + var peg$e137 = peg$literalExpectation("group-bank-account", true); + var peg$e138 = peg$literalExpectation("group-withdrawn", true); + var peg$e139 = peg$literalExpectation("group-withdrawal-id", true); + var peg$e140 = peg$literalExpectation("group-withdrawal-status", true); + var peg$e141 = peg$literalExpectation("group-amount-debited", true); + var peg$e142 = peg$literalExpectation("group-amount-reimbursed", true); + var peg$e143 = peg$literalExpectation("group-category", true); + var peg$e144 = peg$literalExpectation("group-tag", true); + var peg$e145 = peg$literalExpectation("group-merchant", true); + var peg$e146 = peg$literalExpectation("group-day", true); + var peg$e147 = peg$literalExpectation("group-month", true); + var peg$e148 = peg$literalExpectation("group-week", true); + var peg$e149 = peg$literalExpectation("group-year", true); + var peg$e150 = peg$literalExpectation("group-quarter", true); + var peg$e151 = peg$literalExpectation("group-approver", true); + var peg$e152 = peg$literalExpectation("group-violation", true); + var peg$e153 = peg$otherExpectation("operator"); + var peg$e154 = peg$literalExpectation("*:", false); + var peg$e155 = peg$literalExpectation(">=", false); + var peg$e156 = peg$literalExpectation(">", false); + var peg$e157 = peg$literalExpectation("<=", false); + var peg$e158 = peg$literalExpectation("<", false); + var peg$e159 = peg$literalExpectation("\\", false); + var peg$e160 = peg$classExpectation([",", "\"", "\u201D", "\u201C", "\\"], false, false); + var peg$e161 = peg$otherExpectation("word"); + var peg$e162 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e163 = peg$otherExpectation("whitespace"); + var peg$e164 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e165 = peg$otherExpectation("quote"); + var peg$e166 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e167 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e168 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e169 = peg$literalExpectation("\u201C", false); + var peg$e170 = peg$literalExpectation("\u201D", false); + var peg$e171 = peg$literalExpectation("\"", false); + var peg$e172 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e173 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e174 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e175 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e176 = peg$classExpectation([","], false, false); + var peg$e177 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e178 = peg$literalExpectation("footerCount", true); + var peg$e179 = peg$literalExpectation("footer-count", true); + var peg$e180 = peg$literalExpectation("footerCurrency", true); + var peg$e181 = peg$literalExpectation("footer-currency", true); + var peg$e182 = peg$literalExpectation("footerTotal", true); + var peg$e183 = peg$literalExpectation("footer-total", true); + var peg$e184 = peg$literalExpectation("leftPinnedColumns", true); + var peg$e185 = peg$literalExpectation("left-pinned-columns", true); + var peg$e186 = peg$literalExpectation("rightPinnedColumns", true); + var peg$e187 = peg$literalExpectation("right-pinned-columns", true); var peg$f0 = function(filters) { return applyDefaults(filters); }; var peg$f1 = function(head, tail) { @@ -584,6 +588,28 @@ function peg$parse(input, options) { if (keywordFilter.right.length > 0) { nonKeywords.push(keywordFilter); } + const integrationFilters = []; + const templateFilters = []; + for (const filter of nonKeywords) { + if (filter.operator !== "eq") { + continue; + } + if (filter.left === "exportedTo") { + integrationFilters.push(filter); + } else if (filter.left === "exportedToTemplate") { + templateFilters.push(filter); + } + } + + // Picker selections match either destination type. Repeated clauses within each type still require every clause. + if (integrationFilters.length > 0 && templateFilters.length > 0) { + const exportFilterSet = new Set([...integrationFilters, ...templateFilters]); + const otherFilters = nonKeywords.filter((filter) => !exportFilterSet.has(filter)); + const integrationGroup = integrationFilters.reduce((result, filter) => buildFilter("and", result, filter)); + const templateGroup = templateFilters.reduce((result, filter) => buildFilter("and", result, filter)); + otherFilters.push(buildFilter("or", integrationGroup, templateGroup)); + return otherFilters.reduce((result, filter) => buildFilter("and", result, filter)); + } return nonKeywords.reduce((result, filter) => buildFilter("and", result, filter) ); @@ -756,76 +782,78 @@ function peg$parse(input, options) { var peg$f97 = function() { return "bankAccount"; }; var peg$f98 = function() { return "reportID"; }; var peg$f99 = function() { return "base62ReportID"; }; - var peg$f100 = function() { return "transactionID"; }; - var peg$f101 = function() { return "exportedto"; }; - var peg$f102 = function() { return "exportedTo"; }; - var peg$f103 = function() { return "exportedTo"; }; - var peg$f104 = function() { return "exchangeRate"; }; - var peg$f105 = function() { return "reimbursableTotal"; }; - var peg$f106 = function() { return "nonReimbursableTotal"; }; - var peg$f107 = function() { return "groupFrom"; }; - var peg$f108 = function() { return "groupExpenses"; }; - var peg$f109 = function() { return "groupTotal"; }; - var peg$f110 = function() { return "groupCard"; }; - var peg$f111 = function() { return "groupFeed"; }; - var peg$f112 = function() { return "groupBankAccount"; }; - var peg$f113 = function() { return "groupWithdrawn"; }; - var peg$f114 = function() { return "groupWithdrawalID"; }; - var peg$f115 = function() { return "groupWithdrawalStatus"; }; - var peg$f116 = function() { return "groupAmountDebited"; }; - var peg$f117 = function() { return "groupAmountReimbursed"; }; - var peg$f118 = function() { return "amountDebited"; }; - var peg$f119 = function() { return "amountReimbursed"; }; - var peg$f120 = function() { return "groupCategory"; }; - var peg$f121 = function() { return "groupTag"; }; - var peg$f122 = function() { return "groupMerchant"; }; - var peg$f123 = function() { return "groupday"; }; - var peg$f124 = function() { return "groupmonth"; }; - var peg$f125 = function() { return "groupweek"; }; - var peg$f126 = function() { return "groupyear"; }; - var peg$f127 = function() { return "groupquarter"; }; - var peg$f128 = function() { return "groupApprover"; }; - var peg$f129 = function() { return "groupViolation"; }; - var peg$f130 = function() { return "contains"; }; - var peg$f131 = function() { return "eq"; }; - var peg$f132 = function() { return "neq"; }; - var peg$f133 = function() { return "gte"; }; - var peg$f134 = function() { return "gt"; }; - var peg$f135 = function() { return "lte"; }; - var peg$f136 = function() { return "lt"; }; - var peg$f137 = function(o) { + var peg$f100 = function() { return "exportedToTemplate"; }; + var peg$f101 = function() { return "exportedToTemplate"; }; + var peg$f102 = function() { return "transactionID"; }; + var peg$f103 = function() { return "exportedto"; }; + var peg$f104 = function() { return "exportedTo"; }; + var peg$f105 = function() { return "exportedTo"; }; + var peg$f106 = function() { return "exchangeRate"; }; + var peg$f107 = function() { return "reimbursableTotal"; }; + var peg$f108 = function() { return "nonReimbursableTotal"; }; + var peg$f109 = function() { return "groupFrom"; }; + var peg$f110 = function() { return "groupExpenses"; }; + var peg$f111 = function() { return "groupTotal"; }; + var peg$f112 = function() { return "groupCard"; }; + var peg$f113 = function() { return "groupFeed"; }; + var peg$f114 = function() { return "groupBankAccount"; }; + var peg$f115 = function() { return "groupWithdrawn"; }; + var peg$f116 = function() { return "groupWithdrawalID"; }; + var peg$f117 = function() { return "groupWithdrawalStatus"; }; + var peg$f118 = function() { return "groupAmountDebited"; }; + var peg$f119 = function() { return "groupAmountReimbursed"; }; + var peg$f120 = function() { return "amountDebited"; }; + var peg$f121 = function() { return "amountReimbursed"; }; + var peg$f122 = function() { return "groupCategory"; }; + var peg$f123 = function() { return "groupTag"; }; + var peg$f124 = function() { return "groupMerchant"; }; + var peg$f125 = function() { return "groupday"; }; + var peg$f126 = function() { return "groupmonth"; }; + var peg$f127 = function() { return "groupweek"; }; + var peg$f128 = function() { return "groupyear"; }; + var peg$f129 = function() { return "groupquarter"; }; + var peg$f130 = function() { return "groupApprover"; }; + var peg$f131 = function() { return "groupViolation"; }; + var peg$f132 = function() { return "contains"; }; + var peg$f133 = function() { return "eq"; }; + var peg$f134 = function() { return "neq"; }; + var peg$f135 = function() { return "gte"; }; + var peg$f136 = function() { return "gt"; }; + var peg$f137 = function() { return "lte"; }; + var peg$f138 = function() { return "lt"; }; + var peg$f139 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq" || o === "contains"); } isColumnsContext = false; return o; }; - var peg$f138 = function(c) { return c; }; - var peg$f139 = function(chars) { return chars.join("").trim(); }; - var peg$f140 = function() { + var peg$f140 = function(c) { return c; }; + var peg$f141 = function(chars) { return chars.join("").trim(); }; + var peg$f142 = function() { isColumnsContext = false; isExpenseTypeContext = false; isStatusContext = false; return "and"; }; - var peg$f141 = function() { return expectingNestedQuote; }; - var peg$f142 = function(start, inner, end) { //handle no-breaking space + var peg$f143 = function() { return expectingNestedQuote; }; + var peg$f144 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f143 = function(start) {return "“"}; - var peg$f144 = function(start) {return "”"}; - var peg$f145 = function(start) {return "\""}; - var peg$f146 = function(start, inner, end) { + var peg$f145 = function(start) {return "“"}; + var peg$f146 = function(start) {return "”"}; + var peg$f147 = function(start) {return "\""}; + var peg$f148 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; - var peg$f147 = function() { return "footerCount"; }; - var peg$f148 = function() { return "footerCurrency"; }; - var peg$f149 = function() { return "footerTotal"; }; - var peg$f150 = function() { + var peg$f149 = function() { return "footerCount"; }; + var peg$f150 = function() { return "footerCurrency"; }; + var peg$f151 = function() { return "footerTotal"; }; + var peg$f152 = function() { isColumnsContext = true; return "leftPinnedColumns"; }; - var peg$f151 = function() { + var peg$f153 = function() { isColumnsContext = true; return "rightPinnedColumns"; }; @@ -1404,63 +1432,66 @@ function peg$parse(input, options) { if (s1 === peg$FAILED) { s1 = peg$parsepaid(); if (s1 === peg$FAILED) { - s1 = peg$parseexportedTo(); + s1 = peg$parseexportedToTemplate(); if (s1 === peg$FAILED) { - s1 = peg$parseexported(); + s1 = peg$parseexportedTo(); if (s1 === peg$FAILED) { - s1 = peg$parseposted(); + s1 = peg$parseexported(); if (s1 === peg$FAILED) { - s1 = peg$parsewithdrawn(); + s1 = peg$parseposted(); if (s1 === peg$FAILED) { - s1 = peg$parseworkflowStage(); + s1 = peg$parsewithdrawn(); if (s1 === peg$FAILED) { - s1 = peg$parsefeed(); + s1 = peg$parseworkflowStage(); if (s1 === peg$FAILED) { - s1 = peg$parsetitle(); + s1 = peg$parsefeed(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitterUserID(); + s1 = peg$parsetitle(); if (s1 === peg$FAILED) { - s1 = peg$parsesubmitterPayrollID(); + s1 = peg$parsesubmitterUserID(); if (s1 === peg$FAILED) { - s1 = peg$parseorderDealNumbers(); + s1 = peg$parsesubmitterPayrollID(); if (s1 === peg$FAILED) { - s1 = peg$parseapprover(); + s1 = peg$parseorderDealNumbers(); if (s1 === peg$FAILED) { - s1 = peg$parseassignee(); + s1 = peg$parseapprover(); if (s1 === peg$FAILED) { - s1 = peg$parsecreatedBy(); + s1 = peg$parseassignee(); if (s1 === peg$FAILED) { - s1 = peg$parsereimbursable(); + s1 = peg$parsecreatedBy(); if (s1 === peg$FAILED) { - s1 = peg$parsebillable(); + s1 = peg$parsereimbursable(); if (s1 === peg$FAILED) { - s1 = peg$parsedeclined(); + s1 = peg$parsebillable(); if (s1 === peg$FAILED) { - s1 = peg$parseheld(); + s1 = peg$parsedeclined(); if (s1 === peg$FAILED) { - s1 = peg$parseaction(); + s1 = peg$parseheld(); if (s1 === peg$FAILED) { - s1 = peg$parsehas(); + s1 = peg$parseaction(); if (s1 === peg$FAILED) { - s1 = peg$parseis(); + s1 = peg$parsehas(); if (s1 === peg$FAILED) { - s1 = peg$parsepurchaseCurrency(); + s1 = peg$parseis(); if (s1 === peg$FAILED) { - s1 = peg$parseconvertedAmount(); + s1 = peg$parsepurchaseCurrency(); if (s1 === peg$FAILED) { - s1 = peg$parsepurchaseAmount(); + s1 = peg$parseconvertedAmount(); if (s1 === peg$FAILED) { - s1 = peg$parsepolicyID(); + s1 = peg$parsepurchaseAmount(); if (s1 === peg$FAILED) { - s1 = peg$parsestatus(); + s1 = peg$parsepolicyID(); if (s1 === peg$FAILED) { - s1 = peg$parsefooterCount(); + s1 = peg$parsestatus(); if (s1 === peg$FAILED) { - s1 = peg$parsefooterCurrency(); + s1 = peg$parsefooterCount(); if (s1 === peg$FAILED) { - s1 = peg$parsefooterTotal(); + s1 = peg$parsefooterCurrency(); if (s1 === peg$FAILED) { - s1 = peg$parsereportFieldDynamic(); + s1 = peg$parsefooterTotal(); + if (s1 === peg$FAILED) { + s1 = peg$parsereportFieldDynamic(); + } } } } @@ -4208,6 +4239,75 @@ function peg$parse(input, options) { return s0; } + function peg$parseexportedToTemplate() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 18); + if (s1.toLowerCase() === peg$c118) { + peg$currPos += 18; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e123); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseexportedToKeyEnd(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f100(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 20); + if (s1.toLowerCase() === peg$c119) { + peg$currPos += 20; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e124); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseexportedToKeyEnd(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f101(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + function peg$parsetransactionId() { var s0, s1, s2, s3; @@ -4232,7 +4332,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f100(); + s0 = peg$f102(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4250,11 +4350,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c118) { + if (s1.toLowerCase() === peg$c120) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4269,7 +4369,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f101(); + s0 = peg$f103(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4294,7 +4394,16 @@ 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$e126); } + } + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c121) { + s2 = peg$c121; + peg$currPos += 2; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e127); } + } } if (s2 !== peg$FAILED) { s1 = [s1, s2]; @@ -4313,11 +4422,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c119) { + if (s1.toLowerCase() === peg$c122) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } + if (peg$silentFails === 0) { peg$fail(peg$e128); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4332,7 +4441,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f102(); + s0 = peg$f104(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4344,11 +4453,11 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c118) { + if (s1.toLowerCase() === peg$c120) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } + if (peg$silentFails === 0) { peg$fail(peg$e125); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4363,7 +4472,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f103(); + s0 = peg$f105(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4382,11 +4491,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 13); - if (s1.toLowerCase() === peg$c120) { + if (s1.toLowerCase() === peg$c123) { peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e126); } + if (peg$silentFails === 0) { peg$fail(peg$e129); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4401,7 +4510,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f104(); + s0 = peg$f106(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4419,11 +4528,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c121) { + if (s1.toLowerCase() === peg$c124) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e127); } + if (peg$silentFails === 0) { peg$fail(peg$e130); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4438,7 +4547,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f105(); + s0 = peg$f107(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4456,11 +4565,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 22); - if (s1.toLowerCase() === peg$c122) { + if (s1.toLowerCase() === peg$c125) { peg$currPos += 22; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e128); } + if (peg$silentFails === 0) { peg$fail(peg$e131); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4475,7 +4584,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f106(); + s0 = peg$f108(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4493,11 +4602,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c123) { + if (s1.toLowerCase() === peg$c126) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e129); } + if (peg$silentFails === 0) { peg$fail(peg$e132); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4512,7 +4621,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f107(); + s0 = peg$f109(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4530,11 +4639,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c124) { + if (s1.toLowerCase() === peg$c127) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e130); } + if (peg$silentFails === 0) { peg$fail(peg$e133); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4549,7 +4658,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f108(); + s0 = peg$f110(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4567,11 +4676,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c125) { + if (s1.toLowerCase() === peg$c128) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e131); } + if (peg$silentFails === 0) { peg$fail(peg$e134); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4586,7 +4695,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f109(); + s0 = peg$f111(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4604,11 +4713,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c126) { + if (s1.toLowerCase() === peg$c129) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e132); } + if (peg$silentFails === 0) { peg$fail(peg$e135); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4623,7 +4732,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f110(); + s0 = peg$f112(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4641,11 +4750,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c127) { + if (s1.toLowerCase() === peg$c130) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e133); } + if (peg$silentFails === 0) { peg$fail(peg$e136); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4660,7 +4769,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f111(); + s0 = peg$f113(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4678,11 +4787,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c128) { + if (s1.toLowerCase() === peg$c131) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e134); } + if (peg$silentFails === 0) { peg$fail(peg$e137); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4697,7 +4806,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f112(); + s0 = peg$f114(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4715,11 +4824,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 15); - if (s1.toLowerCase() === peg$c129) { + if (s1.toLowerCase() === peg$c132) { peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e135); } + if (peg$silentFails === 0) { peg$fail(peg$e138); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4734,7 +4843,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f113(); + s0 = peg$f115(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4752,11 +4861,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 19); - if (s1.toLowerCase() === peg$c130) { + if (s1.toLowerCase() === peg$c133) { peg$currPos += 19; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e136); } + if (peg$silentFails === 0) { peg$fail(peg$e139); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4771,7 +4880,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f114(); + s0 = peg$f116(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4789,11 +4898,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 23); - if (s1.toLowerCase() === peg$c131) { + if (s1.toLowerCase() === peg$c134) { peg$currPos += 23; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e137); } + if (peg$silentFails === 0) { peg$fail(peg$e140); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4808,7 +4917,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f115(); + s0 = peg$f117(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4826,11 +4935,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 20); - if (s1.toLowerCase() === peg$c132) { + if (s1.toLowerCase() === peg$c135) { peg$currPos += 20; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e138); } + if (peg$silentFails === 0) { peg$fail(peg$e141); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4845,7 +4954,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f116(); + s0 = peg$f118(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4863,11 +4972,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 23); - if (s1.toLowerCase() === peg$c133) { + if (s1.toLowerCase() === peg$c136) { peg$currPos += 23; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e139); } + if (peg$silentFails === 0) { peg$fail(peg$e142); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4882,7 +4991,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f117(); + s0 = peg$f119(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4919,7 +5028,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f118(); + s0 = peg$f120(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4956,7 +5065,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f119(); + s0 = peg$f121(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4974,11 +5083,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c134) { + if (s1.toLowerCase() === peg$c137) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e140); } + if (peg$silentFails === 0) { peg$fail(peg$e143); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4993,7 +5102,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f120(); + s0 = peg$f122(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5011,11 +5120,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 9); - if (s1.toLowerCase() === peg$c135) { + if (s1.toLowerCase() === peg$c138) { peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e141); } + if (peg$silentFails === 0) { peg$fail(peg$e144); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5030,7 +5139,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f121(); + s0 = peg$f123(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5048,11 +5157,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c136) { + if (s1.toLowerCase() === peg$c139) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e142); } + if (peg$silentFails === 0) { peg$fail(peg$e145); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5067,7 +5176,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f122(); + s0 = peg$f124(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5085,11 +5194,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 9); - if (s1.toLowerCase() === peg$c137) { + if (s1.toLowerCase() === peg$c140) { peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e143); } + if (peg$silentFails === 0) { peg$fail(peg$e146); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5104,7 +5213,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f123(); + s0 = peg$f125(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5122,11 +5231,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c138) { + if (s1.toLowerCase() === peg$c141) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e144); } + if (peg$silentFails === 0) { peg$fail(peg$e147); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5141,7 +5250,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f124(); + s0 = peg$f126(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5159,11 +5268,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c139) { + if (s1.toLowerCase() === peg$c142) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e145); } + if (peg$silentFails === 0) { peg$fail(peg$e148); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5178,7 +5287,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f125(); + s0 = peg$f127(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5196,11 +5305,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 10); - if (s1.toLowerCase() === peg$c140) { + if (s1.toLowerCase() === peg$c143) { peg$currPos += 10; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e146); } + if (peg$silentFails === 0) { peg$fail(peg$e149); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5215,7 +5324,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f126(); + s0 = peg$f128(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5233,11 +5342,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 13); - if (s1.toLowerCase() === peg$c141) { + if (s1.toLowerCase() === peg$c144) { peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e147); } + if (peg$silentFails === 0) { peg$fail(peg$e150); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5252,7 +5361,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f127(); + s0 = peg$f129(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5270,11 +5379,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c142) { + if (s1.toLowerCase() === peg$c145) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e148); } + if (peg$silentFails === 0) { peg$fail(peg$e151); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5289,7 +5398,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f128(); + s0 = peg$f130(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5307,11 +5416,11 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 15); - if (s1.toLowerCase() === peg$c143) { + if (s1.toLowerCase() === peg$c146) { peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e149); } + if (peg$silentFails === 0) { peg$fail(peg$e152); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -5326,7 +5435,7 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f129(); + s0 = peg$f131(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5344,16 +5453,16 @@ function peg$parse(input, options) { peg$silentFails++; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c144) { - s1 = peg$c144; + if (input.substr(peg$currPos, 2) === peg$c147) { + s1 = peg$c147; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e151); } + if (peg$silentFails === 0) { peg$fail(peg$e154); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f130(); + s1 = peg$f132(); } s0 = s1; if (s0 === peg$FAILED) { @@ -5363,81 +5472,81 @@ 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$e126); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f131(); + s1 = peg$f133(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c145) { - s1 = peg$c145; + if (input.substr(peg$currPos, 2) === peg$c121) { + s1 = peg$c121; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e152); } + if (peg$silentFails === 0) { peg$fail(peg$e127); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f132(); + s1 = peg$f134(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c146) { - s1 = peg$c146; + if (input.substr(peg$currPos, 2) === peg$c148) { + s1 = peg$c148; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e153); } + if (peg$silentFails === 0) { peg$fail(peg$e155); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f133(); + s1 = peg$f135(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c147; + s1 = peg$c149; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e154); } + if (peg$silentFails === 0) { peg$fail(peg$e156); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f134(); + s1 = peg$f136(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c148) { - s1 = peg$c148; + if (input.substr(peg$currPos, 2) === peg$c150) { + s1 = peg$c150; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e155); } + if (peg$silentFails === 0) { peg$fail(peg$e157); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f135(); + s1 = peg$f137(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c149; + s1 = peg$c151; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e156); } + if (peg$silentFails === 0) { peg$fail(peg$e158); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f136(); + s1 = peg$f138(); } s0 = s1; } @@ -5449,7 +5558,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e150); } + if (peg$silentFails === 0) { peg$fail(peg$e153); } } return s0; @@ -5462,7 +5571,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f137(s1); + s1 = peg$f139(s1); } s0 = s1; @@ -5474,11 +5583,11 @@ function peg$parse(input, options) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c150; + s1 = peg$c152; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e157); } + if (peg$silentFails === 0) { peg$fail(peg$e159); } } if (s1 !== peg$FAILED) { s2 = input.charAt(peg$currPos); @@ -5486,11 +5595,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e158); } + if (peg$silentFails === 0) { peg$fail(peg$e160); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f138(s2); + s0 = peg$f140(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5516,7 +5625,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e160); } + if (peg$silentFails === 0) { peg$fail(peg$e162); } } } if (s2 !== peg$FAILED) { @@ -5529,7 +5638,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e160); } + if (peg$silentFails === 0) { peg$fail(peg$e162); } } } } @@ -5538,13 +5647,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f139(s1); + s1 = peg$f141(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e159); } + if (peg$silentFails === 0) { peg$fail(peg$e161); } } return s0; @@ -5556,7 +5665,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f140(); + s1 = peg$f142(); s0 = s1; return s0; @@ -5572,7 +5681,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e162); } + if (peg$silentFails === 0) { peg$fail(peg$e164); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -5581,12 +5690,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e162); } + if (peg$silentFails === 0) { peg$fail(peg$e164); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e161); } + if (peg$silentFails === 0) { peg$fail(peg$e163); } return s0; } @@ -5596,7 +5705,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f141(); + s1 = peg$f143(); if (s1) { s1 = undefined; } else { @@ -5633,7 +5742,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e164); } + if (peg$silentFails === 0) { peg$fail(peg$e166); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -5642,7 +5751,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e164); } + if (peg$silentFails === 0) { peg$fail(peg$e166); } } } s2 = input.charAt(peg$currPos); @@ -5650,7 +5759,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e165); } + if (peg$silentFails === 0) { peg$fail(peg$e167); } } if (s2 !== peg$FAILED) { s3 = []; @@ -5661,7 +5770,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e166); } + if (peg$silentFails === 0) { peg$fail(peg$e168); } } } while (s4 !== peg$FAILED) { @@ -5673,7 +5782,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e166); } + if (peg$silentFails === 0) { peg$fail(peg$e168); } } } } @@ -5682,7 +5791,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e165); } + if (peg$silentFails === 0) { peg$fail(peg$e167); } } if (s4 !== peg$FAILED) { s5 = []; @@ -5691,7 +5800,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e160); } + if (peg$silentFails === 0) { peg$fail(peg$e162); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -5700,11 +5809,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e160); } + if (peg$silentFails === 0) { peg$fail(peg$e162); } } } peg$savedPos = s0; - s0 = peg$f142(s1, s3, s5); + s0 = peg$f144(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5716,7 +5825,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e163); } + if (peg$silentFails === 0) { peg$fail(peg$e165); } } return s0; @@ -5733,7 +5842,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e164); } + if (peg$silentFails === 0) { peg$fail(peg$e166); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -5742,7 +5851,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e164); } + if (peg$silentFails === 0) { peg$fail(peg$e166); } } } s2 = input.charAt(peg$currPos); @@ -5750,7 +5859,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e165); } + if (peg$silentFails === 0) { peg$fail(peg$e167); } } if (s2 !== peg$FAILED) { s3 = []; @@ -5761,7 +5870,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e166); } + if (peg$silentFails === 0) { peg$fail(peg$e168); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -5777,15 +5886,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c151; + s6 = peg$c153; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e167); } + if (peg$silentFails === 0) { peg$fail(peg$e169); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f143(s1); + s4 = peg$f145(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5808,15 +5917,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c152; + s6 = peg$c154; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e168); } + if (peg$silentFails === 0) { peg$fail(peg$e170); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f144(s1); + s4 = peg$f146(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5839,15 +5948,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c153; + s6 = peg$c155; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e169); } + if (peg$silentFails === 0) { peg$fail(peg$e171); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f145(s1); + s4 = peg$f147(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5869,7 +5978,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e166); } + if (peg$silentFails === 0) { peg$fail(peg$e168); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -5885,15 +5994,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c151; + s6 = peg$c153; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e167); } + if (peg$silentFails === 0) { peg$fail(peg$e169); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f143(s1); + s4 = peg$f145(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5916,15 +6025,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c152; + s6 = peg$c154; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e168); } + if (peg$silentFails === 0) { peg$fail(peg$e170); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f144(s1); + s4 = peg$f146(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5947,15 +6056,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c153; + s6 = peg$c155; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e169); } + if (peg$silentFails === 0) { peg$fail(peg$e171); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f145(s1); + s4 = peg$f147(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -5972,7 +6081,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f146(s1, s3, s4); + s0 = peg$f148(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5984,7 +6093,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e163); } + if (peg$silentFails === 0) { peg$fail(peg$e165); } } return s0; @@ -5999,7 +6108,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e165); } + if (peg$silentFails === 0) { peg$fail(peg$e167); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -6037,7 +6146,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e170); } + if (peg$silentFails === 0) { peg$fail(peg$e172); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -6046,7 +6155,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e170); } + if (peg$silentFails === 0) { peg$fail(peg$e172); } } } s2 = []; @@ -6055,7 +6164,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e171); } + if (peg$silentFails === 0) { peg$fail(peg$e173); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -6064,7 +6173,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e171); } + if (peg$silentFails === 0) { peg$fail(peg$e173); } } } s3 = []; @@ -6073,7 +6182,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e172); } + if (peg$silentFails === 0) { peg$fail(peg$e174); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -6082,7 +6191,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e172); } + if (peg$silentFails === 0) { peg$fail(peg$e174); } } } s4 = peg$parseoperator(); @@ -6101,7 +6210,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e173); } + if (peg$silentFails === 0) { peg$fail(peg$e175); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -6110,7 +6219,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e173); } + if (peg$silentFails === 0) { peg$fail(peg$e175); } } } s2 = peg$currPos; @@ -6157,7 +6266,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e174); } + if (peg$silentFails === 0) { peg$fail(peg$e176); } } } } @@ -6173,7 +6282,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e175); } + if (peg$silentFails === 0) { peg$fail(peg$e177); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -6202,24 +6311,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c154) { + if (s1.toLowerCase() === peg$c156) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e176); } + if (peg$silentFails === 0) { peg$fail(peg$e178); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 12); - if (s1.toLowerCase() === peg$c155) { + if (s1.toLowerCase() === peg$c157) { peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e177); } + if (peg$silentFails === 0) { peg$fail(peg$e179); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f147(); + s1 = peg$f149(); } s0 = s1; @@ -6231,24 +6340,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 14); - if (s1.toLowerCase() === peg$c156) { + if (s1.toLowerCase() === peg$c158) { peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e178); } + if (peg$silentFails === 0) { peg$fail(peg$e180); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 15); - if (s1.toLowerCase() === peg$c157) { + if (s1.toLowerCase() === peg$c159) { peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e179); } + if (peg$silentFails === 0) { peg$fail(peg$e181); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f148(); + s1 = peg$f150(); } s0 = s1; @@ -6260,24 +6369,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 11); - if (s1.toLowerCase() === peg$c158) { + if (s1.toLowerCase() === peg$c160) { peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e180); } + if (peg$silentFails === 0) { peg$fail(peg$e182); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 12); - if (s1.toLowerCase() === peg$c159) { + if (s1.toLowerCase() === peg$c161) { peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e181); } + if (peg$silentFails === 0) { peg$fail(peg$e183); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f149(); + s1 = peg$f151(); } s0 = s1; @@ -6289,24 +6398,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 17); - if (s1.toLowerCase() === peg$c160) { + if (s1.toLowerCase() === peg$c162) { peg$currPos += 17; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e182); } + if (peg$silentFails === 0) { peg$fail(peg$e184); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 19); - if (s1.toLowerCase() === peg$c161) { + if (s1.toLowerCase() === peg$c163) { peg$currPos += 19; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e183); } + if (peg$silentFails === 0) { peg$fail(peg$e185); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f150(); + s1 = peg$f152(); } s0 = s1; @@ -6318,24 +6427,24 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = input.substr(peg$currPos, 18); - if (s1.toLowerCase() === peg$c162) { + if (s1.toLowerCase() === peg$c164) { peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e184); } + if (peg$silentFails === 0) { peg$fail(peg$e186); } } if (s1 === peg$FAILED) { s1 = input.substr(peg$currPos, 20); - if (s1.toLowerCase() === peg$c163) { + if (s1.toLowerCase() === peg$c165) { peg$currPos += 20; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e185); } + if (peg$silentFails === 0) { peg$fail(peg$e187); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f151(); + s1 = peg$f153(); } s0 = s1; diff --git a/src/libs/SearchParser/searchParser.peggy b/src/libs/SearchParser/searchParser.peggy index 86f7be6d39d4..fd3b0a44dc86 100644 --- a/src/libs/SearchParser/searchParser.peggy +++ b/src/libs/SearchParser/searchParser.peggy @@ -218,6 +218,28 @@ filterList if (keywordFilter.right.length > 0) { nonKeywords.push(keywordFilter); } + const integrationFilters = []; + const templateFilters = []; + for (const filter of nonKeywords) { + if (filter.operator !== "eq") { + continue; + } + if (filter.left === "exportedTo") { + integrationFilters.push(filter); + } else if (filter.left === "exportedToTemplate") { + templateFilters.push(filter); + } + } + + // Picker selections match either destination type. Repeated clauses within each type still require every clause. + if (integrationFilters.length > 0 && templateFilters.length > 0) { + const exportFilterSet = new Set([...integrationFilters, ...templateFilters]); + const otherFilters = nonKeywords.filter((filter) => !exportFilterSet.has(filter)); + const integrationGroup = integrationFilters.reduce((result, filter) => buildFilter("and", result, filter)); + const templateGroup = templateFilters.reduce((result, filter) => buildFilter("and", result, filter)); + otherFilters.push(buildFilter("or", integrationGroup, templateGroup)); + return otherFilters.reduce((result, filter) => buildFilter("and", result, filter)); + } return nonKeywords.reduce((result, filter) => buildFilter("and", result, filter) ); @@ -328,6 +350,7 @@ key "key" / anySubmission / approved / paid + / exportedToTemplate / exportedTo / exported / posted diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts index 959e0e8eb3c4..5f216c479b7f 100644 --- a/src/libs/SearchQueryUtils.ts +++ b/src/libs/SearchQueryUtils.ts @@ -81,7 +81,7 @@ import Onyx from 'react-native-onyx'; import type {SearchFullscreenNavigatorParamList} from './Navigation/types'; import type {SearchKey} from './SearchKeyUtils'; -import {getStandardExportTemplateDisplayName} from './AccountingUtils'; +import {EXPORT_TEMPLATE_SEARCH_PREFIX, getExportedToDisplayName, getExportedToPickerValue, getStandardExportTemplateDisplayName} from './AccountingUtils'; import {getBankAccountSearchLabel, isBankAccountPartiallySetup} from './BankAccountUtils'; import {getCardFeedsForDisplay} from './CardFeedUtils'; import {getCardDescription} from './CardUtils'; @@ -1320,7 +1320,10 @@ function normalizeDatePresetsInQuery(query: SearchQueryString): SearchQueryStrin /** * Returns whether a given search filter is supported in a given search data type */ -function isFilterSupported(filter: SearchAdvancedFiltersKey, type: SearchDataTypes) { +function isFilterSupported(filter: SearchAdvancedFiltersKey | typeof CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE, type: SearchDataTypes) { + if (filter === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE) { + return isFilterSupported(CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, type); + } const supportedTypeFilters = ALLOWED_TYPE_FILTERS[type]; if (!supportedTypeFilters) { return false; @@ -1709,6 +1712,24 @@ function getSanitizedRawFilters(queryJSON: SearchQueryJSON): RawQueryFilter[] | return sanitizedFilters; } +function getUnchangedRepeatedExportClauses(values: string[], flatFilters: QueryFilters | undefined): string | undefined { + const {EXPORTED_TO, EXPORTED_TO_TEMPLATE} = CONST.SEARCH.SYNTAX_FILTER_KEYS; + const originalClauses = flatFilters?.filter( + ({key, filters}) => (key === EXPORTED_TO || key === EXPORTED_TO_TEMPLATE) && filters.at(0)?.operator === CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO, + ); + if (!originalClauses || originalClauses.length === new Set(originalClauses.map(({key}) => key)).size) { + return; + } + + const originalValues = new Set(originalClauses.flatMap(({key, filters}) => filters.map(({value}) => getExportedToPickerValue(value.toString(), key === EXPORTED_TO_TEMPLATE)))); + if (originalValues.size !== values.length || !values.every((value) => originalValues.has(value))) { + return; + } + + // The picker stores one list, so rebuilding it would turn separate AND clauses into an OR list. + return originalClauses.map(({key, filters}) => buildFilterValuesString(key, filters).trim()).join(' '); +} + type BuildQueryStringOptions = { sortBy?: string; sortOrder?: string; @@ -1973,6 +1994,21 @@ function buildQueryStringFromFilterFormValues(filterValues: Partial 0 ) { const filterValueArray = [...new Set(filterValue)]; + if (filterKey === FILTER_KEYS.EXPORTED_TO) { + const originalClauses = isNegated ? undefined : getUnchangedRepeatedExportClauses(filterValueArray, options?.flatFilters); + if (originalClauses) { + return originalClauses; + } + const literals = filterValueArray.filter((value) => !value.startsWith(EXPORT_TEMPLATE_SEARCH_PREFIX)); + const templates = filterValueArray.filter((value) => value.startsWith(EXPORT_TEMPLATE_SEARCH_PREFIX)).map(getExportedToDisplayName); + return [ + literals.length ? `${prefix}${CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO}:${literals.map(sanitizeFilterValue).join(',')}` : '', + templates.length ? `${prefix}${CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE}:${templates.map(sanitizeFilterValue).join(',')}` : '', + ] + .filter(Boolean) + .join(' '); + } + const keyInCorrectForm = (Object.keys(CONST.SEARCH.SYNTAX_FILTER_KEYS) as FilterKeys[]).find((key) => CONST.SEARCH.SYNTAX_FILTER_KEYS[key] === filterKey); if (keyInCorrectForm) { @@ -2278,7 +2314,6 @@ function buildFilterFormValuesFromQuery( cardList: OnyxTypes.CardList | undefined, reports: OnyxCollection, taxRates: Record, - exportedToFilterOptions?: string[], currentUserAccountID?: number, bankAccountList?: OnyxTypes.BankAccountList, ) { @@ -2289,7 +2324,6 @@ function buildFilterFormValuesFromQuery( // Pre-compute dynamic validation Sets once (avoids recreating per filter iteration) const validCurrencies = new Set(Object.keys(currencyList)); const allTaxRateKeys = new Set(Object.values(taxRates).flat()); - const exportedToValues = new Set(exportedToFilterOptions ?? []); for (const queryFilter of filters) { const filterList = queryFilter.filters; @@ -2417,8 +2451,12 @@ function buildFilterFormValuesFromQuery( // Don't filter attendee values by personalDetails - they can be accountIDs OR display names for name-only attendees filtersForm[addNegation(filterKey, isNegated)] = filterValues; } - if (filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO) { - filtersForm[addNegation(filterKey, isNegated)] = filterValues.filter((value) => exportedToValues.has(value)); + if (filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO || queryFilter.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE) { + const isTemplate = queryFilter.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE; + const values = filterValues.map((value) => getExportedToPickerValue(value, isTemplate)); + const formKey = addNegation(CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, isNegated); + // A saved destination can be missing from the current picker options. + filtersForm[formKey] = [...new Set([...(filtersForm[formKey] ?? []), ...values])]; } if (filterKey === CONST.SEARCH.SYNTAX_FILTER_KEYS.PAYER) { diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index f44cc84c99df..285fe6bcb0bc 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -127,6 +127,7 @@ import type {CardFeedForDisplay} from './CardFeedUtils'; import type {ReportKey, SearchKey} from './SearchKeyUtils'; import type {SearchTypeMenuItem} from './SearchSuggestionUtils'; +import {getExportedToDisplayName} from './AccountingUtils'; import {startMoneyRequest} from './actions/IOU/MoneyRequest'; import {createTransactionThreadReport} from './actions/Report'; import {getReportActionsFromSearchSnapshot, setOptimisticDataForTransactionThreadPreview} from './actions/Search'; @@ -7117,6 +7118,10 @@ function getDisplayValue( return transactionStatus ? translate(`search.filters.transactionStatus.${transactionStatus}`) : undefined; } + if (key === FILTER_KEYS.EXPORTED_TO || key === FILTER_KEYS.EXPORTED_TO_NOT) { + return form[key]?.map(getExportedToDisplayName).join(', '); + } + const formValue = form[key]; return Array.isArray(formValue) ? formValue.join(', ') : formValue; } diff --git a/tests/ui/MultiSelectTest.tsx b/tests/ui/MultiSelectTest.tsx index 7a2dde538e6e..832b4a87ec5a 100644 --- a/tests/ui/MultiSelectTest.tsx +++ b/tests/ui/MultiSelectTest.tsx @@ -45,6 +45,28 @@ describe('MultiSelect', () => { mockedSelectionList.mockClear(); }); + it('forwards distinct screen reader labels without changing the visible names', () => { + // Given two destinations with the same visible name and different spoken labels. + const integration = {text: 'NetSuite', value: 'NetSuite', accessibilityLabel: 'exported-to:NetSuite'}; + const template = {text: 'NetSuite', value: 'template:NetSuite', accessibilityLabel: 'exported-to-template:NetSuite'}; + const destinations = [integration, template]; + + // When the template is selected in the existing multi-select list. + render( + , + ); + + // Then labels distinguish the choices and the list retains their selection states. + expect(mockedSelectionList.mock.lastCall?.[0].data).toEqual([ + expect.objectContaining({text: 'NetSuite', accessibilityLabel: 'exported-to:NetSuite', isSelected: false}), + expect.objectContaining({text: 'NetSuite', accessibilityLabel: 'exported-to-template:NetSuite', isSelected: true}), + ]); + }); + it('floats pre-selected items to the top on first render', () => { const preselected = buildItem(10); diff --git a/tests/ui/components/SearchAutocompleteInputTest.tsx b/tests/ui/components/SearchAutocompleteInputTest.tsx index 328883bc66d9..611aee4b58ce 100644 --- a/tests/ui/components/SearchAutocompleteInputTest.tsx +++ b/tests/ui/components/SearchAutocompleteInputTest.tsx @@ -123,7 +123,9 @@ describe('SearchAutocompleteInput', () => { jest.mocked(useExportedToFilterOptions).mockImplementation((override) => { const scopedPolicies = getAllPolicyValues(override ?? {value: ['usd'], isNegated: false}, ONYXKEYS.COLLECTION.POLICY, policies); return { - exportedToFilterOptions: scopedPolicies.some((policy) => policy.outputCurrency === CONST.CURRENCY.CAD) ? [standardTemplate, canadianTemplate] : [standardTemplate], + exportedToFilterOptions: scopedPolicies.some((policy) => policy.outputCurrency === CONST.CURRENCY.CAD) + ? [`template:${standardTemplate}`, `template:${canadianTemplate}`] + : [`template:${standardTemplate}`], connectedIntegrationNames: new Set(), }; }); diff --git a/tests/unit/AccountingUtilsTest.ts b/tests/unit/AccountingUtilsTest.ts index 68e901b0a148..f176c6aefc55 100644 --- a/tests/unit/AccountingUtilsTest.ts +++ b/tests/unit/AccountingUtilsTest.ts @@ -1,6 +1,10 @@ import { getAccountingIntegrationDisplayName, + getConnectionNameFromExportLabel, getExportLabelForConnection, + getExportTemplateSearchValue, + getExportedToDisplayName, + getExportedToPickerValue, getExportLabelsForConnection, getQBORefreshTokenExpiryDate, getQBORefreshTokenExpiryStatus, @@ -183,6 +187,24 @@ describe('AccountingUtils', () => { }); }); + describe('getConnectionNameFromExportLabel', () => { + it.each([ + ['xero', CONST.POLICY.CONNECTIONS.NAME.XERO], + ['NetSuite QuickStart', CONST.POLICY.CONNECTIONS.NAME.NETSUITE], + ['Intacct', CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT], + ['FinancialForce', CONST.POLICY.CONNECTIONS.NAME.CERTINIA], + ['Intuit Enterprise Suite', CONST.POLICY.CONNECTIONS.NAME.QBO], + ['COUNT', undefined], + ])('resolves the App connection for export label %s', (label, connectionName) => { + // Given an export label from a saved search, including labels with no App connection + // When resolving the connection for the integration icon + const result = getConnectionNameFromExportLabel(label); + + // Then use the known connection or let the picker show its default icon + expect(result).toBe(connectionName); + }); + }); + describe('getExportLabelsForConnection', () => { it('returns distinct labels for standard QBO and IES policies', () => { expect( @@ -194,3 +216,55 @@ describe('AccountingUtils', () => { }); }); }); + +describe('getExportTemplateSearchValue', () => { + it.each([ + ['NetSuite', 'template:NetSuite'], + ['Sage Intacct', 'template:Sage Intacct'], + ['Intacct', 'template:Intacct'], + ['Certinia', 'template:Certinia'], + ['NetSuite QuickStart', 'template:NetSuite QuickStart'], + ['Sage Accounting', 'template:Sage Accounting'], + ['Odoo', 'template:Odoo'], + ['My export', 'template:My export'], + ['template:NetSuite', 'template:template:NetSuite'], + ])('keeps template %s distinct as %s', (label, expected) => { + // Given a template name that may also be an accounting destination + // When preparing its picker value + const value = getExportTemplateSearchValue(label); + // Then keep its identity separate without changing the name + expect(value).toBe(expected); + }); +}); + +describe('getExportedToDisplayName', () => { + it.each([ + ['NetSuite', 'NetSuite'], + ['template:NetSuite', 'NetSuite'], + ['My export', 'My export'], + ['template:template:NetSuite', 'template:NetSuite'], + ])('keeps %s displayed as %s', (value, expected) => { + // Given an integration or template picker value + // When preparing its visible name + const displayName = getExportedToDisplayName(value); + // Then preserve the original name, including a literal prefix + expect(displayName).toBe(expected); + }); +}); + +describe('getExportedToPickerValue', () => { + it.each([ + ['NetSuite', false, 'NetSuite'], + ['NetSuite', true, 'template:NetSuite'], + ['Budget', false, 'template:Budget'], + ['Budget', true, 'template:Budget'], + ['template:Budget', false, 'template:template:Budget'], + ['template:Budget', true, 'template:template:Budget'], + ])('maps %s with template=%s to %s', (label, isTemplate, expected) => { + // Given a query value from either the legacy or explicit template key + // When resolving its picker identity + const value = getExportedToPickerValue(label, isTemplate); + // Then preserve accounting destinations and complete literal template names + expect(value).toBe(expected); + }); +}); diff --git a/tests/unit/ExportedToSelectorTest.tsx b/tests/unit/ExportedToSelectorTest.tsx new file mode 100644 index 000000000000..41db43860b81 --- /dev/null +++ b/tests/unit/ExportedToSelectorTest.tsx @@ -0,0 +1,104 @@ +import {render} from '@testing-library/react-native'; + +import ExportedToSelector from '@components/Search/FilterComponents/ExportedToSelector'; + +import CONST from '@src/CONST'; +import IntlStore from '@src/languages/IntlStore'; +import ONYXKEYS from '@src/ONYXKEYS'; +import type IconAsset from '@src/types/utils/IconAsset'; + +import type {ReactElement, ReactNode} from 'react'; + +import React from 'react'; + +import {translateLocal} from '../utils/TestHelper'; +import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; + +const mockOnChange = jest.fn(); +const mockIcon = jest.fn(() => null); +const mockTranslate = translateLocal; +const mockIcons = { + NetSuiteSquare: () => null, + Export: () => null, + Table: () => null, + TablePencil: () => null, +}; +const mockMultiSelect = jest.fn< + ReactNode, + [ + { + items: Array<{text: string; value: string; leftElement?: ReactElement; accessibilityLabel?: string}>; + value: Array<{text: string; value: string}>; + onChange: (items: Array<{text: string; value: string}>) => void; + }, + ] +>(() => null); + +const mockPolicies = { + [`${ONYXKEYS.COLLECTION.POLICY}1`]: {id: '1', connections: {[CONST.POLICY.CONNECTIONS.NAME.NETSUITE]: {lastSync: {isConnected: true}}}}, +}; + +jest.mock('@components/Search/FilterComponents/MultiSelect', () => (props: Parameters[0]) => mockMultiSelect(props)); +jest.mock('@components/Icon', () => (props: {src: IconAsset}) => mockIcon(props)); +jest.mock('@hooks/useCombinedExportTemplates', () => () => [{templateName: 'custom-netsuite', name: 'NetSuite', type: 'integrations'}]); +jest.mock('@hooks/useOnyx', () => () => [mockPolicies]); +jest.mock('@hooks/useLocalize', () => () => ({localeCompare: (left: string, right: string) => left.localeCompare(right), translate: mockTranslate})); +jest.mock('@hooks/useTheme', () => () => ({icon: '#000000'})); +jest.mock('@hooks/useThemeStyles', () => () => ({})); +jest.mock('@hooks/useStyleUtils', () => () => ({getWidthAndHeightStyle: () => ({}), getAvatarBorderStyle: () => ({})})); +jest.mock('@hooks/useLazyAsset', () => ({useMemoizedLazyExpensifyIcons: () => mockIcons})); + +describe('ExportedToSelector', () => { + beforeAll(() => { + IntlStore.load(CONST.LOCALES.DEFAULT); + return waitForBatchedUpdates(); + }); + + it('keeps names unchanged while selecting integration and template values separately', () => { + // Given a workspace with an integration and template both named NetSuite + // When opening the picker with the template selected + render( + , + ); + const props = mockMultiSelect.mock.calls.at(-1)?.[0]; + + // Then retain both choices with their existing names and icons + expect(props?.items.map(({text, value}) => ({text, value}))).toEqual([ + {text: 'NetSuite', value: 'NetSuite'}, + {text: 'NetSuite', value: 'template:NetSuite'}, + ]); + expect(props?.items.every(({leftElement}) => leftElement !== undefined)).toBe(true); + expect(props?.items.map(({accessibilityLabel}) => accessibilityLabel)).toEqual(['NetSuite, integration', 'NetSuite, export template']); + expect(props?.value.map(({value}) => value)).toEqual(['template:NetSuite']); + props?.onChange(props.items); + expect(mockOnChange).toHaveBeenCalledWith(['NetSuite', 'template:NetSuite']); + }); + + it('distinguishes saved integrations from templates outside the connected workspace', () => { + // Given saved integrations with and without a known logo outside the selected workspace + render( + , + ); + + // When the picker shows the saved selections alongside any available template + const items = mockMultiSelect.mock.calls.at(-1)?.[0].items ?? []; + mockIcon.mockClear(); + for (const item of items) { + if (item.leftElement) { + render(item.leftElement); + } + } + + // Then use the integration logo and the neutral export icon alongside the distinct template icon + expect(items.map(({accessibilityLabel}) => accessibilityLabel)).toEqual(['COUNT, integration', 'NetSuite, export template', 'NetSuite, integration']); + expect(mockIcon.mock.calls.map(([{src}]) => src)).toEqual([mockIcons.Export, mockIcons.TablePencil, mockIcons.NetSuiteSquare]); + }); +}); diff --git a/tests/unit/Search/SearchQueryUtilsTest.ts b/tests/unit/Search/SearchQueryUtilsTest.ts index 2628ae007d83..eec6e5edbf85 100644 --- a/tests/unit/Search/SearchQueryUtilsTest.ts +++ b/tests/unit/Search/SearchQueryUtilsTest.ts @@ -3215,7 +3215,7 @@ describe('SearchQueryUtils', () => { throw new Error('Failed to parse query string'); } - const result = buildFilterFormValuesFromQuery(queryJSON, policyCategories, currencyList, personalDetails, cardList, reports, taxRates, undefined, currentUserAccountID); + const result = buildFilterFormValuesFromQuery(queryJSON, policyCategories, currencyList, personalDetails, cardList, reports, taxRates, currentUserAccountID); expect(result.from).toEqual(['12345']); }); @@ -3268,7 +3268,7 @@ describe('SearchQueryUtils', () => { throw new Error('Failed to parse query string'); } - const result = buildFilterFormValuesFromQuery(queryJSON, policyCategories, currencyList, personalDetails, cardList, reports, taxRates, undefined, currentUserAccountID); + const result = buildFilterFormValuesFromQuery(queryJSON, policyCategories, currencyList, personalDetails, cardList, reports, taxRates, currentUserAccountID); expect(result.to).toEqual(['99999']); }); @@ -4498,6 +4498,26 @@ describe('SearchQueryUtils', () => { const mockReports = {}; const currentUserAccountID = 12345; + it('preserves literal prefixes in editable Search syntax', () => { + // Given an existing template whose name starts with template: + // When displaying its exported-to value + // Then leave the literal name intact + expect( + getFilterDisplayValue({ + filterName: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, + filterValue: 'template:NetSuite', + personalDetails: {}, + reports: {}, + cardList: {}, + cardFeeds: {}, + policies: {}, + currentUserAccountID, + translate: translateLocal, + formatPhoneNumber, + }), + ).toBe('template:NetSuite'); + }); + it('should return clean phone number without @expensify.sms for SMS login users', () => { const personalDetails = { '99999': { @@ -7869,3 +7889,123 @@ describe('SearchQueryUtils', () => { }); }); }); + +describe('template destination queries', () => { + it('keeps literal quotes in a template name selected in Filters', () => { + // Given a template whose name includes quotation marks + const name = '"Budget"'; + + // When applying the selected template filter + const query = buildQueryStringFromFilterFormValues({exportedTo: [`template:${name}`]}); + + // Then the backend filter still includes the literal quotation marks + expect(buildSearchQueryJSON(query)?.filters).toEqual({operator: 'eq', left: 'exportedToTemplate', right: name}); + }); + + it('keeps repeated export clauses ANDed within each destination type', () => { + // Given separate clauses for two integrations and two templates + const query = 'exported-to:NetSuite exported-to:Xero exported-to-template:Budget exported-to-template:Payroll'; + + // When Search builds the filter tree for Auth + const parsedQuery = buildSearchQueryJSON(query); + + // Then either group can match, but a matching group must satisfy both of its clauses + expect(parsedQuery?.filters).toEqual({ + operator: 'or', + left: {operator: 'and', left: {operator: 'eq', left: 'exportedTo', right: 'NetSuite'}, right: {operator: 'eq', left: 'exportedTo', right: 'Xero'}}, + right: {operator: 'and', left: {operator: 'eq', left: 'exportedToTemplate', right: 'Budget'}, right: {operator: 'eq', left: 'exportedToTemplate', right: 'Payroll'}}, + }); + }); + + it('keeps repeated export clauses when a different filter changes', () => { + // Given a typed search with repeated integration clauses and a template clause + const text = 'exported-to:NetSuite exported-to:Xero exported-to-template:Budget'; + const query = buildSearchQueryJSON(text); + if (!query) { + throw new Error('Expected valid query'); + } + const form = buildFilterFormValuesFromQuery(query, {}, {}, {}, {}, {}, {}); + + // When applying a date filter without editing the destinations + const updated = buildFilterQueryWithSortDefaults({...form, dateAfter: '2026-01-01'}, {}, query) ?? ''; + + // Then the original integration clauses still require both integrations + expect(buildSearchQueryJSON(updated)?.filters).toEqual(buildSearchQueryJSON(`${text} date>2026-01-01`)?.filters); + }); + + it('uses the picker’s any-match behavior after changing the selected destinations', () => { + // Given a typed search requiring two integrations or a template + const query = buildSearchQueryJSON('exported-to:NetSuite exported-to:Xero exported-to-template:Budget'); + if (!query) { + throw new Error('Expected valid query'); + } + const form = buildFilterFormValuesFromQuery(query, {}, {}, {}, {}, {}, {}); + + // When adding a destination in the picker + const updated = buildFilterQueryWithSortDefaults({...form, exportedTo: ['NetSuite', 'Xero', 'COUNT', 'template:Budget']}, {}, query) ?? ''; + + // Then a report exported to any selected destination can match + expect(buildSearchQueryJSON(updated)?.filters).toEqual(buildSearchQueryJSON('exported-to:NetSuite,Xero,COUNT exported-to-template:Budget')?.filters); + }); + + it.each(['NetSuite', 'netsuite', 'COUNT'])('preserves a saved %s integration filter when reapplying Advanced Filters', (name) => { + // Given a saved integration filter for a destination the picker may not list + const query = buildSearchQueryJSON(`exported-to:${name}`); + if (!query) { + throw new Error('Expected valid query'); + } + + // When reopening and applying Advanced Filters + const form = buildFilterFormValuesFromQuery(query, {}, {}, {}, {}, {}, {}); + const updatedQuery = buildSearchQueryJSON(buildQueryStringFromFilterFormValues(form)); + + // Then keep the integration constraint so applying the form cannot broaden the search + expect(updatedQuery?.filters).toEqual(query.filters); + }); + + it.each(['template:Budget', 'template:NetSuite'])('preserves an existing literal template name %s when applying filters', (name) => { + // Given a saved search for a template whose name already contains the old marker + const query = buildSearchQueryJSON(`exported-to:${name}`); + if (!query) { + throw new Error('Expected valid query'); + } + // When opening and applying Advanced filters + const form = buildFilterFormValuesFromQuery(query, {}, {}, {}, {}, {}, {}); + const updatedQuery = buildSearchQueryJSON(buildQueryStringFromFilterFormValues(form)); + // Then preserve the complete template name in the backend filter + expect(form.exportedTo).toEqual([`template:${name}`]); + expect(updatedQuery?.filters).toEqual({operator: 'eq', left: 'exportedToTemplate', right: name}); + }); + + it.each([false, true])('round-trips mixed destinations with negation=%s', (isNegated) => { + // Given both destinations selected in the same picker + const key = isNegated ? FILTER_KEYS.EXPORTED_TO_NOT : FILTER_KEYS.EXPORTED_TO; + // When applying and reopening the filters + const values: Partial = isNegated ? {exportedToNot: ['NetSuite', 'template:NetSuite']} : {exportedTo: ['NetSuite', 'template:NetSuite']}; + const query = buildSearchQueryJSON(buildQueryStringFromFilterFormValues(values)); + if (!query) { + throw new Error('Expected valid query'); + } + const form = buildFilterFormValuesFromQuery(query, {}, {}, {}, {}, {}, {}); + // Then positive selections match either destination and negative selections exclude both + expect(query.filters).toEqual({ + operator: isNegated ? 'and' : 'or', + left: {operator: isNegated ? 'neq' : 'eq', left: 'exportedTo', right: 'NetSuite'}, + right: {operator: isNegated ? 'neq' : 'eq', left: 'exportedToTemplate', right: 'NetSuite'}, + }); + expect(form[key]).toEqual(['NetSuite', 'template:NetSuite']); + }); + + it.each(['NetSuite', 'Budget', 'template:Budget'])('reapplies explicit template %s from a saved search', (name) => { + // Given a saved search with an explicit template filter + const query = buildSearchQueryJSON(`exported-to-template:${name}`); + if (!query) { + throw new Error('Expected valid query'); + } + // When opening Advanced filters + const form = buildFilterFormValuesFromQuery(query, {}, {}, {}, {}, {}, {}); + // Then applying the form cannot silently remove the template constraint + expect(form.exportedTo).toEqual([`template:${name}`]); + expect(buildSearchQueryJSON(buildQueryStringFromFilterFormValues(form))?.filters).toEqual(query.filters); + }); +}); diff --git a/tests/unit/Search/getUpdatedSubstitutionsMapTest.ts b/tests/unit/Search/getUpdatedSubstitutionsMapTest.ts index 9810566c888d..a0c1bb5a3def 100644 --- a/tests/unit/Search/getUpdatedSubstitutionsMapTest.ts +++ b/tests/unit/Search/getUpdatedSubstitutionsMapTest.ts @@ -1,5 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ // we need "dirty" object key names in these tests +import {getQueryWithSubstitutions} from '@components/Search/SearchRouter/getQueryWithSubstitutions'; + import {getUpdatedSubstitutionsMap} from '@src/components/Search/SearchRouter/getUpdatedSubstitutionsMap'; describe('getUpdatedSubstitutionsMap should return updated and cleaned substitutions map', () => { @@ -70,3 +72,17 @@ describe('getUpdatedSubstitutionsMap should return updated and cleaned substitut }); }); }); + +describe('template export queries', () => { + it.each([ + ['exported-to-template:NetSuite -exported-to:NetSuite', '-exported-to:NetSuite'], + ['exported-to:NetSuite -exported-to-template:NetSuite', '-exported-to-template:NetSuite'], + ])('keeps the remaining destination unchanged when editing %s', (originalQuery, editedQuery) => { + // Given an editable query with separate integration and template keys + expect(getQueryWithSubstitutions(originalQuery, {})).toBe(originalQuery); + // When removing one destination + const substitutions = getUpdatedSubstitutionsMap(editedQuery, {}); + // Then the remaining destination keeps its identity + expect(getQueryWithSubstitutions(editedQuery, substitutions)).toBe(editedQuery); + }); +}); diff --git a/tests/unit/SearchAutocompleteListTest.tsx b/tests/unit/SearchAutocompleteListTest.tsx index 2e9b9bb23a96..7171af5c0927 100644 --- a/tests/unit/SearchAutocompleteListTest.tsx +++ b/tests/unit/SearchAutocompleteListTest.tsx @@ -112,10 +112,12 @@ jest.mock('@src/hooks/useRootNavigationState', () => ({ default: () => mockRootNavigationState(), })); +let mockExportedToFilterOptions: string[] = []; + jest.mock('@hooks/useExportedToFilterOptions', () => ({ __esModule: true, default: () => ({ - exportedToFilterOptions: [], + exportedToFilterOptions: mockExportedToFilterOptions, connectedIntegrationNames: new Set(), }), })); @@ -257,6 +259,7 @@ describe('SearchAutocompleteList', () => { }); beforeEach(() => { + mockExportedToFilterOptions = []; jest.useFakeTimers(); global.fetch = TestHelper.getGlobalFetchMock(); wrapOnyxWithWaitForBatchedUpdates(Onyx); @@ -290,6 +293,49 @@ describe('SearchAutocompleteList', () => { expect(mockUseNavigationSuggestions).toHaveBeenCalledWith(expect.any(String), shouldWatchForApprovals); }); + it.each([ + ['exported-to:Bud', 'exported-to-template:Budget'], + ['exported-to:Net', 'exported-to-template:NetSuite'], + ['exported-to:template:Bud', 'exported-to-template:template:Budget'], + ['exported-to-template:template:Bud', 'exported-to-template:template:Budget'], + ['exported-to:Net', 'exported-to:NetSuite'], + ])('inserts the export query shown in the suggestion for %s: %s', async (input, expected) => { + // Given integration and template choices, including a literal template: prefix + mockExportedToFilterOptions = ['NetSuite', 'template:NetSuite', 'template:Budget', 'template:template:Budget']; + render(); + await flushAllUpdates(); + + // When choosing the suggested query shown for a partially typed destination + fireEvent.changeText(screen.getByTestId('search-autocomplete-text-input'), input); + await flushAllUpdates(); + fireEvent.press(screen.getByText(expected)); + await flushAllUpdates(); + + // Then the inserted query matches the preview, preserving the complete template name + expect(screen.getByTestId('search-autocomplete-text-input')).toHaveProp('value', `${expected}\u00A0`); + }); + + it.each([ + ['-exported-to:NetSuite,All Data', 'exported-to-template:All Data - Expense Level Export', '-exported-to:NetSuite -exported-to-template:"All Data - Expense Level Export"'], + ['exported-to:"Budget, F"', 'exported-to-template:Budget, FY2026', 'exported-to-template:"Budget, FY2026"'], + ['exported-to-template:"Budget, F"', 'exported-to-template:Budget, FY2026', 'exported-to-template:"Budget, FY2026"'], + ['-exported-to = Net', 'exported-to-template:NetSuite', '-exported-to-template:NetSuite'], + ])('completes export clauses without changing their meaning: %s', async (input, suggestion, expected) => { + // Given ordinary template names containing spaces or commas + mockExportedToFilterOptions = ['NetSuite', 'template:NetSuite', 'template:All Data - Expense Level Export', 'template:Budget, FY2026']; + render(); + await flushAllUpdates(); + + // When selecting a suggestion from a negated clause or a quoted value + fireEvent.changeText(screen.getByTestId('search-autocomplete-text-input'), input); + await flushAllUpdates(); + fireEvent.press(screen.getByText(suggestion)); + await flushAllUpdates(); + + // Then retain the clause's negation and previous values, with the full template name quoted + expect(screen.getByTestId('search-autocomplete-text-input')).toHaveProp('value', `${expected}\u00A0`); + }); + it('asks for the option list with the config shared with the SearchRouter warm-up', () => { render(); diff --git a/tests/unit/SearchAutocompleteUtilsTest.ts b/tests/unit/SearchAutocompleteUtilsTest.ts index 7b86a6fe66be..13e7321293eb 100644 --- a/tests/unit/SearchAutocompleteUtilsTest.ts +++ b/tests/unit/SearchAutocompleteUtilsTest.ts @@ -1,9 +1,16 @@ import type {SubstitutionMap} from '@components/Search/SearchRouter/getQueryWithSubstitutions'; import {getExportLabelForConnection, getStandardExportTemplateDisplayName, isStandardExportTemplate, isStandardExportTemplateLabel} from '@libs/AccountingUtils'; -import {getAutocompletePolicyData, getTrimmedUserSearchQueryPreservingComma, parseForAutocomplete, parseForLiveMarkdown} from '@libs/SearchAutocompleteUtils'; +import { + getAutocompletePolicyData, + getTrimmedUserSearchQueryPreservingComma, + getQueryWithAutocompleteSelection, + parseForAutocomplete, + parseForLiveMarkdown, +} from '@libs/SearchAutocompleteUtils'; import type {KnownFilterValues} from '@libs/SearchAutocompleteUtils'; import {parse} from '@libs/SearchParser/autocompleteParser'; +import {buildSearchQueryJSON} from '@libs/SearchQueryUtils'; import CONST from '@src/CONST'; @@ -72,8 +79,8 @@ describe('SearchAutocompleteUtils', () => { tags: new Set(['Project A', 'Project B', 'Urgent']), exportedTo: new Set([ ...CONST.POLICY.CONNECTIONS.EXPORTED_TO_INTEGRATION_DISPLAY_NAMES, - CONST.REPORT.EXPORT_OPTION_LABELS.EXPENSE_LEVEL_EXPORT, - CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT, + `template:${CONST.REPORT.EXPORT_OPTION_LABELS.EXPENSE_LEVEL_EXPORT}`, + `template:${CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT}`, ]), }; @@ -833,3 +840,48 @@ describe('ordinary autocomplete parser boundaries', () => { expect(result).toEqual(expected); }); }); + +describe('export destination autocomplete selection', () => { + const templateExclusion = {operator: 'neq', left: 'exportedToTemplate', right: 'Budget'}; + + it.each([ + ['exported-to != Bud', templateExclusion], + ['exported-to != NetSuite,Bud', {operator: 'and', left: {operator: 'neq', left: 'exportedTo', right: 'NetSuite'}, right: templateExclusion}], + ])('parses the completed template exclusion for %s', (input, expectedFilters) => { + // Given an exclusion with an incomplete template name + const completedQuery = getQueryWithAutocompleteSelection(input, CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, 'template:Budget'); + + // When Search parses the completed query + const parsedQuery = buildSearchQueryJSON(completedQuery); + + // Then exclude the template and retain any existing integration exclusion + expect(parsedQuery?.filters).toEqual(expectedFilters); + }); + + it.each([ + ['exported-to:Net', 'template:NetSuite', 'exported-to-template:NetSuite'], + ['-exported-to:Net', 'template:NetSuite', '-exported-to-template:NetSuite'], + ['exportedTo:Net', 'template:NetSuite', 'exported-to-template:NetSuite'], + ['exported-to:NetSuite,Net', 'template:NetSuite', 'exported-to:NetSuite exported-to-template:NetSuite'], + ['-exported-to:NetSuite,Net', 'template:NetSuite', '-exported-to:NetSuite -exported-to-template:NetSuite'], + ['exported-to:template:Bud', 'template:template:Budget', 'exported-to-template:template:Budget'], + ['exported-to:Net', 'NetSuite', 'exported-to:NetSuite'], + ['-exported-to:NetSuite,All Data', 'template:All Data - Expense Level Export', '-exported-to:NetSuite -exported-to-template:"All Data - Expense Level Export"'], + ['exported-to:"Budget, F"', 'template:Budget, FY2026', 'exported-to-template:"Budget, FY2026"'], + ['exported-to:NetSuite,"Budget, F"', 'template:Budget, FY2026', 'exported-to:NetSuite exported-to-template:"Budget, FY2026"'], + ['exported-to : Net', 'template:NetSuite', 'exported-to-template:NetSuite'], + ['-exported-to = Net', 'template:NetSuite', '-exported-to-template:NetSuite'], + ['exported-to != Bud', 'template:Budget', 'exported-to-template!=Budget'], + ['exported-to != NetSuite,Bud', 'template:Budget', 'exported-to != NetSuite exported-to-template!=Budget'], + ['exported-to != NetSuite,', 'template:Budget', 'exported-to != NetSuite exported-to-template!=Budget'], + ['-exported-to != NetSuite,Bud', 'template:Budget', '-exported-to != NetSuite -exported-to-template!=Budget'], + ['exported-to != Xero exported-to:NetSuite,Bud', 'template:Budget', 'exported-to != Xero exported-to:NetSuite exported-to-template:Budget'], + ['exported-to != NetSuite,All Data', 'template:All Data - Expense Level Export', 'exported-to != NetSuite exported-to-template!="All Data - Expense Level Export"'], + ])('selects %s as %s', (input, selectedValue, expected) => { + // Given a partial exported-to query and a destination selected from the picker + // When inserting the suggestion through the router helper + const result = getQueryWithAutocompleteSelection(input, CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, selectedValue); + // Then use a distinct query key and preserve literal template names + expect(result.trim()).toBe(expected); + }); +}); diff --git a/tests/unit/hooks/useAutocompleteSuggestions.test.ts b/tests/unit/hooks/useAutocompleteSuggestions.test.ts index 6ce189e38c13..a8e5f0467627 100644 --- a/tests/unit/hooks/useAutocompleteSuggestions.test.ts +++ b/tests/unit/hooks/useAutocompleteSuggestions.test.ts @@ -161,6 +161,34 @@ describe('useAutocompleteSuggestions', () => { } }); + it('keeps accounting and template autocomplete values distinct after either is selected', () => { + // Given an integration and template both named NetSuite + const originalImplementation = jest.mocked(useExportedToFilterOptions).getMockImplementation(); + jest.mocked(useExportedToFilterOptions).mockReturnValue({exportedToFilterOptions: ['NetSuite', 'template:NetSuite'], connectedIntegrationNames: new Set()}); + parseForAutocomplete.mockReturnValue({autocomplete: {key: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, value: 'Net'}, ranges: []}); + // When searching for that destination + const {result, rerender} = renderHook(({query}) => useAutocompleteSuggestions({...defaultParams, autocompleteQueryValue: query}), {initialProps: {query: 'exported-to:Net'}}); + // Then both are suggested, and selecting either leaves the other available + expect(result.current.map(({text}) => text)).toEqual(['NetSuite', 'template:NetSuite']); + + parseForAutocomplete.mockReturnValue({ + autocomplete: {key: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, value: ''}, + ranges: [{key: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO_TEMPLATE, value: 'NetSuite'}], + }); + rerender({query: 'exported-to-template:NetSuite exported-to:'}); + expect(result.current.map(({text}) => text)).toEqual(['NetSuite']); + + parseForAutocomplete.mockReturnValue({ + autocomplete: {key: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, value: ''}, + ranges: [{key: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, value: 'NetSuite'}], + }); + rerender({query: 'exported-to:NetSuite exported-to:'}); + expect(result.current.map(({text}) => text)).toEqual(['template:NetSuite']); + if (originalImplementation) { + jest.mocked(useExportedToFilterOptions).mockImplementation(originalImplementation); + } + }); + it('returns empty array when autocompleteKey is undefined (empty query)', () => { parseForAutocomplete.mockReturnValue({autocomplete: null, ranges: []}); diff --git a/tests/unit/hooks/useExportedToFilterOptions.test.ts b/tests/unit/hooks/useExportedToFilterOptions.test.ts index 74d78a3b9352..211aab6a6f02 100644 --- a/tests/unit/hooks/useExportedToFilterOptions.test.ts +++ b/tests/unit/hooks/useExportedToFilterOptions.test.ts @@ -91,7 +91,29 @@ describe('useExportedToFilterOptions', () => { const {result} = renderHook(() => useExportedToFilterOptions()); - expect(result.current.exportedToFilterOptions).toContain(customName); + expect(result.current.exportedToFilterOptions).toContain(`template:${customName}`); + }); + + it('keeps an accounting destination and a same-named template separately selectable', async () => { + // Given a connected integration and template sharing a name + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}1`, buildPolicyWithConnection('1', CONST.POLICY.CONNECTIONS.NAME.NETSUITE)); + mockGetExportTemplates.mockReturnValue({ + customTemplates: [ + createMock({ + templateName: 'custom-netsuite', + name: 'NetSuite', + type: CONST.EXPORT_TEMPLATE_TYPES.INTEGRATIONS, + }), + ], + defaultTemplates: [], + }); + + // When loading available export destinations + const {result} = renderHook(() => useExportedToFilterOptions()); + + // Then both destinations remain selectable independently + expect(result.current.exportedToFilterOptions).toContain('NetSuite'); + expect(result.current.exportedToFilterOptions).toContain('template:NetSuite'); }); it('builds templates once without in-app layouts, regardless of how many policies exist', async () => { @@ -151,7 +173,7 @@ describe('useExportedToFilterOptions', () => { const {result} = renderHook(() => useExportedToFilterOptions({value, isNegated})); // Then both the CAD template and accounting integrations follow the override - expect(result.current.exportedToFilterOptions.includes(CONST.REPORT.EXPORT_OPTION_LABELS.MULTIPLE_TAX_EXPORT)).toBe(shouldIncludeMultipleTaxExport); + expect(result.current.exportedToFilterOptions.includes(`template:${CONST.REPORT.EXPORT_OPTION_LABELS.MULTIPLE_TAX_EXPORT}`)).toBe(shouldIncludeMultipleTaxExport); expect(result.current.connectedIntegrationNames.has(CONST.POLICY.CONNECTIONS.NAME.QBO)).toBe(!value || value.includes('usd') !== isNegated); expect(result.current.connectedIntegrationNames.has(CONST.POLICY.CONNECTIONS.NAME.XERO)).toBe(!value || value.includes('cad') !== isNegated); }); @@ -194,7 +216,7 @@ describe('useExportedToFilterOptions', () => { const {result} = renderHook(() => useExportedToFilterOptions()); - expect(result.current.exportedToFilterOptions).toContain(expenseLevelLabel); + expect(result.current.exportedToFilterOptions).toContain(`template:${expenseLevelLabel}`); }); it('returns connectedIntegrationNames from getConnectedIntegrationNamesForPolicies', async () => {