Revision ba003bf8
Von Kivitendo Admin vor fast 10 Jahren hinzugefügt
bin/mozilla/vk.pl | ||
---|---|---|
315 | 315 |
# sellprice_total_including_tax = qty * fxsellprice * (1-discount) / price_factor * exchangerate |
316 | 316 |
# $ar->{sellprice_total_including_tax} = $form->round_amount( $ar->{qty} * ( $ar->{fxsellprice} * ( 1 - $ar->{discount} ) ) / $ar->{price_factor}, $form->{"decimalplaces"}); |
317 | 317 |
|
318 |
my $sellprice_orig = $ar->{sellprice}; |
|
319 |
my $qty_orig = $ar->{qty}; |
|
320 |
# adjust sellprice so it reflects the unit sellprice according to price_factor and basefactor |
|
318 | 321 |
$ar->{sellprice} = $ar->{sellprice} / $ar->{price_factor} / $basefactor; |
319 |
$ar->{sellprice_total} = $form->round_amount( $ar->{qty} * $ar->{sellprice} / $ar->{price_factor} , $form->{"decimalplaces"}); |
|
322 |
# for sellprice_total use the original amounts |
|
323 |
$ar->{sellprice_total} = $form->round_amount( $qty_orig * $sellprice_orig / $ar->{price_factor}, $form->{"decimalplaces"}); |
|
320 | 324 |
|
325 |
my $lastcost_orig = $ar->{lastcost}; |
|
321 | 326 |
$ar->{lastcost} = $ar->{lastcost} / $ar->{price_factor} / $basefactor; |
322 |
$ar->{lastcost_total} = $form->round_amount( $ar->{qty} * $ar->{lastcost} / $ar->{price_factor}, $form->{"decimalplaces"});
|
|
327 |
$ar->{lastcost_total} = $form->round_amount( $qty_orig * $lastcost_orig / $ar->{price_factor}, $form->{"decimalplaces"});
|
|
323 | 328 |
|
324 | 329 |
# marge_percent is recalculated, because the value in invoice used to be empty |
325 | 330 |
$ar->{marge_percent} = $ar->{sellprice_total} ? (($ar->{sellprice_total}-$ar->{lastcost_total}) / $ar->{sellprice_total} * 100) : 0; |
... | ... | |
327 | 332 |
$ar->{marge_total} = $ar->{sellprice_total} ? $ar->{sellprice_total}-$ar->{lastcost_total} : 0; |
328 | 333 |
$ar->{discount} *= 100; # format discount value for output, 10% is stored as 0.1 in db |
329 | 334 |
|
330 |
# adapt qty to the chosen unit
|
|
335 |
# adjust qty to reflect the qty of the base unit
|
|
331 | 336 |
$ar->{qty} *= $basefactor; |
332 | 337 |
|
338 |
# now $ar->{sellprice} * $ar->{qty} should be the same as $qty_orig * $ar->{qty} |
|
339 |
|
|
333 | 340 |
# weight is the still the weight per part, but here we want the total weight |
334 | 341 |
$ar->{weight} *= $ar->{qty}; |
335 | 342 |
|
Auch abrufbar als: Unified diff
Patch für Bug 40, base_unit Umrechnung in VK-Bericht
Patch getestet in Datenbank mit unterschiedlichen Einheiten und
Preisfaktoren.
Möglichkeit zum Testen:
Summe VK-Betrag des Verkaufsberichts sollte gleich sein der Summe Betrag
von Verkauf->Berichte->Rechnungen, wenn man die Debitorenbuchungen
rausfiltert.
z.B. in SL/AR.pm ar_transactions:
my $where = "1 = 1 and a.invoice is true ";
oder dem Benutzer das Recht entziehen, Debitorenbuchungen im
Rechnungsbericht anzuzeigen.