summaryrefslogtreecommitdiff
path: root/FS/FS/Cron
diff options
context:
space:
mode:
authorMitch Jackson <mitch@freeside.biz>2019-05-26 15:29:16 -0400
committerMitch Jackson <mitch@freeside.biz>2019-05-27 17:48:46 -0400
commit1b832fbb0757e4f694528a0685a6875ab2abc50a (patch)
treef345a76afb05a8c274910148c4da80e1aeeaf12d /FS/FS/Cron
parent3bfedb7199c3de10c0f2d9a0c7de675fed63c4d9 (diff)
RT# 83402 CLI tool to repair wa state tax tables
Diffstat (limited to 'FS/FS/Cron')
-rwxr-xr-xFS/FS/Cron/tax_rate_update.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/FS/FS/Cron/tax_rate_update.pm b/FS/FS/Cron/tax_rate_update.pm
index bb9d4d1..4383bc5 100755
--- a/FS/FS/Cron/tax_rate_update.pm
+++ b/FS/FS/Cron/tax_rate_update.pm
@@ -294,6 +294,11 @@ 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();
+
$args->{temp_dir} ||= tempdir();
$args->{filename} ||= wa_sales_fetch_xlsx_file( $args );
@@ -635,6 +640,26 @@ sub wa_sales_fetch_xlsx_file {
}
+=head2 wa_sales_update_tax_table_sanity_check
+
+There should be no duplicate tax table entries in the tax table,
+with the same district value, within a tax class, where source=wa_sales.
+
+If there are, custome taxes may have been user-entered in the
+freeside UI, and incorrectly labelled as source=wa_sales. Or, the
+dupe record may have been created by issues with older wa_sales code.
+
+If these dupes exist, the sysadmin must solve the problem by hand
+with the freeeside-wa-tax-table-resolve script
+
+Returns 1 unless problem sales tax entries are detected
+
+=cut
+
+sub wa_sales_update_tax_table_sanity_check {
+ FS::cust_main_county->find_wa_tax_dupes ? 0 : 1;
+}
+
sub log {
state $log = FS::Log->new('tax_rate_update');
$log;
@@ -655,6 +680,7 @@ sub log_warn_and_warn {
sub log_error_and_die {
my $log_message = shift;
&log()->error( $log_message );
+ warn( "$log_message\n" );
die( "$log_message\n" );
}