From 7a97ed31c38e975c6548083039ff2ce31c6d8cf3 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 7 Oct 2005 02:25:41 +0000 Subject: [PATCH] add require_taxclasses config flag --- FS/FS/Conf.pm | 7 ++++ FS/FS/part_pkg.pm | 4 +++ httemplate/edit/process/quick-charge.cgi | 27 ++++++++++----- httemplate/view/cust_main/quick-charge.html | 53 +++++++++++++++++++---------- 4 files changed, 64 insertions(+), 27 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 0bf1afeeb..30aa1e7ab 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1258,6 +1258,13 @@ httemplate/docs/config.html }, { + 'key' => 'require_taxclasses', + 'section' => 'billing', + 'description' => 'Require a taxclass to be entered for every package', + 'type' => 'checkbox', + }, + + { 'key' => 'welcome_email', 'section' => '', 'description' => 'Template file for welcome email. Welcome emails are sent to the customer email invoice destination(s) each time a svc_acct record is created. See the Text::Template documentation for details on the template substitution language. The following variables are available', diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index db31e456f..73f3bae04 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -441,6 +441,10 @@ sub check { return 'Unknown plan '. $self->plan unless exists($plans{$self->plan}); + my $conf = new FS::Conf; + return 'Taxclass is required' + if ! $self->taxclass && $conf->exists('require_taxclasses'); + ''; } diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 477f58508..9d9aa980a 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -9,15 +9,24 @@ $cgi->param('amount') =~ /^\s*(\d+(\.\d{1,2})?)\s*$/ or die 'illegal amount '. $cgi->param('amount'); my $amount = $1; -my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) - or die "unknown custnum $custnum"; - -my $error = $cust_main->charge( - $amount, - $cgi->param('pkg'), - '$'. sprintf("%.2f",$amount), - $cgi->param('taxclass') -); +my( $error, $cust_main); +if ( $cgi->param('taxclass') eq '(select)' ) { + + + $error = "Must select a tax class"; +} else { + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or die "unknown custnum $custnum"; + + $error = $cust_main->charge( + $amount, + $cgi->param('pkg'), + '$'. sprintf("%.2f",$amount), + $cgi->param('taxclass') + ); + +} if ($error) { %> diff --git a/httemplate/view/cust_main/quick-charge.html b/httemplate/view/cust_main/quick-charge.html index 0b51586d1..9e4fb8c6e 100644 --- a/httemplate/view/cust_main/quick-charge.html +++ b/httemplate/view/cust_main/quick-charge.html @@ -6,26 +6,43 @@
Description: - Amount: - <% +Amount: +<% #false laziness w/ edit/part_pkg.cgi %> +<% if ( $conf->exists('enable_taxclasses') ) { %> + + '; - my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county') - or die dbh->errstr; - $sth->execute or die $sth->errstr; - foreach my $taxclass ( map $_->[0], @{$sth->fetchall_arrayref} ) { - print qq!!; - } - print ''; - } else { - print ''; - } + <% foreach my $taxclass ( @taxclasses ) { %> + +
-- 2.11.0