optimize the SQL query for getting tax rates
This commit is contained in:
parent
d956e58bd7
commit
50fc494759
2 changed files with 6 additions and 14 deletions
|
|
@ -222,20 +222,12 @@ sub getTaxRates {
|
|||
my $code = $address->get('code');
|
||||
my $result = $self->session->db->buildArrayRef(
|
||||
q{
|
||||
select taxRate from tax where
|
||||
(country=? and state='' and city='' and code='')
|
||||
OR (country=? and state=? and city='' and code='')
|
||||
OR (country=? and state=? and city=? and code='')
|
||||
OR (country=? and state=? and city='' and code=? )
|
||||
OR (country=? and state=? and city=? and code=? )
|
||||
select taxRate from tax where country=?
|
||||
and (state='' or state=?)
|
||||
and (city='' or city=?)
|
||||
and (code='' or code=?)
|
||||
},
|
||||
[
|
||||
$country,
|
||||
$country, $state,
|
||||
$country, $state, $city,
|
||||
$country, $state, $code,
|
||||
$country, $state, $city, $code,
|
||||
]);
|
||||
[ $country, $state, $city, $code, ]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@ cmp_deeply(
|
|||
|
||||
cmp_deeply(
|
||||
$taxer->getTaxRates($taxFreeAddress),
|
||||
[0.0],
|
||||
[0,0],
|
||||
'getTaxRates: return correct data for a state with no tax data'
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue