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;
|| $cust_pkg->part_pkg->option('usage_mandate', 'Hush!');
# or use the category from $opt{'part_pkg'} if its not bundled?
- my $section = $cust_pkg->part_pkg->categoryname;
+ my $categoryname = $cust_pkg->part_pkg->categoryname;
return $self->set('display', [])
- unless $separate || $section || $usage_mandate;
+ unless $separate || $categoryname || $usage_mandate;
my @display = ();
- my %hash = ( 'section' => $section );
+ my %hash = ( 'section' => $categoryname );
- $section = $part_pkg->option('usage_section', 'Hush!')
- || $cust_pkg->part_pkg->option('usage_section', 'Hush!');
+ my $usage_section = $part_pkg->option('usage_section', 'Hush!')
+ || $cust_pkg->part_pkg->option('usage_section', 'Hush!');
my $summary = $part_pkg->option('summarize_usage', 'Hush!')
|| $cust_pkg->part_pkg->option('summarize_usage', 'Hush!');
};
}
- if ($separate && $section && $summary) {
+ if ($separate && $usage_section && $summary) {
push @display, new FS::cust_bill_pkg_display { type => 'U',
summary => 'Y',
%hash,
};
}
- if ($usage_mandate || $section && $summary) {
+ if ($usage_mandate || ($usage_section && $summary) ) {
$hash{post_total} = 'Y';
}
if ($separate || $usage_mandate) {
- $hash{section} = $section if ($separate || $usage_mandate);
+ $hash{section} = $usage_section if $usage_section;
push @display, new FS::cust_bill_pkg_display { type => 'U', %hash };
}