PriceSource: Bei item_selected Preisequellen nur in Belegen pollen.
authorSven Schöling <s.schoeling@linet-services.de>
Wed, 4 Feb 2015 15:54:57 +0000 (16:54 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 4 Feb 2015 15:54:57 +0000 (16:54 +0100)
bin/mozilla/io.pl

index 99ba934..54e4803 100644 (file)
@@ -556,23 +556,23 @@ sub item_selected {
 
   map { $form->{"${_}_$i"} = $new_item->{$_} } @new_fields;
 
-  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;
+  if (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;
 
-  if ($best_price) {
-    $::form->{"sellprice_$i"}           = $best_price->price;
-    $::form->{"active_price_source_$i"} = $best_price->source;
-  }
+    if ($best_price) {
+      $::form->{"sellprice_$i"}           = $best_price->price;
+      $::form->{"active_price_source_$i"} = $best_price->source;
+    }
 
-  my $best_discount = $price_source->best_discount;
+    my $best_discount = $price_source->best_discount;
 
-  if ($best_discount) {
-    $::form->{"discount_$i"}               = $best_discount->discount;
-    $::form->{"active_discount_source_$i"} = $best_discount->source;
+    if ($best_discount) {
+      $::form->{"discount_$i"}               = $best_discount->discount;
+      $::form->{"active_discount_source_$i"} = $best_discount->source;
+    }
   }
 
-
   $form->{"marge_price_factor_$i"} = $new_item->{price_factor};
 
   if ($form->{"part_payment_id_$i"} ne "") {