Fix: Une facture classée payée partiellement ne doit pas aparraitre dans la liste des factures sur lesquelles un avoir est possible. En effet si elles ont été classée "payée partiellement" alors un motif a été donné et le manque a gagné peut etre imputé en compta. Il n'y a pas de trous dans la compta.

This commit is contained in:
Laurent Destailleur 2007-01-20 12:15:34 +00:00
parent 576b93e7a8
commit f32673cb49
6 changed files with 1392 additions and 1474 deletions

View File

@ -1891,17 +1891,37 @@ else
$i++; $i++;
} }
// Solde facture // Already payed
print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPayed').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPayed').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Facturé
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
$resteapayeraffiche=$resteapayer;
// Escompte
if ($fac->close_code == 'escompte') if ($fac->close_code == 'escompte')
{ {
print '<tr><td colspan="2" align="right" nowrap="1">'; print '<tr><td colspan="2" align="right" nowrap="1">';
print $html->textwithhelp($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1); print $html->textwithhelp($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1);
print '</td><td align="right">'.price($fac->total_ttc - $totalpaye).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '</td><td align="right">'.price($fac->total_ttc - $totalpaye).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
$resteapayeraffiche=0;
}
// Abandon bad customer
if ($fac->close_code == 'badcustomer')
{
print '<tr><td colspan="2" align="right" nowrap="1">';
print $html->textwithhelp($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1);
print '</td><td align="right">'.price($fac->total_ttc - $totalpaye).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
$resteapayeraffiche=0;
}
// Abandon other
if ($fac->close_code == 'abandon')
{
print '<tr><td colspan="2" align="right" nowrap="1">';
print $html->textwithhelp($langs->trans("Abandoned").':',$langs->trans("HelpAbandonOther"),-1);
print '</td><td align="right">'.price($fac->total_ttc - $totalpaye).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
$resteapayeraffiche=0;
} }
print '<tr><td colspan="2" align="right">'.$langs->trans('RemainderToPay').' :</td>'; print '<tr><td colspan="2" align="right">'.$langs->trans('RemainderToPay').' :</td>';
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayer).'</b></td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayeraffiche).'</b></td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
} }
else else
{ {
@ -2273,121 +2293,6 @@ else
dolibarr_print_error($db); dolibarr_print_error($db);
} }
/*
* Lignes de remise
*/
// Réductions relatives (Remises-Ristournes-Rabbais)
/* Une réduction doit s'appliquer obligatoirement sur des lignes de factures
$var=!$var;
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="action" value="setremisepercent">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<tr class="liste_total"><td>';
print $langs->trans('CustomerRelativeDiscount');
if ($fac->brouillon) print ' <font style="font-weight: normal">('.($soc->remise_client?$langs->trans("CompanyHasRelativeDiscount",$soc->remise_client):$langs->trans("CompanyHasNoRelativeDiscount")).')</font>';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] == 'editrelativediscount')
{
print '<input type="text" name="remise_percent" size="2" value="'.$fac->remise_percent.'">%';
}
else
{
print $fac->remise_percent?$fac->remise_percent.'%':'&nbsp;';
}
print '</font></td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] != 'editrelativediscount') print $fac->remise_percent?'-'.price($fac->remise_percent*$total/100):$langs->trans("DiscountNone");
else print '&nbsp;';
print '</font></td>';
if ($_GET['action'] != 'editrelativediscount')
{
if ($fac->brouillon && $user->rights->facture->creer)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editrelativediscount&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetRelativeDiscount'),1).'</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
if ($fac->brouillon && $user->rights->facture->creer && $fac->remise_percent)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=setremisepercent&amp;rowid='.$objp->rowid.'">';
print img_delete();
print '</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
print '<td>&nbsp;</td>';
}
else
{
print '<td colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
}
print '</tr>';
print '</form>';
*/
// Réductions absolues (Remises-Ristournes-Rabbais)
/* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées
$var=!$var;
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="action" value="setremiseabsolue">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<tr class="liste_total"><td>';
print $langs->trans('CustomerAbsoluteDiscount');
if ($fac->brouillon) print ' <font style="font-weight: normal">('.($absolute_discount?$langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)):$langs->trans("CompanyHasNoAbsoluteDiscount")).')</font>';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] == 'editabsolutediscount')
{
print '-<input type="text" name="remise_absolue" size="2" value="'.$fac->remise_absolue.'">';
}
else
{
print $fac->remise_absolue?'-'.price($fac->remise_absolue):$langs->trans("DiscountNone");
}
print '</font></td>';
if ($_GET['action'] != 'editabsolutediscount')
{
if ($fac->brouillon && $user->rights->facture->creer)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editabsolutediscount&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetAbsoluteDiscount'),1).'</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
if ($fac->brouillon && $user->rights->facture->creer && $fac->remise_absolue)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=setremiseabsolue&amp;rowid='.$objp->rowid.'">';
print img_delete();
print '</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
print '<td>&nbsp;</td>';
}
else
{
print '<td colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
}
print '</tr>';
print '</form>';
*/
/* /*
* Ajouter une ligne * Ajouter une ligne
*/ */
@ -2483,7 +2388,6 @@ else
/* /*
* Boutons actions * Boutons actions
*/ */
if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline') if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';

View File

