diff options
| author | ivan <ivan> | 2011-11-14 04:46:35 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2011-11-14 04:46:35 +0000 | 
| commit | d388634fe71d7b2ced26ec495af72a811257b5b5 (patch) | |
| tree | 4938c5be79f55385202ab1a53d07ebe7456d418a /FS | |
| parent | bda8c33f9b346ba6cd7aa4174ce0d3e37db7bd49 (diff) | |
backport from HEAD to handle hash details for voip_tiered.pm, RT#14903
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/cust_bill_pkg.pm | 35 | 
1 files changed, 23 insertions, 12 deletions
diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index 52b29f2d3..adc09d7a7 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -146,18 +146,29 @@ sub insert {    if ( $self->get('details') ) {      foreach my $detail ( @{$self->get('details')} ) { -      my $cust_bill_pkg_detail = new FS::cust_bill_pkg_detail { -        'billpkgnum' => $self->billpkgnum, -        'format'     => (ref($detail) ? $detail->[0] : '' ), -        'detail'     => (ref($detail) ? $detail->[1] : $detail ), -        'amount'     => (ref($detail) ? $detail->[2] : '' ), -        'classnum'   => (ref($detail) ? $detail->[3] : '' ), -        'phonenum'   => (ref($detail) ? $detail->[4] : '' ), -        'accountcode' => (ref($detail) ? $detail->[5] : '' ), -        'startdate'  => (ref($detail) ? $detail->[6] : '' ), -        'duration'   => (ref($detail) ? $detail->[7] : '' ), -        'regionname' => (ref($detail) ? $detail->[8] : '' ), -      }; +      my %hash = (); +      if ( ref($detail) ) { +        if ( ref($detail) eq 'ARRAY' ) { +          #carp "this way sucks, use a hash"; #but more useful/friendly +          $hash{'format'}      = $detail->[0]; +          $hash{'detail'}      = $detail->[1]; +          $hash{'amount'}      = $detail->[2]; +          $hash{'classnum'}    = $detail->[3]; +          $hash{'phonenum'}    = $detail->[4]; +          $hash{'accountcode'} = $detail->[5]; +          $hash{'startdate'}   = $detail->[6]; +          $hash{'duration'}    = $detail->[7]; +          $hash{'regionname'}  = $detail->[8]; +        } elsif ( ref($detail) eq 'HASH' ) { +          %hash = %$detail; +        } else { +          die "unknow detail type ". ref($detail); +        } +      } else { +        $hash{'detail'} = $detail; +      } +      $hash{'billpkgnum'} = $self->billpkgnum; +      my $cust_bill_pkg_detail = new FS::cust_bill_pkg_detail \%hash;        $error = $cust_bill_pkg_detail->insert;        if ( $error ) {          $dbh->rollback if $oldAutoCommit;  | 
