summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorjeff <jeff>2008-04-06 16:12:46 +0000
committerjeff <jeff>2008-04-06 16:12:46 +0000
commit6626dc2a13c809092aa539c5a72bc72a0c56afdc (patch)
treee92d2d1ea157b941f090a6f27cfbeb2db8dd12a3 /httemplate/edit
parentebfc3f058e29e09631112ee355a2c57dce56914f (diff)
new tax rating engine
Diffstat (limited to 'httemplate/edit')
-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
5 files changed, 46 insertions, 20 deletions
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>