From: G. Richardson Date: Tue, 13 Apr 2010 20:54:27 +0000 (+0200) Subject: EK-Preis editierbar gemacht und marge_total repariert X-Git-Tag: release-2.6.2beta1~342^2~2^2~2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=da804bf2a76bec9da604c00208f789a9a312686b;p=kivitendo-erp.git EK-Preis editierbar gemacht und marge_total repariert Der EK-Preis ist jetzt in Angebot/Auftrag/Rechnung editierbar. Dies ist praktisch für Händler/Wiederverkäufer, bei denen sich der EK-Preis häufig ändert, und es sich nicht lohnt, diesen in den Stammdaten zu pflegen. Der EK-Preis wird (als lastcost) zusammen mit marge_total und marge_percent für jeden Artikel in orderitems/invoice in der DB gespeichert. (Bei marge_total gab es hier einen Bug, der falsche Variablenname wurde benutzt und marge_total war immer leer.) Der Stammdaten-EK-Preis wird nicht verändert, wenn man einen abweichenden EK-Preis eingibt. --- diff --git a/SL/DO.pm b/SL/DO.pm index 819664e45..c509a0e4a 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -277,11 +277,10 @@ sub save { } my $baseqty = $form->{"qty_$i"} * $basefactor; - $form->{"lastcost_$i"} *= 1; - # set values to 0 if nothing entered $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}); $form->{"sellprice_$i"} = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); + $form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"}); $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1; my $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2); diff --git a/SL/IS.pm b/SL/IS.pm index 59ee0dc13..15a26769e 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -591,8 +591,8 @@ sub post_invoice { my $baseqty; $form->{"marge_percent_$i"} = $form->parse_amount($myconfig, $form->{"marge_percent_$i"}) * 1; - $form->{"marge_total_$i"} = $form->parse_amount($myconfig, $form->{"marge_total_$i"}) * 1; - $form->{"lastcost_$i"} = $form->{"lastcost_$i"} * 1; + $form->{"marge_absolut_$i"} = $form->parse_amount($myconfig, $form->{"marge_absolut_$i"}) * 1; + $form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"}) * 1; if ($form->{storno}) { $form->{"qty_$i"} *= -1; @@ -717,7 +717,7 @@ sub post_invoice { $form->{"serialnumber_$i"}, conv_i($pricegroup_id), $form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}), $form->{"cusordnumber_$i"}, $baseqty, $form->{"subtotal_$i"} ? 't' : 'f', - $form->{"marge_percent_$i"}, $form->{"marge_total_$i"}, + $form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"}, $form->{"lastcost_$i"}, conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"marge_price_factor_$i"})); diff --git a/SL/OE.pm b/SL/OE.pm index 321755761..226da8119 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -337,8 +337,9 @@ sub save { my $baseqty = $form->{"qty_$i"} * $basefactor; $form->{"marge_percent_$i"} = $form->parse_amount($myconfig, $form->{"marge_percent_$i"}) * 1; - $form->{"marge_total_$i"} = $form->parse_amount($myconfig, $form->{"marge_total_$i"}) * 1; - $form->{"lastcost_$i"} = $form->{"lastcost_$i"} * 1; + $form->{"marge_absolut_$i"} = $form->parse_amount($myconfig, $form->{"marge_absolut_$i"}) * 1; + + $form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"}); # set values to 0 if nothing entered $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100; @@ -428,7 +429,7 @@ sub save { $form->{"serialnumber_$i"}, $form->{"ship_$i"}, conv_i($pricegroup_id), $form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}), $form->{"cusordnumber_$i"}, $form->{"subtotal_$i"} ? 't' : 'f', - $form->{"marge_percent_$i"}, $form->{"marge_total_$i"}, + $form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"}, $form->{"lastcost_$i"}, conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"marge_price_factor_$i"})); diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 1ce1c4694..f7e859e5b 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -235,6 +235,7 @@ sub prepare_order { $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"}; $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); + $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces); (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); $dec_qty = length $dec_qty; @@ -374,6 +375,7 @@ sub update_delivery_order { $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor}; $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}); + $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}); $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); } @@ -736,7 +738,7 @@ sub invoice { # und keinen anderen discount wert an $i ... $form->{"discount_$i"} ||= $form->{discount}*100; # ... nehmen wir den kundenrabatt } - map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice listprice basefactor); + map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice listprice lastcost basefactor); } $form->{type} = "invoice"; @@ -769,10 +771,15 @@ sub invoice { $form->{"deliverydate_$i"} = $form->{"reqdate_$i"} unless $form->{"deliverydate_$i"}; + $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); + $form->{"lastcost_$i"} = + $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, + $decimalplaces); + (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); $dec_qty = length $dec_qty; $form->{"qty_$i"} = diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 965e4bafa..ec287aa61 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1871,7 +1871,7 @@ sub save { $form->{creditremaining} -= $amount; # redo number formatting, because invoice parse them! - map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(weight listprice sellprice rop); + map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(weight listprice sellprice lastcost rop); } $form->{"id_$i"} = $parts_id; diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index cabb133d6..ce7ce7848 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -159,6 +159,7 @@ sub display_row { ); my @column_index = map { $_->{id} } grep { $_->{display} } @HEADER; + # cache units my $all_units = AM->retrieve_units(\%myconfig, $form); @@ -209,7 +210,9 @@ sub display_row { my %column_data = (); # undo formatting - map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty discount sellprice price_new price_old) unless ($form->{simple_save}); + map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } + qw(qty discount sellprice lastcost price_new price_old) + unless ($form->{simple_save}); # unit begin $form->{"unit_old_$i"} ||= $form->{"unit_$i"}; @@ -294,6 +297,7 @@ sub display_row { } $column_data{sellprice} = $cgi->textfield(-name => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces)); + } $column_data{discount} = $cgi->textfield(-name => "discount_$i", -size => 3, -value => $form->format_amount(\%myconfig, $form->{"discount_$i"})); $column_data{linetotal} = $form->format_amount(\%myconfig, $linetotal, 2); @@ -338,7 +342,10 @@ sub display_row { map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent); - push @ROW2, { value => sprintf qq|%s %s  %s%%  %s %s  %s %s|, + push @ROW2, { value => sprintf qq| + %s %s  %s%% +  %s %s +  %s |, $marge_color, $locale->text('Ertrag'),$form->{"marge_absolut_$i"}, $form->{"marge_percent_$i"}, $locale->text('LP'), $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2), $locale->text('EK'), $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) } @@ -361,8 +368,8 @@ sub display_row { my @hidden_vars; if ($is_delivery_order) { - map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount); - push @hidden_vars, qw(sellprice discount price_factor_id); + map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount lastcost); + push @hidden_vars, qw(sellprice discount price_factor_id lastcost); push @hidden_vars, "stock_${stock_in_out}_sum_qty", "stock_${stock_in_out}"; } @@ -372,7 +379,7 @@ sub display_row { map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" } (qw(orderitems_id bo pricegroup_old price_old id inventory_accno bin partsgroup partnotes income_accno expense_accno listprice assembly taxaccounts ordnumber transdate cusordnumber - longdescription basefactor marge_absolut marge_percent marge_price_factor lastcost), @hidden_vars) + longdescription basefactor marge_absolut marge_percent marge_price_factor), @hidden_vars) ); map { $form->{"${_}_base"} += $linetotal } (split(/ /, $form->{"taxaccounts_$i"})); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index f44c5809c..a47b7e809 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -263,6 +263,8 @@ sub prepare_invoice { (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); $dec_qty = length $dec_qty; + $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces); + $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); $form->{rowcount} = $i; @@ -544,7 +546,7 @@ sub update { $form->{creditremaining} -= $amount; - map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice); + map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice lastcost); $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 02bdf1bce..bef23176a 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -283,6 +283,7 @@ sub prepare_order { $form->{"reqdate_$i"} ||= $form->{"deliverydate_$i"}; $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * ($format_discounts ? 100 : 1)); $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}); + $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}); $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); } @@ -554,6 +555,8 @@ sub update { # select discount as customer_discount from customer $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"$form->{vc}_discount"} * 100); + $form->{"lastcost_$i"} = $form->parse_amount(\%myconfig, $form->{"lastcost_$i"}); + if ($rows) { $form->{"qty_$i"} = 1 unless ($form->parse_amount(\%myconfig, $form->{"qty_$i"})); @@ -599,6 +602,7 @@ sub update { $form->{creditremaining} -= $amount; $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); + $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces); $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); # get pricegroups for parts @@ -1761,7 +1765,7 @@ sub poso { # reset map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered ordnumber); - # if purchase_order was generated from sales_order, use lastcost_$i as sellprice_$i + # if purchase_order was generated from sales_order, use lastcost_$i as sellprice_$i if ( $form->{sales_order_to_purchase_order} ) { for my $i (1 .. $form->{rowcount}) { $form->{"sellprice_${i}"} = $form->format_amount(\%myconfig,$form->{"lastcost_${i}"}); @@ -1829,7 +1833,7 @@ sub delivery_order { delete @{$form}{qw(id subject message cc bcc printed emailed queued creditlimit creditremaining discount tradediscount oldinvtotal closed delivered)}; for my $i (1 .. $form->{rowcount}) { - map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor discount); + map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice lastcost basefactor discount); } my %old_values = map { $_ => $form->{$_} } qw(customer_id oldcustomer customer vendor_id oldvendor vendor);