print reasons with credits on invoices
authorivan <ivan>
Mon, 15 Oct 2001 12:16:42 +0000 (12:16 +0000)
committerivan <ivan>
Mon, 15 Oct 2001 12:16:42 +0000 (12:16 +0000)
use straight eval, not Safe::reval in cust_main::bill for now, as i have no
  idea how to call methods on a share()'ed scalar.  hmm.

add cust_pkg::cust_main method

s/eidiot/idiot/ in httemplate/misc/bill.cgi

FS/FS/cust_bill.pm
FS/FS/cust_main.pm
FS/FS/cust_pkg.pm
httemplate/misc/bill.cgi

index f61137f..b65df89 100644 (file)
@@ -389,8 +389,12 @@ sub print_text {
 
     #something more elaborate if $_->amount ne $_->cust_credit->credited ?
 
 
     #something more elaborate if $_->amount ne $_->cust_credit->credited ?
 
+    my $reason = substr($_->cust_credit->reason,0,32);
+    $reason .= '...' if length($reason) < length($_->cust_credit->reason);
+    $reason = " ($reason) " if $reason;
     push @buf,[
     push @buf,[
-      "Credit #". $_->crednum. " (". time2str("%x",$_->cust_credit->_date) .")",
+      "Credit #". $_->crednum. " (". time2str("%x",$_->cust_credit->_date) .")".
+        $reason,
       $money_char. sprintf("%10.2f",$_->amount)
     ];
   }
       $money_char. sprintf("%10.2f",$_->amount)
     ];
   }
@@ -489,7 +493,7 @@ sub print_text {
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-$Id: cust_bill.pm,v 1.11 2001-09-03 22:07:38 ivan Exp $
+$Id: cust_bill.pm,v 1.12 2001-10-15 12:16:41 ivan Exp $
 
 =head1 BUGS
 
 
 =head1 BUGS
 
index f99a15e..dce73c0 100644 (file)
@@ -843,10 +843,11 @@ sub bill {
       };
       $setup_prog = $1;
 
       };
       $setup_prog = $1;
 
