summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2001-10-15 12:16:42 +0000
committerivan <ivan>2001-10-15 12:16:42 +0000
commita984fa561b6493ae41215c3d26013767f9ce79cb (patch)
tree91545fa0be38a55c501d67a26ab58fb1c8054e9d
parent05eafa5ab3ded207d716685b32edf6946187514a (diff)
print reasons with credits on invoices
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
-rw-r--r--FS/FS/cust_bill.pm8
-rw-r--r--FS/FS/cust_main.pm20
-rw-r--r--FS/FS/cust_pkg.pm23
-rwxr-xr-xhttemplate/misc/bill.cgi40
4 files changed, 56 insertions, 35 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index f61137f54..b65df89c4 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -389,8 +389,12 @@ sub print_text {
#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,[
- "Credit #". $_->crednum. " (". time2str("%x",$_->cust_credit->_date) .")",
+ "Credit #". $_->crednum. " (". time2str("%x",$_->cust_credit->_date) .")".
+ $reason,
$money_char. sprintf("%10.2f",$_->amount)
];
}
@@ -489,7 +493,7 @@ sub print_text {
=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
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index f99a15e69..dce73c0ba 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -843,10 +843,11 @@ sub bill {
};
$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.
@@ -871,10 +872,11 @@ sub bill {
};
$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 ".
@@ -1825,7 +1827,7 @@ sub append_fuzzyfiles {
=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
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 1bcf74f78..cbf4ae50d 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -115,8 +115,7 @@ sub insert {
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;
@@ -189,8 +188,7 @@ sub check {
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"
@@ -433,6 +431,17 @@ sub labels {
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
@@ -576,7 +585,7 @@ sub order {
=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
@@ -598,8 +607,8 @@ moved to check ?
=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
diff --git a/httemplate/misc/bill.cgi b/httemplate/misc/bill.cgi
index 43c7c576d..48da25562 100755
--- a/httemplate/misc/bill.cgi
+++ b/httemplate/misc/bill.cgi
@@ -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 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;
@@ -23,19 +24,24 @@ die "Can't find customer!\n" unless $cust_main;
$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");
+}
%>