use strict;
use vars qw( @ISA @EXPORT_OK $conf
- @cust_main_county %cust_main_county $countyflag );
+ @cust_main_county %cust_main_county $countyflag ); # $cityflag );
use Exporter;
use FS::Record qw( qsearch dbh );
use FS::cust_bill_pkg;
@cust_main_county = ();
$countyflag = '';
+#$cityflag = '';
#ask FS::UID to run this stuff for us later
$FS::UID::callback{'FS::cust_main_county'} = sub {
=item taxnum - primary key (assigned automatically for new tax rates)
-=item state
+=item district - tax district (optional)
+
+=item city
=item county
+=item state
+
=item country
=item tax - percentage
$self->exempt_amount(0) unless $self->exempt_amount;
$self->ut_numbern('taxnum')
- || $self->ut_anything('state')
+ || $self->ut_alphan('district')
+ || $self->ut_textn('city')
|| $self->ut_textn('county')
+ || $self->ut_anything('state')
|| $self->ut_text('country')
|| $self->ut_float('tax')
|| $self->ut_textn('taxclass') # ...
sub sql_taxclass_sameregion {
my $self = shift;
- my $same_query = 'SELECT taxclass FROM cust_main_county '.
+ my $same_query = 'SELECT DISTINCT taxclass FROM cust_main_county '.
' WHERE taxnum != ? AND country = ?';
my @same_param = ( 'taxnum', 'country' );
foreach my $opt_field (qw( state county )) {
map $_->[0], @{ $sth->fetchall_arrayref };
}
-=item taxline TAXABLES, [ OPTIONSHASH ]
+=item taxline TAXABLES_ARRAYREF, [ OPTION => VALUE ... ]
Returns a listref of a name and an amount of tax calculated for the list of
-packages or amounts referenced by TAXABLES. Returns a scalar error message
-on error.
+packages or amounts referenced by TAXABLES_ARRAYREF. Returns a scalar error
+message on error.
-OPTIONSHASH includes custnum and invoice_date and are hints to this method
+Options include custnum and invoice_date and are hints to this method
=cut
sub taxline {
- my $self = shift;
-
- my $taxables;
- my %opt = ();
-
- if (ref($_[0]) eq 'ARRAY') {
- $taxables = shift;
- %opt = @_;
- }else{
- $taxables = [ @_ ];
- # exemptions broken in this case
- }
+ my( $self, $taxables, %opt ) = @_;
my @exemptions = ();
push @exemptions, @{ $_->_cust_tax_exempt_pkg }
my ($mon,$year) =
(localtime( $cust_bill_pkg->sdate || $invoice_date ) )[4,5];
$mon++;
- my $freq = $part_pkg->freq || 1;
+ my $freq = $cust_bill_pkg->freq;
+ unless ($freq) {
+ $freq = $part_pkg->freq || 1; # less trustworthy fallback
+ }
if ( $freq !~ /(\d+)$/ ) {
$dbh->rollback if $oldAutoCommit;
return "daily/weekly package definitions not (yet?)".
'taxnum' => $self->taxnum,
'year' => 1900+$year,
'month' => $mon,
- 'amount' => sprintf("%.2f", $addl ),
+ 'amount' => sprintf('%.2f', $addl ),
} );
if ($cust_bill_pkg->billpkgnum) {
$cust_tax_exempt_pkg->billpkgnum($cust_bill_pkg->billpkgnum);
}
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
- return [ $name, $amount ]
+
+ return {
+ 'name' => $name,
+ 'amount' => $amount,
+ };
+
}
=back