Revision cc471249
Von G. Richardson vor mehr als 13 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
158 | 158 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2); |
159 | 159 |
|
160 | 160 |
if ($form->{taxincluded}) { |
161 |
|
|
161 | 162 |
$taxamount = $linetotal * ($taxrate / (1 + $taxrate)); |
162 | 163 |
$form->{"sellprice_$i"} = $form->{"sellprice_$i"} * (1 / (1 + $taxrate)); |
164 |
|
|
163 | 165 |
} else { |
164 | 166 |
$taxamount = $linetotal * $taxrate; |
165 | 167 |
} |
... | ... | |
380 | 382 |
$invoicediff += $paiddiff; |
381 | 383 |
$expensediff += $paiddiff; |
382 | 384 |
|
383 |
######## this only applies to tax included |
|
385 |
######## this only applies to tax included |
|
386 |
|
|
387 |
# in the sales invoice case rounding errors only have to be corrected for |
|
388 |
# income accounts, it is enough to add the total rounding error to one of |
|
389 |
# the income accounts, with the one assigned to the last row being used |
|
390 |
# (lastinventoryaccno) |
|
391 |
|
|
392 |
# in the purchase invoice case rounding errors may be split between |
|
393 |
# inventory accounts and expense accounts. After rounding, an error of 1 |
|
394 |
# cent is introduced if the total rounding error exceeds 0.005. The total |
|
395 |
# error is made up of $invoicediff and $expensediff, however, so if both |
|
396 |
# values are below 0.005, but add up to a total >= 0.005, correcting |
|
397 |
# lastinventoryaccno and lastexpenseaccno separately has no effect after |
|
398 |
# rounding. This caused bug 1579. Therefore when the combined total exceeds |
|
399 |
# 0.005, but neither do individually, the account with the larger value |
|
400 |
# shall receive the total rounding error, and the next time it is rounded |
|
401 |
# the 1 cent correction will be introduced. |
|
402 |
|
|
403 |
my $total_rounding_diff = $invoicediff+$expensediff; |
|
384 | 404 |
|
385 | 405 |
$form->{amount}{ $form->{id} }{$lastinventoryaccno} -= $invoicediff if $lastinventoryaccno; |
386 | 406 |
$form->{amount}{ $form->{id} }{$lastexpenseaccno} -= $expensediff if $lastexpenseaccno; |
387 | 407 |
|
408 |
if ( ($expensediff+$invoicediff) >= 0.005 and $expensediff < 0.005 and $invoicediff < 0.005 ) { |
|
409 |
|
|
410 |
# in total the rounding error adds up to 1 cent effectively, correct the |
|
411 |
# larger of the two numbers |
|
412 |
|
|
413 |
if ( abs($form->{amount}{ $form->{id} }{$lastinventoryaccno}) > abs($form->{amount}{ $form->{id} }{$lastexpenseaccno}) ) { |
|
414 |
# $invoicediff has already been deducted, now also deduct expensediff |
|
415 |
$form->{amount}{ $form->{id} }{$lastinventoryaccno} -= $expensediff; |
|
416 |
} else { |
|
417 |
# expensediff has already been deducted, now also deduct invoicediff |
|
418 |
$form->{amount}{ $form->{id} }{$lastexpenseaccno} -= $invoicediff; |
|
419 |
}; |
|
420 |
}; |
|
421 |
|
|
388 | 422 |
} else { |
389 | 423 |
$amount = $form->round_amount($netamount * $form->{exchangerate}, 2); |
390 | 424 |
$paiddiff = $amount - $netamount * $form->{exchangerate}; |
... | ... | |
405 | 439 |
|
406 | 440 |
$form->{paid} = $form->round_amount($form->{paid} * $form->{exchangerate} + $paiddiff, 2) if $form->{paid} != 0; |
407 | 441 |
|
408 |
# update exchangerate
|
|
442 |
# update exchangerate |
|
409 | 443 |
|
410 | 444 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0, $form->{exchangerate}) |
411 | 445 |
if ($form->{currency} ne $defaultcurrency) && !$exchangerate; |
412 | 446 |
|
413 |
# record acc_trans transactions
|
|
447 |
# record acc_trans transactions |
|
414 | 448 |
foreach my $trans_id (keys %{ $form->{amount} }) { |
415 | 449 |
foreach my $accno (keys %{ $form->{amount}{$trans_id} }) { |
416 | 450 |
$form->{amount}{$trans_id}{$accno} = $form->round_amount($form->{amount}{$trans_id}{$accno}, 2); |
417 | 451 |
|
452 |
|
|
418 | 453 |
next if $payments_only || !$form->{amount}{$trans_id}{$accno}; |
419 | 454 |
|
420 | 455 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id) |
421 | 456 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
422 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
|
|
457 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
|
423 | 458 |
@values = ($trans_id, $accno, $form->{amount}{$trans_id}{$accno}, |
424 | 459 |
conv_date($form->{invdate}), $accno, $project_id); |
425 | 460 |
do_query($form, $dbh, $query, @values); |
Auch abrufbar als: Unified diff
Bug 1579: Einkaufsrechnung mit bestimmten Werten und 'Steuer im Preis inbegriffen'
Im Gegensatz zur Verkaufsrechnung, wo Rundungsfehler bei der Berechnung von
Netto aus Brutto nur in Erlöskonten mitverfolgt werden, können sich
Rundungsfehler bei Einkaufsrechnungen jeweils in Aufwands- und Bestandskonten
aufsummieren, und werden auch getrennt erfasst. Ist der Rundungsfehler
insgesamt > 0.005, aber bei Aufwand und Bestand jeweils kleiner 0.005, gab es
hierfür bisher keine Korrektur und es gab einen Bilanzfehler von einem Cent im
Buchungsjournal. Diese Prüfung auf Gesamtrundungsfehler wurde hier eingeführt.