FIX set paid on total discount of a product in cash desk
This commit is contained in:
parent
019a825bf4
commit
259737f082
@ -153,22 +153,23 @@ 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 && $remaintopay > 0) {
|
if ($res >= 0) {
|
||||||
$payment = new Paiement($db);
|
$remaintopay = $invoice->getRemainToPay();
|
||||||
$payment->datepaye = $now;
|
if ($remaintopay > 0) {
|
||||||
$payment->fk_account = $bankaccount;
|
$payment = new Paiement($db);
|
||||||
$payment->amounts[$invoice->id] = $amountofpayment;
|
$payment->datepaye = $now;
|
||||||
|
$payment->fk_account = $bankaccount;
|
||||||
|
$payment->amounts[$invoice->id] = $amountofpayment;
|
||||||
|
|
||||||
$payment->paiementid = $paiementid;
|
$payment->paiementid = $paiementid;
|
||||||
$payment->num_payment = $invoice->ref;
|
$payment->num_payment = $invoice->ref;
|
||||||
|
|
||||||
$payment->create($user);
|
$payment->create($user);
|
||||||
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
|
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
|
||||||
|
$remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
|
||||||
|
}
|
||||||
|
|
||||||
$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 status Paid");
|
dol_syslog("Invoice is paid, so we set it to status Paid");
|
||||||
$result = $invoice->set_paid($user);
|
$result = $invoice->set_paid($user);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user