Revision 1e251313
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
121 | 121 |
my $service_units = AM->retrieve_units(\%myconfig, $form, "service"); |
122 | 122 |
my $all_units = AM->retrieve_units(\%myconfig, $form); |
123 | 123 |
|
124 |
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
125 |
|
|
124 | 126 |
push @column_index, qw(unit); |
125 | 127 |
|
126 | 128 |
#for pricegroups column |
... | ... | |
303 | 305 |
($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); |
304 | 306 |
$decimalplaces = max length($dec), 2; |
305 | 307 |
|
306 |
$discount = (100 - $form->{"discount_$i"} * 1) / 100; |
|
307 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount, $decimalplaces); |
|
308 |
$price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1; |
|
309 |
$discount = (100 - $form->{"discount_$i"} * 1) / 100; |
|
310 |
|
|
311 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount / $price_factor, $decimalplaces); |
|
308 | 312 |
|
309 |
my $real_sellprice = $form->{"sellprice_$i"} * $discount; |
|
313 |
my $real_sellprice = $form->{"sellprice_$i"} * $discount / $price_factor;
|
|
310 | 314 |
|
311 | 315 |
# marge calculations |
312 | 316 |
my ($marge_font_start, $marge_font_end); |
313 | 317 |
|
314 | 318 |
$form->{"lastcost_$i"} *= 1; |
315 | 319 |
|
320 |
$marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1; |
|
321 |
|
|
316 | 322 |
if ($real_sellprice && ($form->{"qty_$i"} * 1)) { |
317 |
$form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"}) * 100 / $real_sellprice; |
|
323 |
$form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice;
|
|
318 | 324 |
$myconfig{"marge_percent_warn"} = 15 unless (defined($myconfig{"marge_percent_warn"})); |
319 | 325 |
|
320 | 326 |
if ($form->{"id_$i"} && |
... | ... | |
328 | 334 |
} |
329 | 335 |
|
330 | 336 |
my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1; |
331 |
$form->{"marge_absolut_$i"} = ($real_sellprice - $form->{"lastcost_$i"}) * $form->{"qty_$i"} * $marge_adjust_credit_note; |
|
337 |
$form->{"marge_absolut_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note;
|
|
332 | 338 |
$form->{"marge_total"} += $form->{"marge_absolut_$i"}; |
333 |
$form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"}; |
|
339 |
$form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor;
|
|
334 | 340 |
$form->{"sellprice_total"} += $real_sellprice * $form->{"qty_$i"}; |
335 | 341 |
|
336 | 342 |
map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent); |
... | ... | |
387 | 393 |
$this_unit = "kg"; |
388 | 394 |
} |
389 | 395 |
|
396 |
my $price_factor_select; |
|
397 |
if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) { |
|
398 |
my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} }); |
|
399 |
my %labels = map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
400 |
|
|
401 |
$price_factor_select = |
|
402 |
NTI($cgi->popup_menu('-name' => "price_factor_id_$i", |
|
403 |
'-default' => $form->{"price_factor_id_$i"}, |
|
404 |
'-values' => \@values, |
|
405 |
'-labels' => \%labels, |
|
406 |
'-style' => 'width:90px')) |
|
407 |
. ' '; |
|
408 |
} |
|
409 |
|
|
390 | 410 |
$column_data{"unit"} = "<td>" . |
411 |
$price_factor_select . |
|
391 | 412 |
AM->unit_select_html($is_part || $is_assembly ? $dimension_units : |
392 | 413 |
$is_assigned ? $service_units : $all_units, |
393 | 414 |
"unit_$i", $this_unit, |
... | ... | |
474 | 495 |
"id_$i", "inventory_accno_$i", "bin_$i", "partsgroup_$i", "partnotes_$i", |
475 | 496 |
"income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i", |
476 | 497 |
"taxaccounts_$i", "ordnumber_$i", "transdate_$i", "cusordnumber_$i", |
477 |
"longdescription_$i", "basefactor_$i", "marge_absolut_$i", "marge_percent_$i", "lastcost_$i")); |
|
498 |
"longdescription_$i", "basefactor_$i", "marge_absolut_$i", "marge_percent_$i", "lastcost_$i", |
|
499 |
"marge_price_factor_$i")); |
|
478 | 500 |
|
479 | 501 |
######################################## |
480 | 502 |
# Eintrag fuer Version 2.2.0 geaendert # |
... | ... | |
530 | 552 |
|; |
531 | 553 |
|
532 | 554 |
if ($form->{"id_$i"} && $is_sales) { |
555 |
my $marge_price_factor; |
|
556 |
|
|
557 |
$form->{"marge_price_factor_$i"} *= 1; |
|
558 |
|
|
559 |
if ($form->{"marge_price_factor_$i"} && (1 != $form->{"marge_price_factor_$i"})) { |
|
560 |
$marge_price_factor = '/' . $form->format_amount(\%myconfig, $form->{"marge_price_factor_$i"}); |
|
561 |
} |
|
562 |
|
|
533 | 563 |
print qq| |
534 |
${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b> $form->{"marge_absolut_$i"} $form->{"marge_percent_$i"} % ${marge_font_end}
|
|
564 |
${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b> $form->{"marge_absolut_$i"} $form->{"marge_percent_$i"} % ${marge_font_end} |
|
535 | 565 |
<b>| . $locale->text('LP') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq| |
536 |
<b>| . $locale->text('EK') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2); |
|
566 |
<b>| . $locale->text('EK') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) . $marge_price_factor;
|
|
537 | 567 |
} |
538 | 568 |
|
539 | 569 |
print qq| |
... | ... | |
695 | 725 |
my @new_fields = |
696 | 726 |
qw(bin listprice inventory_accno income_accno expense_accno unit weight |
697 | 727 |
assembly taxaccounts partsgroup formel longdescription not_discountable |
698 |
part_payment_id partnotes id lastcost); |
|
728 |
part_payment_id partnotes id lastcost price_factor_id price_factor);
|
|
699 | 729 |
push(@new_fields, "lizenzen") if ($lizenzen); |
700 | 730 |
|
701 | 731 |
print join "\n", map { $cgi->hidden("-name" => "new_${_}_$i", "-value" => $ref->{$_}) } @new_fields; |
... | ... | |
751 | 781 |
# if there was a price entered, override it |
752 | 782 |
$sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); |
753 | 783 |
|
754 |
map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
|
|
784 |
my @new_fields =
|
|
755 | 785 |
qw(id partnumber description sellprice listprice inventory_accno |
756 | 786 |
income_accno expense_accno bin unit weight assembly taxaccounts |
757 |
partsgroup formel longdescription not_discountable partnotes lastcost); |
|
787 |
partsgroup formel longdescription not_discountable partnotes lastcost |
|
788 |
price_factor_id price_factor); |
|
789 |
|
|
790 |
map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } @new_fields; |
|
791 |
|
|
792 |
$form->{"marge_price_factor_$i"} = $form->{"new_price_factor_$j"}; |
|
793 |
|
|
758 | 794 |
if ($form->{"part_payment_id_$i"} ne "") { |
759 | 795 |
$form->{payment_id} = $form->{"part_payment_id_$i"}; |
760 | 796 |
} |
... | ... | |
804 | 840 |
|
805 | 841 |
# delete all the new_ variables |
806 | 842 |
for $i (1 .. $form->{lastndx}) { |
807 |
map { delete $form->{"new_${_}_$i"} } |
|
808 |
qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id); |
|
843 |
map { delete $form->{"new_${_}_$i"} } @new_fields; |
|
809 | 844 |
} |
810 | 845 |
|
811 | 846 |
map { delete $form->{$_} } qw(ndx lastndx nextsub); |
... | ... | |
871 | 906 |
|
872 | 907 |
print $cgi->hidden("-name" => "previousform", "-value" => $previousform); |
873 | 908 |
map { print $cgi->hidden("-name" => $_, "-value" => $form->{$_}); } qw(rowcount vc login password); |
874 |
map { print $cgi->hidden("-name" => $_, "-value" => $form->{"${_}_$i"}); } qw(partnumber description unit sellprice); |
|
909 |
map { print $cgi->hidden("-name" => $_, "-value" => $form->{"${_}_$i"}); } qw(partnumber description unit sellprice price_factor_id);
|
|
875 | 910 |
print $cgi->hidden("-name" => "taxaccount2", "-value" => $form->{taxaccounts}); |
876 | 911 |
|
877 | 912 |
print qq| |
... | ... | |
992 | 1027 |
$lxdebug->enter_sub(); |
993 | 1028 |
my @a = (); |
994 | 1029 |
my $count = 0; |
995 |
my @flds = ( |
|
996 |
qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor marge_absolut marge_percent lastcost ) |
|
997 |
); |
|
998 |
|
|
1030 |
my @flds = (qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor marge_absolut marge_percent marge_price_factor lastcost price_factor_id)); |
|
999 | 1031 |
|
1000 | 1032 |
# remove any makes or model rows |
1001 | 1033 |
if ($form->{item} eq 'part') { |
... | ... | |
1796 | 1828 |
} keys(%{$form}))); |
1797 | 1829 |
|
1798 | 1830 |
reformat_numbers($output_numberformat, undef, |
1799 |
qw(qty), |
|
1831 |
qw(qty price_factor),
|
|
1800 | 1832 |
grep({ /^qty_\d+$/ |
1801 | 1833 |
} keys(%{$form}))); |
1802 | 1834 |
|
Auch abrufbar als: Unified diff
Preisfatkoren implementiert.