X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg.pm;h=0a1d422b7234de0d5b01a3a7ac557df276103ea5;hb=refs%2Fheads%2Fsvc_elec_features;hp=d396f8239c6e626b72b1849c43d1c8059f1b4b5d;hpb=995a145c931164347683071c95c6754379d36604;p=freeside.git diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index d396f8239..0a1d422b7 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -145,16 +145,22 @@ 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] : '' ), - 'duration' => (ref($detail) ? $detail->[5] : '' ), - 'regionname' => (ref($detail) ? $detail->[6] : '' ), - }; + my $cust_bill_pkg_detail; + if (ref($detail) eq 'FS::cust_bill_pkg_detail') { + $cust_bill_pkg_detail = $detail; + $cust_bill_pkg_detail->billpkgnum($self->billpkgnum); + } else { + $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] : '' ), + 'duration' => (ref($detail) ? $detail->[5] : '' ), + 'regionname' => (ref($detail) ? $detail->[6] : '' ), + }; + } $error = $cust_bill_pkg_detail->insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -870,7 +876,11 @@ sub cust_bill_pkg_detail { my %hash = ( 'billpkgnum' => $self->billpkgnum ); $hash{classnum} = $classnum if $classnum; - qsearch ( 'cust_bill_pkg_detail', { %hash } ), + qsearch ({ + 'table' => 'cust_bill_pkg_detail', + 'hashref' => { %hash }, + 'order_by' => 'ORDER BY detailnum', + }); }