]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/io.pl
Verknüpfungen zwischen Angeboten, Aufträgen, Lieferscheinen, Rechnungen in einer...
[mfinanz.git] / bin / mozilla / io.pl
index 236bd186b8580a1b570aef78c9947bdf4e438ec8..9a1c5aa97de48b5c26039b5a0cfb1964df70e612 100644 (file)
@@ -235,9 +235,8 @@ sub display_row {
     $decimalplaces = max 2, length $1;
 
     $price_factor   = $price_factors{$form->{"price_factor_id_$i"}} || 1;
-    $discount       = $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"} / 100, $decimalplaces);
-    $linetotal      = $form->round_amount(($form->{"sellprice_$i"} - $discount) / $price_factor, $decimalplaces);
-    $linetotal      = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
+    $discount       = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} *        $form->{"discount_$i"}  / 100 / $price_factor, 2);
+    $linetotal      = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} * (100 - $form->{"discount_$i"}) / 100 / $price_factor, 2);
 
     $column_data{runningnumber} = $cgi->textfield(-name => "runningnumber_$i", -size => 5,  -value => $i);    # HuT
     $column_data{partnumber}    = $cgi->textfield(-name => "partnumber_$i",    -size => 12, -value => $form->{"partnumber_$i"});
@@ -253,10 +252,15 @@ sub display_row {
     $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)", -value => $locale->text('*/'))
                        . $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"})
       if $form->{"formel_$i"};
-    $column_data{ship} = !$form->{"id_$i"} ? '' : $form->format_amount_units('amount'     => $form->{"ship_$i"} * 1,
-                                                                             'part_unit'  => $form->{"partunit_$i"},
-                                                                             'conv_units' => 'convertible_not_smaller',
-                                                                             'max_places' => 2);
+
+    $column_data{ship} = '';
+    if ($form->{"id_$i"}) {
+      my $ship_qty        = $form->{"ship_$i"} * 1;
+      $ship_qty          *= $all_units->{$form->{"partunit_$i"}}->{factor};
+      $ship_qty          /= $all_units->{$form->{"unit_$i"}}->{factor};
+
+      $column_data{ship}  = $form->format_amount(\%myconfig, $form->round_amount($ship_qty, 2) * 1) . ' ' . $form->{"unit_$i"};
+    }
 
     # build in drop down list for pricesgroups
     if ($form->{"prices_$i"}) {
@@ -1879,8 +1883,8 @@ sub _update_ship {
 
   AM->retrieve_all_units();
 
-  my %ship = DO->get_shipped_qty('type'      => ($form->{type} eq 'purchase_order') ? 'purchase' : 'sales',
-                                 'ordnumber' => $form->{ordnumber},);
+  my %ship = DO->get_shipped_qty('type'  => ($form->{type} eq 'purchase_order') ? 'purchase' : 'sales',
+                                 'oe_id' => $form->{id},);
 
   foreach my $i (1..$form->{rowcount}) {
     next unless ($form->{"id_${i}"});
@@ -1892,7 +1896,7 @@ sub _update_ship {
     next if (!$ship_entry || ($ship_entry->{qty} <= 0));
 
     my $rowqty =
-      $form->parse_amount(\%myconfig, $form->{"qty_$i"})
+      ($form->{simple_save} ? $form->{"qty_$i"} : $form->parse_amount(\%myconfig, $form->{"qty_$i"}))
       * $all_units->{$form->{"unit_$i"}}->{factor}
       / $all_units->{$form->{"partunit_$i"}}->{factor};