New variable to accept a deposit invoice as available credit even unpaid (#26792)

* New variable to accept a deposit invoice as available credit even unpaid

In many activities, the final invoice must be issued while the requested deposit has not yet been paid.
Often it is the payment deadlines which generate this situation (for example in the finishing work)

* Update card.php

* Update card.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Sylvain Legrand 2023-11-21 23:20:20 +01:00 committed by GitHub
parent 7da90d61e8
commit 83b4ddc0cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5780,8 +5780,8 @@ if ($action == 'create') {
}
// For down payment invoice (deposit)
if ($object->type == Facture::TYPE_DEPOSIT && $usercancreate && $object->statut > Facture::STATUS_DRAFT && empty($discount->id)) {
if (price2num($object->total_ttc, 'MT') == price2num($sumofpaymentall, 'MT') || ($object->type == Facture::STATUS_ABANDONED && in_array($object->close_code, array('bankcharge', 'discount_vat', 'other')))) {
// We can close a down payment only if paid amount is same than amount of down payment (by definition)
// We can close a down payment only if paid amount is same than amount of down payment (by definition). We can bypass this if hidden and unstable option DEPOSIT_AS_CREDIT_AVAILABLE_EVEN_UNPAID is set.
if (price2num($object->total_ttc, 'MT') == price2num($sumofpaymentall, 'MT') || getDolGlobalInt('DEPOSIT_AS_CREDIT_AVAILABLE_EVEN_UNPAID') || ($object->type == Facture::STATUS_ABANDONED && in_array($object->close_code, array('bankcharge', 'discount_vat', 'other')))) {
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a>';
} else {
print '<span class="butActionRefused" title="'.$langs->trans("AmountPaidMustMatchAmountOfDownPayment").'">'.$langs->trans('ConvertToReduc').'</span>';