diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 59be7785e..b0231478a 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -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 diff --git a/docs/upgrades/upgrade_7.10.18-7.10.19.pl b/docs/upgrades/upgrade_7.10.18-7.10.19.pl index 77dd98cb7..c592aaa48 100644 --- a/docs/upgrades/upgrade_7.10.18-7.10.19.pl +++ b/docs/upgrades/upgrade_7.10.18-7.10.19.pl @@ -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; diff --git a/docs/upgrades/upgrade_7.10.19-7.10.20.pl b/docs/upgrades/upgrade_7.10.19-7.10.20.pl index 62e8ab20c..e079b4557 100644 --- a/docs/upgrades/upgrade_7.10.19-7.10.20.pl +++ b/docs/upgrades/upgrade_7.10.19-7.10.20.pl @@ -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 -------------------------------- diff --git a/lib/WebGUI/Shop/TaxDriver/Generic.pm b/lib/WebGUI/Shop/TaxDriver/Generic.pm index 8cb0f0695..b3f49c1be 100644 --- a/lib/WebGUI/Shop/TaxDriver/Generic.pm +++ b/lib/WebGUI/Shop/TaxDriver/Generic.pm @@ -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 diff --git a/t/Shop/TaxDriver/Generic.t b/t/Shop/TaxDriver/Generic.t index 65e3d163d..b280c4d26 100644 --- a/t/Shop/TaxDriver/Generic.t +++ b/t/Shop/TaxDriver/Generic.t @@ -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%