summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/part_pkg.cgi
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-10-31 15:45:50 -0700
committerMark Wells <mark@freeside.biz>2014-10-31 15:45:50 -0700
commit7516e3da0f17eeecba27219ef96a8b5f46af2083 (patch)
tree772fe13627910a7d0774871633697f2a4d1c6faf /httemplate/edit/process/part_pkg.cgi
parentf31a9212ab3835b815aa87a86cca3b19babcaaff (diff)
tax engine refactoring for Avalara and Billsoft tax vendors, #25718
Diffstat (limited to 'httemplate/edit/process/part_pkg.cgi')
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi28
1 files changed, 24 insertions, 4 deletions
diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi
index d27ddb0b0..0343cc0fb 100755
--- a/httemplate/edit/process/part_pkg.cgi
+++ b/httemplate/edit/process/part_pkg.cgi
@@ -96,11 +96,31 @@ my $args_callback = sub {
grep { $_ !~ /^report_option_/ }
@options;
- foreach ( split(',', $cgi->param('taxproductnums') ) ) {
- my $value = $cgi->param("taxproductnum_$_");
- $error ||= "Illegal taxproductnum_$_: $value"
+ foreach my $class ( '', split(',', $cgi->param('taxproductnums') ) ) {
+ my $param = 'taxproductnum';
+ $param .= "_$class" if length($class); # gah, "_$class"?
+ my $value = $cgi->param($param);
+
+ if ( $value == -1 ) {
+ my $desc = $cgi->param($param.'_description');
+ # insert a new part_pkg_taxproduct
+ my $engine = FS::TaxEngine->new;
+ my $obj_or_error = $engine->add_taxproduct($desc);
+ if (ref $obj_or_error) {
+ $value = $obj_or_error->taxproductnum;
+ $cgi->param($param, $value); # for error handling
+ } else {
+ die "$obj_or_error (adding tax product)";
+ }
+ }
+
+ $error ||= "Illegal $param: $value"
unless ( $value =~ /^\d*$/ );
- $options{"usage_taxproductnum_$_"} = $value;
+ if (length($class)) {
+ $options{"usage_taxproductnum_$_"} = $value;
+ } else {
+ $new->set('taxproductnum', $value);
+ }
}
foreach ( grep $_, $cgi->param('report_option') ) {