X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fis.pl;h=f44c5809cb008b3fea0c37b6275a18610e7bfce3;hb=9d60642b51924a3fc44a0108777f0611ae19fb30;hp=d6c5d8b1b4baa6d4f6aa6163f1f5401fb6637bab;hpb=09fe7f33a735ecc3f4a3112ad716f674983b00cc;p=kivitendo-erp.git diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index d6c5d8b1b..f44c5809c 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -34,6 +34,7 @@ use SL::FU; use SL::IS; use SL::PE; +use SL::OE; use Data::Dumper; use List::Util qw(max sum); @@ -155,6 +156,14 @@ sub invoice_links { $ref->{name} = $form->quote($ref->{name}); } + # Load data for a specific order and update form fields + my $order_data = OE->get_order_data_by_ordnumber(%$form) if $form->{ordnumber}; + + # Copy the fields we need to %form + for my $key (qw(payment_id salesman_id orddate taxzone_id quonumber)) { + $form->{$key} = $order_data->{$key}; + } + $form->restore_vars(qw(id)); IS->retrieve_invoice(\%myconfig, \%$form); @@ -162,14 +171,22 @@ sub invoice_links { $form->restore_vars(qw(taxincluded)) if $form->{id}; $form->restore_vars(qw(salesman_id)) if $main::editing; + # build vendor/customer drop down comatibility... don't ask if (@{ $form->{"all_customer"} }) { $form->{"selectcustomer"} = 1; $form->{customer} = qq|$form->{customer}--$form->{"customer_id"}|; } - $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; - $form->{selectcustomer} = 1; + $form->{"oldcustomer"} = $form->{customer}; + + if ($form->{"oldcustomer"} !~ m/--\d+$/ && $form->{"customer_id"}) { + $form->{"oldcustomer"} .= qq|--$form->{"customer_id"}| + } + + +# $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; +# $form->{selectcustomer} = 1; $form->{employee} = "$form->{employee}--$form->{employee_id}"; @@ -276,7 +293,6 @@ sub form_header { $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id}; $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; my $set_duedate_url = "$form->{script}?action=set_duedate"; @@ -295,6 +311,7 @@ sub form_header { "taxzones" => "ALL_TAXZONES", "currencies" => "ALL_CURRENCIES", "customers" => "ALL_CUSTOMERS", + "departments" => "all_departments", "price_factors" => "ALL_PRICE_FACTORS"); $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} }; @@ -397,7 +414,7 @@ sub form_footer { # follow ups if ($form->{id}) { $form->{follow_ups} = FU->follow_ups('trans_id' => $form->{id}) || []; - $form->{follow_ups_unfinished} = sum map { $_->{due} * 1 } @{ $form->{follow_ups} }; + $form->{follow_ups_unfinished} = ( sum map { $_->{due} * 1 } @{ $form->{follow_ups} } ) || 0; } # payments @@ -448,7 +465,7 @@ sub update { my ($recursive_call) = shift; - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining) unless $recursive_call; +# map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining) unless $recursive_call; $form->{print_and_post} = 0 if $form->{second_run}; my $taxincluded = "checked" if $form->{taxincluded}; @@ -639,6 +656,7 @@ sub post { $form->{print_and_post} = 0; } + remove_emptied_rows(); &validate_items; my $closedto = $form->datetonum($form->{closedto}, \%myconfig); @@ -869,8 +887,8 @@ sub credit_note { map { $form->{"select$_"} = "" } ($form->{vc}, 'currency'); - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } - qw(creditlimit creditremaining); +# map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } +# qw(creditlimit creditremaining); my $currency = $form->{currency}; &invoice_links; @@ -881,6 +899,16 @@ sub credit_note { $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal}); + # bei Gutschriften werden Zahlungseingänge aus Rechnung nicht übernommen + for my $i (1 .. $form->{paidaccounts}) { + delete $form->{"paid_$i"}; + delete $form->{"source_$i"}; + delete $form->{"memo_$i"}; + delete $form->{"datepaid_$i"}; + delete $form->{"AR_paid_$i"}; + }; + $form->{paidaccounts} = 1; + &prepare_invoice; @@ -900,10 +928,10 @@ sub yes { if (IS->delete_invoice(\%myconfig, \%$form, $main::spool)) { # saving the history - if(!exists $form->{addition}) { + if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; - $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->{addition} = "DELETED"; + $form->save_history($form->dbconnect(\%myconfig)); } # /saving the history $form->redirect($locale->text('Invoice deleted!'));