one-time charges with tax classes
authorivan <ivan>
Wed, 3 Jul 2002 03:47:40 +0000 (03:47 +0000)
committerivan <ivan>
Wed, 3 Jul 2002 03:47:40 +0000 (03:47 +0000)
FS/FS/cust_main.pm
httemplate/edit/part_pkg.cgi
httemplate/edit/process/quick-charge.cgi
httemplate/view/cust_main.cgi

index 9ed3f2c..6edb6ae 100644 (file)
@@ -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;
index 19545bd..08d5dc9 100755 (executable)
@@ -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')
index 49175d8..477f585 100644 (file)
@@ -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) {
 %>
index 98b6331..dfa32d3 100755 (executable)
@@ -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!&nbsp;<INPUT TYPE="submit" VALUE="One-time charge"></FORM><BR>!;
+  qq!&nbsp;!;
+
+#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>