Revision 525a020a
Von G. Richardson vor etwa 12 Jahren hinzugefügt
SL/DATEV.pm | ||
---|---|---|
410 | 410 |
|
411 | 411 |
my $count = $ref->{amount}; |
412 | 412 |
my $firstrun = 1; |
413 |
|
|
414 |
# if the amount of a booking in a group is smaller than 0.02, any tax |
|
415 |
# amounts will likely be smaller than 1 cent, so go into subcent mode |
|
413 | 416 |
my $subcent = abs($count) < 0.02; |
414 | 417 |
|
418 |
# records from acc_trans are ordered by trans_id and acc_trans_id |
|
419 |
# first check for unbalanced ledger inside one trans_id |
|
420 |
# there may be several groups inside a trans_id, e.g. the original booking and the payment |
|
421 |
# each group individually should be exactly balanced and each group |
|
422 |
# individually needs its own datev lines |
|
423 |
|
|
424 |
# keep fetching new acc_trans lines until the end of a balanced group is reached |
|
415 | 425 |
while (abs($count) > 0.01 || $firstrun || ($subcent && abs($count) > 0.005)) { |
416 | 426 |
my $ref2 = $sth->fetchrow_hashref("NAME_lc"); |
417 | 427 |
last unless ($ref2); |
418 | 428 |
|
429 |
# check if trans_id of current acc_trans line is still the same as the |
|
430 |
# trans_id of the first line in group |
|
431 |
|
|
419 | 432 |
if ($ref2->{trans_id} != $trans->[0]->{trans_id}) { |
420 | 433 |
$self->add_error("Unbalanced ledger! old trans_id " . $trans->[0]->{trans_id} . " new trans_id " . $ref2->{trans_id} . " count $count"); |
421 | 434 |
return; |
... | ... | |
452 | 465 |
next; |
453 | 466 |
} |
454 | 467 |
|
468 |
# determine at which array position the reference value (called absumsatz) is |
|
469 |
# and which amount it has |
|
470 |
|
|
455 | 471 |
for my $j (0 .. (scalar(@{$trans}) - 1)) { |
472 |
|
|
473 |
# Three cases: |
|
474 |
# 1: gl transaction (Dialogbuchung), invoice is false, no double split booking allowed |
|
475 |
|
|
476 |
# 2: sales or vendor invoice (Verkaufs- und Einkaufsrechnung): invoice is |
|
477 |
# true, instead of absumsatz use link AR/AP (there should only be one |
|
478 |
# entry) |
|
479 |
|
|
480 |
# 3. AR/AP transaction (Kreditoren- und Debitorenbuchung): invoice is false, |
|
481 |
# instead of absumsatz use link AR/AP (there should only be one, so jump |
|
482 |
# out of search as soon as you find it ) |
|
483 |
|
|
484 |
# case 1 and 2 |
|
456 | 485 |
# for gl-bookings no split is allowed and there is no AR/AP account, so we always use the maximum value as a reference |
457 | 486 |
# for ap/ar bookings we can always search for AR/AP in link and use that |
458 | 487 |
if ( ( not $trans->[$j]->{'invoice'} and abs($trans->[$j]->{'amount'}) > abs($absumsatz) ) |
... | ... | |
460 | 489 |
$absumsatz = $trans->[$j]->{'amount'}; |
461 | 490 |
$notsplitindex = $j; |
462 | 491 |
} |
492 |
|
|
493 |
# case 3 |
|
494 |
# Problem: we can't distinguish between AR and AP and normal invoices via boolean "invoice" |
|
495 |
# for AR and AP transaction exit the loop as soon as an AR or AP account is found |
|
496 |
# there must be only one AR or AP chart in the booking |
|
497 |
if ( $trans->[$j]->{'link'} eq 'AR' or $trans->[$j]->{'link'} eq 'AP') { |
|
498 |
$notsplitindex = $j; # position in booking with highest amount |
|
499 |
$absumsatz = $trans->[$j]->{'amount'}; |
|
500 |
last; |
|
501 |
}; |
|
463 | 502 |
} |
464 | 503 |
|
465 | 504 |
my $ml = ($trans->[0]->{'umsatz'} > 0) ? 1 : -1; |
466 | 505 |
my $rounding_error = 0; |
467 | 506 |
my @taxed; |
468 | 507 |
|
508 |
# go through each line and determine if it is a tax booking or not |
|
509 |
# skip all tax lines and notsplitindex line |
|
510 |
# push all other accounts (e.g. income or expense) with corresponding taxkey |
|
511 |
|
|
469 | 512 |
for my $j (0 .. (scalar(@{$trans}) - 1)) { |
470 | 513 |
if ( ($j != $notsplitindex) |
471 | 514 |
&& !$trans->[$j]->{is_tax} |
Auch abrufbar als: Unified diff
Doppelte Splitbuchung bei Debitoren- und Kreditorenbuchungen
Erweiterung zu Bug 1676 - dieser hat Problem bei gemischter Rechnung und
Gutschrift behoben. Es kann aber durch Eingeben von Minusbeträgen auch
bei Debitoren- und Kreditorenbuchungen zu doppelten Splitbuchungen
kommen, das wird mit
Außerdem ein paar Kommentare zum DATEV-Modul hinzugefügt