summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/part_pkg_taxproduct.cgi246
-rwxr-xr-xhttemplate/browse/tax_rate.cgi252
-rw-r--r--httemplate/edit/elements/edit.html8
-rwxr-xr-xhttemplate/edit/part_pkg.cgi15
-rw-r--r--httemplate/edit/process/elements/process.html6
-rw-r--r--httemplate/edit/process/tax_rate.html9
-rw-r--r--httemplate/edit/tax_rate.html28
7 files changed, 495 insertions, 69 deletions
diff --git a/httemplate/browse/part_pkg_taxproduct.cgi b/httemplate/browse/part_pkg_taxproduct.cgi
new file mode 100755
index 000000000..3df819715
--- /dev/null
+++ b/httemplate/browse/part_pkg_taxproduct.cgi
@@ -0,0 +1,246 @@
+<% include( 'elements/browse.html',
+ 'title' => "Tax Products $title",
+ 'name_singular' => 'tax product',
+ 'menubar' => \@menubar,
+ 'html_init' => $html_init,
+ 'query' => {
+ 'table' => 'part_pkg_taxproduct',
+ 'hashref' => $hashref,
+ 'order_by' => 'ORDER BY description',
+ 'extra_sql' => $extra_sql,
+ },
+ 'count_query' => $count_query,
+ 'header' => \@header,
+ 'fields' => \@fields,
+ 'align' => $align,
+ 'links' => \@links,
+ 'link_onclicks' => \@link_onclicks,
+ )
+%>
+<%once>
+
+my $conf = new FS::Conf;
+
+my $select_link = [ 'javascript:void(0);', sub { ''; } ];
+
+</%once>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my @menubar;
+my $title = '';
+
+my $data_vendor = '';
+if ( $cgi->param('data_vendor') =~ /^(\w+)$/ ) {
+ $data_vendor = $1;
+ $title = "$data_vendor";
+}
+$cgi->delete('data_vendor');
+
+$title = " for $title" if $title;
+
+my $taxproductnum = $1
+ if ( $cgi->param('taxproductnum') =~ /^(\d+)$/ );
+my $tax_group = $1
+ if ( $cgi->param('tax_group') =~ /^([- \w\(\).\/]+)$/ );
+my $tax_item = $1
+ if ( $cgi->param('tax_item') =~ /^([- \w\(\).\/&%]+)$/ );
+my $tax_provider = $1
+ if ( $cgi->param('tax_provider') =~ /^([ \w]+)$/ );
+my $tax_customer = $1
+ if ( $cgi->param('tax_customer') =~ /^([ \w]+)$/ );
+my $id = $1
+ if ( $cgi->param('id') =~ /^([ \w]+)$/ );
+
+my $select_onclick = sub {
+ my $row = shift;
+ my $taxnum = $row->taxproductnum;
+ my $desc = $row->description;
+ "parent.document.getElementById('$id').value = $taxnum;".
+ "parent.document.getElementById('${id}_description').value = '$desc';".
+ "parent.cClick();";
+}
+ if $id;
+
+my $selected_part_pkg_taxproduct;
+if ($taxproductnum) {
+ $selected_part_pkg_taxproduct =
+ qsearchs('part_pkg_taxproduct', { 'taxproductnum' => $taxproductnum });
+}
+
+my $hashref = {};
+my $extra_sql = '';
+if ( $data_vendor ) {
+ $extra_sql .= ' WHERE data_vendor = '. dbh->quote($data_vendor);
+}
+
+if ($tax_group || $tax_item || $tax_customer || $tax_provider) {
+ my $compare = "LIKE '". ( $tax_group || "%" ). " : ". ( $tax_item || "%" ). " : ".
+ ( $tax_provider || "%" ). " : ". ( $tax_customer || "%" ). "'";
+ $compare = "= '$tax_group:$tax_item:$tax_provider:$tax_customer'"
+ if ($tax_group && $tax_item && $tax_provider && $tax_customer);
+
+ $extra_sql .= ($extra_sql =~ /WHERE/ ? ' AND ' : ' WHERE ').
+ "description $compare";
+
+}
+$cgi->delete('tax_group');
+$cgi->delete('tax_item');
+$cgi->delete('tax_provider');
+$cgi->delete('tax_customer');
+
+
+if ( $tax_group || $tax_item || $tax_provider || $tax_customer ) {
+ push @menubar, 'View all tax products' => $p.'browse/part_pkg_taxproduct.cgi';
+}
+
+$cgi->param('dummy', 1);
+
+#restore this so pagination works
+$cgi->param('data_vendor', $data_vendor) if $data_vendor;
+$cgi->param('tax_group', $tax_group) if $tax_group;
+$cgi->param('tax_item', $tax_item ) if $tax_item;
+$cgi->param('tax_provider', $tax_provider ) if $tax_provider;
+$cgi->param('tax_customer', $tax_customer ) if $tax_customer;
+
+my $count_query = "SELECT COUNT(*) FROM part_pkg_taxproduct $extra_sql";
+
+my @header = ( 'Data Vendor', 'Group', 'Item', 'Provider', 'Customer' );
+my @links = ( $select_link,
+ $select_link,
+ $select_link,
+ $select_link,
+ $select_link,
+ );
+my @link_onclicks = ( $select_onclick,
+ $select_onclick,
+ $select_onclick,
+ $select_onclick,
+ $select_onclick,
+ );
+my $align = 'lllll';
+
+my @fields = (
+ 'data_vendor',
+ sub { shift->description =~ /^(.*):.*:.*:.*$/; $1;},
+ sub { shift->description =~ /^.*:(.*):.*:.*$/; $1;},
+ sub { shift->description =~ /^.*:.*:(.*):.*$/; $1;},
+ sub { shift->description =~ /^.*:.*:.*:(.*)$/; $1;},
+);
+
+my $html_init = '';
+
+$html_init = '<TABLE><TR><TD>Current tax product: </TD><TD>'.
+ $selected_part_pkg_taxproduct->description.
+ '</TD></TR></TABLE><BR><BR>'
+ if $selected_part_pkg_taxproduct;
+
+my $type = $cgi->param('_type');
+$html_init .= qq(
+ <FORM>
+ <INPUT NAME="_type" TYPE="hidden" VALUE="$type">
+ <INPUT NAME="taxproductnum" TYPE="hidden" VALUE="$taxproductnum">
+ <INPUT NAME="id" TYPE="hidden" VALUE="$id">
+ <TABLE>
+ <TR>
+ <TD><SELECT NAME="data_vendor" onChange="this.form.submit()">
+);
+
+my $sql = "SELECT DISTINCT data_vendor FROM part_pkg_taxproduct ORDER BY data_vendor";
+my $dbh = dbh;
+my $sth = $dbh->prepare($sql) or die $dbh->errstr;
+$sth->execute or die $sth->errstr;
+for (['(choose data vendor)'], @{$sth->fetchall_arrayref}) {
+ $html_init .= '<OPTION VALUE="'. $_->[0]. '"'.
+ ($_->[0] eq $data_vendor ? " SELECTED" : "").
+ '">'. $_->[0];
+}
+$html_init .= qq(
+ </SELECT>
+
+<!-- cch specific -->
+ <TD><SELECT NAME="tax_group" onChange="this.form.submit()">
+);
+
+$sql = "SELECT DISTINCT ".
+ qq!substring(description from '#"%#" : % : % : %' for '#'),!.
+ qq!substring(description from '#"%#" : % : % : %' for '#')!.
+ "FROM part_pkg_taxproduct ORDER BY 1";
+
+$sth = $dbh->prepare($sql) or die $dbh->errstr;
+$sth->execute or die $sth->errstr;
+for (['', '(choose group)'], @{$sth->fetchall_arrayref}) {
+ $html_init .= '<OPTION VALUE="'. $_->[0]. '"'.
+ ($_->[0] eq $tax_group ? " SELECTED" : "").
+ '">'. $_->[1];
+}
+
+$html_init .= qq(
+ </SELECT>
+
+ <TD><SELECT NAME="tax_item" onChange="this.form.submit()">
+);
+
+$sql = "SELECT DISTINCT ".
+ qq!substring(description from '% : #"%#" : %: %' for '#'),!.
+ qq!substring(description from '% : #"%#" : %: %' for '#')!.
+ "FROM part_pkg_taxproduct ORDER BY 1";
+
+$sth = $dbh->prepare($sql) or die $dbh->errstr;
+$sth->execute or die $sth->errstr;
+for (@{$sth->fetchall_arrayref}) {
+ $html_init .= '<OPTION VALUE="'. $_->[0]. '"'.
+ ($_->[0] eq $tax_item ? " SELECTED" : "").
+ '">'. ($_->[0] ? $_->[1] : '(choose item)');
+}
+
+$html_init .= qq(
+ </SELECT>
+
+ <TD><SELECT NAME="tax_provider" onChange="this.form.submit()">
+);
+
+$sql = "SELECT DISTINCT ".
+ qq!substring(description from '% : % : #"%#" : %' for '#'),!.
+ qq!substring(description from '% : % : #"%#" : %' for '#')!.
+ "FROM part_pkg_taxproduct ORDER BY 1";
+
+$sth = $dbh->prepare($sql) or die $dbh->errstr;
+$sth->execute or die $sth->errstr;
+for (@{$sth->fetchall_arrayref}) {
+ $html_init .= '<OPTION VALUE="'. $_->[0]. '"'.
+ ($_->[0] eq $tax_provider ? " SELECTED" : "").
+ '">'. ($_->[0] ? $_->[1] : '(choose provider type)');
+}
+
+$html_init .= qq(
+ </SELECT>
+
+ <TD><SELECT NAME="tax_customer" onChange="this.form.submit()">
+);
+
+$sql = "SELECT DISTINCT ".
+ qq!substring(description from '% : % : % : #"%#"' for '#'),!.
+ qq!substring(description from '% : % : % : #"%#"' for '#')!.
+ "FROM part_pkg_taxproduct ORDER BY 1";
+
+$sth = $dbh->prepare($sql) or die $dbh->errstr;
+$sth->execute or die $sth->errstr;
+for (@{$sth->fetchall_arrayref}) {
+ $html_init .= '<OPTION VALUE="'. $_->[0]. '"'.
+ ($_->[0] eq $tax_customer ? " SELECTED" : "").
+ '">'. ($_->[0] ? $_->[1] : '(choose customer type)');
+}
+
+$html_init .= qq(
+ </SELECT>
+
+ </TR>
+ </TABLE>
+ </FORM>
+
+);
+
+</%init>
diff --git a/httemplate/browse/tax_rate.cgi b/httemplate/browse/tax_rate.cgi
index b401b3786..5d43d5939 100755
--- a/httemplate/browse/tax_rate.cgi
+++ b/httemplate/browse/tax_rate.cgi
@@ -4,9 +4,10 @@
'menubar' => \@menubar,
'html_init' => $html_init,
'query' => {
- 'table' => 'tax_rate',
- 'hashref' => $hashref,
- 'order_by' => 'ORDER BY geocode, taxclassnum',
+ 'table' => 'tax_rate',
+ 'hashref' => $hashref,
+ 'order_by' => 'ORDER BY geocode, taxclassnum',
+ 'extra_sql' => $extra_sql,
},
'count_query' => $count_query,
'header' => \@header,
@@ -24,21 +25,62 @@
my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';
-my $exempt_sub = sub {
+my $rate_sub = sub {
my $tax_rate = shift;
- my @exempt = ();
- push @exempt,
- sprintf("$money_char%.2f&nbsp;per&nbsp;month", $tax_rate->exempt_amount )
- if $tax_rate->exempt_amount > 0;
+ my $units = $tax_rate->unittype_name;
+ $units =~ s/ /&nbsp;/g;
+
+ my @rate = ();
+ push @rate,
+ ($tax_rate->tax * 100). '%&nbsp;<FONT SIZE="-1">(edit)</FONT>'
+ if $tax_rate->tax > 0 || $tax_rate->taxbase > 0;
+ push @rate,
+ ($tax_rate->excessrate * 100). '%&nbsp;<FONT SIZE="-1">(edit)</FONT>'
+ if $tax_rate->excessrate > 0;
+ push @rate,
+ $money_char. $tax_rate->fee.
+ qq!&nbsp;per&nbsp;$units<FONT SIZE="-1">(edit)</FONT>!
+ if $tax_rate->fee > 0 || $tax_rate->feebase > 0;
+ push @rate,
+ $money_char. $tax_rate->excessfee.
+ qq!&nbsp;per&nbsp;$units<FONT SIZE="-1">(edit)</FONT>!
+ if $tax_rate->excessfee > 0;
+
+
+ [ map [ {'data'=>$_} ], @rate ];
+};
+
+my $limit_sub = sub {
+ my $tax_rate = shift;
- push @exempt, 'Setup&nbsp;fee'
+ my $maxtype = $tax_rate->maxtype_name;
+ $maxtype =~ s/ /&nbsp;/g;
+
+ my $units = $tax_rate->unittype_name;
+ $units =~ s/ /&nbsp;/g;
+
+ my @limit = ();
+ push @limit,
+ sprintf("$money_char%.2f&nbsp%s", $tax_rate->taxbase, $maxtype )
+ if $tax_rate->taxbase > 0;
+ push @limit,
+ sprintf("$money_char%.2f&nbsp;tax", $tax_rate->taxmax )
+ if $tax_rate->taxmax > 0;
+ push @limit,
+ $tax_rate->feebase. "&nbsp;$units". ($tax_rate->feebase == 1 ? '' : 's')
+ if $tax_rate->feebase > 0;
+ push @limit,
+ $tax_rate->feemax. "&nbsp;$units". ($tax_rate->feebase == 1 ? '' : 's')
+ if $tax_rate->feemax > 0;
+
+ push @limit, 'Excluding&nbsp;setup&nbsp;fee'
if $tax_rate->setuptax =~ /^Y$/i;
- push @exempt, 'Recurring&nbsp;fee'
+ push @limit, 'Excluding&nbsp;recurring&nbsp;fee'
if $tax_rate->recurtax =~ /^Y$/i;
- [ map [ {'data'=>$_} ], @exempt ];
+ [ map [ {'data'=>$_} ], @limit ];
};
my $oldrow;
@@ -67,15 +109,7 @@ my $select_onclick = sub {
my $row = shift;
my $taxnum = $row->taxnum;
my $color = '#333399';
- qq!overlib( OLiframeContent('${p}edit/tax_rate.html?$taxnum', 540, 420, 'edit_tax_rate_popup' ), CAPTION, 'Edit tax rate', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;!;
-};
-
-my $separate_taxclasses_link = sub {
- my( $row ) = @_;
- my $taxnum = $row->taxnum;
- my $url = "${p}edit/process/tax_rate-expand.cgi?taxclassnum=1;taxnum=$taxnum";
-
- qq!<FONT SIZE="-1"><A HREF="$url">!;
+ qq!overlib( OLiframeContent('${p}edit/tax_rate.html?$taxnum', 540, 620, 'edit_tax_rate_popup' ), CAPTION, 'Edit tax rate', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;!;
};
</%once>
@@ -85,26 +119,19 @@ die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
my @menubar;
-
-my $html_init =
- "Click on <u>geocodes</u> to specify rates for a new area.";
-$html_init .= "<BR>Click on <u>separate taxclasses</u> to specify taxes per taxclass.";
-$html_init .= '<BR><BR>';
-
-$html_init .= qq(
- <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws.js"></SCRIPT>
- <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_iframe.js"></SCRIPT>
- <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_draggable.js"></SCRIPT>
- <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/iframecontentmws.js"></SCRIPT>
-);
-
my $title = '';
-my $select_word = 'edit';
+
+my $data_vendor = '';
+if ( $cgi->param('data_vendor') =~ /^(\w+)$/ ) {
+ $data_vendor = $1;
+ $title = "$data_vendor";
+}
+$cgi->delete('data_vendor');
my $geocode = '';
if ( $cgi->param('geocode') =~ /^(\w+)$/ ) {
$geocode = $1;
- $title = "$geocode";
+ $title = " geocode $geocode";
}
$cgi->delete('geocode');
@@ -123,6 +150,36 @@ if ( $cgi->param('taxclassnum') =~ /^(\d+)$/ ) {
}
$cgi->delete('taxclassnum');
+my $tax_type = $1
+ if ( $cgi->param('tax_type') =~ /^(\d+)$/ );
+my $tax_cat = $1
+ if ( $cgi->param('tax_cat') =~ /^(\d+)$/ );
+
+my @taxclassnum = ();
+if ($tax_type || $tax_cat ) {
+ my $compare = "LIKE '". ( $tax_type || "%" ). ":". ( $tax_cat || "%" ). "'";
+ $compare = "= '$tax_type:$tax_cat'" if ($tax_type && $tax_cat);
+ my @tax_class =
+ qsearch({ 'table' => 'tax_class',
+ 'hashref' => {},
+ 'extra_sql' => "WHERE taxclass $compare",
+ });
+ if (@tax_class) {
+ @taxclassnum = map { $_->taxclassnum } @tax_class;
+ $tax_class[0]->description =~ /^(.*):(.*)/;
+ $title .= " for";
+ $title .= " $tax_type ($1) tax type" if $tax_type;
+ $title .= " and" if ($tax_type && $tax_cat);
+ $title .= " $tax_cat ($2) tax category" if $tax_cat;
+ }else{
+ $tax_type = '';
+ $tax_cat = '';
+ }
+}
+$cgi->delete('tax_type');
+$cgi->delete('tax_cat');
+
+
if ( $geocode || $taxclassnum ) {
push @menubar, 'View all tax rates' => $p.'browse/tax_rate.cgi';
}
@@ -130,21 +187,34 @@ if ( $geocode || $taxclassnum ) {
$cgi->param('dummy', 1);
#restore this so pagination works
+$cgi->param('data_vendor', $data_vendor) if $data_vendor;
$cgi->param('geocode', $geocode) if $geocode;
$cgi->param('taxclassnum', $taxclassnum ) if $taxclassnum;
+$cgi->param('tax_type', $tax_type ) if $tax_type;
+$cgi->param('tax_cat', $tax_cat ) if $tax_cat;
my $hashref = {};
-my $count_query = 'SELECT COUNT(*) FROM tax_rate';
+my $extra_sql = '';
+if ( $data_vendor ) {
+ $extra_sql .= ' WHERE data_vendor = '. dbh->quote($data_vendor);
+}
+
if ( $geocode ) {
- $hashref->{'geocode'} = $geocode;
- $count_query .= ' WHERE geocode = '. dbh->quote($geocode);
+ $extra_sql .= ( $extra_sql =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
+ ' geocode LIKE '. dbh->quote($geocode.'%');
}
+
if ( $taxclassnum ) {
- $hashref->{'taxclassnum'} = $taxclassnum;
- $count_query .= ( $count_query =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
- ' taxclassnum = '. dbh->quote($taxclassnum);
+ $extra_sql .= ( $extra_sql =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
+ ' taxclassnum = '. dbh->quote($taxclassnum);
}
+if ( @taxclassnum ) {
+ $extra_sql .= ( $extra_sql =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
+ join(' OR ', map { " taxclassnum = $_ " } @taxclassnum );
+}
+
+my $count_query = "SELECT COUNT(*) FROM tax_rate $extra_sql";
$cell_style = '';
@@ -164,18 +234,15 @@ my @color = (
push @header, qq!Tax class (<A HREF="${p}edit/tax_class.html">add new</A>)!;
push @header2, '(per-tax classification)';
-push @fields, sub { $_[0]->taxclass_description || '(all)&nbsp'.
- &{$separate_taxclasses_link}($_[0], 'Separate Taxclasses').
- 'separate&nbsp;taxclasses</A></FONT>'
- };
-push @color, sub { shift->taxclass ? '000000' : '999999' };
+push @fields, 'taxclass_description';
+push @color, '000000';
push @links, '';
push @link_onclicks, '';
$align .= 'l';
push @header, 'Tax name',
'Rate', #'Tax',
- 'Exemptions',
+ 'Limits',
;
push @header2, '(printed on invoices)',
@@ -185,8 +252,8 @@ push @header2, '(printed on invoices)',
push @fields,
sub { shift->taxname || 'Tax' },
- sub { shift->tax. '%&nbsp;<FONT SIZE="-1">('. $select_word. ')</FONT>' },
- $exempt_sub,
+ $rate_sub,
+ $limit_sub,
;
push @color,
@@ -202,4 +269,91 @@ my @cell_style = map $cell_style_sub, (1..scalar(@header));
push @links, '', $select_link, '';
push @link_onclicks, '', $select_onclick, '';
+my $html_init = '';
+
+$html_init .= qq(
+ <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws.js"></SCRIPT>
+ <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_iframe.js"></SCRIPT>
+ <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_draggable.js"></SCRIPT>
+ <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/iframecontentmws.js"></SCRIPT>
+
+);
+
+$html_init .= qq(
+ <FORM>
+ <TABLE>
+ <TR>
+ <TD><SELECT NAME="data_vendor" onChange="this.form.submit()">
+);
+
+my $sql = "SELECT DISTINCT data_vendor FROM tax_rate ORDER BY data_vendor";
+my $dbh = dbh;
+my $sth = $dbh->prepare($sql) or die $dbh->errstr;
+$sth->execute or die $sth->errstr;
+for (['(choose data vendor)'], @{$sth->fetchall_arrayref}) {
+ $html_init .= '<OPTION VALUE="'. $_->[0]. '"'.
+ ($_->[0] eq $data_vendor ? " SELECTED" : "").
+ '">'. $_->[0];
+}
+$html_init .= qq(
+ </SELECT>
+
+ <TD><INPUT NAME="geocode" TYPE="text" SIZE="12" VALUE="$geocode"></TD>
+
+<!-- generic
+ <TD><INPUT NAME="taxclassnum" TYPE="text" SIZE="12" VALUE="$taxclassnum"></TD>
+ <TD><INPUT TYPE="submit" VALUE="Filter by tax_class"></TD>
+-->
+
+<!-- cch specific -->
+ <TD><SELECT NAME="tax_type" onChange="this.form.submit()">
+);
+
+$sql = "SELECT DISTINCT ".
+ "substring(taxclass from 1 for position(':' in taxclass)-1),".
+ "substring(description from 1 for position(':' in description)-1) ".
+ "FROM tax_class WHERE data_vendor='cch' ORDER BY 2";
+
+$sth = $dbh->prepare($sql) or die $dbh->errstr;
+$sth->execute or die $sth->errstr;
+for (['', '(choose tax type)'], @{$sth->fetchall_arrayref}) {
+ $html_init .= '<OPTION VALUE="'. $_->[0]. '"'.
+ ($_->[0] eq $tax_type ? " SELECTED" : "").
+ '">'. $_->[1];
+}
+
+$html_init .= qq(
+ </SELECT>
+
+ <TD><SELECT NAME="tax_cat" onChange="this.form.submit()">
+);
+
+$sql = "SELECT DISTINCT ".
+ "substring(taxclass from position(':' in taxclass)+1),".
+ "substring(description from position(':' in description)+1) ".
+ "from tax_class WHERE data_vendor='cch' ORDER BY 2";
+
+$sth = $dbh->prepare($sql) or die $dbh->errstr;
+$sth->execute or die $sth->errstr;
+for (['', '(choose tax category)'], @{$sth->fetchall_arrayref}) {
+ $html_init .= '<OPTION VALUE="'. $_->[0]. '"'.
+ ($_->[0] eq $tax_cat ? " SELECTED" : "").
+ '">'. $_->[1];
+}
+
+$html_init .= qq(
+ </SELECT>
+
+ </TR>
+ <TR>
+ <TD></TD>
+ <TD><INPUT TYPE="submit" VALUE="Filter by geocode"></TD>
+ <TD></TD>
+ <TD></TD>
+ </TR>
+ </TABLE>
+ </FORM>
+
+);
+
</%init>
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index ad52f7a4c..c80586a4c 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -97,6 +97,9 @@ Example:
#run when adding
'new_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; },
+ #run before display to return a different value
+ 'value_callback' => sub { my( $columname, $value } ) = @_; },
+
#XXX describe
'field_callback' => sub { },
@@ -273,7 +276,10 @@ Example:
% #$field .= $fieldnum;
% $onchange .= "\nspawn_$field(what);";
% } else {
-% $curr_value = $object->$field();
+% $curr_value =
+% ($opt{'value_callback'} && $mode ne 'error')
+% ? &{ $opt{'value_callback'} }( $f->{'field'}, $object->$field() )
+% : $object->$field();
% }
%
% my @include = &{ $include_sub }(
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index 2e7c732e6..c00af197e 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -94,7 +94,7 @@ Tax information
<TD align="right">Tax product</TD>
<TD>
<INPUT name="part_pkg_taxproduct_taxproductnum" id="taxproductnum" type="hidden" value="<% $hashref->{'taxproductnum'}%>">
- <INPUT name="part_pkg_taxproduct_description" id="taxproduct_description" type="text" value="<% $taxproduct_description %>" size="12" onclick="overlib( OLiframeContent('part_pkg_taxproduct.html?'+document.getElementById('taxproductnum').value, 1000, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">
+ <INPUT name="part_pkg_taxproduct_description" id="taxproductnum_description" type="text" value="<% $taxproduct_description %>" size="12" onclick="overlib( OLiframeContent('<% $p %>/browse/part_pkg_taxproduct.cgi?_type=select&id=taxproductnum&taxproductnum='+document.getElementById('taxproductnum').value, 1000, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">
</TD>
</TR>
<TR>
@@ -111,6 +111,7 @@ Tax information
% } else {
<INPUT TYPE="hidden" NAME="taxproductnum" VALUE="<% $hashref->{taxproductnum} %>">
+ <INPUT TYPE="hidden" NAME="tax_override" VALUE="<% $tax_override %>">
% }
@@ -466,10 +467,16 @@ if ( $cgi->param('clone') ) {
} elsif ( $query && $query =~ /^(\d+)$/ ) {
(@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1})
unless $part_pkg;
- $tax_override =
+ unless ($part_pkg) {
+ $tax_override =
join (",", map {$_->taxclassnum}
- qsearch('part_pkg_taxoverride',{'pkgpart'=>$1}))
- unless $part_pkg;
+ qsearch( 'part_pkg_taxoverride', {'pkgpart' => $1} )
+ );
+# join (",", map {$_->taxclassnum}
+# $part_pkg->part_pkg_taxrate( 'cch', $conf->config('defaultloc')
+# );
+# unless $tax_override;
+ }
$part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1});
$pkgpart = $part_pkg->pkgpart;
} else {
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index a671ca118..d29ffcfe5 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -145,7 +145,11 @@ if ( $pkeyvalue ) {
});
}
-my %hash = map { $_ => scalar($cgi->param($_)) } @$fields;
+my %hash =
+ map { my @entry = ( $_ => $cgi->param($_) );
+ $opt{'value_callback'} ? ( $_ => &{ $opt{'value_callback'} }( @entry ))
+ : ( @entry )
+ } @$fields;
my $new = $class->new( \%hash );
diff --git a/httemplate/edit/process/tax_rate.html b/httemplate/edit/process/tax_rate.html
index 933bf07d6..431e54264 100644
--- a/httemplate/edit/process/tax_rate.html
+++ b/httemplate/edit/process/tax_rate.html
@@ -1,9 +1,18 @@
<% include( 'elements/process.html',
'table' => 'tax_rate',
+ 'value_callback' => $value_callback,
'popup_reload' => 'Tax changed', #a popup "parent reload" for now
#someday change the individual element and go away instead
)
%>
+<%once>
+
+my $value_callback = sub { my ($field, $value) = @_;
+ ($field =~ /^(tax|excessrate|usetax|useexcessrate)$/)
+ ? $value/100
+ : $value
+ };
+</%once>
<%init>
my $conf = new FS::Conf;
diff --git a/httemplate/edit/tax_rate.html b/httemplate/edit/tax_rate.html
index e1d8d4f93..c48bdd1df 100644
--- a/httemplate/edit/tax_rate.html
+++ b/httemplate/edit/tax_rate.html
@@ -1,14 +1,21 @@
<% include('elements/edit.html',
- 'popup' => 1,
- 'name' => 'Tax rate', #Edit tax rate
- 'table' => 'tax_rate',
- 'labels' => $labels,
- 'fields' => \@fields,
+ 'popup' => 1,
+ 'name' => 'Tax rate', #Edit tax rate
+ 'table' => 'tax_rate',
+ 'labels' => $labels,
+ 'fields' => \@fields,
+ 'value_callback' => $value_callback,
)
%>
<%once>
my $conf = new FS::Conf;
+my $value_callback =
+ sub { my ( $field, $value ) = @_;
+ ( $field =~ /^(tax|excessrate|usetax|useexcessrate)$/ )
+ ? $value*100
+ : $value;
+ };
</%once>
@@ -90,16 +97,9 @@ my @fields = (
{ field=>'passtype', type=>'hidden' } ,
{ field=>'passtype_name', type=>'fixed' } ,
{ field=>'passflag', type=>'fixed' } ,
- { field=>'setuptax', type=>'checkbox' } ,
- { field=>'recurtax', type=>'checkbox' } ,
+ { field=>'setuptax', type=>'checkbox', value=>'Y' } ,
+ { field=>'recurtax', type=>'checkbox', value=>'Y' } ,
{ field=>'manual', type=>'hidden', value=>'Y' } ,
);
-#push @fields,
-# { type=>'tablebreak-tr-title', value=>'Exemptions' },
-# { field=>'setuptax', type=>'checkbox', value=>'Y', },
-# { field=>'recurtax', type=>'checkbox', value=>'Y', },
-# { field=>'exempt_amount', type=>'money', },
-#;
-
</%init>