1 # @tag: remove_double_tax_entries_skr04
 
   2 # @description: doppelte Steuer-Einträge und alte 16% Konten für SKR04 entfernen, wenn unbebucht
 
   3 # @depends: release_3_5_5
 
   4 package SL::DBUpgrade2::remove_double_tax_entries_skr04;
 
   9 use parent qw(SL::DBUpgrade2::Base);
 
  16   if (!$self->check_coa('Germany-DATEV-SKR04EU')) {
 
  21     SELECT id FROM tax WHERE chart_id = (SELECT id FROM chart WHERE accno LIKE ?) AND taxkey = ? AND rate = ? ORDER BY id;
 
  25     DELETE FROM taxkeys WHERE tax_id = ?;
 
  29     DELETE FROM tax WHERE id = ?;
 
  33     {accno => '3806', taxkey => 3, rate => 0.19},
 
  34     {accno => '1406', taxkey => 9, rate => 0.19},
 
  35     {accno => '3805', taxkey => 5, rate => 0.16},
 
  36     {accno => '1405', taxkey => 7, rate => 0.16},
 
  40   foreach my $tax_to_test (@taxes_to_test) {
 
  41     my @entries = selectall_hashref_query($::form, $self->dbh, $query, ($tax_to_test->{accno}, $tax_to_test->{taxkey}, $tax_to_test->{rate}));
 
  43     if (scalar @entries > 1) {
 
  44       foreach my $tax (@entries) {
 
  45         my ($num_acc_trans_entries) = $self->dbh->selectrow_array("SELECT COUNT(*) FROM acc_trans WHERE tax_id = ?", undef, $tax->{id});
 
  46         next if $num_acc_trans_entries > 0;
 
  48         $self->db_query($query2, bind => [ $tax->{id} ]);
 
  49         $self->db_query($query3, bind => [ $tax->{id} ]);
 
  51         last; # delete only one tax