This commit is contained in:
Timmy Crawford 2018-12-13 09:06:26 -08:00 committed by GitHub
parent 2dbbc39071
commit 19b209fca4
2 changed files with 18 additions and 2 deletions

View File

@ -12,8 +12,7 @@ import { stringifyQuery } from '@woocommerce/navigation';
/**
* Internal dependencies
*/
import { computeSuggestionMatch } from './utils';
import { getTaxCode } from 'analytics/report/taxes/utils';
import { computeSuggestionMatch, getTaxCode } from './utils';
/**
* A tax completer.

View File

@ -1,4 +1,9 @@
/** @format */
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
/**
* Parse a string suggestion, split apart by where the first matching query is.
* Used to display matched partial in bold.
@ -19,3 +24,15 @@ export function computeSuggestionMatch( suggestion, query ) {
suggestionAfterMatch: suggestion.substring( indexOfMatch + query.length ),
};
}
export function getTaxCode( tax ) {
return [ tax.country, tax.state, tax.name || __( 'TAX', 'wc-admin' ), tax.priority ]
.map( item =>
item
.toString()
.toUpperCase()
.trim()
)
.filter( Boolean )
.join( '-' );
}