Revision 1e251313
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
82 | 82 |
my $q_item_unit = qq|SELECT unit FROM parts WHERE id = ?|; |
83 | 83 |
my $h_item_unit = prepare_query($form, $dbh, $q_item_unit); |
84 | 84 |
|
85 |
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); |
|
86 |
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
87 |
my $price_factor; |
|
88 |
|
|
85 | 89 |
for my $i (1 .. $form->{rowcount}) { |
86 | 90 |
next unless $form->{"id_$i"}; |
87 | 91 |
|
... | ... | |
119 | 123 |
|
120 | 124 |
map { $taxrate += $form->{"${_}_rate"} } @taxaccounts; |
121 | 125 |
|
126 |
$price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1; |
|
127 |
|
|
122 | 128 |
if ($form->{"inventory_accno_$i"}) { |
123 | 129 |
|
124 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2); |
|
130 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
|
|
125 | 131 |
|
126 | 132 |
if ($form->{taxincluded}) { |
127 | 133 |
$taxamount = $linetotal * ($taxrate / (1 + $taxrate)); |
... | ... | |
151 | 157 |
} |
152 | 158 |
|
153 | 159 |
# add purchase to inventory, this one is without the tax! |
154 |
$amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate}; |
|
155 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2) * $form->{exchangerate}; |
|
160 |
$amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate} / $price_factor;
|
|
161 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2) * $form->{exchangerate};
|
|
156 | 162 |
$linetotal = $form->round_amount($linetotal, 2); |
157 | 163 |
|
158 | 164 |
# this is the difference for the inventory |
... | ... | |
230 | 236 |
|
231 | 237 |
$sth->finish(); |
232 | 238 |
|
233 |
} else { |
|
239 |
} else { # if ($form->{"inventory_accno_id_$i"})
|
|
234 | 240 |
|
235 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2); |
|
241 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
|
|
236 | 242 |
|
237 | 243 |
if ($form->{taxincluded}) { |
238 | 244 |
$taxamount = $linetotal * ($taxrate / (1 + $taxrate)); |
... | ... | |
258 | 264 |
map { $form->{amount}{ $form->{id} }{$_} -= $taxamount * $form->{"${_}_rate"} / $taxrate } @taxaccounts; |
259 | 265 |
} |
260 | 266 |
|
261 |
$amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate}; |
|
262 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2) * $form->{exchangerate}; |
|
267 |
$amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate} / $price_factor;
|
|
268 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2) * $form->{exchangerate};
|
|
263 | 269 |
$linetotal = $form->round_amount($linetotal, 2); |
264 | 270 |
|
265 | 271 |
# this is the difference for expense |
... | ... | |
286 | 292 |
$query = |
287 | 293 |
qq|INSERT INTO invoice (trans_id, parts_id, description, qty, base_qty, |
288 | 294 |
sellprice, fxsellprice, allocated, unit, deliverydate, |
289 |
project_id, serialnumber) |
|
290 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; |
|
295 |
project_id, serialnumber, price_factor_id, price_factor, marge_price_factor)
|
|
296 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|;
|
|
291 | 297 |
@values = (conv_i($form->{id}), conv_i($form->{"id_$i"}), |
292 | 298 |
$form->{"description_$i"}, $form->{"qty_$i"} * -1, |
293 | 299 |
$baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $allocated, |
294 | 300 |
$form->{"unit_$i"}, conv_date($form->{deliverydate}), |
295 |
conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"}); |
|
301 |
conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"}, |
|
302 |
conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"marge_price_factor_$i"})); |
|
296 | 303 |
do_query($form, $dbh, $query, @values); |
297 | 304 |
} |
298 | 305 |
|
... | ... | |
728 | 735 |
c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid, |
729 | 736 |
|
730 | 737 |
i.description, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber, |
731 |
p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup |
|
738 |
i.price_factor_id, i.price_factor, i.marge_price_factor, |
|
739 |
p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup |
|
732 | 740 |
|
733 | 741 |
FROM invoice i |
734 | 742 |
JOIN parts p ON (i.parts_id = p.id) |
... | ... | |
947 | 955 |
p.id, p.partnumber, p.description, p.lastcost AS sellprice, p.listprice, |
948 | 956 |
p.unit, p.assembly, p.bin, p.onhand, p.formel, |
949 | 957 |
p.notes AS partnotes, p.notes AS longdescription, p.not_discountable, |
950 |
p.inventory_accno_id, |
|
958 |
p.inventory_accno_id, p.price_factor_id, |
|
959 |
|
|
960 |
pfac.factor AS price_factor, |
|
951 | 961 |
|
952 | 962 |
c1.accno AS inventory_accno, |
953 | 963 |
c1.new_chart_id AS inventory_new_chart, |
... | ... | |
977 | 987 |
FROM buchungsgruppen |
978 | 988 |
WHERE id = p.buchungsgruppen_id) = c3.id) |
979 | 989 |
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id) |
990 |
LEFT JOIN price_factors pfac ON (pfac.id = p.price_factor_id) |
|
980 | 991 |
WHERE $where|; |
981 | 992 |
my $sth = prepare_execute_query($form, $dbh, $query, @values); |
982 | 993 |
|
Auch abrufbar als: Unified diff
Preisfatkoren implementiert.