oe.pl::dispatcher - unnötige Lokalisierungen von Globals entfernt.
[kivitendo-erp.git] / bin / mozilla / is.pl
index 7ac9f4d..740002b 100644 (file)
@@ -266,7 +266,13 @@ sub prepare_invoice {
 
     # 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();
 }
@@ -468,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};
@@ -631,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));
 
@@ -780,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();