From 2f6636f68edda5b8a47afd16fda868033a7076ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Sun, 24 May 2015 12:04:10 +0200 Subject: [PATCH] Listenpreis in Belegen u. Ausdruck richtig formatieren und nicht mehr parsen. listprice wird in den Belegen nur angezeigt. Man kann ihn nicht eingeben und auch nicht speichern. Deshalb wird er jetzt nur zur Ausgabe formatiert (io.pl:display_row, OE.pm:order_details, IS.pm:invoice_details), aber nicht formatiert gespeichert. io.pl:display_row schreibt ihn auch unformatiert als hidden in die Form. Das war wohl so gedacht, aber nicht konsequent eingehalten und auch von mir an einigen Stellen "verschlimmbessert" worden. Evtl. sollte der listprice gar nicht als hidden mitgeschliffen werden, sondern immer aus der DB gelesen werden. behebt #46 (redmine) --- SL/DB/Helper/FlattenToForm.pm | 2 +- SL/IS.pm | 3 ++- SL/OE.pm | 3 ++- bin/mozilla/do.pl | 2 +- bin/mozilla/io.pl | 12 +++++------- bin/mozilla/is.pl | 5 ----- bin/mozilla/oe.pl | 6 +++--- 7 files changed, 14 insertions(+), 19 deletions(-) diff --git a/SL/DB/Helper/FlattenToForm.pm b/SL/DB/Helper/FlattenToForm.pm index 4dca557f9..9c34958c8 100644 --- a/SL/DB/Helper/FlattenToForm.pm +++ b/SL/DB/Helper/FlattenToForm.pm @@ -62,7 +62,7 @@ sub flatten_to_form { $form->{"partsgroup_${idx}"} = $item->part->partsgroup->partsgroup if _has($item->part, 'partsgroup_id'); _copy($item->part, $form, '', "_${idx}", 0, qw(id partnumber weight)); - _copy($item->part, $form, '', "_${idx}", $format_amounts, qw(listprice)); + _copy($item->part, $form, '', "_${idx}", 0, qw(listprice)); _copy($item, $form, '', "_${idx}", 0, qw(description project_id ship serialnumber pricegroup_id ordnumber donumber cusordnumber unit subtotal longdescription price_factor_id marge_price_factor approved_sellprice reqdate transdate)); _copy($item, $form, '', "_${idx}", $format_amounts, qw(qty sellprice marge_total marge_percent lastcost)); diff --git a/SL/IS.pm b/SL/IS.pm index 7bc724b90..fda5070d3 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -220,7 +220,8 @@ sub invoice_details { push @{ $form->{TEMPLATE_ARRAYS}->{price_factor_name} }, $price_factor->{description}; push @{ $form->{TEMPLATE_ARRAYS}->{partsgroup} }, $form->{"partsgroup_$i"}; push @{ $form->{TEMPLATE_ARRAYS}->{reqdate} }, $form->{"reqdate_$i"}; - push(@{ $form->{TEMPLATE_ARRAYS}->{listprice} }, $form->{"listprice_$i"}); + push @{ $form->{TEMPLATE_ARRAYS}->{listprice} }, $form->format_amount($myconfig, $form->{"listprice_$i"}, 2); + push(@{ $form->{TEMPLATE_ARRAYS}->{listprice_nofmt} }, $form->{"listprice_$i"}); my $sellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); my ($dec) = ($sellprice =~ /\.(\d+)/); diff --git a/SL/OE.pm b/SL/OE.pm index 8430e2aa4..dc21c51ef 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -1295,7 +1295,8 @@ sub order_details { push @{ $form->{TEMPLATE_ARRAYS}->{reqdate} }, $form->{"reqdate_$i"}; push @{ $form->{TEMPLATE_ARRAYS}->{sellprice} }, $form->{"sellprice_$i"}; push @{ $form->{TEMPLATE_ARRAYS}->{sellprice_nofmt} }, $form->parse_amount($myconfig, $form->{"sellprice_$i"}); - push @{ $form->{TEMPLATE_ARRAYS}->{listprice} }, $form->{"listprice_$i"}; + push @{ $form->{TEMPLATE_ARRAYS}->{listprice} }, $form->format_amount($myconfig, $form->{"listprice_$i"}, 2); + push @{ $form->{TEMPLATE_ARRAYS}->{listprice_nofmt} }, $form->{"listprice_$i"}; push @{ $form->{TEMPLATE_ARRAYS}->{price_factor} }, $price_factor->{formatted_factor}; push @{ $form->{TEMPLATE_ARRAYS}->{price_factor_name} }, $price_factor->{description}; push @{ $form->{TEMPLATE_ARRAYS}->{partsgroup} }, $form->{"partsgroup_$i"}; diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 33ab98c01..764a84d71 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -820,7 +820,7 @@ sub invoice { } } } - map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice listprice lastcost basefactor); + map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice lastcost basefactor); $form->{"donumber_$i"} = $form->{donumber}; $form->{"converted_from_delivery_order_items_id_$i"} = delete $form->{"delivery_order_items_id_$i"}; } diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 12bc4ae6c..c51189330 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -420,8 +420,6 @@ sub display_row { $locale->text('EK'), $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces) } if $form->{"id_$i"} && ($form->{type} =~ /^sales_/ || $form->{type} =~ /invoice/ || $form->{type} =~ /^credit_note$/ ) && !$is_delivery_order; - $form->{"listprice_$i"} = $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) - if $form->{"id_$i"} && ($form->{type} =~ /^sales_/ || $form->{type} =~ /invoice/) ; # / marge calculations ending # Calculate total weight @@ -557,7 +555,7 @@ sub item_selected { } map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } - qw(sellprice listprice weight); + qw(sellprice weight); if ( $mode eq 'IC' ) { # assembly mode: @@ -667,7 +665,7 @@ sub item_selected { map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) - } qw(sellprice listprice lastcost qty) if $form->{item} ne 'assembly'; + } qw(sellprice lastcost qty) if $form->{item} ne 'assembly'; $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100.0) if $form->{item} ne 'assembly'; delete $form->{nextsub}; @@ -728,7 +726,7 @@ sub check_form { #$form->{sellprice} = 0; $form->{weight} = 0; map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } - qw(listprice sellprice rop stock); + qw(sellprice rop stock); my @flds = qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup lastcost); @@ -934,7 +932,7 @@ sub order { 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)); + qw(ship qty sellprice basefactor discount)); $form->{"converted_from_invoice_id_$i"} = delete $form->{"invoice_id_$i"}; } @@ -1002,7 +1000,7 @@ sub quotation { map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } - qw(ship qty sellprice listprice basefactor discount lastcost)); + qw(ship qty sellprice basefactor discount lastcost)); } &prepare_order; diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index a4f9e85b9..a83f77180 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -1019,11 +1019,6 @@ sub credit_note { # map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } # qw(creditlimit creditremaining); - for my $i (1 .. $form->{rowcount}) { - for (qw(listprice)) { - $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"}; - } - } # set new persistent ids for credit note and link previous invoice id $form->{"converted_from_invoice_id_$_"} = delete $form->{"invoice_id_$_"} for 1 .. $form->{"rowcount"}; diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 9d297b8ae..5984c859a 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1445,7 +1445,7 @@ sub invoice { $form->{cp_id} *= 1; for my $i (1 .. $form->{rowcount}) { - for (qw(ship qty sellprice listprice basefactor)) { + for (qw(ship qty sellprice basefactor)) { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"}; } $form->{"converted_from_orderitems_id_$i"} = delete $form->{"orderitems_id_$i"}; @@ -1847,7 +1847,7 @@ sub poso { }; 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 lastcost); + map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice basefactor discount lastcost); } my %saved_vars = map { $_ => $form->{$_} } grep { $form->{$_} } qw(currency); @@ -1909,7 +1909,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 lastcost basefactor discount); + map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice lastcost basefactor discount); $form->{"converted_from_orderitems_id_$i"} = delete $form->{"orderitems_id_$i"}; } -- 2.20.1