diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 6a67d9d03f9..2fcb9e0a6d8 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -165,8 +165,12 @@ if ($action == 'valid' && $user->rights->facture->creer)
$constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];
if ($invoice->statut != Facture::STATUS_DRAFT)
{
- dol_syslog("Sale already validated");
- dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1);
+ //If invoice is validated but it is not fully paid is not error and make the payment
+ if ($invoice->getRemainToPay()>0) $res=1;
+ else{
+ dol_syslog("Sale already validated");
+ dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1);
+ }
}
elseif (count($invoice->lines)==0)
{
@@ -199,7 +203,7 @@ if ($action == 'valid' && $user->rights->facture->creer)
$payment->amounts[$invoice->id] = $amountofpayment;
// If user has not used change control, add total invoice payment
- if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $invoice->total_ttc;
+ if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $remaintopay;
$payment->paiementid=$paiementid;
$payment->num_payment=$invoice->ref;
@@ -427,7 +431,6 @@ $sectionwithinvoicelink='';
if ($action=="valid" || $action=="history")
{
$sectionwithinvoicelink.=''."\n";
- $sectionwithinvoicelink.='';
$sectionwithinvoicelink.='';
$sectionwithinvoicelink.=$invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - ";
$remaintopay = $invoice->getRemainToPay();
@@ -582,7 +585,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
if ($mobilepage=="invoice" || $mobilepage=="") {
print $langs->trans('TotalTTC');
print ' : ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . '';
- print '
' . $sectionwithinvoicelink;
+ print '
' . $sectionwithinvoicelink;
print '';
}
if ($_SESSION["basiclayout"]!=1)
diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php
index 63bf151f40a..349c03540b2 100644
--- a/htdocs/takepos/pay.php
+++ b/htdocs/takepos/pay.php
@@ -172,9 +172,8 @@ else print "var received=0;";
}
console.log("We click on the payment mode to pay amount = "+amountpayed);
parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() {
- //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
- parent.$.colorbox.close();
- //parent.setFocusOnSearchField(); // This does not have effect
+ if (amountpayed > || amountpayed == || amountpayed==0 ) parent.$.colorbox.close();
+ else location.reload();
});
}