From e709c005a084ec7ac6d09b9185d48a6eecf7c430 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 12:28:48 +0200 Subject: [PATCH] FIX Payment was not saved on TakePOS module. --- htdocs/takepos/invoice.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 1f3d4a22563..2b8b0f21921 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -115,7 +115,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice = new Facture($db); $invoice->fetch($placeid); - if($invoice->total_ttc<0){ + if ($invoice->total_ttc < 0) { $invoice->type= $invoice::TYPE_CREDIT_NOTE; $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE "; $sql.="fk_soc = '".$invoice->socid."' "; @@ -153,8 +153,10 @@ if ($action == 'valid' && $user->rights->facture->creer) $res = $invoice->validate($user); } + $remaintopay = $invoice->getRemainToPay(); + // Add the payment - if ($res > 0) { + if ($res >= 0 && $remaintopay > 0) { $payment = new Paiement($db); $payment->datepaye = $now; $payment->fk_account = $bankaccount; @@ -166,9 +168,9 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $remaintopay = $invoice->getRemainToPay(); + $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded if ($remaintopay == 0) { - dol_syslog("Invoice is paid, so we set it to pay"); + dol_syslog("Invoice is paid, so we set it to status Paid"); $result = $invoice->set_paid($user); if ($result > 0) $invoice->paye = 1; } else {