QS Bernd/Sven: Weniger Code und klarer
[kivitendo-erp.git] / bin / mozilla / gl.pl
index 79e5085..886d756 100644 (file)
@@ -1365,8 +1365,9 @@ sub post_transaction {
       die "guru meditation error: Can only assign amount to one bank account booking" if scalar @{ $payment } > 1;
 
       # credit/debit * -1 matches the sign for bt.amount and bt.invoice_amount
-      die "Can only assign the full (partial) bank amount to a single general ledger booking"
-        unless $bt->not_assigned_amount == $payment->[0]->amount * -1;
+
+      die "Can only assign the full (partial) bank amount to a single general ledger booking" . $bt->not_assigned_amount . " " .  ($payment->[0]->amount * -1)
+        unless (abs($bt->not_assigned_amount - ($payment->[0]->amount * -1)) < 0.001);
 
       $bt->update_attributes(invoice_amount => $bt->invoice_amount + ($payment->[0]->amount * -1));
 
@@ -1394,6 +1395,10 @@ sub post_transaction {
   if ($form->{callback} =~ /BankTransaction/ && $form->{bt_id}) {
     print $form->redirect_header($form->{callback});
     $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id});
+  } elsif ($::instance_conf->get_gl_add_doc && $::instance_conf->get_doc_storage) {
+    my $add_doc_url = build_std_url("script=gl.pl", 'action=edit', 'id=' . E($form->{id}));
+    print $form->redirect_header($add_doc_url);
+    $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id});
   }
 
   # remove or clarify