@ -2304,7 +2304,7 @@ class Facture extends CommonObject
/** /**
* \brief Renvoi liste des factures qualifiables pour avoir * \brief Renvoi liste des factures qualifiables pour avoir
* Statut validee + pas deja remplacées * Statut >= validee + pas classé payée completement + pas classé payée partiellement + pas deja remplacée
* \param socid Id societe * \param socid Id societe
* \return array Tableau des factures ($id => $ref) * \return array Tableau des factures ($id => $ref)
*/ */
@ -2318,7 +2318,9 @@ class Facture extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=1)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=1)";
$sql.= " WHERE f.fk_statut >= 1 AND f.paye = 0"; $sql.= " WHERE f.fk_statut >= 1";
$sql.= " AND f.paye = 0"; // Pas classé payé complètement
$sql.= " AND f.close_code IS NULL"; // Pas classé payé partiellement
$sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
$sql.= " ORDER BY f.facnumber"; $sql.= " ORDER BY f.facnumber";

View File

@ -135,6 +135,7 @@ ShowInvoiceAvoir=Show credit note
ShowPayment=Show payment ShowPayment=Show payment
File=File File=File
AlreadyPayed=Already payed AlreadyPayed=Already payed
Abandoned=Abandoned
RemainderToPay=Remainder to pay RemainderToPay=Remainder to pay
RemainderToTake=Remainder to take RemainderToTake=Remainder to take
EscompteOffered=Discount offered (payment before term) EscompteOffered=Discount offered (payment before term)
@ -192,6 +193,8 @@ DiscountStillRemaining=Discount still remaining
DiscountAlreadyCounted=Discount already counted DiscountAlreadyCounted=Discount already counted
BillAddress=Bill address BillAddress=Bill address
HelpEscompte=This discount is a discount granted to customer because its paiement was made before term. HelpEscompte=This discount is a discount granted to customer because its paiement was made before term.
HelpAbandonBadCustomer=This amount has been abandoned (customer said to be a bad customer) and is considered as an exceptionnal loose.
HelpAbandonOther=This amount has been abandoned and is considered as an exceptionnal loose.
# PaymentConditions # PaymentConditions
PaymentConditionShortRECEP=Immediate PaymentConditionShortRECEP=Immediate
PaymentConditionRECEP=Immediate PaymentConditionRECEP=Immediate

View File

@ -186,6 +186,8 @@ DiscountStillRemaining=Remises fixes restant en cours
DiscountAlreadyCounted=Remises fixes déjà appliquées DiscountAlreadyCounted=Remises fixes déjà appliquées
BillAddress=Adresse de facturation BillAddress=Adresse de facturation
HelpEscompte=Cette réduction est allouée au client car son paiement a été fait avant échéance. HelpEscompte=Cette réduction est allouée au client car son paiement a été fait avant échéance.
HelpAbandonBadCustomer=Ce montant a été abandonné (client jugé mauvais payeur) et est considéré comme un perte exceptionnelle.
HelpAbandonOther=Ce montant a été abandonné et est considéré comme un perte exceptionnelle.
# PaymentConditions=undefined # PaymentConditions=undefined
PaymentConditionShortRECEP=À réception PaymentConditionShortRECEP=À réception
PaymentConditionRECEP=À réception de facture PaymentConditionRECEP=À réception de facture

View File

@ -136,6 +136,7 @@ ShowInvoiceAvoir=Afficher facture avoir
ShowPayment=Afficher réglement ShowPayment=Afficher réglement
File=Fichier File=Fichier
AlreadyPayed=Déjà réglé AlreadyPayed=Déjà réglé
Abandoned=Abandonné
RemainderToPay=Reste à payer RemainderToPay=Reste à payer
RemainderToTake=Reste à encaisser RemainderToTake=Reste à encaisser
EscompteOffered=Escompte (réglement avant échéance) EscompteOffered=Escompte (réglement avant échéance)
@ -193,6 +194,8 @@ DiscountStillRemaining=Remises fixes restant en cours
DiscountAlreadyCounted=Remises fixes déjà appliquées DiscountAlreadyCounted=Remises fixes déjà appliquées
BillAddress=Adresse de facturation BillAddress=Adresse de facturation
HelpEscompte=Un <b>escompte</b> est une remise accordée, sur une facture donnée, à un client car ce dernier a réalisé son réglement bien avant l'échéance. HelpEscompte=Un <b>escompte</b> est une remise accordée, sur une facture donnée, à un client car ce dernier a réalisé son réglement bien avant l'échéance.
HelpAbandonBadCustomer=Ce montant a été abandonné (client jugé mauvais payeur) et est considéré comme un perte exceptionnelle.
HelpAbandonOther=Ce montant a été abandonné et est considéré comme un perte exceptionnelle.
# PaymentConditions # PaymentConditions
PaymentConditionShortRECEP=A réception PaymentConditionShortRECEP=A réception
PaymentConditionRECEP=A réception de facture PaymentConditionRECEP=A réception de facture

View File

@ -515,6 +515,10 @@ function top_htmlhead($head, $title="", $target="")
if ($conf->use_javascript || $conf->use_ajax) if ($conf->use_javascript || $conf->use_ajax)
{ {
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_head.js"></script>'."\n"; print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_head.js"></script>'."\n";
if (file_exists(DOL_DOCUMENT_ROOT.'/lib/lib_head_perso.js'))
{
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_head_perso.js"></script>';
}
} }
if ($conf->use_ajax) if ($conf->use_ajax)
{ {