. is used in some implementations of classic crypt
[freeside.git] / FS / FS / cust_bill_ApplicationCommon.pm
index 467b581..af7e087 100644 (file)
@@ -8,7 +8,7 @@ use FS::Record qw( qsearch qsearchs dbh );
 
 @ISA = qw( FS::Record );
 
-$DEBUG = 1;
+$DEBUG = 0;
 $me = '[FS::cust_bill_ApplicationCommon]';
 
 =head1 NAME
@@ -33,6 +33,8 @@ represent application of things to invoices, currently payments
 
 =head1 METHODS
 
+=over 4
+
 =item insert
 
 =cut
@@ -178,7 +180,15 @@ sub apply_to_lineitems {
     # - apply based on weights...
 
     my $weight_col = $self->_app_part_pkg_weight_column;
-    my @openweight = map { [ $_, ($_->cust_pkg->part_pkg->$weight_col()||0) ] }
+    my @openweight = map { 
+                           my $open = $_;
+                           my $cust_pkg = $open->cust_pkg;
+                           my $weight =
+                             $cust_pkg
+                               ? ( $cust_pkg->part_pkg->$weight_col() || 0 )
+                               : 0; #default or per-tax weight?
+                           [ $open, $weight ]
+                         }
                          @open;
 
     my %saw = ();
@@ -351,6 +361,18 @@ sub cust_bill {
   qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
 }
 
+=item applied_to_invoice
+
+Returns a string representing the invoice (see L<FS::cust_bill>), for example:
+"applied to Invoice #54 (3/20/2008)"
+
+=cut
+
+sub applied_to_invoice {
+  my $self = shift;
+  'applied to '. $self->cust_bill->invnum_date_pretty;
+}
+
 =item lineitem_breakdown_table 
 
 =cut