Revision 1e251313
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
SL/OE.pm | ||
---|---|---|
230 | 230 |
my %taxaccounts; |
231 | 231 |
my $netamount = 0; |
232 | 232 |
|
233 |
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); |
|
234 |
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
235 |
my $price_factor; |
|
236 |
|
|
233 | 237 |
for my $i (1 .. $form->{rowcount}) { |
234 | 238 |
|
235 | 239 |
map({ $form->{"${_}_$i"} = |
... | ... | |
275 | 279 |
$form->{"inventory_accno_$i"} *= 1; |
276 | 280 |
$form->{"expense_accno_$i"} *= 1; |
277 | 281 |
|
278 |
$linetotal =
|
|
279 |
$form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
|
|
282 |
$price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
|
|
283 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
|
|
280 | 284 |
|
281 | 285 |
@taxaccounts = split(/ /, $form->{"taxaccounts_$i"}); |
282 | 286 |
$taxrate = 0; |
... | ... | |
324 | 328 |
} |
325 | 329 |
} |
326 | 330 |
|
327 |
$netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"}; |
|
331 |
$netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor;
|
|
328 | 332 |
|
329 | 333 |
$reqdate = |
330 | 334 |
($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef; |
... | ... | |
342 | 346 |
$query .= qq|trans_id, parts_id, description, longdescription, qty, base_qty, | . |
343 | 347 |
qq|sellprice, discount, unit, reqdate, project_id, serialnumber, ship, | . |
344 | 348 |
qq|pricegroup_id, ordnumber, transdate, cusordnumber, subtotal, | . |
345 |
qq|marge_percent, marge_total, lastcost) | . |
|
349 |
qq|marge_percent, marge_total, lastcost, price_factor_id, price_factor, marge_price_factor) | .
|
|
346 | 350 |
qq|VALUES (|; |
347 | 351 |
if($form->{"orderitems_id_$i"}) { |
348 | 352 |
$query .= qq|?,|; |
349 | 353 |
push(@values, $form->{"orderitems_id_$i"}); |
350 | 354 |
} |
351 |
$query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; |
|
355 |
$query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, |
|
356 |
(SELECT factor FROM price_factors WHERE id = ?), ?)|; |
|
352 | 357 |
push(@values, |
353 | 358 |
conv_i($form->{id}), conv_i($form->{"id_$i"}), |
354 | 359 |
$form->{"description_$i"}, $form->{"longdescription_$i"}, |
... | ... | |
359 | 364 |
$form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}), |
360 | 365 |
$form->{"cusordnumber_$i"}, $form->{"subtotal_$i"} ? 't' : 'f', |
361 | 366 |
$form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"}, |
362 |
$form->{"lastcost_$i"}); |
|
367 |
$form->{"lastcost_$i"}, |
|
368 |
conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), |
|
369 |
conv_i($form->{"marge_price_factor_$i"})); |
|
363 | 370 |
do_query($form, $dbh, $query, @values); |
364 | 371 |
|
365 | 372 |
$form->{"sellprice_$i"} = $fxsellprice; |
... | ... | |
724 | 731 |
o.sellprice, o.parts_id AS id, o.unit, o.discount, p.bin, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, |
725 | 732 |
o.reqdate, o.project_id, o.serialnumber, o.ship, o.lastcost, |
726 | 733 |
o.ordnumber, o.transdate, o.cusordnumber, o.subtotal, o.longdescription, |
734 |
o.price_factor_id, o.price_factor, o.marge_price_factor, |
|
727 | 735 |
pr.projectnumber, p.formel, |
728 | 736 |
pg.partsgroup, o.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=o.pricegroup_id) as pricegroup |
729 | 737 |
FROM orderitems o |
... | ... | |
873 | 881 |
|
874 | 882 |
push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); |
875 | 883 |
|
884 |
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); |
|
885 |
my %price_factors; |
|
886 |
|
|
887 |
foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) { |
|
888 |
$price_factors{$pfac->{id}} = $pfac; |
|
889 |
$pfac->{factor} *= 1; |
|
890 |
$pfac->{formatted_factor} = $form->format_amount($myconfig, $pfac->{factor}); |
|
891 |
} |
|
892 |
|
|
876 | 893 |
# sort items by partsgroup |
877 | 894 |
for $i (1 .. $form->{rowcount}) { |
878 | 895 |
$partsgroup = ""; |
... | ... | |
900 | 917 |
qw(runningnumber number description longdescription qty ship unit bin |
901 | 918 |
partnotes serialnumber reqdate sellprice listprice netprice |
902 | 919 |
discount p_discount discount_sub nodiscount_sub |
903 |
linetotal nodiscount_linetotal tax_rate projectnumber); |
|
920 |
linetotal nodiscount_linetotal tax_rate projectnumber |
|
921 |
price_factor price_factor_name); |
|
904 | 922 |
|
905 | 923 |
my $sameitem = ""; |
906 | 924 |
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) { |
... | ... | |
933 | 951 |
$position++; |
934 | 952 |
} |
935 | 953 |
|
936 |
push @{ $form->{runningnumber} }, $position; |
|
937 |
push @{ $form->{number} }, $form->{"partnumber_$i"}; |
|
938 |
push @{ $form->{description} }, $form->{"description_$i"}; |
|
939 |
push @{ $form->{longdescription} }, $form->{"longdescription_$i"}; |
|
940 |
push @{ $form->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); |
|
941 |
push @{ $form->{ship} }, $form->format_amount($myconfig, $form->{"ship_$i"}); |
|
942 |
push @{ $form->{unit} }, $form->{"unit_$i"}; |
|
943 |
push @{ $form->{bin} }, $form->{"bin_$i"}; |
|
944 |
push @{ $form->{partnotes} }, $form->{"partnotes_$i"}; |
|
945 |
push @{ $form->{serialnumber} }, $form->{"serialnumber_$i"}; |
|
946 |
push @{ $form->{reqdate} }, $form->{"reqdate_$i"}; |
|
947 |
push @{ $form->{sellprice} }, $form->{"sellprice_$i"}; |
|
948 |
push @{ $form->{listprice} }, $form->{"listprice_$i"}; |
|
954 |
my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 }; |
|
955 |
|
|
956 |
push @{ $form->{runningnumber} }, $position; |
|
957 |
push @{ $form->{number} }, $form->{"partnumber_$i"}; |
|
958 |
push @{ $form->{description} }, $form->{"description_$i"}; |
|
959 |
push @{ $form->{longdescription} }, $form->{"longdescription_$i"}; |
|
960 |
push @{ $form->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); |
|
961 |
push @{ $form->{ship} }, $form->format_amount($myconfig, $form->{"ship_$i"}); |
|
962 |
push @{ $form->{unit} }, $form->{"unit_$i"}; |
|
963 |
push @{ $form->{bin} }, $form->{"bin_$i"}; |
|
964 |
push @{ $form->{partnotes} }, $form->{"partnotes_$i"}; |
|
965 |
push @{ $form->{serialnumber} }, $form->{"serialnumber_$i"}; |
|
966 |
push @{ $form->{reqdate} }, $form->{"reqdate_$i"}; |
|
967 |
push @{ $form->{sellprice} }, $form->{"sellprice_$i"}; |
|
968 |
push @{ $form->{listprice} }, $form->{"listprice_$i"}; |
|
969 |
push @{ $form->{price_factor} }, $price_factor->{formatted_factor}; |
|
970 |
push @{ $form->{price_factor_name} }, $price_factor->{description}; |
|
949 | 971 |
|
950 | 972 |
my $sellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); |
951 | 973 |
my ($dec) = ($sellprice =~ /\.(\d+)/); |
952 | 974 |
my $decimalplaces = max 2, length($dec); |
953 | 975 |
|
954 |
my $discount = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100, $decimalplaces); |
|
955 |
my $linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100, 2); |
|
956 |
my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice, 2); |
|
976 |
my $discount = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100 / $price_factor->{factor}, $decimalplaces);
|
|
977 |
my $linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100 / $price_factor->{factor}, 2);
|
|
978 |
my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2);
|
|
957 | 979 |
$form->{"netprice_$i"} = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2); |
958 | 980 |
|
959 | 981 |
push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : ''; |
Auch abrufbar als: Unified diff
Preisfatkoren implementiert.