Merge branch 'master' of ssh://lx-office/~/lx-office-erp
[kivitendo-erp.git] / bin / mozilla / do.pl
index 8ba48d6..4ae7f45 100644 (file)
@@ -359,7 +359,7 @@ sub update_delivery_order {
     my $rows = scalar @{ $form->{item_list} };
 
     if ($rows) {
-      $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
+      $form->{"qty_$i"} = 1 unless $form->parse_amount(\%myconfig, $form->{"qty_$i"});
 
       if ($rows > 1) {
 
@@ -466,7 +466,7 @@ sub orders {
 
   my @hidden_variables = map { "l_${_}" } @columns;
   push @hidden_variables, $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered donumber ordnumber
-                                          transaction_description transdatefrom transdateto type vc employee_id salesman_id);
+                                          transaction_description transdatefrom transdateto type vc employee_id salesman_id project_id);
 
   my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
 
@@ -477,7 +477,7 @@ sub orders {
     'donumber'                => { 'text' => $locale->text('Delivery Order'), },
     'ordnumber'               => { 'text' => $locale->text('Order'), },
     'name'                    => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer') : $locale->text('Vendor'), },
-    'employee'                => { 'text' => $locale->text('Salesperson'), },
+    'employee'                => { 'text' => $locale->text('Employee'), },
     'shipvia'                 => { 'text' => $locale->text('Ship via'), },
     'globalprojectnumber'     => { 'text' => $locale->text('Project Number'), },
     'transaction_description' => { 'text' => $locale->text('Transaction description'), },
@@ -609,6 +609,7 @@ sub save {
   # $locale->text('Customer missing!');
   # $locale->text('Vendor missing!');
 
+  remove_emptied_rows();
   validate_items();
 
   # if the name changed get new values
@@ -618,9 +619,23 @@ sub save {
   }
 
   $form->{id} = 0 if $form->{saveasnew};
-
+  # best case fix für bug 1079. Einkaufsrabatt wird nicht richtig
+  # aus Lieferantenauftrag -> Lieferschein -> Rechnung übernommen
+  # Tritt nur auf, wenn man direkt über Lieferschein -> speichern ->
+  # Workflow Rechnung geht (beim Aufruf über edit() i.O.)
+  # Gut. DO-save() speichert den Discount im DB-Format 0.12 für
+  # 12%, die Konvertierung wird leider in $form gemacht und daher
+  # wird die Maske mit dem falschen Rabatt wieder aufgebaut.
+  # Wie immer: backup_vars verwenden um nichts anderes kaputt zu
+  # machen. jan 03.03.2010
+  for my $i (1 .. $form->{rowcount}) {
+    $form->{"backup_discount_$i"} = $form->{"discount_$i"};
+  };
   DO->save();
-
+  for my $i (1 .. $form->{rowcount}) {
+    $form->{"discount_$i"} = $form->{"backup_discount_$i"};
+    delete $form->{"backup_discount_$i"};
+  };
   # saving the history
   if(!exists $form->{addition}) {
     $form->{snumbers} = qq|donumber_| . $form->{donumber};
@@ -857,6 +872,7 @@ sub save_as_new {
   $form->{closed}    = 0;
   $form->{delivered} = 0;
   map { delete $form->{$_} } qw(printed emailed queued);
+  delete @{ $form }{ grep { m/^stock_(?:in|out)_\d+/ } keys %{ $form } };
 
   # Let Lx-Office assign a new order number if the user hasn't changed the
   # previous one. If it has been changed manually then use it as-is.
@@ -1191,10 +1207,10 @@ sub transfer_in {
 
       my $do_base_qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"}) * $units->{$form->{"unit_$i"}}->{factor} / $base_unit_factor;
 
-      if ($do_base_qty != $row_sum_base_qty) {
-        push @{ $form->{ERRORS} }, $locale->text('Error in position #1: You must either assign no stock at all or the full quantity of #2 #3.',
-                                                 $i, $form->{"qty_$i"}, $form->{"unit_$i"});
-      }
+#      if ($do_base_qty != $row_sum_base_qty) {
+#        push @{ $form->{ERRORS} }, $locale->text('Error in position #1: You must either assign no stock at all or the full quantity of #2 #3.',
+#                                                 $i, $form->{"qty_$i"}, $form->{"unit_$i"});
+#      }
     }
 
     if (@{ $form->{ERRORS} }) {
@@ -1262,10 +1278,10 @@ sub transfer_out {
 
       my $do_base_qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"}) * $units->{$form->{"unit_$i"}}->{factor} / $base_unit_factor;
 
-      if ($do_base_qty != $row_sum_base_qty) {
-        push @{ $form->{ERRORS} }, $locale->text('Error in position #1: You must either assign no transfer at all or the full quantity of #2 #3.',
-                                                 $i, $form->{"qty_$i"}, $form->{"unit_$i"});
-      }
+#      if ($do_base_qty != $row_sum_base_qty) {
+#        push @{ $form->{ERRORS} }, $locale->text('Error in position #1: You must either assign no transfer at all or the full quantity of #2 #3.',
+#                                                 $i, $form->{"qty_$i"}, $form->{"unit_$i"});
+#      }
     }
 
     if (%request_map) {