NEW: deposit payment terms: check invoice module activation + rights

This commit is contained in:
Marc de Lima Lucio 2021-09-30 12:57:00 +02:00
parent e1c5d01361
commit d74776622d

View File

@ -687,7 +687,12 @@ if (empty($reshook)) {
$deposit = null;
$locationTarget = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
if (!$error && GETPOST('statut', 'int') == $object::STATUS_SIGNED && GETPOST('generate_deposit', 'int') > 0) {
$deposit_percent_from_payment_terms = getDictvalue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id);
if (
!$error && GETPOST('statut', 'int') == $object::STATUS_SIGNED && GETPOST('generate_deposit', 'int') > 0
&& ! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)
) {
$deposit = Facture::createDepositFromOrigin($object, $user, 0, GETPOST('validate_generated_deposit', 'int') > 0);
if ($deposit) {
@ -1971,7 +1976,7 @@ if ($action == 'create') {
$deposit_percent_from_payment_terms = getDictvalue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id);
if (! empty($deposit_percent_from_payment_terms)) {
if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) {
$object->fetchObjectLinked();
$eligibleForDepositGeneration = true;
@ -2032,7 +2037,7 @@ if ($action == 'create') {
'
);
}
}
}
if (!empty($conf->notification->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';