[freeside-commits] branch master updated. 66720bf1f5bae4b1d4022eabff456c247447fbc1

Ivan ivan at 420.am
Wed May 8 13:33:25 PDT 2013


The branch, master has been updated
       via  66720bf1f5bae4b1d4022eabff456c247447fbc1 (commit)
      from  fe5b1c30b591e50abc6f5496853f24f79a84e1c1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 66720bf1f5bae4b1d4022eabff456c247447fbc1
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed May 8 13:33:24 2013 -0700

    fix cch update removal of PLUS4/ZIP and TXMATRIX, RT#21687

diff --git a/FS/FS/cust_tax_location.pm b/FS/FS/cust_tax_location.pm
index 1a9bf5a..aec9410 100644
--- a/FS/FS/cust_tax_location.pm
+++ b/FS/FS/cust_tax_location.pm
@@ -234,13 +234,15 @@ sub batch_import {
       if (exists($hash->{actionflag}) && $hash->{actionflag} eq 'D') {
         delete($hash->{actionflag});
 
-        my $cust_tax_location = qsearchs('cust_tax_location', $hash);
+        my @cust_tax_location = qsearch('cust_tax_location', $hash);
         return "Can't find cust_tax_location to delete: ".
                join(" ", map { "$_ => ". $hash->{$_} } @fields)
-          unless $cust_tax_location;
+          unless scalar(@cust_tax_location) || $param->{'delete_only'} ;
 
-        my $error = $cust_tax_location->delete;
-        return $error if $error;
+        foreach my $cust_tax_location (@cust_tax_location) {
+          my $error = $cust_tax_location->delete;
+          return $error if $error;
+        }
 
         delete($hash->{$_}) foreach (keys %$hash);
       }
diff --git a/FS/FS/part_pkg_taxrate.pm b/FS/FS/part_pkg_taxrate.pm
index c83f700..a732720 100644
--- a/FS/FS/part_pkg_taxrate.pm
+++ b/FS/FS/part_pkg_taxrate.pm
@@ -5,8 +5,7 @@ use vars qw( @ISA );
 use Date::Parse;
 use DateTime;
 use DateTime::Format::Strptime;
-use FS::UID qw(dbh);
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearch qsearchs dbh );
 use FS::part_pkg_taxproduct;
 use FS::Misc qw(csv_from_fixed);
 
@@ -310,8 +309,8 @@ sub batch_import {
           }
         }
 
-        my $part_pkg_taxrate = qsearchs('part_pkg_taxrate', $hash);
-        unless ( $part_pkg_taxrate ) {
+        my @part_pkg_taxrate = qsearch('part_pkg_taxrate', $hash);
+        unless ( scalar(@part_pkg_taxrate) || $param->{'delete_only'} ) {
           if ( $hash->{taxproductnum} ) {
             my $taxproduct =
               qsearchs( 'part_pkg_taxproduct',
@@ -324,8 +323,10 @@ sub batch_import {
                  join(" ", map { "$_ => *". $hash->{$_}. '*' } keys(%$hash) );
         }
 
-        my $error = $part_pkg_taxrate->delete;
-        return $error if $error;
+        foreach my $part_pkg_taxrate (@part_pkg_taxrate) {
+          my $error = $part_pkg_taxrate->delete;
+          return $error if $error;
+        }
 
         delete($hash->{$_}) foreach (keys %$hash);
       }
diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm
index 721d5f5..2653833 100644
--- a/FS/FS/tax_rate.pm
+++ b/FS/FS/tax_rate.pm
@@ -967,7 +967,7 @@ sub _perform_batch_import {
       my $file = lc($name). 'file';
 
       unless ($files{$file}) {
-        $error = "No $name supplied";
+        #$error = "No $name supplied";
         next;
       }
       next if $name eq 'DETAIL' && $format =~ /update/;
@@ -1002,10 +1002,17 @@ sub _perform_batch_import {
       'DETAIL', "$dir/".$files{detailfile}, \&FS::tax_rate::batch_import, $format
       if $format =~ /update/;
 
+    my %addl_param = ();
+    if ( $param->{'delete_only'} ) {
+      $addl_param{'delete_only'} = $param->{'delete_only'};
+      @insert_list = () 
+    }
+
     $error ||= _perform_cch_tax_import( $job,
                                         [ @predelete_list ],
                                         [ @insert_list ],
                                         [ @delete_list ],
+                                        \%addl_param,
     );
     
     
@@ -1030,7 +1037,8 @@ sub _perform_batch_import {
 
 
 sub _perform_cch_tax_import {
-  my ( $job, $predelete_list, $insert_list, $delete_list ) = @_;
+  my ( $job, $predelete_list, $insert_list, $delete_list, $addl_param ) = @_;
+  $addl_param ||= {};
 
   my $error = '';
   foreach my $list ($predelete_list, $insert_list, $delete_list) {
@@ -1039,7 +1047,11 @@ sub _perform_cch_tax_import {
       my $fmt = "$format-update";
       $fmt = $format. ( lc($name) eq 'zip' ? '-zip' : '' );
       open my $fh, "< $file" or $error ||= "Can't open $name file $file: $!";
-      $error ||= &{$method}({ 'filehandle' => $fh, 'format' => $fmt }, $job);
+      my $param = { 'filehandle' => $fh,
+                    'format'     => $fmt,
+                    %$addl_param,
+                  };
+      $error ||= &{$method}($param, $job);
       close $fh;
     }
   }

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_tax_location.pm |   10 ++++++----
 FS/FS/part_pkg_taxrate.pm  |   13 +++++++------
 FS/FS/tax_rate.pm          |   18 +++++++++++++++---
 3 files changed, 28 insertions(+), 13 deletions(-)




More information about the freeside-commits mailing list