[freeside-commits] branch FREESIDE_3_BRANCH updated. af9ff3772e41d0464c024364157d92ac1e679c10

Mitch Jackson mitch at freeside.biz
Mon May 27 16:47:44 PDT 2019


The branch, FREESIDE_3_BRANCH has been updated
       via  af9ff3772e41d0464c024364157d92ac1e679c10 (commit)
      from  88eb510de322b91936a6a022b3f52d758f029c41 (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 af9ff3772e41d0464c024364157d92ac1e679c10
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Mon May 27 17:20:27 2019 -0400

    RT# 83320 Fix UI bug managing taxes
    
    No longer incorrectly carrying the source and district
    columns from other tax rows into new tax rows

diff --git a/httemplate/edit/process/cust_main_county-add.cgi b/httemplate/edit/process/cust_main_county-add.cgi
index fc8956b0c..2610ba794 100755
--- a/httemplate/edit/process/cust_main_county-add.cgi
+++ b/httemplate/edit/process/cust_main_county-add.cgi
@@ -27,26 +27,59 @@ my @expansion = split /[\n\r]{1,2}/, $cgi->param('expansion');
   $1;
 } @expansion;
 
-foreach ( @expansion ) {
-  my(%hash)=$cust_main_county->hash;
-  my($new)=new FS::cust_main_county \%hash;
-  $new->setfield('taxnum','');
-  $new->setfield('taxclass', '');
-  if ( $cgi->param('what') eq 'state' ) { #??
-    $new->setfield('state',$_);
-    $new->setfield('county', '');
-    $new->setfield('city', '');
-  } elsif ( $cgi->param('what') eq 'county' ) {
-    $new->setfield('county',$_);
-    $new->setfield('city', '');
-  } elsif ( $cgi->param('what') eq 'city' ) {
-    #uppercase cities in the US to try and agree with USPS validation
-    $new->setfield('city', $new->country eq 'US' ? uc($_) : $_ );
-  } else { #???
-    die 'unknown what '. $cgi->param('what');
+my $what = $cgi->param('what');
+foreach my $new_tax_area ( @expansion ) {
+
+  # Clone specific tax columns from original tax row
+  #
+  # UI Note:  Preserving original behavior, of cloning
+  #   tax amounts into new tax record, against better
+  #   judgement.  If the new city/county/state has a
+  #   different tax value than the one being populated
+  #   (rather likely?) now the user must remember to
+  #   revisit each newly created tax row, and correct
+  #   the possibly incorrect tax values that were populated.
+  #   Values would be easier to identify and correct if
+  #   they were initially populated with 0% tax rates
+  # District Note: The 'district' column is NOT cloned
+  #   to the new tax row.   Manually entered taxes
+  #   are not be divided into road maintenance districts
+  #   like Washington state sales taxes
+  my $new = FS::cust_main_county->new({
+    map { $_ => $cust_main_county->getfield($_) }
+    qw/
+      charge_prediscount
+      exempt_amount
+      exempt_amount_currency
+      recurtax
+      setuptax
+      tax
+      taxname
+    /
+  });
+
+  # Clone additional location columns, based on the $what value
+  my %clone_cols_for = (
+    state  => [qw/country /],
+    county => [qw/country state/],
+    city   => [qw/country state county/],
+  );
+
+  die "unknown what: $what"
+    unless grep { $_ eq $what } keys %clone_cols_for;
+
+  $new->setfield( $_ => $cust_main_county->getfield($_) )
+    for @{ $clone_cols_for{ $cgi->param('what') } };
+
+  # In the US, store cities upper case for USPS validation
+  $new_tax_area = uc($new_tax_area)
+    if $what eq 'city'
+    && $new->country eq 'US';
+
+  $new->setfield( $what, $new_tax_area );
+  if ( my $error = $new->insert ) {
+    die $error;
   }
-  my $error = $new->insert;
-  die $error if $error;
 }
 
 </%init>

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

Summary of changes:
 httemplate/edit/process/cust_main_county-add.cgi | 71 +++++++++++++++++-------
 1 file changed, 52 insertions(+), 19 deletions(-)




More information about the freeside-commits mailing list