From 2dfa3a4c75b6f68ab75df739a3e82ceb1b61dcff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 2 Mar 2017 15:22:33 +0100 Subject: [PATCH] =?utf8?q?Preisquellen:=20Support=20f=C3=BCr=20editierbare?= =?utf8?q?=20Preisquellen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/PriceSource/Price.pm | 18 +++++++++++++++++- bin/mozilla/io.pl | 27 +++++++++++++++------------ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/SL/PriceSource/Price.pm b/SL/PriceSource/Price.pm index 0ecc8b002..89a23e858 100644 --- a/SL/PriceSource/Price.pm +++ b/SL/PriceSource/Price.pm @@ -5,7 +5,7 @@ use strict; use parent 'SL::DB::Object'; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(price description spec price_source invalid missing) ], - 'scalar --get_set_init' => [ qw(priority) ], + 'scalar --get_set_init' => [ qw(priority editable) ], ); require SL::DB::Helper::Attr; @@ -43,6 +43,10 @@ sub init_priority { 3 } +sub init_editable { + 0 +} + 1; __END__ @@ -119,6 +123,18 @@ A ref to the creating algorithm. OPTIONAL. Prices may supply a numerical priority. Higher will trump lower, even when supplying higher prices. Defaults to 3 (as in middle of 1-5). +=item C + +OPTIONAL. Prices may flag themselves as editable. An editable price will still +be subject to checks for higher or lower prices, but will be rendered in a +fashion that allows the user to overwrite it. + +This is potentially very distracting if the price is usually a default price +and will be changed in a lot of instances so use with caution. + +On the other hand it can provide the capability that users unfamiliar with the +system will intuitively expect so it can be a good way to introduce the system. + =item C OPTIONAL. Both indicator and localized message that the price with this spec diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index e5b88c41c..33a5930c4 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -218,7 +218,7 @@ sub display_row { # special alignings my %align = map { $_ => 'right' } qw(qty ship right discount linetotal stock_in_out weight ship_missing); - my %nowrap = map { $_ => 1 } qw(description unit); + my %nowrap = map { $_ => 1 } qw(description unit price_source); $form->{marge_total} = 0; $form->{sellprice_total} = 0; @@ -336,24 +336,18 @@ sub display_row { $column_data{ship_missing} = $form->format_amount(\%myconfig, $ship_missing_qty) . ' ' . $form->{"unit_$i"} . '; ' . $form->format_amount(\%myconfig, $ship_missing_amount, $decimalplaces); } - my $sellprice_value = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); - my $discount_value = $form->format_amount(\%myconfig, $form->{"discount_$i"}); - my $edit_prices = $main::auth->assert('edit_prices', 1) && !$::form->{"active_price_source_$i"}; - my $edit_discounts = $main::auth->assert('edit_prices', 1) && !$::form->{"active_discount_source_$i"}; - $column_data{sellprice} = (!$edit_prices) - ? $cgi->hidden( -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value - : $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value); - $column_data{discount} = (!$edit_discounts) - ? $cgi->hidden( -name => "discount_$i", -id => "discount_$i", -value => $discount_value) . $discount_value . ' %' - : $cgi->textfield(-name => "discount_$i", -id => "discount_$i", -size => 3, -value => $discount_value); $column_data{linetotal} = $form->format_amount(\%myconfig, $linetotal, 2); $column_data{bin} = $form->{"bin_$i"}; $column_data{weight} = $form->format_amount(\%myconfig, $form->{"qty_$i"} * $form->{"weight_$i"}, 3) . ' ' . $defaults->{weightunit} if $defaults->{show_weight}; + my $sellprice_value = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); + my $discount_value = $form->format_amount(\%myconfig, $form->{"discount_$i"}); + + my $price; if ($form->{"id_${i}"} && !$is_delivery_order) { my $price_source = SL::PriceSource->new(record_item => $record_item, record => $record); - my $price = $price_source->price_from_source($::form->{"active_price_source_$i"}); + $price = $price_source->price_from_source($::form->{"active_price_source_$i"}); my $discount = $price_source->discount_from_source($::form->{"active_discount_source_$i"}); my $best_price = $price_source->best_price; my $best_discount = $price_source->best_discount; @@ -378,6 +372,15 @@ sub display_row { } } + my $edit_prices = $main::auth->assert('edit_prices', 1) && (!$::form->{"active_price_source_$i"} || !$price || $price->editable); + my $edit_discounts = $main::auth->assert('edit_prices', 1) && !$::form->{"active_discount_source_$i"}; + $column_data{sellprice} = (!$edit_prices) + ? $cgi->hidden( -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value + : $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value); + $column_data{discount} = (!$edit_discounts) + ? $cgi->hidden( -name => "discount_$i", -id => "discount_$i", -value => $discount_value) . $discount_value . ' %' + : $cgi->textfield(-name => "discount_$i", -id => "discount_$i", -size => 3, -value => $discount_value); + if ($is_delivery_order) { $column_data{stock_in_out} = calculate_stock_in_out($i); } -- 2.20.1