Change the generic tax driver to remove spaces around commas when adding a new row. Add tests and a convenience method for getting one line of tax information. Upgrade sub fixes any information already in the db.
This commit is contained in:
parent
6ac46be8bd
commit
2bcda0c9f5
5 changed files with 69 additions and 7 deletions
|
|
@ -1,10 +1,9 @@
|
|||
7.10.20
|
||||
- fixed: Do not call group methods on an undefined value.
|
||||
- fixed #12178: random deletion of columns may happen when a schema is saved
|
||||
(Amir Plivatsky)
|
||||
- fixed #12179: DataTable Field types get reset to "Text" in Edit Schema
|
||||
(Amir Plivatsky)
|
||||
- fixed #12178: random deletion of columns may happen when a schema is saved (Amir Plivatsky)
|
||||
- fixed #12179: DataTable Field types get reset to "Text" in Edit Schema (Amir Plivatsky)
|
||||
- added: FormField macro for rendering Form objects directly from templates
|
||||
- fixed: Generic Tax driver does not like spaces around commas
|
||||
|
||||
7.10.19
|
||||
- fixed #12169: extras uploads symlink export
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ finish($session); # this line required
|
|||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Fix calendar feed urls that had adminId attached to them until they blew up
|
||||
sub fixBrokenCalendarFeedUrls {
|
||||
my $session = shift;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ my $session = start(); # this line required
|
|||
addFormFieldMacroToConfig();
|
||||
|
||||
# upgrade functions go here
|
||||
fixSpacesInTaxInfo ( $session );
|
||||
|
||||
sub addFormFieldMacroToConfig {
|
||||
print "\tAdd FormField macro to config... " unless $quiet;
|
||||
|
|
@ -51,6 +52,22 @@ finish($session); # this line required
|
|||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Fix calendar feed urls that had adminId attached to them until they blew up
|
||||
sub fixSpacesInTaxInfo {
|
||||
my $session = shift;
|
||||
print "\tRemoving spaces around commas in generic tax rate information... " unless $quiet;
|
||||
use WebGUI::Shop::TaxDriver::Generic;
|
||||
my $taxer = WebGUI::Shop::TaxDriver::Generic->new($session);
|
||||
my $taxIterator = $taxer->getItems;
|
||||
while (my $taxInfo = $taxIterator->hashRef) {
|
||||
my $taxId = $taxInfo->{taxId};
|
||||
$taxer->add($taxInfo); ##Automatically removes spaces now.
|
||||
$taxer->delete({taxId => $taxId});
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@ sub add {
|
|||
unless exists($params->{taxRate}) and defined $params->{taxRate};
|
||||
|
||||
$params->{taxId} = 'new';
|
||||
##Remove spaces around commas, which will break tax lookups
|
||||
foreach my $param (qw/country city state code/) {
|
||||
$params->{$param} =~ s/\s*,\s*/,/g;
|
||||
}
|
||||
my $id = $self->session->db->setRow('tax_generic_rates', 'taxId', $params);
|
||||
return $id;
|
||||
}
|
||||
|
|
@ -222,6 +226,24 @@ sub getAllItems {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getItem ( $taxId )
|
||||
|
||||
Returns all data for one tax item as a hash reference.
|
||||
|
||||
=head3 $taxId
|
||||
|
||||
The identifier for the row of tax data to return.
|
||||
|
||||
=cut
|
||||
|
||||
sub getItem {
|
||||
my $self = shift;
|
||||
my $result = $self->session->db->quickHashRef('select * from tax_generic_rates where taxId=?',[shift]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getItems ( )
|
||||
|
||||
Returns a WebGUI::SQL::Result object for accessing all of the data in the tax table. This
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ $session->user({userId => 3});
|
|||
|
||||
my $addExceptions = getAddExceptions($session);
|
||||
|
||||
my $tests = 79 + 2*scalar(@{$addExceptions});
|
||||
my $tests = 80 + 2*scalar(@{$addExceptions});
|
||||
plan tests => $tests;
|
||||
|
||||
WebGUI::Test->addToCleanup(SQL => 'delete from tax_generic_rates');
|
||||
#WebGUI::Test->addToCleanup(SQL => 'delete from tax_generic_rates');
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -147,6 +147,30 @@ my $dupId = $taxer->add($taxData);
|
|||
$taxIterator = $taxer->getItems;
|
||||
is($taxIterator->rows, 3, 'add permits adding duplicate information.');
|
||||
|
||||
my $spaceId = $taxer->add({
|
||||
country => 'USA, United States , United States Of America ,U.S.A',
|
||||
state => 'Wisconsin, WI',
|
||||
city => 'MADCITY, madcity, Madison , WebGUIVille',
|
||||
code => '77575, 54703 , 97424',
|
||||
taxRate => '7.77',
|
||||
});
|
||||
|
||||
my $no_spaces = $taxer->getItem($spaceId);
|
||||
cmp_deeply (
|
||||
$no_spaces,
|
||||
{
|
||||
country => 'USA,United States,United States Of America,U.S.A',
|
||||
state => 'Wisconsin,WI',
|
||||
city => 'MADCITY,madcity,Madison,WebGUIVille',
|
||||
taxRate => '7.77',
|
||||
taxId => $spaceId,
|
||||
code => '77575,54703,97424',
|
||||
},
|
||||
'Spaces removed from content when adding'
|
||||
);
|
||||
|
||||
$taxer->delete({taxId => $spaceId});
|
||||
|
||||
##Madison zip codes:
|
||||
##53701-53709
|
||||
##city rate: 0.5%
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue