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, t.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 do_statement($form, $sth, $self->{queries}->{get_tax_info}, $params{taxkey}, $params{transdate});
83 my $ref = $sth->fetchrow_hashref() || { };
85 $main::lxdebug->leave_sub();
90 sub get_full_tax_info {
91 $main::lxdebug->enter_sub();
96 Common::check_params(\%params, qw(transdate));
98 my $myconfig = \%main::myconfig;
99 my $form = $main::form;
103 'taxchart_ids' => { },
106 my @all_taxkeys = map { $_->{taxkey} } (selectall_hashref_query($form, $form->get_standard_dbh(), qq|SELECT DISTINCT taxkey FROM tax WHERE taxkey IS NOT NULL|));
108 foreach my $taxkey (@all_taxkeys) {
109 my $ref = $self->get_tax_info('transdate' => $params{transdate}, 'taxkey' => $taxkey);
111 $tax_info{taxkeys}->{$taxkey} = $ref;
112 $tax_info{accnos}->{$ref->{taxchart_id}} = $ref if ($ref->{taxchart_id});
115 $main::lxdebug->leave_sub();