Aufrufe von 'exit' durch eigene Funktion '::end_of_request()' ersetzt.
[kivitendo-erp.git] / bin / mozilla / is.pl
index f44c580..7084d0a 100644 (file)
@@ -263,6 +263,8 @@ sub prepare_invoice {
       (my $dec_qty)            = ($form->{"qty_$i"} =~ /\.(\d+)/);
       $dec_qty                 = length $dec_qty;
 
+      $form->{"lastcost_$i"}  = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces);
+
       $form->{"qty_$i"}        = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
 
       $form->{rowcount}        = $i;
@@ -510,7 +512,7 @@ sub update {
       if ($rows > 1) {
 
         &select_item;
-        exit;
+        ::end_of_request();
 
       } else {
 
@@ -544,7 +546,7 @@ sub update {
 
         $form->{creditremaining} -= $amount;
 
-        map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice);
+        map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice lastcost);
 
         $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
 
@@ -650,8 +652,15 @@ sub post {
   # if oldcustomer ne customer redo form
   if (&check_name('customer')) {
     &update;
+    ::end_of_request();
+  }
+
+  if ($myconfig{mandatory_departments} && !$form->{department_id}) {
+    $form->{saved_message} = $::locale->text('You have to specify a department.');
+    update();
     exit;
   }
+
   if ($form->{second_run}) {
     $form->{print_and_post} = 0;
   }