Merge branch 'master' of https://github.com/jgoodman/Freeside
[freeside.git] / FS / FS / tax_rate.pm
index 342c7cb..4516004 100644 (file)
@@ -1,7 +1,8 @@
 package FS::tax_rate;
+use base qw( FS::Record );
 
 use strict;
-use vars qw( @ISA $DEBUG $me
+use vars qw( $DEBUG $me
              %tax_unittypes %tax_maxtypes %tax_basetypes %tax_authorities
              %tax_passtypes %GetInfoType $keep_cch_files );
 use Date::Parse;
@@ -11,6 +12,7 @@ use Storable qw( thaw nfreeze );
 use IO::File;
 use File::Temp;
 use Text::CSV_XS;
+use URI::Escape;
 use LWP::UserAgent;
 use HTTP::Request;
 use HTTP::Response;
@@ -29,10 +31,6 @@ use FS::part_pkg_taxproduct;
 use FS::cust_main;
 use FS::Misc qw( csv_from_fixed );
 
-use URI::Escape;
-
-@ISA = qw( FS::Record );
-
 $DEBUG = 0;
 $me = '[FS::tax_rate]';
 $keep_cch_files = 0;
@@ -215,7 +213,7 @@ sub check {
   $self->ut_numbern('taxnum')
     || $self->ut_text('geocode')
     || $self->ut_textn('data_vendor')
-    || $self->ut_textn('location')
+    || $self->ut_cch_textn('location')
     || $self->ut_foreign_key('taxclassnum', 'tax_class', 'taxclassnum')
     || $self->ut_snumbern('effective_date')
     || $self->ut_float('tax')
@@ -245,6 +243,18 @@ sub check {
 
 }
 
+#ut_text / ut_textn w/ ` added cause now that's in the data
+sub ut_cch_textn {
+  my($self,$field)=@_;
+  $self->getfield($field)
+    =~ /^([\wô \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]\<\>\`]*)$/
+      or return gettext('illegal_or_empty_text'). " $field: ".
+                 $self->getfield($field);
+  $self->setfield($field,$1);
+  '';
+
+}
+
 =item taxclass_description
 
 Returns the human understandable value associated with the related
@@ -361,7 +371,7 @@ sub passtype_name {
   $tax_passtypes{$self->passtype};
 }
 
-=item taxline TAXABLES, [ OPTIONSHASH ]
+=item taxline TAXABLES
 
 Returns a listref of a name and an amount of tax calculated for the list
 of packages/amounts referenced by TAXABLES.  If an error occurs, a message
@@ -371,13 +381,13 @@ is returned as a scalar.
 
 sub taxline {
   my $self = shift;
+  # this used to accept a hash of options but none of them did anything
+  # so it's been removed.
 
   my $taxables;
-  my %opt = ();
 
   if (ref($_[0]) eq 'ARRAY') {
     $taxables = shift;
-    %opt = @_;
   }else{
     $taxables = [ @_ ];
     #exemptions would be broken in this case
@@ -514,10 +524,10 @@ sub _fatal_or_null {
   }
 }
 
-=item tax_on_tax CUST_MAIN
+=item tax_on_tax CUST_LOCATION
 
 Returns a list of taxes which are candidates for taxing taxes for the
-given customer (see L<FS::cust_main>)
+given service location (see L<FS::cust_location>)
 
 =cut
 
@@ -525,13 +535,13 @@ given customer (see L<FS::cust_main>)
 sub tax_on_tax {
        #akshun
   my $self = shift;
-  my $cust_main = shift;
+  my $cust_location = shift;
 
   warn "looking up taxes on tax ". $self->taxnum. " for customer ".
-    $cust_main->custnum
+    $cust_location->custnum
     if $DEBUG;
 
-  my $geocode = $cust_main->geocode($self->data_vendor);
+  my $geocode = $cust_location->geocode($self->data_vendor);
 
   # CCH oddness in m2m
   my $dbh = dbh;
@@ -2120,8 +2130,7 @@ EOF
 
 =head1 SEE ALSO
 
-L<FS::Record>, L<FS::cust_main>, L<FS::cust_bill>, schema.html from the base
-documentation.
+L<FS::Record>, L<FS::cust_location>, L<FS::cust_bill>
 
 =cut