fix (hopefully the rest of the) fallout from rating CDRs to sub-penny amounts
[freeside.git] / FS / FS / cust_bill_pkg.pm
index bb30f03..96f09c9 100644 (file)
@@ -111,7 +111,7 @@ sub insert {
     return $error;
   }
 
-  if ( defined dbdef->table('cust_bill_pkg_detail') && $self->get('details') ) {
+  if ( $self->get('details') ) {
     foreach my $detail ( @{$self->get('details')} ) {
       my $cust_bill_pkg_detail = new FS::cust_bill_pkg_detail {
         'billpkgnum' => $self->billpkgnum,
@@ -119,22 +119,23 @@ sub insert {
         'detail'     => (ref($detail) ? $detail->[1] : $detail ),
         'amount'     => (ref($detail) ? $detail->[2] : '' ),
         'classnum'   => (ref($detail) ? $detail->[3] : '' ),
+        'phonenum'   => (ref($detail) ? $detail->[4] : '' ),
       };
       $error = $cust_bill_pkg_detail->insert;
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
-        return $error;
+        return "error inserting cust_bill_pkg_detail: $error";
       }
     }
   }
 
-  if ( defined dbdef->table('cust_bill_pkg_display') && $self->get('display') ){
+  if ( $self->get('display') ) {
     foreach my $cust_bill_pkg_display ( @{ $self->get('display') } ) {
       $cust_bill_pkg_display->billpkgnum($self->billpkgnum);
       $error = $cust_bill_pkg_display->insert;
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
-        return $error;
+        return "error inserting cust_bill_pkg_display: $error";
       }
     }
   }
@@ -145,7 +146,7 @@ sub insert {
       $error = $cust_tax_exempt_pkg->insert;
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
-        return $error;
+        return "error inserting cust_tax_exempt_pkg: $error";
       }
     }
   }
@@ -159,7 +160,7 @@ sub insert {
       warn $error;
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
-        return $error;
+        return "error inserting cust_bill_pkg_tax_location: $error";
       }
     }
   }
@@ -172,7 +173,7 @@ sub insert {
       warn $error;
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
-        return $error;
+        return "error inserting cust_bill_pkg_tax_rate_location: $error";
       }
     }
   }
@@ -184,7 +185,7 @@ sub insert {
     warn $error;
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
-      return $error;
+      return "error replacing cust_tax_adjustment: $error";
     }
   }
 
@@ -371,7 +372,7 @@ sub details {
   $format_sub = $opt{format_function} if $opt{format_function};
 
   map { ( $_->format eq 'C'
-          ? &{$format_sub}( $_->detail )
+          ? &{$format_sub}( $_->detail, $_ )
           : &{$escape_function}( $_->detail )
         )
       }