diff options
author | ivan <ivan> | 2002-07-03 03:47:40 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-07-03 03:47:40 +0000 |
commit | 2c9b97801b3981efaf6c65118e3cc1a0368e649c (patch) | |
tree | 538401050aac5124e4925fa7a6c8f3722fc56a67 | |
parent | e1ef1693e6942bbf82ee088f782d871a3b5eefee (diff) |
one-time charges with tax classes
-rw-r--r-- | FS/FS/cust_main.pm | 12 | ||||
-rwxr-xr-x | httemplate/edit/part_pkg.cgi | 1 | ||||
-rw-r--r-- | httemplate/edit/process/quick-charge.cgi | 7 | ||||
-rwxr-xr-x | httemplate/view/cust_main.cgi | 20 |
4 files changed, 34 insertions, 6 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 9ed3f2cab..6edb6ae8f 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1734,7 +1734,7 @@ sub credit { $cust_credit->insert; } -=item charge AMOUNT PKG COMMENT +=item charge AMOUNT [ PKG [ COMMENT [ TAXCLASS ] ] ] Creates a one-time charge for this customer. If there is an error, returns the error, otherwise returns false. @@ -1742,7 +1742,10 @@ the error, otherwise returns false. =cut sub charge { - my ( $self, $amount, $pkg, $comment ) = @_; + my ( $self, $amount ) = @_; + my $pkg = @_ ? shift : 'One-time charge'; + my $comment = @_ ? shift : '$'. sprintf("%.2f",$amount); + my $taxclass = @_ ? shift : ''; local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -1756,12 +1759,13 @@ sub charge { my $dbh = dbh; my $part_pkg = new FS::part_pkg ( { - 'pkg' => $pkg || 'One-time charge', - 'comment' => $comment || '$'. sprintf("%.2f",$amount), + 'pkg' => $pkg, + 'comment' => $comment, 'setup' => $amount, 'freq' => 0, 'recur' => '0', 'disabled' => 'Y', + 'taxclass' => $taxclass, } ); my $error = $part_pkg->insert; diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 19545bd12..08d5dc906 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -89,6 +89,7 @@ print '>'; print '</TD></TR>'; my $conf = new FS::Conf; +#false laziness w/ view/cust_main.cgi quick order if ( $conf->exists('enable_taxclasses') ) { print '<TR><TD ALIGN="right">Tax class</TD><TD><SELECT NAME="taxclass">'; my $sth = dbh->prepare('SELECT DISTINCT taxclass FROM cust_main_county') diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 49175d848..477f58508 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -12,7 +12,12 @@ 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') ); +my $error = $cust_main->charge( + $amount, + $cgi->param('pkg'), + '$'. sprintf("%.2f",$amount), + $cgi->param('taxclass') +); if ($error) { %> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 98b6331ed..dfa32d3a5 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -272,7 +272,25 @@ print '<BR>'. qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!. qq!Description:<INPUT TYPE="text" NAME="pkg">!. qq! Amount:<INPUT TYPE="text" NAME="amount" SIZE=6>!. - qq! <INPUT TYPE="submit" VALUE="One-time charge"></FORM><BR>!; + qq! !; + +#false laziness w/ edit/part_pkg.cgi +if ( $conf->exists('enable_taxclasses') ) { + print '<SELECT NAME="taxclass">'; + 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!<OPTION VALUE="$taxclass"!; + #print ' SELECTED' if $taxclass eq $hashref->{taxclass}; + print qq!>$taxclass</OPTION>!; + } + print '</SELECT>'; +} else { + print '<INPUT TYPE="hidden" NAME="taxclass" VALUE="">'; +} + +print qq!<INPUT TYPE="submit" VALUE="One-time charge"></FORM><BR>!; print <<END; <SCRIPT> |