+
+sub add_tax {
+ $lxdebug->enter_sub();
+
+ $form->{title} = $locale->text('Add');
+
+ $form->{callback} =
+ "$form->{script}?action=add_tax&login=$form->{login}&password=$form->{password}"
+ unless $form->{callback};
+
+ _get_taxaccount_selection();
+
+ $form->header();
+
+ my $parameters_ref = {
+# ChartTypeIsAccount => $ChartTypeIsAccount,
+ };
+
+ # Ausgabe des Templates
+ print($form->parse_html_template2('am/edit_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub edit_tax {
+ $lxdebug->enter_sub();
+
+ $form->{title} = $locale->text('Edit');
+
+ AM->get_tax(\%myconfig, \%$form);
+ _get_taxaccount_selection();
+
+ $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
+
+ $form->header();
+
+ my $parameters_ref = {
+ };
+
+ # Ausgabe des Templates
+ print($form->parse_html_template2('am/edit_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub list_tax {
+ $lxdebug->enter_sub();
+
+ AM->taxes(\%myconfig, \%$form);
+
+ map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
+
+ $form->{callback} = build_std_url('action=list_tax');
+
+ $form->{title} = $locale->text('Tax-O-Matic');
+
+ $form->header();
+
+ # Ausgabe des Templates
+ print($form->parse_html_template2('am/list_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub _get_taxaccount_selection{
+ $lxdebug->enter_sub();
+
+ AM->get_tax_accounts(\%myconfig, \%$form);
+
+ map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
+
+ $lxdebug->leave_sub();
+}
+
+sub save_tax {
+ $lxdebug->enter_sub();
+
+ $form->isblank("rate", $locale->text('Taxrate missing!'));
+ $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
+ $form->isblank("taxkey", $locale->text('Taxkey missing!'));
+
+ $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
+
+ if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
+ $form->error($locale->text('Tax Percent is a number between 0 and 100'));
+ }
+
+ if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
+ $form->error($locale->text('Tax Percent is a number between 0 and 100'));
+ }
+
+ AM->save_tax(\%myconfig, \%$form);
+ $form->redirect($locale->text('Tax saved!'));
+
+ $lxdebug->leave_sub();
+}
+
+sub delete_tax {
+ $lxdebug->enter_sub();
+
+ AM->delete_tax(\%myconfig, \%$form);
+ $form->redirect($locale->text('Tax deleted!'));
+
+ $lxdebug->leave_sub();
+}