diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_bill.pm | 20 | ||||
-rw-r--r-- | FS/FS/cust_bill_pkg.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 24 | ||||
-rw-r--r-- | FS/FS/cust_main_county.pm | 3 | ||||
-rwxr-xr-x | FS/bin/freeside-setup | 22 |
5 files changed, 56 insertions, 18 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 258b32e15..f0667258c 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -510,10 +510,13 @@ sub send_csv { time2str("%x", $cust_bill_pkg->edate), ); - } else { #pkgnum Tax + } else { #pkgnum tax next unless $cust_bill_pkg->setup != 0; + my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc') + ? ( $cust_bill_pkg->itemdesc || 'Tax' ) + : 'Tax'; ($pkg, $setup, $recur, $sdate, $edate) = - ( 'Tax', sprintf("%10.2f",$cust_bill_pkg->setup), '', '', '' ); + ( $itemdesc, sprintf("%10.2f",$cust_bill_pkg->setup), '', '', '' ); } $csv->combine( @@ -858,7 +861,9 @@ sub print_text { } #new charges - foreach ( $self->cust_bill_pkg ) { + foreach ( ( grep { $_->pkgnum } $self->cust_bill_pkg ), #packages first + ( grep { ! $_->pkgnum } $self->cust_bill_pkg ), #then taxes + ) { if ( $_->pkgnum ) { @@ -882,8 +887,11 @@ sub print_text { map { [ " ". $_->[0]. ": ". $_->[1], '' ] } $cust_pkg->labels; } - } else { #pkgnum Tax - push @buf,["Tax", $money_char. sprintf("%10.2f",$_->setup) ] + } else { #pkgnum tax + my $itemdesc = defined $_->dbdef_table->column('itemdesc') + ? ( $_->itemdesc || 'Tax' ) + : 'Tax'; + push @buf,[$itemdesc, $money_char. sprintf("%10.2f",$_->setup) ] if $_->setup != 0; } } @@ -1031,7 +1039,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.45 2002-09-17 10:21:47 ivan Exp $ +$Id: cust_bill.pm,v 1.46 2002-09-21 11:17:39 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index 72f9ce4a9..5a1dcd2aa 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -47,6 +47,8 @@ supported: =item edate - ending date of recurring fee +=item itemdesc - Line item description (currentlty used only when pkgnum is 0) + =back sdate and edate are specified as UNIX timestamps; see L<perlfunc/"time">. Also @@ -111,6 +113,7 @@ sub check { || $self->ut_money('recur') || $self->ut_numbern('sdate') || $self->ut_numbern('edate') + || $self->ut_textn('itemdesc') ; return $error if $error; @@ -140,7 +143,7 @@ sub cust_pkg { =head1 VERSION -$Id: cust_bill_pkg.pm,v 1.3 2002-04-06 22:32:43 ivan Exp $ +$Id: cust_bill_pkg.pm,v 1.4 2002-09-21 11:17:39 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 84fd3d150..2701ac35d 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -904,10 +904,12 @@ sub bill { my( $total_setup, $total_recur ) = ( 0, 0 ); #my( $taxable_setup, $taxable_recur ) = ( 0, 0 ); my @cust_bill_pkg = (); - my $tax = 0;## + #my $tax = 0;## #my $taxable_charged = 0;## #my $charged = 0;## + my %tax; + foreach my $cust_pkg ( qsearch('cust_pkg', { 'custnum' => $self->custnum } ) ) { @@ -1101,7 +1103,10 @@ sub bill { } #if $cust_main_county->exempt_amount $taxable_charged = sprintf( "%.2f", $taxable_charged); - $tax += $taxable_charged * $cust_main_county->tax / 100 + + #$tax += $taxable_charged * $cust_main_county->tax / 100 + $tax{ $cust_main_county->taxname || 'Tax' } += + $taxable_charged * $cust_main_county->tax / 100 } #unless $self->tax =~ /Y/i # || $self->payby eq 'COMP' @@ -1134,16 +1139,17 @@ sub bill { # $taxable_charged * ( $cust_main_county->getfield('tax') / 100 ) # ); - $tax = sprintf("%.2f", $tax); - if ( $tax > 0 ) { + foreach my $taxname ( grep { $tax{$_} > 0 } keys %tax ) { + my $tax = sprintf("%.2f", $tax{$taxname} ); $charged = sprintf( "%.2f", $charged+$tax ); my $cust_bill_pkg = new FS::cust_bill_pkg ({ - 'pkgnum' => 0, - 'setup' => $tax, - 'recur' => 0, - 'sdate' => '', - 'edate' => '', + 'pkgnum' => 0, + 'setup' => $tax, + 'recur' => 0, + 'sdate' => '', + 'edate' => '', + 'itemdesc' => $taxname, }); push @cust_bill_pkg, $cust_bill_pkg; } diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm index e41564d21..d8796e451 100644 --- a/FS/FS/cust_main_county.pm +++ b/FS/FS/cust_main_county.pm @@ -61,6 +61,8 @@ currently supported: =item exempt_amount +=item taxname - if defined, printed on invoices instead of "Tax" + =back =head1 METHODS @@ -110,6 +112,7 @@ sub check { || $self->ut_float('tax') || $self->ut_textn('taxclass') # ... || $self->ut_money('exempt_amount') + || $self->ut_textn('taxname') ; } diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index e8bb7ec62..f6a543fc8 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -189,7 +189,23 @@ foreach my $table ( grep { ! /^h_/ } $dbdef->tables ) { 'default' => '', 'local' => '', } ), - map { $tableobj->column($_) } $tableobj->columns + map { + my $column = $tableobj->column($_); + + #clone so as to not disturb the original + $column = DBIx::DBSchema::Column->new( { + map { $_ => $column->$_() } + qw( name type null length default local ) + } ); + + $column->type('int') + if $column->type eq 'serial'; + #$column->default('') + # if $column->default =~ /^nextval\(/i; + #( my $local = $column->local ) =~ s/AUTO_INCREMENT//i; + #$column->local($local); + $column; + } $tableobj->columns ], } ); $dbdef->addtable($h_tableobj); @@ -397,9 +413,10 @@ sub tables_hash_hack { 'recur', @money_type, 'sdate', @date_type, 'edate', @date_type, + 'itemdesc', 'varchar', 'NULL', $char_d, ], 'primary_key' => '', - 'unique' => [ ['pkgnum', 'invnum'] ], + 'unique' => [], 'index' => [ ['invnum'] ], }, @@ -504,6 +521,7 @@ sub tables_hash_hack { 'taxclass', 'varchar', 'NULL', $char_d, 'exempt_amount', @money_type, 'tax', 'real', '', '', #tax % + 'taxname', 'varchar', 'NULL', $char_d, ], 'primary_key' => 'taxnum', 'unique' => [], |