[freeside-commits] branch master updated. 939cd87eba0cdb7a275ddce2382880f3954e8762
Mitch Jackson
mitch at freeside.biz
Mon May 27 14:36:02 PDT 2019
The branch, master has been updated
via 939cd87eba0cdb7a275ddce2382880f3954e8762 (commit)
via 4ef042d6aea8b8922fc5cfb596023d04da4690be (commit)
via 7f10b76569406cadce292208389c644c84e90979 (commit)
via 5e3e809798a51b3b1535eaeedb9747ea74a91560 (commit)
from d397c0135075feca088abf09e801ceb18d425f10 (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 939cd87eba0cdb7a275ddce2382880f3954e8762
Author: Mitch Jackson <mitch at freeside.biz>
Date: Mon May 27 17:32:29 2019 -0400
RT# 83122 Fix update tool to properly display caught error
diff --git a/FS/bin/freeside-wa-tax-table-update b/FS/bin/freeside-wa-tax-table-update
index ad14687c9..b197ac845 100755
--- a/FS/bin/freeside-wa-tax-table-update
+++ b/FS/bin/freeside-wa-tax-table-update
@@ -106,8 +106,8 @@ $log->info('Begin wa_tax_rate_update');
};
if ( $@ ) {
- $log->error( "Error: $@" );
warn "Error: $@\n";
+ $log->error( "Error: $@" );
} else {
$log->info( 'Finished wa_tax_rate_update' );
warn "Finished wa_tax_rate_update\n";
commit 4ef042d6aea8b8922fc5cfb596023d04da4690be
Author: Mitch Jackson <mitch at freeside.biz>
Date: Mon May 27 17:26:06 2019 -0400
RT# 83122 Do not auto-repair wa state sales tax rows
Dupe rows may actually be dupes, or they may be
manually created taxes for other purposes!
Pulled out auto-repair code, because it could be
harming user's manually entered tax tables.
When dupes are detected, wa sales taxes will not
auto update, and instead generate error and log
messages pointing user towardst the
freeside-wa-tax-table-resolve CLI tool
diff --git a/FS/FS/Cron/tax_rate_update.pm b/FS/FS/Cron/tax_rate_update.pm
index 4383bc501..5111ef4d0 100755
--- a/FS/FS/Cron/tax_rate_update.pm
+++ b/FS/FS/Cron/tax_rate_update.pm
@@ -294,10 +294,13 @@ sub wa_sales_update_tax_table {
)
);
- # The checks themselves will fully log details about the problem,
- # so simple error message is sufficient here
- log_error_and_die('abort tax table update, sanity checks failed')
- unless wa_sales_update_tax_table_sanity_check();
+ unless ( wa_sales_update_tax_table_sanity_check() ) {
+ log_error_and_die(
+ 'Duplicate district rows exist in the Washington state sales tax table. '.
+ 'These must be resolved before updating the tax tables. '.
+ 'See "freeside-wa-tax-table-resolve --check" to repair the tax tables. '
+ );
+ }
$args->{temp_dir} ||= tempdir();
@@ -356,7 +359,7 @@ sub wa_sales_update_cust_main_county {
cust_main_county => {
source => 'wa_sales',
district => { op => '!=', value => undef },
- tax_class => $taxclass,
+ taxclass => $taxclass,
}
)
) {
@@ -381,19 +384,30 @@ sub wa_sales_update_cust_main_county {
$cust_main_county{$district} = $row;
}
- # Merge any dupes, place resulting non-dupe row in %cust_main_county
- # Merge, even if one of the dupes has a $0 tax, or some other
- # variation on tax row data. Data for this row will get corrected
- # during the following tax import
- for my $dupe_district_aref ( values %cust_main_county_dupe ) {
- my $row_to_keep = shift @$dupe_district_aref;
- while ( my $row_to_merge = shift @$dupe_district_aref ) {
- $row_to_merge->_merge_into(
- $row_to_keep,
- { identical_record_check => 0 },
- );
- }
- $cust_main_county{$row_to_keep->district} = $row_to_keep;
+ # # Merge any dupes, place resulting non-dupe row in %cust_main_county
+ # # Merge, even if one of the dupes has a $0 tax, or some other
+ # # variation on tax row data. Data for this row will get corrected
+ # # during the following tax import
+ # for my $dupe_district_aref ( values %cust_main_county_dupe ) {
+ # my $row_to_keep = shift @$dupe_district_aref;
+ # while ( my $row_to_merge = shift @$dupe_district_aref ) {
+ # $row_to_merge->_merge_into(
+ # $row_to_keep,
+ # { identical_record_check => 0 },
+ # );
+ # }
+ # $cust_main_county{$row_to_keep->district} = $row_to_keep;
+ # }
+
+ # If there are duplicate rows, it may be unsafe to auto-resolve them
+ if ( %cust_main_county_dupe ) {
+ warn "Unable to continue!";
+ log_error_and_die( sprintf(
+ 'Tax district duplicate rows detected(%s) - '.
+ 'WA Sales tax tables cannot be updated without resolving duplicates - '.
+ 'Please use tool freeside-wa-tax-table-resolve for tax table repair',
+ join( ',', keys %cust_main_county_dupe )
+ ));
}
for my $district ( @{ $args->{tax_districts} } ) {
commit 7f10b76569406cadce292208389c644c84e90979
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 fcc138f49..fcd6be48f 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>
commit 5e3e809798a51b3b1535eaeedb9747ea74a91560
Author: Mitch Jackson <mitch at freeside.biz>
Date: Mon May 27 17:12:47 2019 -0400
RT# 82906 Fix typos in script help text
diff --git a/FS/bin/freeside-issue-credit-for-taxnums b/FS/bin/freeside-issue-credit-for-taxnums
index 8b7a12252..016c14ed6 100755
--- a/FS/bin/freeside-issue-credit-for-taxnums
+++ b/FS/bin/freeside-issue-credit-for-taxnums
@@ -293,18 +293,18 @@ sub validate_opts {
error_and_help( '--csv_dir is required' )
unless $csv_dir;
- error_and_help( '--start_date is required' )
+ error_and_help( '--start-date is required' )
unless $start_date;
error_and_help( '--end-date is required' )
unless $end_date;
error_and_help( '--taxnums is required' )
unless @taxnums;
- error_and_help( '--credit-reasonnum is required with --apply-credits' )
+ error_and_help( '--credit-reasonnum is required with --insert-credits' )
if $insert_credits && !$credit_reasonnum;
- error_and_help( '--credit-addlinfo is required with --apply-credits' )
+ error_and_help( '--credit-addlinfo is required with --insert-credits' )
if $insert_credits && !$credit_addlinfo;
- error_and_help( "csv dir ($csv_dir) is not a writable directoryu" )
+ error_and_help( "csv dir ($csv_dir) is not a writable directory" )
unless -d $csv_dir && -r $csv_dir;
error_and_help( "start_date($start_date) is not a valid date string")
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Cron/tax_rate_update.pm | 50 +++++++++++------
FS/bin/freeside-issue-credit-for-taxnums | 8 +--
FS/bin/freeside-wa-tax-table-update | 2 +-
httemplate/edit/process/cust_main_county-add.cgi | 71 +++++++++++++++++-------
4 files changed, 89 insertions(+), 42 deletions(-)
More information about the freeside-commits
mailing list