Revision 1e251313
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
60 | 60 |
|
61 | 61 |
push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); |
62 | 62 |
|
63 |
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); |
|
64 |
my %price_factors; |
|
65 |
|
|
66 |
foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) { |
|
67 |
$price_factors{$pfac->{id}} = $pfac; |
|
68 |
$pfac->{factor} *= 1; |
|
69 |
$pfac->{formatted_factor} = $form->format_amount($myconfig, $pfac->{factor}); |
|
70 |
} |
|
71 |
|
|
63 | 72 |
# sort items by partsgroup |
64 | 73 |
for $i (1 .. $form->{rowcount}) { |
65 | 74 |
$partsgroup = ""; |
... | ... | |
123 | 132 |
deliverydate_oe ordnumber_oe transdate_oe licensenumber validuntil |
124 | 133 |
partnotes serialnumber reqdate sellprice listprice netprice |
125 | 134 |
discount p_discount discount_sub nodiscount_sub |
126 |
linetotal nodiscount_linetotal tax_rate projectnumber); |
|
135 |
linetotal nodiscount_linetotal tax_rate projectnumber |
|
136 |
price_factor price_factor_name); |
|
127 | 137 |
|
128 | 138 |
my @tax_arrays = |
129 | 139 |
qw(taxbase tax taxdescription taxrate taxnumber); |
... | ... | |
157 | 167 |
$position++; |
158 | 168 |
} |
159 | 169 |
|
160 |
push @{ $form->{runningnumber} }, $position; |
|
161 |
push @{ $form->{number} }, $form->{"partnumber_$i"}; |
|
162 |
push @{ $form->{serialnumber} }, $form->{"serialnumber_$i"}; |
|
163 |
push @{ $form->{bin} }, $form->{"bin_$i"}; |
|
164 |
push @{ $form->{"partnotes"} }, $form->{"partnotes_$i"}; |
|
165 |
push @{ $form->{description} }, $form->{"description_$i"}; |
|
166 |
push @{ $form->{longdescription} }, $form->{"longdescription_$i"}; |
|
167 |
push @{ $form->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); |
|
168 |
push @{ $form->{unit} }, $form->{"unit_$i"}; |
|
169 |
push @{ $form->{deliverydate_oe} }, $form->{"deliverydate_$i"}; |
|
170 |
push @{ $form->{sellprice} }, $form->{"sellprice_$i"}; |
|
171 |
push @{ $form->{ordnumber_oe} }, $form->{"ordnumber_$i"}; |
|
172 |
push @{ $form->{transdate_oe} }, $form->{"transdate_$i"}; |
|
173 |
push @{ $form->{invnumber} }, $form->{"invnumber"}; |
|
174 |
push @{ $form->{invdate} }, $form->{"invdate"}; |
|
170 |
my $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || { 'factor' => 1 }; |
|
171 |
|
|
172 |
push @{ $form->{runningnumber} }, $position; |
|
173 |
push @{ $form->{number} }, $form->{"partnumber_$i"}; |
|
174 |
push @{ $form->{serialnumber} }, $form->{"serialnumber_$i"}; |
|
175 |
push @{ $form->{bin} }, $form->{"bin_$i"}; |
|
176 |
push @{ $form->{"partnotes"} }, $form->{"partnotes_$i"}; |
|
177 |
push @{ $form->{description} }, $form->{"description_$i"}; |
|
178 |
push @{ $form->{longdescription} }, $form->{"longdescription_$i"}; |
|
179 |
push @{ $form->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); |
|
180 |
push @{ $form->{unit} }, $form->{"unit_$i"}; |
|
181 |
push @{ $form->{deliverydate_oe} }, $form->{"deliverydate_$i"}; |
|
182 |
push @{ $form->{sellprice} }, $form->{"sellprice_$i"}; |
|
183 |
push @{ $form->{ordnumber_oe} }, $form->{"ordnumber_$i"}; |
|
184 |
push @{ $form->{transdate_oe} }, $form->{"transdate_$i"}; |
|
185 |
push @{ $form->{invnumber} }, $form->{"invnumber"}; |
|
186 |
push @{ $form->{invdate} }, $form->{"invdate"}; |
|
187 |
push @{ $form->{price_factor} }, $price_factor->{formatted_factor}; |
|
188 |
push @{ $form->{price_factor_name} }, $price_factor->{description}; |
|
175 | 189 |
|
176 | 190 |
if ($form->{lizenzen}) { |
177 | 191 |
if ($form->{"licensenumber_$i"}) { |
... | ... | |
193 | 207 |
my ($dec) = ($sellprice =~ /\.(\d+)/); |
194 | 208 |
my $decimalplaces = max 2, length($dec); |
195 | 209 |
|
196 |
my $discount = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100, $decimalplaces); |
|
197 |
my $linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100, 2); |
|
198 |
my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice, 2); |
|
210 |
my $discount = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100 / $price_factor->{factor}, $decimalplaces);
|
|
211 |
my $linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100 / $price_factor->{factor}, 2);
|
|
212 |
my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2);
|
|
199 | 213 |
$form->{"netprice_$i"} = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2); |
200 | 214 |
|
201 | 215 |
push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : ''; |
... | ... | |
517 | 531 |
|
518 | 532 |
my %baseunits; |
519 | 533 |
|
534 |
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); |
|
535 |
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
536 |
my $price_factor; |
|
537 |
|
|
520 | 538 |
foreach my $i (1 .. $form->{rowcount}) { |
521 | 539 |
if ($form->{type} eq "credit_note") { |
522 | 540 |
$form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}) * -1; |
... | ... | |
577 | 595 |
$form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"}); |
578 | 596 |
|
579 | 597 |
# round linetotal to 2 decimal places |
580 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2); |
|
598 |
$price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1; |
|
599 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2); |
|
581 | 600 |
|
582 | 601 |
if ($form->{taxincluded}) { |
583 | 602 |
$taxamount = $linetotal * ($taxrate / (1 + $taxrate)); |
... | ... | |
597 | 616 |
} |
598 | 617 |
|
599 | 618 |
# add amount to income, $form->{amount}{trans_id}{accno} |
600 |
$amount = |
|
601 |
$form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate}; |
|
619 |
$amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * $form->{exchangerate} / $price_factor; |
|
602 | 620 |
|
603 |
$linetotal = |
|
604 |
$form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2) * |
|
605 |
$form->{exchangerate}; |
|
621 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2) * $form->{exchangerate}; |
|
606 | 622 |
$linetotal = $form->round_amount($linetotal, 2); |
607 | 623 |
|
608 | 624 |
# this is the difference from the inventory |
... | ... | |
662 | 678 |
sellprice, fxsellprice, discount, allocated, assemblyitem, |
663 | 679 |
unit, deliverydate, project_id, serialnumber, pricegroup_id, |
664 | 680 |
ordnumber, transdate, cusordnumber, base_qty, subtotal, |
665 |
marge_percent, marge_total, lastcost) |
|
666 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; |
|
681 |
marge_percent, marge_total, lastcost, |
|
682 |
price_factor_id, price_factor, marge_price_factor) |
|
683 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, |
|
684 |
(SELECT factor FROM price_factors WHERE id = ?), ?)|; |
|
667 | 685 |
|
668 | 686 |
@values = (conv_i($form->{id}), conv_i($form->{"id_$i"}), |
669 | 687 |
$form->{"description_$i"}, $form->{"longdescription_$i"}, $form->{"qty_$i"}, |
... | ... | |
674 | 692 |
$form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}), |
675 | 693 |
$form->{"cusordnumber_$i"}, $baseqty, $form->{"subtotal_$i"} ? 't' : 'f', |
676 | 694 |
$form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"}, |
677 |
$form->{"lastcost_$i"}); |
|
695 |
$form->{"lastcost_$i"}, |
|
696 |
conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), |
|
697 |
conv_i($form->{"marge_price_factor_$i"})); |
|
678 | 698 |
do_query($form, $dbh, $query, @values); |
679 | 699 |
|
680 | 700 |
if ($form->{lizenzen} && $form->{"licensenumber_$i"}) { |
... | ... | |
1387 | 1407 |
|
1388 | 1408 |
i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.discount, i.parts_id AS id, i.unit, i.deliverydate, |
1389 | 1409 |
i.project_id, i.serialnumber, i.id AS invoice_pos, i.pricegroup_id, i.ordnumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost, |
1410 |
i.price_factor_id, i.price_factor, i.marge_price_factor, |
|
1390 | 1411 |
p.partnumber, p.assembly, p.bin, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, p.formel, |
1391 | 1412 |
pr.projectnumber, pg.partsgroup, prg.pricegroup |
1392 | 1413 |
|
... | ... | |
1687 | 1708 |
p.unit, p.assembly, p.bin, p.onhand, |
1688 | 1709 |
p.notes AS partnotes, p.notes AS longdescription, |
1689 | 1710 |
p.not_discountable, p.formel, p.payment_id AS part_payment_id, |
1711 |
p.price_factor_id, |
|
1712 |
|
|
1713 |
pfac.factor AS price_factor, |
|
1690 | 1714 |
|
1691 | 1715 |
pg.partsgroup |
1692 | 1716 |
|
... | ... | |
1704 | 1728 |
FROM buchungsgruppen |
1705 | 1729 |
WHERE id = p.buchungsgruppen_id) = c3.id) |
1706 | 1730 |
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id) |
1731 |
LEFT JOIN price_factors pfac ON (pfac.id = p.price_factor_id) |
|
1707 | 1732 |
WHERE $where|; |
1708 | 1733 |
my $sth = prepare_execute_query($form, $dbh, $query, @values); |
1709 | 1734 |
|
Auch abrufbar als: Unified diff
Preisfatkoren implementiert.