Pricefaktoren auch im assembly_row flow mitschleifen und berechnen.
authorSven Schöling <s.schoeling@linet-services.de>
Thu, 14 May 2009 15:54:58 +0000 (15:54 +0000)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 14 May 2009 15:54:58 +0000 (15:54 +0000)
Fix für Bug 987

SL/IC.pm
bin/mozilla/ic.pl

index f691a35..7843665 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -690,9 +690,11 @@ sub assembly_item {
   my $dbh = $form->dbconnect($myconfig);
 
   my $query =
-    qq|SELECT p.id, p.partnumber, p.description, p.sellprice, p.weight, p.onhand, p.unit, pg.partsgroup
+    qq|SELECT p.id, p.partnumber, p.description, p.sellprice, p.weight, p.onhand, p.unit, pg.partsgroup,
+              p.price_factor_id, pfac.factor AS price_factor
        FROM parts p
        LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id)
+       LEFT JOIN price_factors pfac ON pfac.id = p.price_factor_id
        WHERE $where|;
   $form->{item_list} = selectall_hashref_query($form, $dbh, $query, @values);
 
index 3a34b2b..d75436c 100644 (file)
@@ -1586,9 +1586,9 @@ sub assembly_row {
     $form->{"partnumber_$i"} =~ s/\"/&quot;/g;
 
     $linetotal =
-      $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
+      $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / ($form->{"price_factor_$i"} || 1), 2);
     $line_purchase_price  =
-      $form->round_amount($form->{"lastcost_$i"} * $form->{"qty_$i"}, 2); #lastcost == purchase_price | ungenaue datenbankfeld-übersetzung
+      $form->round_amount($form->{"lastcost_$i"} * $form->{"qty_$i"} / ($form->{"price_factor_$i"} || 1), 2); #lastcost == purchase_price | ungenaue datenbankfeld-übersetzung
     $form->{assemblytotal} += $linetotal;
     $form->{assembly_purchase_price_total}  += $line_purchase_price;
 
@@ -1672,6 +1672,8 @@ sub assembly_row {
   <input type=hidden name="id_$i" value=$form->{"id_$i"}>
   <input type=hidden name="sellprice_$i" value=$form->{"sellprice_$i"}>
   <input type=hidden name="weight_$i" value=$form->{"weight_$i"}>
+  <input type=hidden name="price_factor_id_$i" value=$form->{"price_factor_id_$i"}>
+  <input type=hidden name="price_factor_$i" value=$form->{"price_factor_$i"}>
 |;
   }