diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e6ca4650150..61b63315295 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4416,7 +4416,7 @@ else if ($id > 0 || ! empty($ref)) print '
'; } } - + // Create a credit note if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $user->rights->facture->creer) { @@ -4425,6 +4425,25 @@ else if ($id > 0 || ! empty($ref)) print ''; } } + + + // For situation invoice with excess received + if ($object->statut == Facture::STATUS_VALIDATED + && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 + && $user->rights->facture->creer + && !$objectidnext + && $object->is_last_in_cycle() + ) + { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) + { + print ''; + } else { + print '