X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fis.pl;h=07b40d4d5b8cd5025a7add8d2d475a040b42e662;hb=2c1c6a9a9204afad82c8e403f3fce1d0d4b9cd90;hp=9ec9becb8e71def539b85108f0a299c83dc727b1;hpb=b2a7bb87ffbc75c753d106c0e6c62b9b2d0654a8;p=kivitendo-erp.git diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 9ec9becb8..07b40d4d5 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -132,8 +132,8 @@ sub invoice_links { $form->{vc} = 'customer'; # create links - $form->{webdav} = $main::webdav; - $form->{lizenzen} = $main::lizenzen; + $form->{webdav} = $::lx_office_conf{system}->{webdav}; + $form->{lizenzen} = $::lx_office_conf{system}->{lizenzen}; $form->create_links("AR", \%myconfig, "customer"); @@ -155,14 +155,6 @@ 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); @@ -266,13 +258,21 @@ sub prepare_invoice { $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); + $form->{"sellprice_pg_$i"} = join ('--', $form->{"sellprice_$i"}, $form->{"pricegroup_id_$i"}); + $form->{rowcount} = $i; } # get pricegroups for parts IS->get_pricegroups_for_parts(\%myconfig, \%$form); - set_pricegroup($_) for 1 .. $form->{rowcount}; + + # Problem: set_pricegroup resets the sellprice of old invoices to the price + # currently defined in the pricegroup, which is a problem if the price has + # changed, as the old invoice gets the new price + # set_pricegroup must never be called, when an old invoice is initially loaded + + # set_pricegroup($_) for 1 .. $form->{rowcount}; } $main::lxdebug->leave_sub(); } @@ -423,9 +423,17 @@ sub form_footer { $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); $form->{paid_indices} = [ 1 .. $form->{paidaccounts} ]; + # Standard Konto für Umlaufvermögen + my $accno_arap = IS->get_standard_accno_current_assets(\%myconfig, \%$form); + for my $i (1 .. $form->{paidaccounts}) { $form->{"selectAR_paid_$i"} = $form->{selectAR_paid}; - $form->{"selectAR_paid_$i"} =~ s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/; + if (!$form->{"AR_paid_$i"}) { + $form->{"selectAR_paid_$i"} =~ s/option>$accno_arap--(.*?)$accno_arap--$1{"selectAR_paid_$i"} =~ s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/; + } + $totalpaid += $form->{"paid_$i"}; } @@ -466,7 +474,7 @@ sub update { my ($recursive_call) = shift; -# map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining) unless $recursive_call; + $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}) unless $recursive_call; $form->{print_and_post} = 0 if $form->{second_run}; my $taxincluded = "checked" if $form->{taxincluded}; @@ -503,7 +511,11 @@ sub update { my $rows = scalar @{ $form->{item_list} }; - $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{customer_discount} * 100); + # Falls kein Kundenrabatt vorhanden ist, den aktuellen Rabatt nicht mit 0% überschreiben, + # da hier der Anwender schon manual einen Wert eingetragen haben könnte (analog zu qty) Bugfix: 1412 + if ($form->{customer_discount}){ + $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{customer_discount} * 100); + } if ($rows) { $form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1; @@ -549,7 +561,7 @@ sub update { $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); - if ($main::lizenzen) { + if ($::lx_office_conf{system}->{lizenzen}) { if ($form->{"inventory_accno_$i"} ne "") { $form->{"lizenzen_$i"} = qq||; foreach my $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) { @@ -625,7 +637,7 @@ sub post_payment { # Das Problem hierbei ist, dass in IS.pm post_invoice IMMER alle Zahlungseingänge aus $form # erneut gespeichert werden. Prinzipiell wäre es besser NUR die Änderungen des Rechnungs- # belegs (neue Zahlung aber nichts anderes) zu speichern ... - # Vielleicht könnte man ähnlich wie bei Rechnung löschen verfahren + # Vielleicht könnte man ähnlich wie bei Rechnung löschen verfahren $form->error($locale->text('Cannot post payment for a closed period!')) if ($form->date_closed($form->{"datepaid_$form->{paidaccounts}"}, \%myconfig)); @@ -774,6 +786,11 @@ sub use_as_template { $form->{paidaccounts} = 1; $form->{rowcount}--; $form->{invdate} = $form->current_date(\%myconfig); + + # remember pricegroups for "use as template" + IS->get_pricegroups_for_parts(\%myconfig, \%$form); + set_pricegroup($_) for 1 .. $form->{rowcount}; + &display_form; $main::lxdebug->leave_sub(); @@ -947,7 +964,7 @@ sub yes { $main::auth->assert('invoice_edit'); - if (IS->delete_invoice(\%myconfig, \%$form, $main::spool)) { + if (IS->delete_invoice(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber};