summaryrefslogtreecommitdiff
path: root/FS/FS/Cron
diff options
context:
space:
mode:
authorMitch Jackson <mitch@freeside.biz>2019-05-27 17:26:06 -0400
committerMitch Jackson <mitch@freeside.biz>2019-05-27 17:49:02 -0400
commit57acf63e75062d7a598d2ba4042642f8287bf836 (patch)
tree7f0de5185ba4e9aa1cf7dc25530c1de551fa2ab6 /FS/FS/Cron
parentd9b63c1b63dcfd950f59caa04179d4eaacc6af40 (diff)
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
Diffstat (limited to 'FS/FS/Cron')
-rwxr-xr-xFS/FS/Cron/tax_rate_update.pm50
1 files changed, 32 insertions, 18 deletions
diff --git a/FS/FS/Cron/tax_rate_update.pm b/FS/FS/Cron/tax_rate_update.pm
index 4383bc5..5111ef4 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} } ) {