Browse Source

mark expense report as paid if payement set the remaining sold to 0

De Coninck Laurent 8 years ago
parent
commit
ae2e40e5e7
1 changed files with 12 additions and 0 deletions
  1. 12 0
      htdocs/expensereport/payment/payment.php

+ 12 - 0
htdocs/expensereport/payment/payment.php

@@ -134,6 +134,18 @@ if ($action == 'add_payment')
                 }
             }
 
+            if (!$error) {
+                $payment->fetch($paymentid);
+                if ($expensereport->total_ttc - $payment->amount == 0) {
+                    $result = $expensereport->set_paid($expensereport->id, $user);
+                    if (!$result > 0) {
+                        $errmsg = $payment->error;
+                        $error++;
+                    }
+                }
+
+            }
+
     	    if (! $error)
             {
                 $db->commit();