X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fic.pl;h=28d41f3b3928c0aaac41a001517a5b4fe21ca44f;hb=b6133a726fa261cb97f2c105ea4a93161609d6ca;hp=86bddaa70deaa6a350c81959e381f76bebfc2dac;hpb=957896de327365e3d83e3f0d6525af02849c483d;p=kivitendo-erp.git diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 86bddaa70..28d41f3b3 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -2931,8 +2931,7 @@ sub save { $form->{weight} -= $form->{"weight_$i"} * $form->{"qty_$i"}; # change/add values for assembly item - map { $form->{"${_}_$i"} = $newform{$_} } - qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno); + map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno price_factor_id); $form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"}; $form->{weight} += $form->{"weight_$i"} * $form->{"qty_$i"}; @@ -2943,15 +2942,17 @@ sub save { $i = $form->{rowcount}; $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"}); - map { $form->{"${_}_$i"} = $newform{$_} } - qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice); + map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice lastcost price_factor_id); + $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id}); + if ($form->{exchangerate} != 0) { $form->{"sellprice_$i"} /= $form->{exchangerate}; } + $lxdebug->message($LXDebug::DEBUG1, qq|sellprice_$i in previousform 2 = | . $form->{"sellprice_$i"} . qq|\n|); - map { $form->{"taxaccounts_$i"} .= "$_ " } split / /, - $newform{taxaccount}; + + map { $form->{"taxaccounts_$i"} .= "$_ " } split / /, $newform{taxaccount}; chop $form->{"taxaccounts_$i"}; foreach my $item (qw(description rate taxnumber)) { my $index = $form->{"taxaccounts_$i"} . "_$item"; @@ -2959,26 +2960,28 @@ sub save { } # credit remaining calculation - $amount = - $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) * - $form->{"qty_$i"}; - map { $form->{"${_}_base"} += $amount } - (split / /, $form->{"taxaccounts_$i"}); - map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } - split / /, $form->{"taxaccounts_$i"} - if !$form->{taxincluded}; + $amount = $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) * $form->{"qty_$i"}; + + map { $form->{"${_}_base"} += $amount } (split / /, $form->{"taxaccounts_$i"}); + map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded}; $form->{creditremaining} -= $amount; # redo number formatting, because invoice parse them! - $i = $form->{rowcount}; - map { - $form->{"${_}_$i"} = - $form->format_amount(\%myconfig, $form->{"${_}_$i"}) - } qw(weight listprice sellprice rop); + map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(weight listprice sellprice rop); } $form->{"id_$i"} = $parts_id; + + # Get the actual price factor (not just the ID) for the marge calculation. + $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); + foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) { + next if ($pfac->{id} != $newform{price_factor_id}); + $form->{"marge_price_factor_$i"} = $pfac->{factor}; + last; + } + delete $form->{ALL_PRICE_FACTORS}; + delete $form->{action}; # restore original callback