Revision fd041aff
Von Kivitendo Admin vor fast 10 Jahren hinzugefügt
bin/mozilla/ic.pl | ||
---|---|---|
1787 | 1787 |
|
1788 | 1788 |
$auth->assert('part_service_assembly_edit'); |
1789 | 1789 |
|
1790 |
# update checks whether pricegroups, makemodels or assembly items have been changed/added |
|
1791 |
# new items might have been added (and the original form might have been stored and restored) |
|
1792 |
# so at the end the ic form is run through check_form in io.pl |
|
1793 |
# The various combination of events can lead to problems with the order of parse_amount and format_amount |
|
1794 |
# Currently check_form parses some variables in assembly mode, but not in article or service mode |
|
1795 |
# This will only ever really be sanely resolved with a rewrite... |
|
1796 |
|
|
1790 | 1797 |
# parse pricegroups. and no, don't rely on check_form for this... |
1791 | 1798 |
map { $form->{"price_$_"} = $form->parse_amount(\%myconfig, $form->{"price_$_"}) } 1 .. $form->{price_rows}; |
1792 |
$form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(sellprice listprice ve gv); |
|
1799 |
|
|
1800 |
unless ($form->{item} eq 'assembly') { |
|
1801 |
# for assemblies check_form will parse sellprice and listprice, but not for parts or services |
|
1802 |
$form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(sellprice listprice ve gv); |
|
1803 |
}; |
|
1793 | 1804 |
|
1794 | 1805 |
if ($form->{item} eq 'part') { |
1795 | 1806 |
$form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(weight rop); |
... | ... | |
1809 | 1820 |
if ( ($form->{"partnumber_$i"} eq "") |
1810 | 1821 |
&& ($form->{"description_$i"} eq "") |
1811 | 1822 |
&& ($form->{"partsgroup_$i"} eq "")) { |
1823 |
# no new assembly item was added |
|
1812 | 1824 |
|
1813 | 1825 |
&check_form; |
1814 | 1826 |
|
1815 | 1827 |
} else { |
1816 |
|
|
1828 |
# search db for newly added assemblyitems, via partnumber or description |
|
1817 | 1829 |
IC->assembly_item(\%myconfig, \%$form); |
1818 | 1830 |
|
1831 |
# form->{item_list} contains the possible matches, next check whether the |
|
1832 |
# match is unique or we need to call the page to select the item |
|
1819 | 1833 |
my $rows = scalar @{ $form->{item_list} }; |
1820 | 1834 |
|
1821 | 1835 |
if ($rows) { |
bin/mozilla/io.pl | ||
---|---|---|
509 | 509 |
print $::form->parse_html_template('io/select_item', { PREVIOUS_FORM => $previous_form, |
510 | 510 |
MODE => $mode, |
511 | 511 |
ITEM_LIST => \@item_list, |
512 |
IS_ASSEMBLY => $mode eq 'IC', |
|
512 | 513 |
IS_PURCHASE => $mode eq 'IS' }); |
513 | 514 |
|
514 | 515 |
$main::lxdebug->leave_sub(); |
515 | 516 |
} |
516 | 517 |
|
517 | 518 |
sub item_selected { |
519 |
|
|
520 |
# this function is used for adding parts to records (mode = IR/IS) |
|
521 |
# and to assemblies (mode = IC) |
|
522 |
|
|
518 | 523 |
$main::lxdebug->enter_sub(); |
519 | 524 |
|
520 | 525 |
my $form = $main::form; |
... | ... | |
528 | 533 |
my $id = delete($form->{select_item_id}) || croak 'Missing item selection ID'; |
529 | 534 |
my $i = $form->{ $mode eq 'IC' ? 'assembly_rows' : 'rowcount' }; |
530 | 535 |
|
536 |
if ( $mode eq 'IC' ) { |
|
537 |
# assembly mode: |
|
538 |
# the qty variables of the existing assembly items are all still formatted, so we parse them here (1 .. $i-1) |
|
539 |
# including the qty of the just added part ($i) |
|
540 |
$form->{"qty_$_"} = $form->parse_amount(\%myconfig, $form->{"qty_$_"}) for (1 .. $i); |
|
541 |
}; |
|
542 |
|
|
531 | 543 |
$form->{"id_${i}"} = $id; |
532 | 544 |
|
533 | 545 |
if ($mode eq 'IS') { |
... | ... | |
598 | 610 |
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } |
599 | 611 |
qw(sellprice listprice weight); |
600 | 612 |
|
613 |
# at this stage qty of newly added part needs to be have been parsed |
|
601 | 614 |
$form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"}); |
602 | 615 |
|
603 | 616 |
if ($form->{"not_discountable_$i"}) { |
Auch abrufbar als: Unified diff
Ticket #42 - Nachkommastellen in Menge bei Erzeugniskomponenten
Danke an Joachim Zach für einen Patch, ich habe bei der Gelegenheit auch
noch ein paar Codestellen kommentiert. Das Verhalten von item_selected
bzgl. parse/format_amount unterscheidet sich mittlerweile je nachdem, ob
es in Belegen oder in Erzeugnissen verwendet wird.