upgrade part_pkg before cust_credit
[freeside.git] / FS / FS / cust_bill.pm
index f536c97..520bfe1 100644 (file)
@@ -1347,7 +1347,7 @@ sub print_csv {
       if ( $cust_bill_pkg->pkgnum ) {
       
         ($pkg, $setup, $recur, $sdate, $edate) = (
-          $cust_bill_pkg->cust_pkg->part_pkg->pkg,
+          $cust_bill_pkg->part_pkg->pkg,
           ( $cust_bill_pkg->setup != 0
             ? sprintf("%.2f", $cust_bill_pkg->setup )
             : '' ),
@@ -1468,7 +1468,7 @@ sub realtime_bop {
              $cust_main->agentnum. ")";
     my $agent = $agent_obj->agent;
     my $pkgs = join(', ',
-      map { $_->cust_pkg->part_pkg->pkg }
+      map { $_->part_pkg->pkg }
         grep { $_->pkgnum } $self->cust_bill_pkg
     );
     $description = eval qq("$dtempl");
@@ -1740,7 +1740,7 @@ sub print_generic {
                          );
   my $escape_function = $escape_functions{$format};
 
-  my %date_formats = ( 'latex'    => '%b, %o, %Y',
+  my %date_formats = ( 'latex'    => '%b %o, %Y',
                        'html'     => '%b %o, %Y',
                        'template' => '%s',
                      );
@@ -1785,13 +1785,17 @@ sub print_generic {
           );
   } elsif ( grep /\S/, $conf->config('company_address') ) {
 
-    $returnaddress = join( "\n", $conf->config('company_address') );
-
-    $returnaddress =
-      join( '\\*'."\n", map s/( {2,})/'~' x length($1)/eg,
-                            $conf->config('company_address')
-          )
-        if $format eq 'latex';
+    my $convert_map = $convert_maps{$format}{'returnaddress'};
+    $returnaddress = join( "\n", &$convert_map(
+                                   map { s/( {2,})/'~' x length($1)/eg;
+                                         s/$/\\\\\*/;
+                                         $_
+                                       }
+                                     ( $conf->config('company_name'),
+                                       $conf->config('company_address'),
+                                     )
+                                 )
+                     );
 
   } else {
 
@@ -2412,7 +2416,7 @@ sub _items_sections {
 
     if ( $cust_bill_pkg->pkgnum > 0 ) {
 
-      my $desc = $cust_bill_pkg->cust_pkg->part_pkg->classname;
+      my $desc = $cust_bill_pkg->part_pkg->classname;
 
       $s{$desc} += $cust_bill_pkg->setup
         if ( $cust_bill_pkg->setup != 0 );
@@ -2479,7 +2483,7 @@ sub _items_pkg {
   my @cust_bill_pkg =
     grep { $_->pkgnum &&
            ( defined($section)
-               ? $_->cust_pkg->part_pkg->classname eq $section->{'description'}
+               ? $_->part_pkg->classname eq $section->{'description'}
                : 1
            )
          } $self->cust_bill_pkg;