From c97bd14278de5872e7d3d213c70f4044eac1336a Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Tue, 24 Sep 2019 10:08:48 +0200 Subject: [PATCH] FIX TakePOS no invoice validation control and good payment translate --- htdocs/takepos/invoice.php | 43 +++++++++++++++++++------------------- htdocs/takepos/pay.php | 10 ++++----- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index accc4befe82..1f3d4a22563 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -144,38 +144,39 @@ if ($action == 'valid' && $user->rights->facture->creer) $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $invoice->validate($user, '', $conf->global->$constantforkey); + $res = $invoice->validate($user, '', $conf->global->$constantforkey); $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; } else { - $invoice->validate($user); + $res = $invoice->validate($user); } // Add the payment - $payment=new Paiement($db); - $payment->datepaye = $now; - $payment->fk_account = $bankaccount; - $payment->amounts[$invoice->id] = $amountofpayment; + if ($res > 0) { + $payment = new Paiement($db); + $payment->datepaye = $now; + $payment->fk_account = $bankaccount; + $payment->amounts[$invoice->id] = $amountofpayment; - $payment->paiementid=$paiementid; - $payment->num_payment=$invoice->ref; + $payment->paiementid = $paiementid; + $payment->num_payment = $invoice->ref; - $payment->create($user); - $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + $payment->create($user); + $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay == 0) - { - dol_syslog("Invoice is paid, so we set it to pay"); - $result = $invoice->set_paid($user); - if ($result > 0) $invoice->paye = 1; - } - else - { - dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); - } + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay == 0) { + dol_syslog("Invoice is paid, so we set it to pay"); + $result = $invoice->set_paid($user); + if ($result > 0) $invoice->paye = 1; + } else { + dol_syslog("Invoice is not paid, remain to pay = " . $remaintopay); + } + } else { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } } if ($action == 'history') diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 83f4aefb5f5..9fd19b7378f 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -190,7 +190,7 @@ else print "var received=0;";
-
trans("Received"); ?>:
+
trans("Received"); ?>:
trans("Change"); ?>:
@@ -225,7 +225,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + @@ -238,7 +238,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + @@ -253,7 +253,7 @@ $button = array_pop($action_buttons); if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + - +