From 42ccfb976289de017f9f355bd3bf0e02bcec80ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 23 Oct 2015 22:29:11 +0200 Subject: [PATCH] Auftrags-Controller: PriceSources: Umstellung auf discount_from_source. --- SL/Controller/Order.pm | 24 +++++++++--------------- templates/webpages/order/tabs/_row.html | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 79e4ee834..33628ba46 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -305,17 +305,15 @@ sub action_add_item { $price_src->price(0) if !$price_source->best_price; } - # bb: not sure but: maybe there should be a $price_source->discount_from_source - # which can also return an empty_discout if source is "". - my $discount; my $discount_src; if ($item->discount) { - $discount = $item->discount; + $discount_src = $price_source->discount_from_source(""); + $discount_src->discount($item->discount); } else { - $discount = $price_source->best_discount - ? $price_source->best_discount->discount - : 0; - $discount_src = $price_source->best_discount->source if $price_source->best_discount; + $discount_src = $price_source->best_discount + ? $price_source->best_discount + : $price_source->discount_from_source(""); + $discount_src->discount(0) if !$price_source->best_discount; } my %new_attr; @@ -323,7 +321,7 @@ sub action_add_item { $new_attr{description} = $part->description if ! $item->description; $new_attr{qty} = 1.0 if ! $item->qty; $new_attr{sellprice} = $price_src->price; - $new_attr{discount} = $discount; + $new_attr{discount} = $discount_src->discount; $new_attr{active_price_source} = $price_src; $new_attr{active_discount_source} = $discount_src; @@ -604,13 +602,9 @@ sub _pre_render { foreach my $item (@{$self->order->items}) { my $price_source = SL::PriceSource->new(record_item => $item, record => $self->order); + $item->active_price_source( $price_source->price_from_source( $item->active_price_source )); + $item->active_discount_source($price_source->discount_from_source($item->active_discount_source)); - my $price_src = $price_source->price_from_source($item->active_price_source); - $item->active_price_source($price_src); - - my $discount_src; - $discount_src = $price_source->price_from_source($item->active_discount_source)->source if $item->active_discount_source; - $item->active_discount_source($discount_src); } $::request->{layout}->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery); diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index 7138d36ca..637769b7b 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -67,7 +67,7 @@ [%- END %] - [%- L.hidden_tag("order.orderitems[].active_discount_source", ITEM.active_discount_source) %] + [%- L.hidden_tag("order.orderitems[].active_discount_source", ITEM.active_discount_source.source) %] [%- L.input_tag("order.orderitems[].discount_as_percent", ITEM.discount_as_percent, size = 5, -- 2.20.1