From 250e04533e00c90c0e9af72cf06f112d225e1cf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 12 Aug 2015 15:16:13 +0200 Subject: [PATCH] =?utf8?q?Auftrags-Controller:=20Summen=20und=20Steuern=20?= =?utf8?q?nach=20L=C3=B6schen=20von=20Artikeln=20neu=20berechnen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Order.pm | 21 +++++++++++++++---- templates/webpages/order/tabs/basic_data.html | 10 +++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 6aeee9669..6f286e7d3 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -30,7 +30,7 @@ use Rose::Object::MakeMethods::Generic # safety __PACKAGE__->run_before('_check_auth'); -__PACKAGE__->run_before('_setup', +__PACKAGE__->run_before('_recalc', only => [ qw(edit update save) ]); @@ -145,7 +145,7 @@ sub action_add_item { $self->order->add_items($item); - $self->_setup(); + $self->_recalc(); my $row_as_html = $self->p->render('order/tabs/_row', ITEM => $item); @@ -192,7 +192,7 @@ sub action_set_item_values { $item->assign_attributes(%new_attr); - $self->_setup(); + $self->_recalc(); $self->js ->val( '#' . $::form->{qty_dom_id}, $item->qty_as_number) @@ -208,6 +208,19 @@ sub action_set_item_values { } +sub action_recalc_amounts_and_taxes { + my ($self) = @_; + + $self->_recalc(); + + $self->js + ->html('#netamount_id', $::form->format_amount(\%::myconfig, $self->order->netamount, -2)) + ->html('#amount_id', $::form->format_amount(\%::myconfig, $self->order->amount, -2)) + ->remove('.tax_row') + ->insertBefore($self->build_tax_rows, '#amount_row_id') + ->render($self); +} + # # helpers # @@ -310,7 +323,7 @@ sub _make_order { } -sub _setup { +sub _recalc { my ($self) = @_; # bb: todo: currency later diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index 52bb065d7..83bd04859 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -211,6 +211,8 @@ function add_item() { function delete_order_item_row(clicked) { var row = $(clicked).parents("tr").first(); $(row).remove(); + + recalc_amounts_and_taxes() } function set_item_values(event) { @@ -236,6 +238,14 @@ function set_item_values(event) { $.post("controller.pl", data, kivi.eval_json_result); } +function recalc_amounts_and_taxes() { + var data = $('#order_form').serialize(); + data += '&action=Order/recalc_amounts_and_taxes'; + data += '&type=' + $('#type').val(); + + $.post("controller.pl", data, kivi.eval_json_result); +} + function display_linetotal(item_id, amount) { $('#item_' + item_id).parents("tr").first().find('[name="linetotal"]').html(amount); } -- 2.20.1