+ # taxnumber is used for grouping the amount of the various taxes
+
+ # this code assumes that at most one tax entry can point to the same
+ # chart_id, even though chart_id does not have a unique constraint!
+
+ # this chart_id is then looked up via its accno, which is the key that is
+ # used to group the different taxes by for a record
+
+ # not every tax has a taxnumber (e.g. tax-free), but that is ok, because
+ # then there would be no tax amount to assign it to
+
+ my $tax_objs = SL::DB::Manager::Tax->get_objects_from_sql(
+ sql => 'SELECT * FROM tax WHERE chart_id = (SELECT id FROM chart WHERE accno = ?)',
+ args => [ $form->{"${item}_taxnumber"} ]
+ );
+ my $tax_obj;
+ if ( $tax_objs ) {
+ $tax_obj = $tax_objs->[0];
+ }