+ $hash->{'taxable'} = '' if ($hash->{'taxable'} eq 'N');
+
+ if (exists($hash->{actionflag}) && $hash->{actionflag} eq 'D') {
+ delete($hash->{actionflag});
+
+ foreach my $intfield (qw( taxproductnum taxclassnum effdate )) {
+ if ( $hash->{$intfield} eq '' ) {
+ return "$intfield is empty in search! -- ".
+ join(" ", map { "$_ => *". $hash->{$_}. '*' } keys(%$hash) );
+ }
+ }
+
+ my @part_pkg_taxrate = qsearch('part_pkg_taxrate', $hash);
+ unless ( scalar(@part_pkg_taxrate) || $param->{'delete_only'} ) {
+ if ( $hash->{taxproductnum} ) {
+ my $taxproduct =
+ qsearchs( 'part_pkg_taxproduct',
+ { 'taxproductnum' => $hash->{taxproductnum} }
+ );
+ $hash->{taxproductnum} .= ' ( '. $taxproduct->taxproduct. ' )'
+ if $taxproduct;
+ }
+ warn "WARNING: Can't find part_pkg_taxrate to delete: ".
+ join(" ", map { "$_ => *". $hash->{$_}. '*' } keys(%$hash) );
+ }
+
+ foreach my $part_pkg_taxrate (@part_pkg_taxrate) {
+ my $error = $part_pkg_taxrate->delete;
+ return $error if $error;
+ }
+
+ delete($hash->{$_}) foreach (keys %$hash);
+ }
+
+ delete($hash->{actionflag});