Auftrags-Controller: Währung bei Kunden-/Lieferantenwechsel setzen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 5 Jun 2020 15:09:13 +0000 (17:09 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 27 Jul 2020 13:26:42 +0000 (15:26 +0200)
SL/Controller/Order.pm
js/kivi.Order.js

index 17b88fd..f06f06e 100644 (file)
@@ -689,11 +689,13 @@ sub action_customer_vendor_changed {
     ->replaceWith('#business_info_row',      $self->build_business_info_row)
     ->val(        '#order_taxzone_id',       $self->order->taxzone_id)
     ->val(        '#order_taxincluded',      $self->order->taxincluded)
+    ->val(        '#order_currency_id',      $self->order->currency_id)
     ->val(        '#order_payment_id',       $self->order->payment_id)
     ->val(        '#order_delivery_term_id', $self->order->delivery_term_id)
     ->val(        '#order_intnotes',         $self->order->intnotes)
     ->val(        '#language_id',            $self->order->$cv_method->language_id)
-    ->focus(      '#order_' . $self->cv . '_id');
+    ->focus(      '#order_' . $self->cv . '_id')
+    ->run('kivi.Order.update_exchangerate');
 
   $self->js_redisplay_amounts_and_taxes;
   $self->js_redisplay_cvpartnumbers;
@@ -1507,7 +1509,7 @@ sub new_item {
 sub setup_order_from_cv {
   my ($order) = @_;
 
-  $order->$_($order->customervendor->$_) for (qw(taxzone_id payment_id delivery_term_id));
+  $order->$_($order->customervendor->$_) for (qw(taxzone_id payment_id delivery_term_id currency_id));
 
   $order->intnotes($order->customervendor->notes);
 
index 4d7971d..74bd343 100644 (file)
@@ -175,6 +175,11 @@ namespace('kivi.Order', function(ns) {
   };
 
   ns.update_exchangerate = function(event) {
+    if (!ns.check_cv()) {
+      $('#order_currency_id').val($('#old_currency_id').val());
+      return;
+    }
+
     var rate_input = $('#order_exchangerate_as_null_number');
     rate_input.prop('disabled', true);