FIX Payment was not saved on TakePOS module.
This commit is contained in:
parent
084ab53b4b
commit
e709c005a0
@ -115,7 +115,7 @@ if ($action == 'valid' && $user->rights->facture->creer)
|
|||||||
|
|
||||||
$invoice = new Facture($db);
|
$invoice = new Facture($db);
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
if($invoice->total_ttc<0){
|
if ($invoice->total_ttc < 0) {
|
||||||
$invoice->type= $invoice::TYPE_CREDIT_NOTE;
|
$invoice->type= $invoice::TYPE_CREDIT_NOTE;
|
||||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE ";
|
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE ";
|
||||||
$sql.="fk_soc = '".$invoice->socid."' ";
|
$sql.="fk_soc = '".$invoice->socid."' ";
|
||||||
@ -153,8 +153,10 @@ if ($action == 'valid' && $user->rights->facture->creer)
|
|||||||
$res = $invoice->validate($user);
|
$res = $invoice->validate($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$remaintopay = $invoice->getRemainToPay();
|
||||||
|
|
||||||
// Add the payment
|
// Add the payment
|
||||||
if ($res > 0) {
|
if ($res >= 0 && $remaintopay > 0) {
|
||||||
$payment = new Paiement($db);
|
$payment = new Paiement($db);
|
||||||
$payment->datepaye = $now;
|
$payment->datepaye = $now;
|
||||||
$payment->fk_account = $bankaccount;
|
$payment->fk_account = $bankaccount;
|
||||||
@ -166,9 +168,9 @@ if ($action == 'valid' && $user->rights->facture->creer)
|
|||||||
$payment->create($user);
|
$payment->create($user);
|
||||||
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
|
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
|
||||||
|
|
||||||
$remaintopay = $invoice->getRemainToPay();
|
$remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
|
||||||
if ($remaintopay == 0) {
|
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);
|
$result = $invoice->set_paid($user);
|
||||||
if ($result > 0) $invoice->paye = 1;
|
if ($result > 0) $invoice->paye = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user