]> wagnertech.de Git - kivitendo-erp.git/blobdiff - bin/mozilla/oe.pl
PriceSource: Rabattbehandlung
[kivitendo-erp.git] / bin / mozilla / oe.pl
index 146063080165f9c5a27cf6e79e3ed1e6a2ae8472..860d722d40cfe76e0411ba8fecdcf6f6b74d31d6 100644 (file)
@@ -465,7 +465,7 @@ sub form_header {
     }
   }
 
-  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase show_form_details show_history show_vc_details ckeditor/ckeditor ckeditor/adapters/jquery));
+  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase show_form_details show_history show_vc_details ckeditor/ckeditor ckeditor/adapters/jquery kivi.io));
 
   $form->header;
   if ($form->{CFDD_shipto} && $form->{CFDD_shipto_id} ) {
@@ -678,16 +678,20 @@ sub update {
         if ($sellprice) {
           $form->{"sellprice_$i"} = $sellprice;
         } else {
-          my $record       = _make_record();
-          my $price_source = SL::PriceSource->new(record_item => $record->items->[$i-1], record => $record);
-          my $best_price   = $price_source->best_price;
+          my $record        = _make_record();
+          my $price_source  = SL::PriceSource->new(record_item => $record->items->[$i-1], record => $record);
+          my $best_price    = $price_source->best_price;
+          my $best_discount = $price_source->best_discount;
 
           if ($best_price) {
             $::form->{"sellprice_$i"}           = $best_price->price;
             $::form->{"active_price_source_$i"} = $best_price->source;
           }
+          if ($best_discount) {
+            $::form->{"discount_$i"}               = $best_discount->discount;
+            $::form->{"active_discount_source_$i"} = $best_discount->source;
+          }
 
-          $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
           $form->{"sellprice_$i"} /= $exchangerate;   # if there is an exchange rate adjust sellprice
         }