Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9d2d867c

Von Niclas Zimmermann vor mehr als 11 Jahren hinzugefügt

  • ID 9d2d867c1a5569ea0ddee859f77f9edead770720
  • Vorgänger 6ac47be4
  • Nachfolger 36d5081f

tax_id auslesen

Statt die tax_id aus einem Join auf die Tabelle taxkeys zu bekommen,
wird nun direkt von der acc_trans auf die Steuer zugegriffen. Dies
geschieht an verschiedenen Stellen:

Die tax_id wird jetzt in Kreditoren-/Debitoren- und Dialogbuchungen
aus der acc_trans gelesen statt aus der Tabelle taxkeys.

Im DATEV-Export wird jetzt die id über den Eintrag in der acc_trans
ermittelt anstatt über die Tabelle taxkeys.

Unterschiede anzeigen:

SL/DATEV.pm
31 31

  
32 32
use SL::DBUtils;
33 33
use SL::DATEV::KNEFile;
34
use SL::Taxkeys;
35 34

  
36 35
use Data::Dumper;
37 36
use DateTime;
......
360 359

  
361 360
  $fromto      =~ s/transdate/ac\.transdate/g;
362 361

  
363
  my $taxkeys  = Taxkeys->new();
364 362
  my $filter   = '';            # Useful for debugging purposes
365 363

  
366 364
  my %all_taxchart_ids = selectall_as_map($form, $self->dbh, qq|SELECT DISTINCT chart_id, TRUE AS is_set FROM tax|, 'chart_id', 'is_set');
......
370 368
         ar.invnumber, ar.duedate, ar.amount as umsatz, ar.deliverydate,
371 369
         ct.name,
372 370
         c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
373
         ar.invoice
371
         ar.invoice,
372
         t.rate AS taxrate
374 373
       FROM acc_trans ac
375 374
       LEFT JOIN ar          ON (ac.trans_id    = ar.id)
376 375
       LEFT JOIN customer ct ON (ar.customer_id = ct.id)
377 376
       LEFT JOIN chart c     ON (ac.chart_id    = c.id)
377
       LEFT JOIN tax t       ON (ac.tax_id      = t.id)
378 378
       WHERE (ar.id IS NOT NULL)
379 379
         AND $fromto
380 380
         $trans_id_filter
......
386 386
         ap.invnumber, ap.duedate, ap.amount as umsatz, ap.deliverydate,
387 387
         ct.name,
388 388
         c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
389
         ap.invoice
389
         ap.invoice,
390
         t.rate AS taxrate
390 391
       FROM acc_trans ac
391 392
       LEFT JOIN ap        ON (ac.trans_id  = ap.id)
392 393
       LEFT JOIN vendor ct ON (ap.vendor_id = ct.id)
393 394
       LEFT JOIN chart c   ON (ac.chart_id  = c.id)
395
       LEFT JOIN tax t     ON (ac.tax_id    = t.id)
394 396
       WHERE (ap.id IS NOT NULL)
395 397
         AND $fromto
396 398
         $trans_id_filter
......
402 404
         gl.reference AS invnumber, gl.transdate AS duedate, ac.amount as umsatz, NULL as deliverydate,
403 405
         gl.description AS name,
404 406
         c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link,
405
         FALSE AS invoice
407
         FALSE AS invoice,
408
         t.rate AS taxrate
406 409
       FROM acc_trans ac
407 410
       LEFT JOIN gl      ON (ac.trans_id  = gl.id)
408 411
       LEFT JOIN chart c ON (ac.chart_id  = c.id)
412
       LEFT JOIN tax t   ON (ac.tax_id    = t.id)
409 413
       WHERE (gl.id IS NOT NULL)
410 414
         AND $fromto
411 415
         $trans_id_filter
......
475 479
      }
476 480
    }
477 481

  
478
    my %taxid_taxkeys = ();
479 482
    my $absumsatz     = 0;
480 483
    if (scalar(@{$trans}) <= 2) {
481 484
      push @{ $self->{DATEV} }, $trans;
......
545 548
        push @{ $self->{DATEV} }, [ \%new_trans, $trans->[$j] ];
546 549

  
547 550
      } elsif (($j != $notsplitindex) && !$trans->[$j]->{is_tax}) {
548
        my %tax_info = $taxkeys->get_full_tax_info('transdate' => $trans->[$j]->{transdate},
549
                                                   'deliverydate' => $trans->[$j]->{deliverydate});
550 551

  
551 552
        my %new_trans = ();
552 553
        map { $new_trans{$_} = $trans->[$notsplitindex]->{$_}; } keys %{ $trans->[$notsplitindex] };
553 554

  
554
        my $tax_rate              = $tax_info{taxkeys}->{ $trans->[$j]->{'taxkey'} }->{taxrate};
555
        my $tax_rate              = $trans->[$j]->{'taxrate'};
555 556
        $new_trans{'net_amount'}  = $trans->[$j]->{'amount'} * -1;
556 557
        $new_trans{'tax_rate'}    = 1 + $tax_rate;
557 558

  
SL/Form.pm
2762 2762
         FROM acc_trans a
2763 2763
         LEFT JOIN chart c ON (c.id = a.chart_id)
2764 2764
         LEFT JOIN project p ON (p.id = a.project_id)
2765
         LEFT JOIN tax t ON (t.id= (SELECT tk.tax_id FROM taxkeys tk
2766
                                    WHERE (tk.taxkey_id=a.taxkey) AND
2767
                                      ((CASE WHEN a.chart_id IN (SELECT chart_id FROM taxkeys WHERE taxkey_id = a.taxkey)
2768
                                        THEN tk.chart_id = a.chart_id
2769
                                        ELSE 1 = 1
2770
                                        END)
2771
                                       OR (c.link='%tax%')) AND
2772
                                      (startdate <= a.transdate) ORDER BY startdate DESC LIMIT 1))
2765
         LEFT JOIN tax t ON (t.id= a.tax_id)
2773 2766
         WHERE a.trans_id = ?
2774 2767
         AND a.fx_transaction = '0'
2775 2768
         ORDER BY a.acc_trans_id, a.transdate|;
SL/GL.pm
670 670
         FROM acc_trans a
671 671
         JOIN chart c ON (c.id = a.chart_id)
672 672
         LEFT JOIN project p ON (p.id = a.project_id)
673
         LEFT JOIN tax t ON
674
           (t.id =
675
             (SELECT tk.tax_id
676
              FROM taxkeys tk
677
              WHERE (tk.taxkey_id = a.taxkey) AND
678
                ((CASE WHEN a.chart_id IN
679
                    (SELECT chart_id FROM taxkeys WHERE taxkey_id = a.taxkey)
680
                  THEN tk.chart_id = a.chart_id
681
                  ELSE 1 = 1
682
                  END)
683
                 OR (c.link LIKE '%tax%'))
684
                AND (startdate <= a.transdate)
685
              ORDER BY startdate DESC LIMIT 1))
673
         LEFT JOIN tax t ON (t.id = a.tax_id)
686 674
         WHERE (a.trans_id = ?)
687 675
           AND (a.fx_transaction = '0')
688 676
         ORDER BY a.acc_trans_id, a.transdate|;

Auch abrufbar als: Unified diff