[freeside-commits] branch FREESIDE_4_BRANCH updated. c878d776eb79d9948de3a25594eae55a26858d41

Ivan ivan at 420.am
Tue Aug 15 08:04:10 PDT 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  c878d776eb79d9948de3a25594eae55a26858d41 (commit)
      from  77e830e5864c15c84aadbc55a478f34a1957328b (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 c878d776eb79d9948de3a25594eae55a26858d41
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Aug 15 08:04:09 2017 -0700

    SureTax: use less memory, provide additional debugging, RT#76987

diff --git a/FS/FS/TaxEngine/suretax.pm b/FS/FS/TaxEngine/suretax.pm
index 1a00cda..fe8764b 100644
--- a/FS/FS/TaxEngine/suretax.pm
+++ b/FS/FS/TaxEngine/suretax.pm
@@ -14,7 +14,7 @@ our $DEBUG = 1; # prints progress messages
 #   $DEBUG = 2; # prints decoded request and response (noisy, be careful)
 #   $DEBUG = 3; # prints raw response from the API, ridiculously unreadable
 
-our $json = Cpanel::JSON::XS->new->pretty(1);
+our $json = Cpanel::JSON::XS->new->pretty(0)->shrink(1);
 
 our %taxproduct_cache;
 
@@ -328,13 +328,14 @@ sub make_taxlines {
     return;
   }
 
-  warn "sending SureTax request\n" if $DEBUG;
+  warn "encoding SureTax request\n" if $DEBUG;
   my $request_json = $json->encode($request);
   warn $request_json if $DEBUG > 1;
 
   my $host = $conf->config('suretax-hostname');
   $host ||= 'testapi.taxrating.net';
 
+  warn "sending SureTax request\n" if $DEBUG;
   # We are targeting the "V05" interface:
   # - accepts both telecom and general sales transactions
   # - produces results broken down by "invoice" (Freeside line item)
@@ -346,8 +347,8 @@ sub make_taxlines {
     'Accept'        => 'application/json',
   );
 
+  warn "received SureTax response\n" if $DEBUG;
   my $raw_response = $http_response->content;
-  warn "received response\n" if $DEBUG;
   warn $raw_response if $DEBUG > 2;
   my $response;
   if ( $raw_response =~ /^<\?xml/ ) {
@@ -356,6 +357,8 @@ sub make_taxlines {
     $response = XMLin( $raw_response );
     $raw_response = $response->{content};
   }
+
+  warn "decoding SureTax response\n" if $DEBUG;
   $response = eval { $json->decode($raw_response) }
     or die "$raw_response\n";
 
@@ -375,6 +378,7 @@ sub make_taxlines {
   }
 
   return if !$response->{GroupList};
+  warn "creating FS objects from SureTax data\n" if $DEBUG;
   foreach my $taxable ( @{ $response->{GroupList} } ) {
     # each member of this array here corresponds to what SureTax calls an
     # "invoice" and we call a "line item". The invoice number is 
@@ -420,6 +424,7 @@ sub make_taxlines {
       });
     }
   }
+  warn "TaxEngine/suretax.pm make_taxlines done; returning FS objects\n" if $DEBUG;
   return @elements;
 }
 

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

Summary of changes:
 FS/FS/TaxEngine/suretax.pm |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list