Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision da72a663

Von Philip Reetz vor fast 18 Jahren hinzugefügt

  • ID da72a663113b0f4d286622b23131748232e48b61
  • Vorgänger 12451e34
  • Nachfolger 0965925a

Fehler beim Export von Buchungen mit 16% behoben

Unterschiede anzeigen:

SL/DATEV.pm
224 224

  
225 225
  $fromto =~ s/transdate/ac\.transdate/g;
226 226

  
227
  $query = qq|SELECT taxkey, rate FROM tax|;
227
  $query = qq|SELECT id, taxkey, rate FROM tax|;
228 228
  $sth   = $dbh->prepare($query);
229 229
  $sth->execute || $form->dberror($query);
230 230

  
231 231
  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
232
    $taxes{ $ref->{taxkey} } = $ref->{rate};
232
    $taxes{ $ref->{id} } = $ref->{rate};
233 233
  }
234 234

  
235 235
  $sth->finish();
236 236

  
237 237
  $query =
238 238
    qq|SELECT ac.oid, ac.transdate, ac.trans_id,ar.id, ac.amount, ac.taxkey, ar.invnumber, ar.duedate, ar.amount as umsatz,
239
              ct.name, c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, t.chart_id, t.rate FROM acc_trans ac,ar ar, customer ct,
239
              ct.name, c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, t.chart_id, t.rate, t.id AS taxid, t.taxkey AS taxtaxkey FROM acc_trans ac,ar ar, customer ct,
240 240
              chart c LEFT JOIN tax t ON
241 241
                 (t.chart_id=c.id)WHERE $fromto AND ac.trans_id=ar.id AND ac.trans_id=ar.id
242 242
              AND ar.customer_id=ct.id AND ac.chart_id=c.id
243 243
              UNION ALL
244 244
              SELECT ac.oid, ac.transdate, ac.trans_id,ap.id, ac.amount, ac.taxkey, ap.invnumber, ap.duedate, ap.amount as umsatz,
245
              ct.name, c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, t.chart_id, t.rate FROM acc_trans ac, ap ap, vendor ct, chart c LEFT JOIN tax t ON
245
              ct.name, c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, t.chart_id, t.rate, t.id AS taxid, t.taxkey AS taxtaxkey FROM acc_trans ac, ap ap, vendor ct, chart c LEFT JOIN tax t ON
246 246
                 (t.chart_id=c.id)
247 247
              WHERE $fromto AND ac.trans_id=ap.id AND ap.vendor_id=ct.id AND ac.chart_id=c.id
248 248
              UNION ALL
249 249
              SELECT ac.oid, ac.transdate, ac.trans_id,gl.id, ac.amount, ac.taxkey, gl.reference AS invnumber, gl.transdate AS duedate, ac.amount as umsatz,
250
              gl.description AS name, c.accno,  c.taxkey_id as charttax, c.datevautomatik, c.id, t.chart_id, t.rate FROM acc_trans ac, gl gl,
250
              gl.description AS name, c.accno,  c.taxkey_id as charttax, c.datevautomatik, c.id, t.chart_id, t.rate, t.id AS taxid, t.taxkey AS taxtaxkey FROM acc_trans ac, gl gl,
251 251
              chart c LEFT JOIN tax t ON
252 252
                 (t.chart_id=c.id) WHERE $fromto AND ac.trans_id=gl.id AND ac.chart_id=c.id
253 253
              ORDER BY trans_id, oid|;
......
275 275
      push @{$i}, $ref2;
276 276
      $firstrun = 0;
277 277
    }
278
    my %taxid_taxkeys = ();
278 279
    $absumsatz = 0;
279 280
    if (scalar(@{$i}) > 2) {
280 281
      for my $j (0 .. (scalar(@{$i}) - 1)) {
......
282 283
          $absumsatz     = $i->[$j]->{'amount'};
283 284
          $notsplitindex = $j;
284 285
        }
286
        if (($i->[$j]->{'taxtaxkey'}) && ($i->[$j]->{'taxid'})) {
287
          $taxid_taxkeys{$i->[$j]->{'taxtaxkey'}}     = $i->[$j]->{'taxid'};
288
        }
285 289
      }
286 290
      $ml = ($i->[0]->{'umsatz'} > 0) ? 1 : -1;
287 291
      for my $j (0 .. (scalar(@{$i}) - 1)) {
......
306 310
          $g++;
307 311
          } elsif (($j != $notsplitindex) && ($i->[$j]->{'chart_id'} eq "")) {
308 312
          $absumsatz +=
309
            ($i->[$j]->{'amount'} * (1 + $taxes{ $i->[$j]->{'taxkey'} }));
313
            ($i->[$j]->{'amount'} * (1 + $taxes{ $taxid_taxkeys{$i->[$j]->{'taxkey'}} }));
310 314
          my %blubb = {};
311 315
          map({ $blubb{$_} = $i->[$notsplitindex]->{$_}; }
312 316
              keys(%{ $i->[$notsplitindex] }));
313
          $test = 1 + $taxes{ $i->[$j]->{'taxkey'} };
317
          $test = 1 + $taxes{  $taxid_taxkeys{$i->[$j]->{'taxkey'}} };
314 318
          $blubb{'amount'} =
315 319
            $form->round_amount(($i->[$j]->{'amount'} * $test * -1), 2);
316 320

  
......
329 333
        }
330 334
      }
331 335
      if (abs($absumsatz) > 0.01) {
332
        $form->error("Datev-Export fehlgeschlagen! Bei Transaktion $i->[0]->{trans_id}\n");
336
        $form->error("Datev-Export fehlgeschlagen! Bei Transaktion $i->[0]->{trans_id} $absumsatz\n");
333 337
      }
334 338
    } else {
335 339
      push @{ $form->{DATEV} }, \@{$i};

Auch abrufbar als: Unified diff