diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 32a1970fc0f913afbb8c2a3379daeaaeddc15b6f..e75a6c80232ec3e1f18bb5d845d113005afac7b4 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -167,6 +167,25 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->glo $fac = new Facture($db); $fac->fetch($_GET['facid']); + // On v�rifie si la facture a des paiements + $sql = 'SELECT pf.amount,'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; + $sql.= ' WHERE pf.fk_facture = '.$fac->id; + + $result = $db->query($sql); + + if ($result) + { + while ($i < $num) + { + $objp = $db->fetch_object($result); + $totalpaye += $objp->amount; + $i++; + } + } + + $resteapayer = $fac->total_ttc - $totalpaye; + // On v�rifie si les lignes de factures ont �t� export�es en compta et/ou ventil�es $ventilExportCompta = $fac->getVentilExportCompta();