16 return $self->_init();
22 $self->_finish_statements();
28 $self->{handles} = { };
29 $self->{queries} = { };
31 memoize 'get_tax_info';
32 memoize 'get_full_tax_info';
37 sub _finish_statements {
38 $main::lxdebug->enter_sub();
42 foreach my $idx (keys %{ $self->{handles} }) {
43 $self->{handles}->{$idx}->finish();
44 delete $self->{handles}->{$idx};
47 $main::lxdebug->leave_sub();
51 $main::lxdebug->enter_sub();
56 Common::check_params(\%params, qw(transdate taxkey));
58 my $myconfig = \%main::myconfig;
59 my $form = $main::form;
61 if (!$self->{handles}->{get_tax_info}) {
62 $self->{queries}->{get_tax_info} = qq|
63 SELECT t.rate AS taxrate, c.accno as taxnumber, t.taxdescription, t.chart_id AS taxchart_id,
64 c.accno AS taxaccno, c.description AS taxaccount
66 LEFT JOIN tax t ON (tk.tax_id = t.id)
67 LEFT JOIN chart c ON (t.chart_id = c.id)
73 ORDER BY startdate DESC
77 $self->{handles}->{get_tax_info} = prepare_query($form, $params{dbh} || $form->get_standard_dbh($myconfig), $self->{queries}->{get_tax_info});
80 my $sth = $self->{handles}->{get_tax_info};
81 # Lieferdatum (deliverydate) ist entscheidend für den Steuersatz
82 do_statement($form, $sth, $self->{queries}->{get_tax_info}, $params{taxkey}, $params{deliverydate} || $params{transdate});
84 my $ref = $sth->fetchrow_hashref() || { };
86 $main::lxdebug->leave_sub();
91 sub get_full_tax_info {
92 $main::lxdebug->enter_sub();
97 Common::check_params(\%params, qw(transdate));
99 my $myconfig = \%main::myconfig;
100 my $form = $main::form;
104 'taxchart_ids' => { },
107 my @all_taxkeys = map { $_->{taxkey} } (selectall_hashref_query($form, $form->get_standard_dbh(), qq|SELECT DISTINCT taxkey FROM tax WHERE taxkey IS NOT NULL|));
109 foreach my $taxkey (@all_taxkeys) {
110 my $ref = $self->get_tax_info('transdate' => $params{transdate}, 'taxkey' => $taxkey, 'deliverydate' => $params{deliverydate});
112 $tax_info{taxkeys}->{$taxkey} = $ref;
113 $tax_info{accnos}->{$ref->{taxchart_id}} = $ref if ($ref->{taxchart_id});
116 $main::lxdebug->leave_sub();