diff options
-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 | ||||
-rw-r--r-- | README.1.5.0pre1 | 3 | ||||
-rwxr-xr-x | bin/create-history-tables | 13 | ||||
-rwxr-xr-x | httemplate/browse/cust_main_county.cgi | 11 | ||||
-rw-r--r-- | httemplate/docs/schema.dia | bin | 14438 -> 14438 bytes | |||
-rw-r--r-- | httemplate/docs/schema.html | 2 | ||||
-rwxr-xr-x | httemplate/edit/cust_main_county.cgi | 5 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_main_county.cgi | 17 |
12 files changed, 95 insertions, 30 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' => [], diff --git a/README.1.5.0pre1 b/README.1.5.0pre1 index ff3e5a6cc..57fc36af6 100644 --- a/README.1.5.0pre1 +++ b/README.1.5.0pre1 @@ -4,6 +4,9 @@ schema changes: *** 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 diff --git a/bin/create-history-tables b/bin/create-history-tables index d37d682d8..33eb0e5a3 100755 --- a/bin/create-history-tables +++ b/bin/create-history-tables @@ -2,7 +2,7 @@ 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; @@ -64,7 +64,16 @@ foreach my $table ( @tables ) { '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) ) { diff --git a/httemplate/browse/cust_main_county.cgi b/httemplate/browse/cust_main_county.cgi index 991606087..c2473c4c8 100755 --- a/httemplate/browse/cust_main_county.cgi +++ b/httemplate/browse/cust_main_county.cgi @@ -21,7 +21,8 @@ print '<BR><BR>'. &table(). <<END; <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> @@ -111,6 +112,14 @@ END } 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>'. diff --git a/httemplate/docs/schema.dia b/httemplate/docs/schema.dia Binary files differindex c0842a602..746561550 100644 --- a/httemplate/docs/schema.dia +++ b/httemplate/docs/schema.dia diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index 54adec3a7..c518d4a4d 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -57,6 +57,7 @@ <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> @@ -133,6 +134,7 @@ <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> diff --git a/httemplate/edit/cust_main_county.cgi b/httemplate/edit/cust_main_county.cgi index 7ef37a48d..f3d28825a 100755 --- a/httemplate/edit/cust_main_county.cgi +++ b/httemplate/edit/cust_main_county.cgi @@ -15,7 +15,8 @@ print qq!<FORM ACTION="!, popurl(1), <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> @@ -46,6 +47,8 @@ END : ' 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}, diff --git a/httemplate/edit/process/cust_main_county.cgi b/httemplate/edit/process/cust_main_county.cgi index 990a23919..6d80ad512 100755 --- a/httemplate/edit/process/cust_main_county.cgi +++ b/httemplate/edit/process/cust_main_county.cgi @@ -2,17 +2,18 @@ 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 ); |