X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=a3425ecde477f1bc6b65cd5d77f192fb11ffacb8;hb=844a541e0d8f59644540413f675e8f07cd154cf6;hp=15aef539f7fd4ac4340b752b51f257b555c81b90;hpb=b122ba4c2f6275c2db31a0388c94f10f3d33c30e;p=kivitendo-erp.git diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 15aef539f..a3425ecde 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -160,7 +160,7 @@ sub add { $form->{show_details} = $::myconfig{show_form_details}; - &order_links; + order_links(is_new => 1); &prepare_order; &display_form; @@ -245,6 +245,8 @@ sub edit { sub order_links { $main::lxdebug->enter_sub(); + my (%params) = @_; + my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; @@ -266,8 +268,12 @@ sub order_links { $form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes shipto_id delivery_term_id currency)); # get customer / vendor - IR->get_vendor(\%myconfig, \%$form) if $form->{type} =~ /(purchase_order|request_quotation)/; - IS->get_customer(\%myconfig, \%$form) if $form->{type} =~ /sales_(order|quotation)/; + if ($form->{type} =~ /(purchase_order|request_quotation)/) { + IR->get_vendor(\%myconfig, \%$form); + } else { + IS->get_customer(\%myconfig, \%$form); + $form->{billing_address_id} = $form->{default_billing_address_id} if $params{is_new}; + } $form->restore_vars(qw(payment_id language_id taxzone_id intnotes cp_id shipto_id delivery_term_id)); $form->restore_vars(qw(currency)) if $form->{id}; @@ -775,8 +781,12 @@ sub update { if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) { $::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id}; - IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; - IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; + if ($vc eq 'customer') { + IS->get_customer(\%myconfig, $form); + $::form->{billing_address_id} = $::form->{default_billing_address_id}; + } else { + IR->get_vendor(\%myconfig, $form); + } } if (!$form->{forex}) { # read exchangerate from input field (not hidden) @@ -1239,7 +1249,7 @@ sub orders { my $edit_url = $params{want_binary_pdf} ? '' - : ($::instance_conf->get_feature_experimental) + : ($::instance_conf->get_feature_experimental_order) ? build_std_url('script=controller.pl', 'action=Order/edit', 'type') : build_std_url('action=edit', 'type', 'vc'); foreach my $oe (@{ $form->{OE} }) { @@ -1378,6 +1388,8 @@ sub save_and_close { IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; + $::form->{billing_address_id} = $::form->{default_billing_address_id}; + update(); $::dispatcher->end_request; } @@ -1480,8 +1492,13 @@ sub save { if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) { $::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id}; - IS->get_customer(\%myconfig, $form) if $vc eq 'customer'; - IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor'; + if ($vc eq 'customer') { + IS->get_customer(\%myconfig, $form); + $::form->{billing_address_id} = $::form->{default_billing_address_id}; + + } else { + IR->get_vendor(\%myconfig, $form); + } update(); $::dispatcher->end_request; @@ -2065,6 +2082,7 @@ sub oe_prepare_xyz_from_order { my $order = SL::DB::Order->new(id => $::form->{id})->load; $order->flatten_to_form($::form, format_amounts => 1); + $::form->{taxincluded_changed_by_user} = 1; # hack: add partsgroup for first row if it does not exists, # because _remove_billed_or_delivered_rows and _remove_full_delivered_rows