From: Bernd Bleßmann Date: Wed, 27 Apr 2022 09:34:35 +0000 (+0200) Subject: Auftrags-Controller: Preisquellen bei Erneuern von Positionen aus Stammdaten … X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~41 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d6fed9b55a11dca1cfd9cd6f43940a945533d318;p=kivitendo-erp.git Auftrags-Controller: Preisquellen bei Erneuern von Positionen aus Stammdaten … … nicht nur berücksichtigen, sondern auch anzeigen. Und Rabatt-Quellen ebefalls berücksichtigen und anzeigen. --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index e67576c3b..e963994f4 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -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); diff --git a/js/kivi.Order.js b/js/kivi.Order.js index b82358b67..8815d9b29 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -558,7 +558,7 @@ namespace('kivi.Order', function(ns) { $.post("controller.pl", data, kivi.eval_json_result); }; - ns.update_price_source = function(item_id, source, descr, price_str, price_editable) { + ns.set_price_and_source_text = function(item_id, source, descr, price_str, price_editable) { var row = $('#item_' + item_id).parents("tbody").first(); var source_elt = $(row).find('[name="order.orderitems[].active_price_source"]'); var button_elt = $(row).find('[name="price_chooser_button"]'); @@ -587,13 +587,17 @@ namespace('kivi.Order', function(ns) { var html_elt = $(row).find('[name="sellprice_text"]'); price_elt.val(price_str); html_elt.html(price_str); - ns.recalc_amounts_and_taxes(); } + }; + + ns.update_price_source = function(item_id, source, descr, price_str, price_editable) { + ns.set_price_source_text(item_id, source, descr, price_str, price_editable); + if (price_str) ns.recalc_amounts_and_taxes(); kivi.io.close_dialog(); }; - ns.update_discount_source = function(item_id, source, descr, discount_str, price_editable) { + ns.set_discount_and_source_text = function(item_id, source, descr, discount_str, price_editable) { var row = $('#item_' + item_id).parents("tbody").first(); var source_elt = $(row).find('[name="order.orderitems[].active_discount_source"]'); var button_elt = $(row).find('[name="price_chooser_button"]'); @@ -622,9 +626,11 @@ namespace('kivi.Order', function(ns) { var html_elt = $(row).find('[name="discount_text"]'); discount_elt.val(discount_str); html_elt.html(discount_str); - ns.recalc_amounts_and_taxes(); } + }; + ns.update_discount_source = function(item_id, source, descr, discount_str, price_editable) { + if (discount_str) ns.recalc_amounts_and_taxes(); kivi.io.close_dialog(); };