X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=baa041f364d9288bd5da8c5070f8d38153c946d3;hb=06b678305ce21a082d5c76d43cd9275969931156;hp=e05d0130a1f0cc994da8e24a867047167241df2e;hpb=8f3dc0b4dfd14847df54366f0c146d058522d022;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index e05d0130a..baa041f36 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -79,8 +79,9 @@ sub edit { # editing without stuff to edit? try adding it first if ($form->{rowcount}) { - map {$id++ if $form->{"id_$_"}} (1 .. $form->{rowcount}); + map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount}); if (!$id) { + # reset rowcount undef $form->{rowcount}; &add; @@ -131,18 +132,24 @@ sub order_links { # retrieve order/quotation $form->{webdav} = $webdav; - # set jscalendar $form->{jscalendar} = $jscalendar; OE->retrieve(\%myconfig, \%$form); # if multiple rowcounts (== collective order) then check if the - # there were more than one customer (in that case OE::retrieve removes + # there were more than one customer (in that case OE::retrieve removes # the content from the field) - if ($form->{rowcount} && $form->{type} eq 'sales_order' && defined $form->{customer} && $form->{customer} eq '') { -# $main::lxdebug->message(0, "Detected Edit order with concurrent customers"); - $form->error($locale->text('Collective Orders only work for orders from one customer!')); + if ( $form->{rowcount} + && $form->{type} eq 'sales_order' + && defined $form->{customer} + && $form->{customer} eq '') { + + # $main::lxdebug->message(0, "Detected Edit order with concurrent customers"); + $form->error( + $locale->text( + 'Collective Orders only work for orders from one customer!') + ); } $taxincluded = $form->{taxincluded}; @@ -221,37 +228,42 @@ sub prepare_order { $form->{media} = "screen"; $form->{formname} = $form->{type}; - map { $form->{$_} =~ s/\"/"/g } - qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact); + map { $form->{$_} =~ s/\"/"/g } + qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact); - foreach $ref (@{ $form->{form_details} }) { - $form->{rowcount} = ++$i; + foreach $ref (@{ $form->{form_details} }) { + $form->{rowcount} = ++$i; - map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref}; - } - - for my $i (1 .. $form->{rowcount}) { - $form->{"discount_$i"} = + map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref}; + } + for my $i (1 .. $form->{rowcount}) { + if ($form->{id}) { + $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100); + } else { + $form->{"discount_$i"} = + $form->format_amount(\%myconfig, $form->{"discount_$i"}); + } + ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); + $dec = length $dec; + $decimalplaces = ($dec > 2) ? $dec : 2; - ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); - $dec = length $dec; - $decimalplaces = ($dec > 2) ? $dec : 2; + # copy reqdate from deliverydate for invoice -> order conversion + $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} + unless $form->{"reqdate_$i"}; - # copy reqdate from deliverydate for invoice -> order conversion - $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"}; + $form->{"sellprice_$i"} = + $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, + $decimalplaces); - $form->{"sellprice_$i"} = - $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, - $decimalplaces); - - (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); - $dec_qty = length $dec_qty; - $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); + (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); + $dec_qty = length $dec_qty; + $form->{"qty_$i"} = + $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); - map { $form->{"${_}_$i"} =~ s/\"/"/g } - qw(partnumber description unit); - } + map { $form->{"${_}_$i"} =~ s/\"/"/g } + qw(partnumber description unit); + } $lxdebug->leave_sub(); } @@ -831,10 +843,15 @@ Bearbeiten des $form->{heading}
. $locale->text('Save as new') . qq|"> |; - if ($form->{type} =~ /quotation$/) { + if ($form->{type} =~ /sales_quotation$/) { + print qq| +|; + } + if ($form->{type} =~ /request_quotation$/) { print qq| |; + . $locale->text('Purchase Order') . qq|">|; } print qq| |; } - if ($form->{menubar}) { require "$form->{path}/menu.pl"; @@ -975,6 +991,7 @@ sub update { } else { $form->{"sellprice_$i"} *= (1 - $form->{tradediscount}); + # if there is an exchange rate adjust sellprice $form->{"sellprice_$i"} /= $exchangerate; } @@ -1028,7 +1045,6 @@ sub update { } } - $lxdebug->leave_sub(); } @@ -1507,7 +1523,8 @@ sub orders { $subtotalnetamount += $oe->{netamount}; $subtotalamount += $oe->{amount}; - $column_data{ids} = qq||; + $column_data{ids} = + qq||; $column_data{id} = "$oe->{id}"; $column_data{transdate} = "$oe->{transdate} "; $column_data{reqdate} = "$oe->{reqdate} "; @@ -1573,13 +1590,13 @@ sub orders { |; -# multiple invoice edit button only if gotten there via sales_order form. + # multiple invoice edit button only if gotten there via sales_order form. -if ($form->{type} =~ /sales_order/) { -print qq| + if ($form->{type} =~ /sales_order/) { + print qq| + . $locale->text('Continue') . qq|"> @@ -1588,9 +1605,9 @@ print qq| |; -} + } -print qq| + print qq|
@@ -1796,11 +1813,18 @@ sub invoice { $lxdebug->enter_sub(); if ($form->{type} =~ /_order$/) { + # these checks only apply if the items don't bring their own ordnumbers/transdates. # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields. - $form->isblank("ordnumber", $locale->text('Order Number missing!')) if ( +{ map { $form->{"ordnumber_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} ); - $form->isblank("transdate", $locale->text('Order Date missing!')) if ( +{ map { $form->{"transdate_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} ); - + $form->isblank("ordnumber", $locale->text('Order Number missing!')) + if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) } + ->{''}); + $form->isblank("transdate", $locale->text('Order Date missing!')) + if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) } + ->{''}); + + # also copy deliverydate from the order + $form->{deliverydate} = $form->{reqdate} if $form->{reqdate}; } else { $form->isblank("quonumber", $locale->text('Quotation Number missing!')); $form->isblank("transdate", $locale->text('Quotation Date missing!')); @@ -1836,7 +1860,7 @@ sub invoice { # close orders/quotations $form->{closed} = 1; - # save order if one ordnumber has been given + # save order if one ordnumber has been given # if not it's most likely a collective order, which can't be saved back # so they just have to be closed if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) { @@ -1917,15 +1941,17 @@ sub invoice { $decimalplaces = ($dec > 2) ? $dec : 2; # copy delivery date from reqdate for order -> invoice conversion - $form->{"deliverydate_$i"} = $form->{"reqdate_$i"} unless $form->{"deliverydate_$i"}; + $form->{"deliverydate_$i"} = $form->{"reqdate_$i"} + unless $form->{"deliverydate_$i"}; $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); - + (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/); - $dec_qty = length $dec_qty; - $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); + $dec_qty = length $dec_qty; + $form->{"qty_$i"} = + $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description unit); @@ -2100,6 +2126,15 @@ sub save_as_new { sub purchase_order { $lxdebug->enter_sub(); + if ( $form->{type} eq 'sales_quotation' + || $form->{type} eq 'request_quotation') { + $form->{closed} = 1; + OE->save(\%myconfig, \%$form); + } + + ($null, $form->{cp_id}) = split /--/, $form->{contact}; + $form->{cp_id} *= 1; + $form->{title} = $locale->text('Add Purchase Order'); $form->{vc} = "vendor"; $form->{type} = "purchase_order";