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);
$form->{"partnumber_$i"} =~ s/\"/"/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;
<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"}>
|;
}