-      my $cpt = new Safe;
-      #$cpt->permit(); #what is necessary?
-      $cpt->share(qw( $cust_pkg )); #can $cpt now use $cust_pkg methods?
-      $setup = $cpt->reval($setup_prog);
+        #my $cpt = new Safe;
+        ##$cpt->permit(); #what is necessary?
+        #$cpt->share(qw( $cust_pkg )); #can $cpt now use $cust_pkg methods?
+        #$setup = $cpt->reval($setup_prog);
+      $setup = eval $setup_prog;
       unless ( defined($setup) ) {
         $dbh->rollback if $oldAutoCommit;
         return "Error reval-ing part_pkg->setup pkgpart ". $part_pkg->pkgpart.
       unless ( defined($setup) ) {
         $dbh->rollback if $oldAutoCommit;
         return "Error reval-ing part_pkg->setup pkgpart ". $part_pkg->pkgpart.
@@ -871,10 +872,11 @@ sub bill {
       };
       $recur_prog = $1;
 
       };
       $recur_prog = $1;
 
-      my $cpt = new Safe;
-      #$cpt->permit(); #what is necessary?
-      $cpt->share(qw( $cust_pkg )); #can $cpt now use $cust_pkg methods?
-      $recur = $cpt->reval($recur_prog);
+        #my $cpt = new Safe;
+        ##$cpt->permit(); #what is necessary?
+        #$cpt->share(qw( $cust_pkg )); #can $cpt now use $cust_pkg methods?
+        #$recur = $cpt->reval($recur_prog);
+      $recur = eval $recur_prog;
       unless ( defined($recur) ) {
         $dbh->rollback if $oldAutoCommit;
         return "Error reval-ing part_pkg->recur pkgpart ".
       unless ( defined($recur) ) {
         $dbh->rollback if $oldAutoCommit;
         return "Error reval-ing part_pkg->recur pkgpart ".
@@ -1825,7 +1827,7 @@ sub append_fuzzyfiles {
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-$Id: cust_main.pm,v 1.40 2001-10-15 10:42:28 ivan Exp $
+$Id: cust_main.pm,v 1.41 2001-10-15 12:16:42 ivan Exp $
 
 =head1 BUGS
 
 
 =head1 BUGS
 
index 1bcf74f..cbf4ae5 100644 (file)
@@ -115,8 +115,7 @@ sub insert {
   my $error = $self->ut_number('custnum');
   return $error if $error;
 
   my $error = $self->ut_number('custnum');
   return $error if $error;
 
-  return "Unknown customer ". $self->custnum
-    unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
+  return "Unknown customer ". $self->custnum unless $self->cust_main;
 
   $self->SUPER::insert;
 
 
   $self->SUPER::insert;
 
@@ -189,8 +188,7 @@ sub check {
   return $error if $error;
 
   if ( $self->custnum ) { 
   return $error if $error;
 
   if ( $self->custnum ) { 
-    return "Unknown customer"
-      unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
+    return "Unknown customer ". $self->custnum unless $self->cust_main;
   }
 
   return "Unknown pkgpart"
   }
 
   return "Unknown pkgpart"
@@ -433,6 +431,17 @@ sub labels {
   map { [ $_->label ] } qsearch ( 'cust_svc', { 'pkgnum' => $self->pkgnum } );
 }
 
   map { [ $_->label ] } qsearch ( 'cust_svc', { 'pkgnum' => $self->pkgnum } );
 }
 
+=item cust_main
+
+Returns the parent customer object (see L<FS::cust_main>).
+
+=cut
+
+sub cust_main {
+  my $self = shift;
+  qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
+}
+
 =back
 
 =head1 SUBROUTINES
 =back
 
 =head1 SUBROUTINES
@@ -576,7 +585,7 @@ sub order {
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-$Id: cust_pkg.pm,v 1.9 2001-10-09 23:10:16 ivan Exp $
+$Id: cust_pkg.pm,v 1.10 2001-10-15 12:16:42 ivan Exp $
 
 =head1 BUGS
 
 
 =head1 BUGS
 
@@ -598,8 +607,8 @@ moved to check ?
 
 =head1 SEE ALSO
 
 
 =head1 SEE ALSO
 
-L<FS::Record>, L<FS::cust_main>, L<FS::part_pkg>, L<FS::cust_svc>
-L<FS::pkg_svc>, schema.html from the base documentation
+L<FS::Record>, L<FS::cust_main>, L<FS::part_pkg>, L<FS::cust_svc>,
+L<FS::pkg_svc>, schema.html from the base documentation
 
 =cut
 
 
 =cut
 
index 43c7c57..48da255 100755 (executable)
@@ -1,12 +1,13 @@
 <%
 <%
-#<!-- $Id: bill.cgi,v 1.3 2001-09-03 22:07:39 ivan Exp $ -->
+#<!-- $Id: bill.cgi,v 1.4 2001-10-15 12:16:42 ivan Exp $ -->
 
 use strict;
 use vars qw( $cgi $query $custnum $cust_main $error );
 use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
 
 use strict;
 use vars qw( $cgi $query $custnum $cust_main $error );
 use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use FS::UID qw(cgisuidsetup);
-use FS::CGI qw(popurl eidiot);
+#use FS::CGI qw(popurl eidiot);
+use FS::CGI qw(popurl idiot);
 use FS::Record qw(qsearchs);
 use FS::cust_main;
 
 use FS::Record qw(qsearchs);
 use FS::cust_main;
 
@@ -23,19 +24,24 @@ die "Can't find customer!\n" unless $cust_main;
 $error = $cust_main->bill(
 #                          'time'=>$time
                          );
 $error = $cust_main->bill(
 #                          'time'=>$time
                          );
-&eidiot($error) if $error;
-
-$cust_main->apply_payments;
-$cust_main->apply_credits;
-
-$error = $cust_main->collect(
-#                             'invoice-time'=>$time,
-#                             'batch_card'=> 'yes',
-                             'batch_card'=> 'no',
-                             'report_badcard'=> 'yes',
-                            );
-&eidiot($error) if $error;
-
-print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum");
-
+#&eidiot($error) if $error;
+
+unless ( $error ) {
+  $cust_main->apply_payments;
+  $cust_main->apply_credits;
+
+  $error = $cust_main->collect(
+  #                             'invoice-time'=>$time,
+  #                             'batch_card'=> 'yes',
+                               'batch_card'=> 'no',
+                               'report_badcard'=> 'yes',
+                              );
+}
+#&eidiot($error) if $error;
+
+if ( $error ) {
+  &idiot($error);
+} else {
+  print $cgi->redirect(popurl(2). "view/cust_main.cgi?$custnum");
+}
 %>
 %>