[freeside-commits] freeside/FS/FS cust_bill_pkg.pm,1.59,1.60

Ivan,,, ivan at wavetail.420.am
Thu Sep 22 15:03:17 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv1500/FS/FS

Modified Files:
	cust_bill_pkg.pm 
Log Message:
pass cust_bill_pkg_detail as hash, not a long ordered list.  duh.

Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -w -d -r1.59 -r1.60
--- cust_bill_pkg.pm	3 Aug 2011 22:13:06 -0000	1.59
+++ cust_bill_pkg.pm	22 Sep 2011 22:03:15 -0000	1.60
@@ -146,18 +146,29 @@
 
   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;



More information about the freeside-commits mailing list