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(
}
#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 ) {
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;
}
}
=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
=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
|| $self->ut_money('recur')
|| $self->ut_numbern('sdate')
|| $self->ut_numbern('edate')
+ || $self->ut_textn('itemdesc')
;
return $error if $error;
=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
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 } )
) {
} #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'
# $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;
}
=item exempt_amount
+=item taxname - if defined, printed on invoices instead of "Tax"
+
=back
=head1 METHODS
|| $self->ut_float('tax')
|| $self->ut_textn('taxclass') # ...
|| $self->ut_money('exempt_amount')
+ || $self->ut_textn('taxname')
;
}
'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);
'recur', @money_type,
'sdate', @date_type,
'edate', @date_type,
+ 'itemdesc', 'varchar', 'NULL', $char_d,
],
'primary_key' => '',
- 'unique' => [ ['pkgnum', 'invnum'] ],
+ 'unique' => [],
'index' => [ ['invnum'] ],
},
'taxclass', 'varchar', 'NULL', $char_d,
'exempt_amount', @money_type,
'tax', 'real', '', '', #tax %
+ 'taxname', 'varchar', 'NULL', $char_d,
],
'primary_key' => 'taxnum',
'unique' => [],
*** get svc_broadband changes from pc-intouch
*** otaker changes s/8/32 all otkaer fields
*** optional: sequence changes
+ *** add column cust_main_county.taxname
+ *** add column cust_bill_pkg.itemdesc
+ *** drop index cust_bill_pkg1
install DBIx::DBSchema 0.21
install NetAddr::IP
use strict;
use DBI;
-use DBIx::DBSchema 0.20;
+use DBIx::DBSchema 0.21;
use DBIx::DBSchema::Table;
use DBIx::DBSchema::Column;
use DBIx::DBSchema::ColGroup::Unique;
'default' => '',
'local' => '',
} ),
- map { $tableobj->column($_) } $tableobj->columns
+ map {
+ my $column = $tableobj->column($_);
+ $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
],
} );
foreach my $statement ( $h_tableobj->sql_create_table($dbh) ) {
<TH><FONT SIZE=-1>Country</FONT></TH>
<TH><FONT SIZE=-1>State</FONT></TH>
<TH>County</TH>
- <TH>Taxclass</TH>
+ <TH>Taxclass<BR><FONT SIZE=-1>(per-package classification)</FONT></TH>
+ <TH>Tax name<BR><FONT SIZE=-1>(printed on invoices)</FONT></TH>
<TH><FONT SIZE=-1>Tax</FONT></TH>
<TH><FONT SIZE=-1>Exempt<BR>per<BR>month</TH>
</TR>
}
print "</TD>";
+ print "<TD";
+ if ( $hashref->{taxname} ) {
+ print ' BGCOLOR="#ffffff">'. $hashref->{taxname};
+ } else {
+ print ' BGCOLOR="#cccccc">Tax';
+ }
+ print "</TD>";
+
print "<TD BGCOLOR=\"#ffffff\">$hashref->{tax}%</TD>".
'<TD BGCOLOR="#ffffff">$'.
sprintf("%.2f", $hashref->{exempt_amount} || 0). '</TD>'.
<li>recur - recurring fee
<li>sdate - starting date
<li>edate - ending date
+ <li>itemdesc - Line item description (currently used only when pkgnum is 0)
</ul>
<li><a name="cust_credit" href="man/FS/cust_credit.html">cust_credit</a> - Credits. The equivalent of a negative <a href="#cust_bill">cust_bill</a> record.
<ul>
<li>tax - % rate
<li>taxclass
<li>exempt_amount
+ <li>taxname - if defined, printed on invoices instead of "Tax"
</ul>
<li><a name="cust_tax_exempt" href="man/FS/cust_tax_exempt.html">cust_tax_exempt</a> - Tax exemption record
<ul>
<TH><FONT SIZE=-1>Country</FONT></TH>
<TH><FONT SIZE=-1>State</FONT></TH>
<TH><FONT SIZE=-1>County</FONT></TH>
- <TH><FONT SIZE=-1>Taxclass</FONT></TH>
+ <TH><FONT SIZE=-1>Taxclass</FONT><BR><FONT SIZE=-2>(per-package classification)</FONT></TH>
+ <TH><FONT SIZE=-1>Tax name</FONT><BR><FONT SIZE=-2>(printed on invoices)</FONT></TH>
<TH><FONT SIZE=-1>Tax</FONT></TH>
<TH><FONT SIZE=-1>Exempt<BR>per<BR>month</TH>
</TR>
: ' BGCOLOR="#cccccc">(ALL)'
, "</TD>";
+ print qq!<TD><INPUT TYPE="text" NAME="taxname!, $hashref->{taxnum},
+ qq!" VALUE="!, $hashref->{taxname}, qq!"></TD>!;
print qq!<TD><INPUT TYPE="text" NAME="tax!, $hashref->{taxnum},
qq!" VALUE="!, $hashref->{tax}, qq!" SIZE=6 MAXLENGTH=6>%</TD>!;
print qq!<TD>\$<INPUT TYPE="text" NAME="exempt_amount!, $hashref->{taxnum},
foreach ( grep { /^tax\d+$/ } $cgi->param ) {
/^tax(\d+)$/ or die "Illegal form $_!";
- my($taxnum)=$1;
- my($old)=qsearchs('cust_main_county',{'taxnum'=>$taxnum})
+ my $taxnum = $1;
+ my $old = qsearchs('cust_main_county', { 'taxnum' => $taxnum })
or die "Couldn't find taxnum $taxnum!";
- my $exempt_amount = $cgi->param("exempt_amount$taxnum");
- next unless $old->tax ne $cgi->param("tax$taxnum")
- || $old->exempt_amount ne $exempt_amount;
+ next unless $old->tax != $cgi->param("tax$taxnum")
+ || $old->exempt_amount != $cgi->param("exempt_amount$taxnum")
+ || $old->taxname ne $cgi->param("taxname$taxnum");
my %hash = $old->hash;
$hash{tax} = $cgi->param("tax$taxnum");
- $hash{exempt_amount} = $exempt_amount;
- my($new)=new FS::cust_main_county \%hash;
- my($error)=$new->replace($old);
+ $hash{exempt_amount} = $cgi->param("exempt_amount$taxnum");
+ $hash{taxname} = $cgi->param("taxname$taxnum");
+ my $new = new FS::cust_main_county \%hash;
+ my $error = $new->replace($old);
if ( $error ) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). "cust_main_county.cgi?". $cgi->query_string );