X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Foe.pl;h=e6ec1f9435c3c64d8fe24911128b7a04afb9ce94;hb=20e6c6695eb9b9742686b947b4037636c31b13dd;hp=9cc570ace09482ffa3cc9f9e129bfcffb4cb9772;hpb=9bd3030a376850c427c102c6e0c54f19bd19332e;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 9cc570ace..e6ec1f943 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1688,7 +1688,9 @@ sub purchase_order { check_oe_access(); $main::auth->assert('purchase_order_edit'); + $form->{sales_order_to_purchase_order} = 0; if ($form->{type} eq 'sales_order') { + $form->{sales_order_to_purchase_order} = 1; check_for_direct_delivery(); } @@ -1706,6 +1708,8 @@ sub purchase_order { &poso; + delete $form->{sales_order_to_purchase_order}; + $main::lxdebug->leave_sub(); } @@ -1754,8 +1758,14 @@ sub poso { $form->{old_salesman_id} = $form->{salesman_id}; # reset - map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered - ordnumber); + map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered ordnumber); + + # if purchase_order was generated from sales_order, use lastcost_$i as sellprice_$i + if ( $form->{sales_order_to_purchase_order} ) { + for my $i (1 .. $form->{rowcount}) { + $form->{"sellprice_${i}"} = $form->format_amount(\%myconfig,$form->{"lastcost_${i}"}); + }; + }; for my $i (1 .. $form->{rowcount}) { map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor discount); @@ -1767,14 +1777,17 @@ sub poso { map { $form->{$_} = $saved_vars{$_} } keys %saved_vars; - &prepare_order; - # prepare_order assumes that the discount is in db-notation (0.05) and not user-notation (5) - # and therefore multiplies the values by 100 in the case of reading from db or making an order from several quotation, so we convert this back into percent-notation for the user interface by multiplying with 0.01 + # and therefore multiplies the values by 100 in the case of reading from db or making an order + # from several quotation, so we convert this back into percent-notation for the user interface by multiplying with 0.01 + # ergänzung 03.10.2010 muss vor prepare_order passieren (s.a. Svens Kommentar zu Bug 1017) + # das parse_amount wird oben schon ausgeführt, deswegen an dieser stelle raus (wichtig: kommawerte bei discount testen) for my $i (1 .. $form->{rowcount}) { - $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 0.01); + $form->{"discount_$i"} /=100; }; + &prepare_order; + # format amounts for my $i (1 .. $form->{rowcount} - 1) { map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description unit);