From 61ab3c630bf655d54cb44f70f871eed5879f9693 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 8 Oct 2009 00:20:45 +0200 Subject: [PATCH] =?utf8?q?Fix=20f=C3=BCr=20Bug=201081.=20Bei=20Buchung=20e?= =?utf8?q?iner=20Einkaufsrechnung=20geht=20das=20Rabatt=20verloren.=201.)?= =?utf8?q?=20Der=20Rabatt=20wurde=20nicht=20korrekt=20in=20die=20Tabelle?= =?utf8?q?=20invoice=20geschrieben,=20bzw.=20auch=20nicht=20wieder=20ausge?= =?utf8?q?lesen.=202.)=20Bei=20Buchung=20in=20die=20acc=5Ftrans=20wurde=20?= =?utf8?q?entsprechend=20auch=20nicht=20der=20Rabatt=20vorab=20berechnen.?= =?utf8?q?=203.)=20Prinzipiell=20w=C3=BCrde=20ich=20mir=20eine=20zentrale?= =?utf8?q?=20'Rabatt-Berechnungsfunktion'=20=C3=BCber=20alle=20Buchungsmas?= =?utf8?q?ken=20w=C3=BCnschen=20(s.a.=20Kommentar)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/IR.pm | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/SL/IR.pm b/SL/IR.pm index 2af4f9580..78970e3d2 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -131,7 +131,27 @@ sub post_invoice { map { $taxrate += $form->{"${_}_rate"} } @taxaccounts; $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1; - + ##################################################################### + # das ist aus IS.pm kopiert. schlimm. jb 7.10.2009 + # ich würde mir wünschen, dass diese vier stellen zusammengefasst werden + # ... vier stellen = (einkauf + verkauf) * (maske + backend) + # ansonsten stolpert man immer wieder viermal statt einmal heftig + # und auch das undo discount formatting ist nicht besonders wartungsfreundlich + + # keep entered selling price + my $fxsellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); + + # keine ahnung wofür das in IS.pm gemacht wird: + # my ($dec) = ($fxsellprice =~ /\.(\d+)/); + # $dec = length $dec; + # my $decimalplaces = ($dec > 2) ? $dec : 2; + + # undo discount formatting + $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100; + # deduct discount + $form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"}); + + ###################################################################### if ($form->{"inventory_accno_$i"}) { $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2); @@ -298,12 +318,12 @@ sub post_invoice { $query = qq|INSERT INTO invoice (id, trans_id, parts_id, description, qty, base_qty, - sellprice, fxsellprice, allocated, unit, deliverydate, + sellprice, fxsellprice, discount, allocated, unit, deliverydate, project_id, serialnumber, price_factor_id, price_factor, marge_price_factor) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|; + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|; @values = ($invoice_id, conv_i($form->{id}), conv_i($form->{"id_$i"}), $form->{"description_$i"}, $form->{"qty_$i"} * -1, - $baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $allocated, + $baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated, $form->{"unit_$i"}, conv_date($form->{deliverydate}), conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"}, conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"marge_price_factor_$i"})); @@ -777,7 +797,7 @@ sub retrieve_invoice { i.id AS invoice_id, i.description, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber, - i.price_factor_id, i.price_factor, i.marge_price_factor, + i.price_factor_id, i.price_factor, i.marge_price_factor, i.discount, p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup FROM invoice i -- 2.20.1