From df181d1f3504815fc55f50c574f53f962379093a Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 20 Oct 2019 22:01:54 +0200 Subject: [PATCH 1/2] Multiple payments in a TakePOS sale --- htdocs/takepos/invoice.php | 13 ++++++++----- htdocs/takepos/pay.php | 5 ++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 6a67d9d03f9..2068981c98d 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] = $invoice->getRemainToPay(); $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(); }); } From 6638b361d4e2bc419cb006dbad04398db066b50e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 12:44:19 +0200 Subject: [PATCH 2/2] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2068981c98d..2fcb9e0a6d8 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -203,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->getRemainToPay(); + if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $remaintopay; $payment->paiementid=$paiementid; $payment->num_payment=$invoice->ref;