From: Bernd Bleßmann Date: Wed, 30 Sep 2015 10:25:31 +0000 (+0200) Subject: Auftrags-Controller: taxincluded vom Kunden oder aus Benutzereinstellung holen. X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=87bd35148cceaf805d14d5ed2042142a40981519;p=kivitendo-erp.git Auftrags-Controller: taxincluded vom Kunden oder aus Benutzereinstellung holen. --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index f275f87b0..193382790 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -243,31 +243,37 @@ sub action_save_and_delivery_order { sub action_customer_vendor_changed { my ($self) = @_; - if ($self->cv eq 'customer') { - $self->order->customer(SL::DB::Manager::Customer->find_by_or_create(id => $::form->{cv_id})); - - } elsif ($self->cv eq 'vendor') { - $self->order->vendor(SL::DB::Manager::Vendor->find_by_or_create(id => $::form->{cv_id})); - } + my $cv_method = $self->cv; - if ($self->order->{$self->cv}->contacts && scalar @{ $self->order->{$self->cv}->contacts } > 0) { + if ($self->order->$cv_method->contacts && scalar @{ $self->order->$cv_method->contacts } > 0) { $self->js->show('#cp_row'); } else { $self->js->hide('#cp_row'); } - if ($self->order->{$self->cv}->shipto && scalar @{ $self->order->{$self->cv}->shipto } > 0) { + if ($self->order->$cv_method->shipto && scalar @{ $self->order->$cv_method->shipto } > 0) { $self->js->show('#shipto_row'); } else { $self->js->hide('#shipto_row'); } + $self->order->taxzone_id($self->order->$cv_method->taxzone_id); + + $self->order->taxincluded(defined($self->order->$cv_method->taxincluded_checked) + ? $self->order->$cv_method->taxincluded_checked + : $::myconfig{taxincluded_checked}); + + $self->_recalc(); + $self->js - ->replaceWith('#order_cp_id', $self->build_contact_select) - ->replaceWith('#order_shipto_id', $self->build_shipto_select) - ->val('#order_taxzone_id', $self->order->{$self->cv}->taxzone_id) - ->focus('#order_' . $self->cv . '_id') - ->render($self); + ->replaceWith('#order_cp_id', $self->build_contact_select) + ->replaceWith('#order_shipto_id', $self->build_shipto_select) + ->val( '#order_taxzone_id', $self->order->taxzone_id) + ->val( '#order_taxincluded', $self->order->taxincluded) + ->focus( '#order_' . $self->cv . '_id'); + + $self->_js_redisplay_amounts_and_taxes; + $self->js->render(); } sub action_add_item { diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index f0928aa27..5368bd728 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -244,10 +244,10 @@