summaryrefslogtreecommitdiff
path: root/FS/FS/cust_bill_pkg_tax_rate_location.pm
diff options
context:
space:
mode:
authorjeff <jeff>2009-10-26 07:12:12 +0000
committerjeff <jeff>2009-10-26 07:12:12 +0000
commit64fcb43c61c196766260319cd9219eb70ea27767 (patch)
tree43a4a49ae30ebf1e8662489139604a44626f53ec /FS/FS/cust_bill_pkg_tax_rate_location.pm
parent08ab7010467cf25578acdf8d9a9a068a87f1c49f (diff)
credits return taxes, but the magic calculation button does not yet work properly (grrr - more sleep required) RT#4729
Diffstat (limited to 'FS/FS/cust_bill_pkg_tax_rate_location.pm')
-rw-r--r--FS/FS/cust_bill_pkg_tax_rate_location.pm83
1 files changed, 82 insertions, 1 deletions
diff --git a/FS/FS/cust_bill_pkg_tax_rate_location.pm b/FS/FS/cust_bill_pkg_tax_rate_location.pm
index fc5734f..89c2529 100644
--- a/FS/FS/cust_bill_pkg_tax_rate_location.pm
+++ b/FS/FS/cust_bill_pkg_tax_rate_location.pm
@@ -5,7 +5,9 @@ use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );
use FS::cust_bill_pkg;
use FS::cust_pkg;
-use FS::cust_location;
+use FS::tax_rate_location;
+use FS::cust_bill_pay_pkg;
+use FS::cust_credit_bill_pkg;
=head1 NAME
@@ -122,6 +124,85 @@ sub check {
$self->SUPER::check;
}
+=item cust_bill_pkg
+
+Returns the associated cust_bill_pkg object
+
+=cut
+
+sub cust_bill_pkg {
+ my $self = shift;
+ qsearchs( 'cust_bill_pkg', { 'billpkgnum' => $self->billpkgnum } );
+}
+
+=item tax_rate_location
+
+Returns the associated tax_rate_location object
+
+=cut
+
+sub tax_rate_location {
+ my $self = shift;
+ qsearchs( 'tax_rate_location',
+ { 'taxratelocationnum' => $self->taxratelocationnum }
+ );
+}
+
+=item desc
+
+Returns a description for this tax line item constituent. Currently this
+is the desc of the associated line item followed by the
+state,county,city,locationtaxid for the location in parentheses.
+
+=cut
+
+sub desc {
+ my $self = shift;
+ my $tax_rate_location = $self->tax_rate_location;
+ my $location = join(', ', grep { $_ }
+ map { $tax_rate_location->$_ }
+ qw( state county city )
+ );
+ $location .= ( $location && $self->locationtaxid ) ? ', ' : '';
+ $location .= $self->locationtaxid;
+ $self->cust_bill_pkg->desc. " ($location)";
+}
+
+
+=item owed
+
+Returns the amount owed (still outstanding) on this tax line item which is
+the amount of this record minus all payment applications and credit
+applications.
+
+=cut
+
+sub owed {
+ my $self = shift;
+ my $balance = $self->amount;
+ $balance -= $_->amount foreach ( $self->cust_bill_pay_pkg('setup') );
+ $balance -= $_->amount foreach ( $self->cust_credit_bill_pkg('setup') );
+ $balance = sprintf( '%.2f', $balance );
+ $balance =~ s/^\-0\.00$/0.00/; #yay ieee fp
+ $balance;
+}
+
+sub cust_bill_pay_pkg {
+ my $self = shift;
+ qsearch( 'cust_bill_pay_pkg', { map { $_ => $self->$_ }
+ qw( billpkgtaxratelocationnum billpkgnum )
+ }
+ );
+}
+
+sub cust_credit_bill_pkg {
+ my $self = shift;
+ qsearch( 'cust_credit_bill_pkg', { map { $_ => $self->$_ }
+ qw( billpkgtaxratelocationnum billpkgnum )
+ }
+ );
+}
+
=back
=head1 BUGS