[freeside-commits] freeside/FS/FS cust_bill_pkg.pm, 1.23, 1.24 cust_main.pm, 1.363, 1.364 tax_rate.pm, 1.9, 1.10
Jeff Finucane,420,,
jeff at wavetail.420.am
Fri Aug 29 19:10:11 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv14464/FS/FS
Modified Files:
cust_bill_pkg.pm cust_main.pm tax_rate.pm
Log Message:
bug squashing for multiple usage classes
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cust_bill_pkg.pm 28 Aug 2008 07:38:38 -0000 1.23
+++ cust_bill_pkg.pm 30 Aug 2008 02:10:08 -0000 1.24
@@ -139,7 +139,7 @@
'billpkgnum' => $self->billpkgnum,
'format' => (ref($detail) ? $detail->[0] : '' ),
'detail' => (ref($detail) ? $detail->[1] : $detail ),
- 'charge' => (ref($detail) ? $detail->[2] : '' ),
+ 'amount' => (ref($detail) ? $detail->[2] : '' ),
'classnum' => (ref($detail) ? $detail->[3] : '' ),
};
$error = $cust_bill_pkg_detail->insert;
@@ -481,13 +481,13 @@
@values =
map { $_->[2] }
grep { ref($_) && ( defined($classnum) ? $_->[3] eq $classnum : 1 ) }
- $self->get('details');
+ @{ $self->get('details') };
}else{
my $hashref = { 'billpkgnum' => $self->billpkgnum };
$hashref->{ 'classnum' } = $classnum if defined($classnum);
- @values = map { $_->charge } qsearch('cust_bill_pkg_detail', $hashref);
+ @values = map { $_->amount } qsearch('cust_bill_pkg_detail', $hashref);
}
Index: tax_rate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/tax_rate.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- tax_rate.pm 28 Aug 2008 22:00:05 -0000 1.9
+++ tax_rate.pm 30 Aug 2008 02:10:08 -0000 1.10
@@ -397,7 +397,12 @@
my $taxable_units = 0;
unless ($self->recurtax =~ /^Y$/i) {
if ($self->unittype == 0) {
- $taxable_units += $_->units foreach @cust_bill_pkg;
+ my %seen = ();
+ foreach (@cust_bill_pkg) {
+ $taxable_units += $_->units
+ unless $seen{$_->pkgnum};
+ $seen{$_->pkgnum}++;
+ }
}elsif ($self->unittype == 1) {
return qq!fatal: can't (yet) handle fee with minute unit type!;
}elsif ($self->unittype == 2) {
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.363
retrieving revision 1.364
diff -u -d -r1.363 -r1.364
--- cust_main.pm 28 Aug 2008 21:32:20 -0000 1.363
+++ cust_main.pm 30 Aug 2008 02:10:08 -0000 1.364
@@ -2542,7 +2542,8 @@
: '';
my @classes;
- push @classes, $cust_bill_pkg->usage_classes if $cust_bill_pkg->type eq 'U';
+ #push @classes, $cust_bill_pkg->usage_classes if $cust_bill_pkg->type eq 'U';
+ push @classes, $cust_bill_pkg->usage_classes if $cust_bill_pkg->usage;
push @classes, 'setup' if $cust_bill_pkg->setup;
push @classes, 'recur' if $cust_bill_pkg->recur;
@@ -2610,32 +2611,40 @@
my $cust_bill_pkg_recur = new FS::cust_bill_pkg { $cust_bill_pkg->hash };
$cust_bill_pkg->set('details', []);
$cust_bill_pkg->recur(0);
+ $cust_bill_pkg->unitrecur(0);
$cust_bill_pkg->type('');
+ $cust_bill_pkg_recur->setup(0);
+ $cust_bill_pkg_recur->unitsetup(0);
$cust_bill_pkg{recur} = $cust_bill_pkg_recur;
}
#split usage from recur
- my $usage = $cust_bill_pkg->usage;
+ my $usage = sprintf( "%.2f", $cust_bill_pkg{recur}->usage );
+ warn "usage is $usage\n" if $DEBUG;
if ($usage) {
my $cust_bill_pkg_usage =
new FS::cust_bill_pkg { $cust_bill_pkg{recur}->hash };
- $cust_bill_pkg_usage->recur($usage);
- $cust_bill_pkg{recur}->recur( $cust_bill_pkg{recur}->recur - $usage );
+ $cust_bill_pkg_usage->recur( $usage );
+ $cust_bill_pkg_usage->type( 'U' );
+ my $recur = sprintf( "%.2f", $cust_bill_pkg{recur}->recur - $usage );
+ $cust_bill_pkg{recur}->recur( $recur );
$cust_bill_pkg{recur}->type( '' );
+ $cust_bill_pkg{recur}->set('details', []);
$cust_bill_pkg{''} = $cust_bill_pkg_usage;
}
#subdivide usage by usage_class
if (exists($cust_bill_pkg{''})) {
- foreach my $class (grep {$_} @classes) {
- my $usage = $cust_bill_pkg{''}->usage($class);
+ foreach my $class (grep {$_ && $_ ne 'setup' && $_ ne 'recur' } @classes) {
+ my $usage = sprintf( "%.2f", $cust_bill_pkg{''}->usage($class) );
my $cust_bill_pkg_usage =
new FS::cust_bill_pkg { $cust_bill_pkg{''}->hash };
- $cust_bill_pkg_usage->recur($usage);
- $cust_bill_pkg{''}->recur( $cust_bill_pkg{''}->recur - $usage );
+ $cust_bill_pkg_usage->recur( $usage );
+ $cust_bill_pkg_usage->set('details', []);
+ my $classless = sprintf( "%.2f", $cust_bill_pkg{''}->recur - $usage );
+ $cust_bill_pkg{''}->recur( $classless );
$cust_bill_pkg{$class} = $cust_bill_pkg_usage;
}
- $cust_bill_pkg{''}->set('details', []);
delete $cust_bill_pkg{''} unless $cust_bill_pkg{''}->recur;
}
More information about the freeside-commits
mailing list