Fix_situation_discount_used

This commit is contained in:
John 2018-05-14 14:55:33 +02:00
parent 20c50e809d
commit b42c87256c

View File

@ -1362,11 +1362,26 @@ if (empty($reshook))
$object->origin = $origin;
$object->origin_id = $originid;
foreach ($object->lines as &$line)
foreach ($object->lines as $i => &$line)
{
$line->origin = $object->origin;
$line->origin_id = $line->id;
$line->fetch_optionals($line->id);
// Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée
if ($line->fk_remise_except)
{
$discount=new DiscountAbsolute($line->db);
$result=$discount->fetch($line->fk_remise_except);
if ($result > 0)
{
// Check if discount not already affected to another invoice
if ($discount->fk_facture_line > 0)
{
unset($object->lines[$i]);
}
}
}
}
}