[freeside-commits] freeside/FS/FS cust_bill.pm, 1.132,
1.133 cust_bill_pkg.pm, 1.8, 1.9
Ivan,,,
ivan at wavetail.420.am
Sat Jul 9 03:36:45 PDT 2005
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv14740
Modified Files:
cust_bill.pm cust_bill_pkg.pm
Log Message:
add desc method to cust_bill_pkg and use it in cust_bill... this should help with any *other* cust_bill_pkg.pkgnum == -1 stuff that needs to be sorted out
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cust_bill_pkg.pm 8 Jun 2005 21:52:46 -0000 1.8
+++ cust_bill_pkg.pm 9 Jul 2005 10:36:42 -0000 1.9
@@ -204,6 +204,25 @@
#qsearch ( 'cust_bill_pkg_detail', { 'lineitemnum' => $self->lineitemnum });
}
+=item desc
+
+Returns a description for this line item. For typical line items, this is the
+I<pkg> field of the corresponding B<FS::part_pkg> object (see L<FS::part_pkg>).
+For one-shot line items and named taxes, it is the I<itemdesc> field of this
+line item, and for generic taxes, simply returns "Tax".
+
+=cut
+
+sub desc {
+ my $self = shift;
+
+ if ( $self->pkgnum > 0 ) {
+ $self->cust_pkg->part_pkg->pkg;
+ } else {
+ $self->itemdesc || 'Tax';
+ }
+}
+
=back
=head1 BUGS
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- cust_bill.pm 15 Jun 2005 04:46:50 -0000 1.132
+++ cust_bill.pm 9 Jul 2005 10:36:42 -0000 1.133
@@ -818,7 +818,7 @@
) or die "can't create csv";
print CSV $csv->string. "\n";
- #new charges (false laziness w/print_text)
+ #new charges (false laziness w/print_text and _items stuff)
foreach my $cust_bill_pkg ( $self->cust_bill_pkg ) {
my($pkg, $setup, $recur, $sdate, $edate);
@@ -1061,7 +1061,7 @@
=cut
-#still some false laziness w/print_text
+#still some false laziness w/_items stuff (and send_csv)
sub print_text {
my( $self, $today, $template ) = @_;
@@ -1102,50 +1102,49 @@
( grep { ! $_->pkgnum } $self->cust_bill_pkg ), #then taxes
) {
- if ( $cust_bill_pkg->pkgnum > 0 ) {
+ my $desc = $cust_bill_pkg->desc;
- my $cust_pkg = qsearchs('cust_pkg', { pkgnum =>$cust_bill_pkg->pkgnum } );
- my $part_pkg = qsearchs('part_pkg', { pkgpart=>$cust_pkg->pkgpart } );
- my $pkg = $part_pkg->pkg;
+ if ( $cust_bill_pkg->pkgnum > 0 ) {
if ( $cust_bill_pkg->setup != 0 ) {
- my $description = $pkg;
+ my $description = $desc;
$description .= ' Setup' if $cust_bill_pkg->recur != 0;
push @buf, [ $description,
$money_char. sprintf("%10.2f", $cust_bill_pkg->setup) ];
push @buf,
map { [ " ". $_->[0]. ": ". $_->[1], '' ] }
- $cust_pkg->h_labels($self->_date);
+ $cust_bill_pkg->cust_pkg->h_labels($self->_date);
}
if ( $cust_bill_pkg->recur != 0 ) {
push @buf, [
- "$pkg (" . time2str("%x", $cust_bill_pkg->sdate) . " - " .
- time2str("%x", $cust_bill_pkg->edate) . ")",
+ "$desc (" . time2str("%x", $cust_bill_pkg->sdate) . " - " .
+ time2str("%x", $cust_bill_pkg->edate) . ")",
$money_char. sprintf("%10.2f", $cust_bill_pkg->recur)
];
push @buf,
map { [ " ". $_->[0]. ": ". $_->[1], '' ] }
- $cust_pkg->h_labels($cust_bill_pkg->edate, $cust_bill_pkg->sdate);
+ $cust_bill_pkg->cust_pkg->h_labels( $cust_bill_pkg->edate,
+ $cust_bill_pkg->sdate );
}
push @buf, map { [ " $_", '' ] } $cust_bill_pkg->details;
} else { #pkgnum tax or one-shot line item
- my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc')
- ? ( $cust_bill_pkg->itemdesc || 'Tax' )
- : 'Tax';
+
if ( $cust_bill_pkg->setup != 0 ) {
- push @buf, [ $itemdesc,
+ push @buf, [ $desc,
$money_char. sprintf("%10.2f", $cust_bill_pkg->setup) ];
}
if ( $cust_bill_pkg->recur != 0 ) {
- push @buf, [ "$itemdesc (". time2str("%x", $cust_bill_pkg->sdate). " - "
- . time2str("%x", $cust_bill_pkg->edate). ")",
+ push @buf, [ "$desc (". time2str("%x", $cust_bill_pkg->sdate). " - "
+ . time2str("%x", $cust_bill_pkg->edate). ")",
$money_char. sprintf("%10.2f", $cust_bill_pkg->recur)
];
}
+
}
+
}
push @buf,['','-----------'];
@@ -1305,7 +1304,7 @@
=cut
-#still some false laziness w/print_text
+#still some false laziness w/print_text (mostly print_text should use _items stuff though)
sub print_latex {
my( $self, $today, $template ) = @_;
@@ -1999,21 +1998,19 @@
my @b = ();
foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
- if ( $cust_bill_pkg->pkgnum > 0 ) {
+ my $desc = $cust_bill_pkg->desc;
- my $cust_pkg = qsearchs('cust_pkg', { pkgnum =>$cust_bill_pkg->pkgnum } );
- my $part_pkg = qsearchs('part_pkg', { pkgpart=>$cust_pkg->pkgpart } );
- my $pkg = $part_pkg->pkg;
+ if ( $cust_bill_pkg->pkgnum > 0 ) {
if ( $cust_bill_pkg->setup != 0 ) {
- my $description = $pkg;
+ my $description = $desc;
$description .= ' Setup' if $cust_bill_pkg->recur != 0;
- my @d = $cust_pkg->h_labels_short($self->_date);
+ my @d = $cust_bill_pkg->cust_pkg->h_labels_short($self->_date);
push @d, $cust_bill_pkg->details if $cust_bill_pkg->recur == 0;
push @b, {
description => $description,
#pkgpart => $part_pkg->pkgpart,
- pkgnum => $cust_pkg->pkgnum,
+ pkgnum => $cust_bill_pkg->pkgnum,
amount => sprintf("%.2f", $cust_bill_pkg->setup),
ext_description => \@d,
};
@@ -2021,33 +2018,31 @@
if ( $cust_bill_pkg->recur != 0 ) {
push @b, {
- description => "$pkg (" .
+ description => "$desc (" .
time2str('%x', $cust_bill_pkg->sdate). ' - '.
time2str('%x', $cust_bill_pkg->edate). ')',
#pkgpart => $part_pkg->pkgpart,
- pkgnum => $cust_pkg->pkgnum,
+ pkgnum => $cust_bill_pkg->pkgnum,
amount => sprintf("%.2f", $cust_bill_pkg->recur),
- ext_description => [ $cust_pkg->h_labels_short($cust_bill_pkg->edate,
- $cust_bill_pkg->sdate),
- $cust_bill_pkg->details,
- ],
+ ext_description =>
+ [ $cust_bill_pkg->cust_pkg->h_labels_short( $cust_bill_pkg->edate,
+ $cust_bill_pkg->sdate),
+ $cust_bill_pkg->details,
+ ],
};
}
} else { #pkgnum tax or one-shot line item (??)
- my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc')
- ? ( $cust_bill_pkg->itemdesc || 'Tax' )
- : 'Tax';
if ( $cust_bill_pkg->setup != 0 ) {
push @b, {
- 'description' => $itemdesc,
+ 'description' => $desc,
'amount' => sprintf("%.2f", $cust_bill_pkg->setup),
};
}
if ( $cust_bill_pkg->recur != 0 ) {
push @b, {
- 'description' => "$itemdesc (".
+ 'description' => "$desc (".
time2str("%x", $cust_bill_pkg->sdate). ' - '.
time2str("%x", $cust_bill_pkg->edate). ')',
'amount' => sprintf("%.2f", $cust_bill_pkg->recur),
More information about the freeside-commits
mailing list