]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/ap.pl
Bei Kreditoren- und Debitorenbuchungen eine Funktion zum spaeteren Buchen eines Zahlu...
[mfinanz.git] / bin / mozilla / ap.pl
index 7b09f2f0a73a91a0f4e13c7af9e8ff24cbd13722..5a633e1ebea7606289816ec3ae4ea27d9bc5a80f 100644 (file)
@@ -748,7 +748,10 @@ sub form_footer {
 <input class=submit type=submit name=action value="|
         . $locale->text('Use As Template') . qq|">
 |;
+      print qq|
+<input class=submit type=submit name=action value="|
+        . $locale->text('Post Payment') . qq|">
+|;
   } else {
     if (($transdate > $closedto) && !$form->{id}) {
       print qq|<input class=submit type=submit name=action value="|
@@ -875,6 +878,38 @@ sub update {
   $lxdebug->leave_sub();
 }
 
+
+sub post_payment {
+  $lxdebug->enter_sub();
+  for $i (1 .. $form->{paidaccounts}) {
+    if ($form->{"paid_$i"}) {
+      $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
+
+      $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
+
+      $form->error($locale->text('Cannot post payment for a closed period!'))
+        if ($datepaid <= $closedto);
+
+      if ($form->{currency} ne $form->{defaultcurrency}) {
+        $form->{"exchangerate_$i"} = $form->{exchangerate}
+          if ($invdate == $datepaid);
+        $form->isblank("exchangerate_$i",
+                       $locale->text('Exchangerate for payment missing!'));
+      }
+    }
+  }
+
+  ($form->{AP})      = split /--/, $form->{AP};
+  ($form->{AP_paid}) = split /--/, $form->{AP_paid};
+  $form->redirect($locale->text(' Payment posted!'))
+      if (AP->post_payment(\%myconfig, \%$form));
+    $form->error($locale->text('Cannot post payment!'));
+
+
+  $lxdebug->leave_sub();
+}
+
+
 sub post {
   $lxdebug->enter_sub();