Zeilenanzahl der Preisgruppen im Dialog Stammdaten->Dienstleistung erfassen gefixt.
[kivitendo-erp.git] / bin / mozilla / is.pl
index 4e6a066..7d79ba9 100644 (file)
@@ -33,6 +33,7 @@
 
 use SL::IS;
 use SL::PE;
+use Data::Dumper;
 
 require "$form->{path}/io.pl";
 require "$form->{path}/arap.pl";
@@ -194,12 +195,14 @@ sub prepare_invoice {
     map { $form->{$_} =~ s/\"/"/g }
       qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
 
+    #     # get pricegroups for parts
+    #     IS->get_pricegroups_for_parts(\%myconfig, \%$form);
+
     foreach $ref (@{ $form->{invoice_details} }) {
       $i++;
       map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
       $form->{"discount_$i"} =
         $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
-
       ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
       $dec           = length $dec;
       $decimalplaces = ($dec > 2) ? $dec : 2;
@@ -207,11 +210,17 @@ sub prepare_invoice {
       $form->{"sellprice_$i"} =
         $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
                              $decimalplaces);
-      $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
+
+      (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
+      $dec_qty = length $dec_qty;
+
+      $form->{"qty_$i"} =
+        $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
 
       map { $form->{"${_}_$i"} =~ s/\"/"/g }
         qw(partnumber description unit partnotes);
       $form->{rowcount} = $i;
+
     }
   }
   $lxdebug->leave_sub();
@@ -389,6 +398,7 @@ sub form_header {
              <tr>
                <th align=right nowrap>| . $locale->text('Customer') . qq|</th>
                <td colspan=3>$customer</td>
+    <input type=hidden name=customer_klass value=$form->{customer_klass}>
                <input type=hidden name=customer_id value=$form->{customer_id}>
                <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
                 <th align=richt nowrap>|
@@ -855,7 +865,9 @@ sub update {
 
   map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
     qw(exchangerate creditlimit creditremaining);
-
+  if ($form->{second_run}) {
+    $form->{print_and_post} = 0;
+  }
   &check_name(customer);
 
   &check_project;
@@ -973,6 +985,11 @@ sub update {
           }
         }
 
+        # get pricegroups for parts
+        IS->get_pricegroups_for_parts(\%myconfig, \%$form);
+
+        # build up html code for prices_$i
+        &set_pricegroup($i);
       }
 
       &display_form;
@@ -1003,7 +1020,6 @@ sub update {
 
 sub post {
   $lxdebug->enter_sub();
-
   $form->isblank("invdate",  $locale->text('Invoice Date missing!'));
   $form->isblank("customer", $locale->text('Customer missing!'));
 
@@ -1012,6 +1028,9 @@ sub post {
     &update;
     exit;
   }
+  if ($form->{second_run}) {
+    $form->{print_and_post} = 0;
+  }
 
   &validate_items;
 
@@ -1072,6 +1091,7 @@ sub print_and_post {
   $print_post             = 1;
   $form->{print_and_post} = 1;
   &post();
+
   &display_form();
   $lxdebug->leave_sub();
 
@@ -1092,7 +1112,9 @@ sub preview {
 
 sub delete {
   $lxdebug->enter_sub();
-
+  if ($form->{second_run}) {
+    $form->{print_and_post} = 0;
+  }
   $form->header;
 
   print qq|