X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FOrder.pm;h=e963994f4750d816dafe68934b3a114ff82b3715;hb=d6fed9b55a11dca1cfd9cd6f43940a945533d318;hp=e5313124de1097d05a4cd4c340361d818c61f0de;hpb=958b82d600cebec78ff208257b1fd348ee0439bf;p=kivitendo-erp.git diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index e5313124d..e963994f4 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -1165,11 +1165,11 @@ sub action_create_part { flash_later('info', t8('You are adding a new part while you are editing another document. You will be redirected to your document when saving the new part or aborting this form.')); my @redirect_params = ( - controller => 'Part', - action => 'add', - part_type => $::form->{add_item}->{create_part_type}, - callback => $callback, - show_abort => 1, + controller => 'Part', + action => 'add', + part_type => $::form->{add_item}->{create_part_type}, + callback => $callback, + inline_create => 1, ); $self->redirect_to(@redirect_params); @@ -1253,12 +1253,22 @@ sub action_update_row_from_master_data { $price_src->price(0) if !$price_source->best_price; } + my $discount_src; + $discount_src = $price_source->best_discount + ? $price_source->best_discount + : $price_source->discount_from_source(""); + $discount_src->discount(0) if !$price_source->best_discount; $item->sellprice($price_src->price); $item->active_price_source($price_src); + $item->discount($discount_src->discount); + $item->active_discount_source($discount_src); + + my $price_editable = $self->order->is_sales ? $::auth->assert('sales_edit_prices', 1) : $::auth->assert('purchase_edit_prices', 1); $self->js - ->run('kivi.Order.update_sellprice', $item_id, $item->sellprice_as_number) + ->run('kivi.Order.set_price_and_source_text', $item_id, $price_src ->source, $price_src ->source_description, $item->sellprice_as_number, $price_editable) + ->run('kivi.Order.set_discount_and_source_text', $item_id, $discount_src->source, $discount_src->source_description, $item->discount_as_percent, $price_editable) ->html('.row_entry:has(#item_' . $item_id . ') [name = "partnumber"] a', $item->part->partnumber) ->val ('.row_entry:has(#item_' . $item_id . ') [name = "order.orderitems[].description"]', $item->description) ->val ('.row_entry:has(#item_' . $item_id . ') [name = "order.orderitems[].longdescription"]', $item->longdescription); @@ -1704,6 +1714,7 @@ sub new_item { my $part = SL::DB::Part->new(id => $attr->{parts_id})->load; my $price_source = SL::PriceSource->new(record_item => $item, record => $record); + $item->qty(1.0) if !$item->qty; $item->unit($part->unit) if !$item->unit; my $price_src; @@ -1736,7 +1747,6 @@ sub new_item { my %new_attr; $new_attr{part} = $part; $new_attr{description} = $part->description if ! $item->description; - $new_attr{qty} = 1.0 if ! $item->qty; $new_attr{price_factor_id} = $part->price_factor_id if ! $item->price_factor_id; $new_attr{sellprice} = $price_src->price; $new_attr{discount} = $discount_src->discount;