FIX: supplier invoice: autoatically calculate payment term when modifying payment condition

This commit is contained in:
Marc de Lima Lucio 2020-10-22 16:11:12 +02:00
parent f2fafe04b6
commit 1795ec6a9d

View File

@ -325,7 +325,18 @@ if (empty($reshook))
// payments conditions
if ($action == 'setconditions' && $user->rights->fournisseur->facture->creer)
{
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
$object->fetch($id);
$object->cond_reglement_code = 0; // To clean property
$object->cond_reglement_id = 0; // To clean property
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
if ($result < 0) dol_print_error($db, $object->error);
$old_date_echeance = $object->date_echeance;
$new_date_echeance = $object->calculate_date_lim_reglement();
if ($new_date_echeance > $old_date_echeance) $object->date_echeance = $new_date_echeance;
if ($object->date_echeance < $object->date) $object->date_echeance = $object->date;
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
}
// Set incoterm