Merge branch 'master' of ssh://git-jbueren@lx-office.linet-services.de/~/lx-office-erp
[kivitendo-erp.git] / SL / AP.pm
index aaf2d5e..fce222d 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -46,7 +46,7 @@ sub post_transaction {
   $main::lxdebug->enter_sub();
 
   my ($self, $myconfig, $form, $provided_dbh, $payments_only) = @_;
-
+  my $rc = 0; # return code auf false setzen
   # connect to database
   my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig);
 
@@ -54,6 +54,7 @@ sub post_transaction {
   my $exchangerate = 0;
 
   $form->{defaultcurrency} = $form->get_default_currency($myconfig);
+  delete $form->{currency} unless $form->{defaultcurrency};
 
   ($null, $form->{department_id}) = split(/--/, $form->{department});
   $form->{department_id} *= 1;
@@ -356,12 +357,13 @@ sub post_transaction {
 
   IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh);
 
-  my $rc = 1;
   if (!$provided_dbh) {
     $dbh->commit();
     $dbh->disconnect();
   }
 
+  $rc = 1; #  Den return-code auf true setzen, aber nur falls beim commit alles i.O. ist
+
   $main::lxdebug->leave_sub();
 
   return $rc;
@@ -586,11 +588,9 @@ sub post_payment {
 
   $self->setup_form($form);
 
-  ($form->{defaultcurrency}) = selectrow_query($form, $dbh, qq|SELECT curr FROM defaults|);
-  $form->{defaultcurrency}   = (split m/:/, $form->{defaultcurrency})[0];
-  $form->{currency}          = $form->{defaultcurrency} if ($form->{defaultcurrency} && ($form->{currency} =~ m/^\s*$/));
-
-  $form->{exchangerate}      = $form->format_amount($myconfig, $form->{exchangerate});
+  $form->{exchangerate}    = $form->format_amount($myconfig, $form->{exchangerate});
+  $form->{defaultcurrency} = $form->get_default_currency($myconfig);
+  delete $form->{currency} unless $form->{defaultcurrency};
 
   # Get the AP accno.
   $query =