New: Gestion des avoirs la saisie des factures

This commit is contained in:
Laurent Destailleur
2006-04-04 00:12:45 +00:00
parent f0ca61ce1c
commit b9b4fc5ff6
12 changed files with 613 additions and 375 deletions

View File

@@ -1,6 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -172,11 +172,12 @@ if ($_socid > 0)
/* /*
* Liste de l'historique des remises * Liste de l'historique des remises
*/ */
$sql = "SELECT rc.rowid,rc.remise_client,".$db->pdate("rc.datec")." as dc, u.code"; $sql = "SELECT rc.rowid,rc.remise_client,".$db->pdate("rc.datec")." as dc,";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; $sql.= " u.rowid as user_id, u.code";
$sql .= " WHERE rc.fk_soc =". $objsoc->id; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u";
$sql .= " AND u.rowid = rc.fk_user_author"; $sql.= " WHERE rc.fk_soc =". $objsoc->id;
$sql .= " ORDER BY rc.datec DESC"; $sql.= " AND u.rowid = rc.fk_user_author";
$sql.= " ORDER BY rc.datec DESC";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
@@ -186,7 +187,7 @@ if ($_socid > 0)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>'; print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Discount").'</td>'; print '<td>'.$langs->trans("Discount").'</td>';
print '<td>'.$langs->trans("User").'</td>'; print '<td align="center">'.$langs->trans("User").'</td>';
print '</tr>'; print '</tr>';
$i = 0 ; $i = 0 ;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@@ -198,7 +199,7 @@ if ($_socid > 0)
print '<tr '.$bc[$tag].'>'; print '<tr '.$bc[$tag].'>';
print '<td>'.dolibarr_print_date($obj->dc,"%d %B %Y %H:%M").'</td>'; print '<td>'.dolibarr_print_date($obj->dc,"%d %B %Y %H:%M").'</td>';
print '<td>'.$obj->remise_client.' %</td>'; print '<td>'.$obj->remise_client.' %</td>';
print '<td>'.$obj->code.'</td>'; print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->code.'</a></td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }

View File

@@ -94,6 +94,22 @@ if ($_POST['action'] == 'setconditions')
if ($result < 0) dolibarr_print_error($facture->db,$facture->error); if ($result < 0) dolibarr_print_error($facture->db,$facture->error);
} }
if ($_POST['action'] == 'setremisepercent' && $user->rights->facture->creer)
{
$fac = new Facture($db);
$fac->fetch($_POST['facid']);
$result = $fac->set_remise($user, $_POST['remise_percent']);
$_GET['facid']=$_POST['facid'];
}
if ($_POST['action'] == 'setremiseabsolue' && $user->rights->facture->creer)
{
$fac = new Facture($db);
$fac->fetch($_POST['facid']);
$result = $fac->set_remise_absolue($user, $_POST['remise_absolue']);
$_GET['facid']=$_POST['facid'];
}
if ($_POST['action'] == 'classin') if ($_POST['action'] == 'classin')
{ {
$facture = new Facture($db); $facture = new Facture($db);
@@ -108,6 +124,28 @@ if ($_POST['action'] == 'set_ref_client')
$facture->set_ref_client($_POST['ref_client']); $facture->set_ref_client($_POST['ref_client']);
} }
// Classe <20> "valid<69>e"
if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->facture->valider)
{
$fac = new Facture($db);
$fac->fetch($_GET['facid']);
$soc = new Societe($db);
$soc->fetch($fac->socidp);
$result = $fac->set_valid($fac->id, $user, $soc);
if ($result)
{
facture_pdf_create($db, $fac->id);
}
}
// Classe <20> "pay<61>e"
if ($_POST['action'] == 'confirm_payed' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement)
{
$fac = new Facture($db);
$fac->fetch($_GET['facid']);
$result = $fac->set_payed($user);
}
/* /*
* Insertion facture * Insertion facture
*/ */
@@ -134,7 +172,7 @@ if ($_POST['action'] == 'add')
$facture->cond_reglement_id = $_POST['cond_reglement_id']; $facture->cond_reglement_id = $_POST['cond_reglement_id'];
$facture->mode_reglement_id = $_POST['mode_reglement_id']; $facture->mode_reglement_id = $_POST['mode_reglement_id'];
$facture->amount = $_POST['amount']; $facture->amount = $_POST['amount'];
$facture->remise = $_POST['remise']; $facture->remise_absolue = $_POST['remise_absolue'];
$facture->remise_percent = $_POST['remise_percent']; $facture->remise_percent = $_POST['remise_percent'];
$facture->ref_client = $_POST['ref_client']; $facture->ref_client = $_POST['ref_client'];
@@ -303,35 +341,6 @@ if ($_POST['action'] == 'add')
} }
} }
// Classe <20> "valid<69>e"
if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->facture->valider)
{
$fac = new Facture($db);
$fac->fetch($_GET['facid']);
$soc = new Societe($db);
$soc->fetch($fac->socidp);
$result = $fac->set_valid($fac->id, $user, $soc);
if ($result)
{
facture_pdf_create($db, $fac->id);
}
}
// Classe <20> "pay<61>e"
if ($_POST['action'] == 'confirm_payed' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement)
{
$fac = new Facture($db);
$fac->fetch($_GET['facid']);
$result = $fac->set_payed($user);
}
if ($_POST['action'] == 'setremise' && $user->rights->facture->creer)
{
$fac = new Facture($db);
$fac->fetch($_GET['facid']);
$result = $fac->set_remise($user, $_POST['remise']);
}
if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $user->rights->facture->creer) if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $user->rights->facture->creer)
{ {
if ($_POST['qty'] && ( $_POST['desc'] || $_POST['idprod'])) if ($_POST['qty'] && ( $_POST['desc'] || $_POST['idprod']))
@@ -676,45 +685,77 @@ if ($_GET['action'] == 'create')
print '<form name="add" action="facture.php" method="post">'; print '<form name="add" action="facture.php" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n"; print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
print '<input name="facnumber" type="hidden" value="provisoire">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Reference // Reference
print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>'; print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
print '<input name="facnumber" type="hidden" value="provisoire">';
// Societe
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$soc->nom_url.'</td>'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$soc->nom_url.'</td>';
print '</tr>'; print '</tr>';
print '<tr><td>'.$langs->trans('Author').'</td><td colspan="2">'.$user->fullname.'</td>'; // Date facture
print '</tr>'; print '<tr><td>'.$langs->trans('Date').'</td><td colspan="2">';
print '<tr><td>'.$langs->trans('Date').'</td><td>';
$html->select_date('','','','','',"add"); $html->select_date('','','','','',"add");
print '</td></tr>'; print '</td></tr>';
// Conditions de r<>glement // Conditions de r<>glement
print '<tr><td nowrap>'.$langs->trans('PaymentConditions').'</td><td>'; print '<tr><td nowrap>'.$langs->trans('PaymentConditions').'</td><td colspan="2">';
$html->select_conditions_paiements($cond_reglement_id,'cond_reglement_id'); $html->select_conditions_paiements($cond_reglement_id,'cond_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Mode de r<>glement // Mode de r<>glement
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>'; print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
$html->select_types_paiements($mode_reglement_id,'mode_reglement_id'); $html->select_types_paiements($mode_reglement_id,'mode_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Remise relative
$relative_discount=$soc->remise_client;
print '<tr><td>'.$langs->trans("CustomerRelativeDiscount").'</td>';
print '<td>';
print '<input type="text" name="remise_percent" size="1" value="'.$relative_discount.'"> %';
print '</td><td>'.img_info().' ';
if ($relative_discount)
{
print $langs->trans("CompanyHasRelativeDiscount",$relative_discount);
}
else
{
print $langs->trans("CompanyHasNoRelativeDiscount");
}
print '</td></tr>';
// Remise avoirs
$absolute_discount=$soc->getCurrentDiscount();
print '<tr><td>'.$langs->trans("CustomerAbsoluteDiscount").'</td>';
print '<td>';
print '<input type="text" name="remise_absolue" size="1" value="0"> '.$langs->trans("Currency".$conf->monnaie);
print '</td><td>'.img_info().' ';
if ($absolute_discount)
{
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
}
else
{
print $langs->trans("CompanyHasNoAbsoluteDiscount");
}
print '</td></tr>';
// Projet // Projet
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
$langs->load('projects'); $langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>'; print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
$html->select_projects($societe_id, $projet, 'projetid'); $html->select_projects($societe_id, $projet, 'projetid');
print '</td></tr>'; print '</td></tr>';
} }
// Note publique // Note publique
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>'; print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top">'; print '<td valign="top" colspan="2">';
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">'; print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
if (is_object($propal)) if (is_object($propal))
{ {
@@ -731,8 +772,9 @@ if ($_GET['action'] == 'create')
print '</textarea></td></tr>'; print '</textarea></td></tr>';
// Note priv<69>e // Note priv<69>e
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>'; print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top">'; print '<td valign="top" colspan="2">';
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'; print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">';
if (is_object($propal)) if (is_object($propal))
{ {
@@ -766,7 +808,7 @@ if ($_GET['action'] == 'create')
print '<input type="hidden" name="amount" value="'.$propal->price.'">'."\n"; print '<input type="hidden" name="amount" value="'.$propal->price.'">'."\n";
print '<input type="hidden" name="total" value="'.$propal->total.'">'."\n"; print '<input type="hidden" name="total" value="'.$propal->total.'">'."\n";
print '<input type="hidden" name="tva" value="'.$propal->tva.'">'."\n"; print '<input type="hidden" name="tva" value="'.$propal->tva.'">'."\n";
print '<input type="hidden" name="remise" value="'.$propal->remise.'">'."\n"; print '<input type="hidden" name="remise_absolue" value="'.$propal->remise_absolue.'">'."\n";
print '<input type="hidden" name="remise_percent" value="'.$propal->remise_percent.'">'."\n"; print '<input type="hidden" name="remise_percent" value="'.$propal->remise_percent.'">'."\n";
print '<input type="hidden" name="propalid" value="'.$propal->id.'">'; print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
@@ -781,7 +823,7 @@ if ($_GET['action'] == 'create')
print '<input type="hidden" name="amount" value="'.$commande->total_ht.'">'."\n"; print '<input type="hidden" name="amount" value="'.$commande->total_ht.'">'."\n";
print '<input type="hidden" name="total" value="'.$commande->total_ttc.'">'."\n"; print '<input type="hidden" name="total" value="'.$commande->total_ttc.'">'."\n";
print '<input type="hidden" name="tva" value="'.$commande->tva.'">'."\n"; print '<input type="hidden" name="tva" value="'.$commande->tva.'">'."\n";
print '<input type="hidden" name="remise" value="'.$commande->remise.'">'."\n"; print '<input type="hidden" name="remise_absolue" value="'.$commande->remise_absolue.'">'."\n";
print '<input type="hidden" name="remise_percent" value="'.$commande->remise_percent.'">'."\n"; print '<input type="hidden" name="remise_percent" value="'.$commande->remise_percent.'">'."\n";
print '<input type="hidden" name="commandeid" value="'.$commande->id.'">'; print '<input type="hidden" name="commandeid" value="'.$commande->id.'">';
@@ -793,14 +835,14 @@ if ($_GET['action'] == 'create')
elseif ($_GET['contratid'] > 0) elseif ($_GET['contratid'] > 0)
{ {
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
$contrat->remise=0; $contrat->remise_absolue=0;
$contrat->remise_percent=$soc->remise_client; $contrat->remise_percent=$soc->remise_client;
$contrat->update_price(); $contrat->update_price();
print '<input type="hidden" name="amount" value="'.$contrat->total_ht.'">'."\n"; print '<input type="hidden" name="amount" value="'.$contrat->total_ht.'">'."\n";
print '<input type="hidden" name="total" value="'.$contrat->total_ttc.'">'."\n"; print '<input type="hidden" name="total" value="'.$contrat->total_ttc.'">'."\n";
print '<input type="hidden" name="tva" value="'.$contrat->total_tva.'">'."\n"; print '<input type="hidden" name="tva" value="'.$contrat->total_tva.'">'."\n";
print '<input type="hidden" name="remise" value="'.$contrat->remise.'">'."\n"; print '<input type="hidden" name="remise_absolue" value="'.$contrat->remise_absolue.'">'."\n";
print '<input type="hidden" name="remise_percent" value="'.$contrat->remise_percent.'">'."\n"; print '<input type="hidden" name="remise_percent" value="'.$contrat->remise_percent.'">'."\n";
print '<input type="hidden" name="contratid" value="'.$contrat->id.'">'; print '<input type="hidden" name="contratid" value="'.$contrat->id.'">';
@@ -813,6 +855,7 @@ if ($_GET['action'] == 'create')
{ {
print '<tr><td colspan="3">'; print '<tr><td colspan="3">';
// Zone de choix des produits pr<70>d<EFBFBD>finis <20> la cr<63>ation
print '<table class="noborder">'; print '<table class="noborder">';
print '<tr><td>'.$langs->trans('ProductsAndServices').'</td><td>'.$langs->trans('Qty').'</td><td>'.$langs->trans('Discount').'</td><td> &nbsp; &nbsp; </td>'; print '<tr><td>'.$langs->trans('ProductsAndServices').'</td><td>'.$langs->trans('Qty').'</td><td>'.$langs->trans('Discount').'</td><td> &nbsp; &nbsp; </td>';
if ($conf->service->enabled) if ($conf->service->enabled)
@@ -828,7 +871,7 @@ if ($_GET['action'] == 'create')
else else
$html->select_produits('','idprod'.$i,'',$conf->produit->limit_size); $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size);
print '</td>'; print '</td>';
print '<td><input type="text" size="3" name="qty'.$i.'" value="1"></td>'; print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>';
print '<td nowrap="nowrap"><input type="text" size="1" name="remise_percent'.$i.'" value="0">%</td>'; print '<td nowrap="nowrap"><input type="text" size="1" name="remise_percent'.$i.'" value="0">%</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
// Si le module service est actif, on propose des dates de d<>but et fin <20> la ligne // Si le module service est actif, on propose des dates de d<>but et fin <20> la ligne
@@ -882,9 +925,10 @@ if ($_GET['action'] == 'create')
// Bouton "Create Draft" // Bouton "Create Draft"
print '<tr><td colspan="3" align="center"><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></td></tr>'; print '<tr><td colspan="3" align="center"><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></td></tr>';
print "</form>\n";
print "</table>\n"; print "</table>\n";
print "</form>\n";
// Si creation depuis un propal // Si creation depuis un propal
if ($_GET['propalid']) if ($_GET['propalid'])
{ {
@@ -1161,7 +1205,8 @@ else
{ {
$soc = new Societe($db, $fac->socidp); $soc = new Societe($db, $fac->socidp);
$soc->fetch($fac->socidp); $soc->fetch($fac->socidp);
$avoir_en_cours=$soc->getCurrentDiscount();
$author = new User($db); $author = new User($db);
if ($fac->user_author) if ($fac->user_author)
{ {
@@ -1227,62 +1272,8 @@ else
// Dates // Dates
print '<tr><td>'.$langs->trans('Date').'</td>'; print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="3">'.dolibarr_print_date($fac->date,'%A %d %B %Y').'</td>'; print '<td colspan="3">'.dolibarr_print_date($fac->date,'%A %d %B %Y').'</td>';
print '<td>'.$langs->trans('DateMaxPayment').'</td><td>' . dolibarr_print_date($fac->date_lim_reglement,'%A %d %B %Y');
if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans('Late')); $nbrows=8;
print '</td></tr>';
// Conditions et modes de r<>glement
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditions');
print '</td>';
if ($_GET['action'] != 'editconditions' && $fac->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editconditions')
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'cond_reglement_id');
}
else
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'none');
}
print '</td>';
print '<td width="25%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($_GET['action'] != 'editmode' && $fac->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td width="25%">';
if ($_GET['action'] == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->mode_reglement_id,'mode_reglement_id');
}
else
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->mode_reglement_id,'none');
}
print '</td></tr>';
// Remise globale
print '<tr><td>'.$langs->trans('GlobalDiscount').'</td>';
if ($fac->brouillon == 1 && $user->rights->facture->creer)
{
print '<td colspan="3">';
print '<form action="facture.php?facid='.$fac->id.'" method="post">';
print '<input type="hidden" name="action" value="setremise">';
print '<input type="text" name="remise" size="1" value="'.$fac->remise_percent.'">% ';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
print '</td>';
}
else
{
print '<td colspan="3">'.$fac->remise_percent.'%</td>';
}
$nbrows=5;
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++; if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++;
print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">'; print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
@@ -1339,8 +1330,52 @@ else
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print '</td></tr>';
// Date limite reglement
print '<tr>';
print '<td>'.$langs->trans('DateMaxPayment').'</td>';
print '<td colspan="3">' . dolibarr_print_date($fac->date_lim_reglement,'%A %d %B %Y');
if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans('Late'));
print '</td></tr>'; print '</td></tr>';
// Conditions de r<>glement
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditions');
print '</td>';
if ($_GET['action'] != 'editconditions' && $fac->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editconditions')
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'cond_reglement_id');
}
else
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'none');
}
print '</td></tr>';
// Mode de reglement
print '<tr><td width="25%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($_GET['action'] != 'editmode' && $fac->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;facid='.$fac->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->mode_reglement_id,'mode_reglement_id');
}
else
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->mode_reglement_id,'none');
}
print '</td></tr>';
/* /*
\todo \todo
L'info "Reference commande client" est une carac de la commande et non de la facture. L'info "Reference commande client" est une carac de la commande et non de la facture.
@@ -1365,10 +1400,37 @@ else
} }
} }
// Lit lignes de facture pour d<>terminer montant
// On s'en sert pas mais ca sert pour debuggage
$sql = 'SELECT l.price as price, l.qty, l.rowid, l.tva_taux,';
$sql .= ' l.remise_percent, l.subprice';
$sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l ';
$sql .= ' WHERE l.fk_facture = '.$fac->id;
$resql = $db->query($sql);
if ($resql)
{
$num_lignes = $db->num_rows($resql);
$i=0;
$total_lignes_ht=0;
$total_lignes_vat=0;
$total_lignes_ttc=0;
while ($i < $num_lignes)
{
$obj=$db->fetch_object($resql);
$ligne_ht=($obj->price*$obj->qty);
$ligne_vat=($ligne_ht*$obj->tva_taux/100);
$ligne_ttc=($ligne_ht+$ligne_vat);
$total_lignes_ht+=$ligne_ht;
$total_lignes_vat+=$ligne_vat;
$total_lignes_ttc+=$ligne_ttc;
$i++;
}
}
// Montants
print '<tr><td>'.$langs->trans('AmountHT').'</td>'; print '<tr><td>'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2" nowrap><b>'.price($fac->total_ht).'</b></td>'; print '<td align="right" colspan="2" nowrap>'.price($fac->total_ht).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_tva).'</td>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_tva).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_ttc).'</td>'; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_ttc).'</td>';
@@ -1420,12 +1482,10 @@ else
$sql .= ' '.$db->pdate('l.date_start').' as date_start,'; $sql .= ' '.$db->pdate('l.date_start').' as date_start,';
$sql .= ' '.$db->pdate('l.date_end').' as date_end, '; $sql .= ' '.$db->pdate('l.date_end').' as date_end, ';
$sql .= ' p.ref, p.fk_product_type, p.label as product'; $sql .= ' p.ref, p.fk_product_type, p.label as product';
if ($conf->global->FAC_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC) if ($conf->global->FAC_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC)
{ {
$sql.= ', p.description as product_desc'; $sql.= ', p.description as product_desc';
} }
$sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l '; $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l ';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON l.fk_product=p.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON l.fk_product=p.rowid';
$sql .= ' WHERE l.fk_facture = '.$fac->id; $sql .= ' WHERE l.fk_facture = '.$fac->id;
@@ -1585,6 +1645,100 @@ else
dolibarr_print_error($db); dolibarr_print_error($db);
} }
/*
* Lignes de remise
*/
// Remise relative
$var=!$var;
print '<form name="updateligne" action="facture.php" 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>';
}
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>';
// Remise absolue
$var=!$var;
print '<form name="updateligne" action="facture.php" 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">('.($avoir_en_cours?$langs->trans("CompanyHasAbsoluteDiscount",$avoir_en_cours,$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>';
}
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
*/ */

View File

@@ -285,7 +285,7 @@ if ($socid > 0)
print '</td></tr></table>'; print '</td></tr></table>';
print '</td>'; print '</td>';
print '<td colspan="3">'; print '<td colspan="3">';
$amount_discount=$societe->getcurrentDiscount(); $amount_discount=$societe->getCurrentDiscount();
if ($amount_discount < 0) dolibarr_print_error($db,$societe->error); if ($amount_discount < 0) dolibarr_print_error($db,$societe->error);
if ($amount_discount > 0) print $amount_discount.'&nbsp;'.$langs->trans("Currency".$conf->monnaie); if ($amount_discount > 0) print $amount_discount.'&nbsp;'.$langs->trans("Currency".$conf->monnaie);
else print $langs->trans("None"); else print $langs->trans("None");

View File

@@ -122,8 +122,9 @@ class Facture
$this->mode_reglement = $_facrec->mode_reglement_id; $this->mode_reglement = $_facrec->mode_reglement_id;
$this->mode_reglement_id = $_facrec->mode_reglement_id; $this->mode_reglement_id = $_facrec->mode_reglement_id;
$this->amount = $_facrec->amount; $this->amount = $_facrec->amount;
$this->remise = $_facrec->remise; $this->remise_absolue = $_facrec->remise_absolue;
$this->remise_percent = $_facrec->remise_percent; $this->remise_percent = $_facrec->remise_percent;
$this->remise_absolue = $_facrec->remise;
} }
// Definition de la date limite // Definition de la date limite
@@ -138,15 +139,15 @@ class Facture
$totalht = ($amount - $remise); $totalht = ($amount - $remise);
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture ('; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture (';
$sql.= ' facnumber, fk_soc, datec, amount, remise, remise_percent,'; $sql.= ' facnumber, fk_soc, datec, amount, remise_absolue, remise_percent,';
$sql.= ' datef,'; $sql.= ' datef,';
$sql.= ' note,'; $sql.= ' note,';
$sql.= ' note_public,'; $sql.= ' note_public,';
$sql.= ' fk_user_author, fk_projet,'; $sql.= ' fk_user_author, fk_projet,';
$sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement, ref_client) '; $sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement, ref_client) ';
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "'$number','$socid', now(), '$totalht', '$remise'"; $sql.= "'$number','$socid', now(), '$totalht', '".$this->remise_absolue."'";
$sql.= ",'$this->remise_percent', ".$this->db->idate($this->date); $sql.= ",'".$this->remise_percent."', ".$this->db->idate($this->date);
$sql.= ",".($this->note?"'".addslashes($this->note)."'":"null"); $sql.= ",".($this->note?"'".addslashes($this->note)."'":"null");
$sql.= ",".($this->note_public?"'".addslashes($this->note_public)."'":"null"); $sql.= ",".($this->note_public?"'".addslashes($this->note_public)."'":"null");
$sql.= ",".$user->id; $sql.= ",".$user->id;
@@ -154,7 +155,7 @@ class Facture
$sql.= ','.$this->cond_reglement_id; $sql.= ','.$this->cond_reglement_id;
$sql.= ",".$this->mode_reglement_id; $sql.= ",".$this->mode_reglement_id;
$sql.= ','.$this->db->idate($datelim); $sql.= ','.$this->db->idate($datelim);
$sql.= ', \''.$this->ref_client.'\')'; $sql.= ", '".$this->ref_client."')";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@@ -281,7 +282,7 @@ class Facture
/* /*
* \brief Affecte la remise exceptionnelle * \todo Plus utilis<69>. A reprendre dans validation facture
*/ */
function _affect_remise_exceptionnelle() function _affect_remise_exceptionnelle()
{ {
@@ -289,60 +290,19 @@ class Facture
$this->db->begin(); $this->db->begin();
if ($this->remise_exceptionnelle[1] > 0) $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql .= ' SET fk_facture = '.$this->id.',';
$sql .= " amount_ht = '".price2num($remise)."'";
$sql .= ' WHERE rowid ='.$this->remise_exceptionnelle[0];
$sql .= ' AND fk_soc ='. $this->socidp;
if (! $this->db->query( $sql))
{ {
// Calcul valeur de remise a appliquer (remise) et reliquat $error++;
if ($this->remise_exceptionnelle[1] > ($this->total_ht * 0.9)) }
{
$remise = floor($this->total_ht * 0.9);
$reliquat = $this->remise_exceptionnelle[1] - $remise;
}
else
{
$remise = $this->remise_exceptionnelle[1];
$reliquat=0;
}
$result_insert = $this->addline($this->id, if ($reliquat > 0)
'Remise exceptionnelle', {
'',
(0 - $remise),
1,
'0'); // Une remise est un n<>gatif sur le TTC, on ne doit pas appliquer de TVA,
// sinon on impute une TVA n<>gative.
if ($result_insert < 0)
{
$error++;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql .= ' SET fk_facture = '.$this->id;
$sql .= " ,amount_ht = '".price2num($remise)."'";
$sql .= ' WHERE rowid ='.$this->remise_exceptionnelle[0];
$sql .= ' AND fk_soc ='. $this->socidp;
if (! $this->db->query( $sql))
{
$error++;
}
if ($reliquat > 0)
{
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'societe_remise_except';
$sql .= ' (fk_soc, datec, amount_ht, fk_user) ';
$sql .= ' VALUES ';
$sql .= ' ('.$this->socidp;
$sql .= ' ,now()';
$sql .= " ,'".price2num($reliquat)."'";
$sql .= ' ,'.$this->remise_exceptionnelle[3];
$sql .= ')';
if (! $this->db->query( $sql) )
{
$error++;
}
}
} }
if (! $error) if (! $error)
@@ -367,7 +327,7 @@ class Facture
{ {
//dolibarr_syslog("Facture::Fetch rowid : $rowid, societe_id : $societe_id"); //dolibarr_syslog("Facture::Fetch rowid : $rowid, societe_id : $societe_id");
$sql = 'SELECT f.fk_soc,f.facnumber,f.amount,f.tva,f.total,f.total_ttc,f.remise,f.remise_percent'; $sql = 'SELECT f.fk_soc,f.facnumber,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise';
$sql .= ','.$this->db->pdate('f.datef').' as df, f.fk_projet'; $sql .= ','.$this->db->pdate('f.datef').' as df, f.fk_projet';
$sql .= ','.$this->db->pdate('f.date_lim_reglement').' as dlr'; $sql .= ','.$this->db->pdate('f.date_lim_reglement').' as dlr';
$sql .= ', f.note, f.note_public, f.paye, f.fk_statut, f.fk_user_author'; $sql .= ', f.note, f.note_public, f.paye, f.fk_statut, f.fk_user_author';
@@ -395,12 +355,13 @@ class Facture
$this->ref = $obj->facnumber; $this->ref = $obj->facnumber;
$this->ref_client = $obj->ref_client; $this->ref_client = $obj->ref_client;
$this->amount = $obj->amount; $this->amount = $obj->amount;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
$this->remise = $obj->remise; $this->remise = $obj->remise;
$this->total_ht = $obj->total; $this->total_ht = $obj->total;
$this->total_tva = $obj->tva; $this->total_tva = $obj->tva;
$this->total_ttc = $obj->total_ttc; $this->total_ttc = $obj->total_ttc;
$this->paye = $obj->paye; $this->paye = $obj->paye;
$this->remise_percent = $obj->remise_percent;
$this->socidp = $obj->fk_soc; $this->socidp = $obj->fk_soc;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->date_lim_reglement = $obj->dlr; $this->date_lim_reglement = $obj->dlr;
@@ -492,84 +453,26 @@ class Facture
$this->client = $client; $this->client = $client;
} }
/** /**
* \brief Valide la facture * \brief Valide la facture
* \param userid id de l'utilisateur qui valide * \param userid Id de l'utilisateur qui valide
*/ * \return int <0 si ko, >0 si ok
* \remarks Utiliser set_valid directement plutot que cette methode
* \deprecated
*/
function valid($userid) function valid($userid)
{ {
$error = 0; $user=new User($this->db);
$user->fetch($userid);
if ($this->db->begin())
{ $soc=new Societe($this->db);
/* $soc->fetch($this->socidp);
* Lecture de la remise exceptionnelle
* return set_valid($this->rowid,$user,$soc,'');
*/
$sql = 'SELECT rowid, rc.amount_ht, fk_soc, fk_user';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
$sql .= ' WHERE rc.fk_soc ='. $this->socidp;
$sql .= ' AND fk_facture IS NULL';
$resql = $this->db->query($sql) ;
if ( $resql)
{
$nurmx = $this->db->num_rows($resql);
if ($nurmx > 0)
{
$row = $this->db->fetch_row($resql);
$this->remise_exceptionnelle = $row;
}
$this->db->free($resql);
}
else
{
dolibarr_syslog('Facture::Valide Erreur lecture Remise');
$error++;
}
/*
* Affectation de la remise exceptionnelle
*/
if ( $this->_affect_remise_exceptionnelle() <> 0)
{
$error++;
}
else
{
$this->updateprice($this->id);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET fk_statut = 1, date_valid=now(), fk_user_valid='.$userid;
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
if (! $this->db->query($sql) )
{
$error++;
dolibarr_syslog('Facture::Valide Erreur ');
}
}
if ($error == 0)
{
$this->db->commit();
}
else
{
$this->db->rollback();
}
}
else
{
$error++;
}
if ($error > 0)
{
return 0;
}
else
{
return 1;
}
} }
/** /**
* \brief Classe la facture dans un projet * \brief Classe la facture dans un projet
* \param projid Id du projet dans lequel classer la facture * \param projid Id du projet dans lequel classer la facture
@@ -612,9 +515,9 @@ class Facture
} }
/** /**
* \brief Supprime la facture * \brief Supprime la facture
* \param rowid id de la facture <20> supprimer * \param rowid id de la facture <20> supprimer
*/ */
function delete($rowid) function delete($rowid)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
@@ -633,11 +536,9 @@ class Facture
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid;
if ($this->db->query( $sql) ) if ($this->db->query( $sql) )
{ {
/* // On d<>saffecte de la facture les remises li<6C>es
* On repositionne la remise
*/
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql .= ' SET fk_facture = NULL WHERE fk_facture = '.$rowid; $sql.= ' SET fk_facture = NULL WHERE fk_facture = '.$rowid;
if ($this->db->query( $sql) ) if ($this->db->query( $sql) )
{ {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid.' AND fk_statut = 0'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid.' AND fk_statut = 0';
@@ -828,11 +729,12 @@ class Facture
} }
/** /**
* \brief Tag la facture comme valid<69>e + appel trigger BILL_VALIDATE * \brief Tag la facture comme valid<69>e + appel trigger BILL_VALIDATE
* \param rowid Id de la facture <20> valider * \param rowid Id de la facture <20> valider
* \param user Utilisateur qui valide la facture * \param user Utilisateur qui valide la facture
* \param soc Objet societe * \param soc Objet societe
* \param force_number R<EFBFBD>f<EFBFBD>rence <20> forcer de la facture * \param force_number R<EFBFBD>f<EFBFBD>rence <20> forcer de la facture
* \return int <0 si ko, >0 si ok
*/ */
function set_valid($rowid, $user, $soc, $force_number='') function set_valid($rowid, $user, $soc, $force_number='')
{ {
@@ -841,6 +743,8 @@ class Facture
$error = 0; $error = 0;
if ($this->brouillon) if ($this->brouillon)
{ {
$this->db->begin();
$action_notify = 2; // ne pas modifier cette valeur $action_notify = 2; // ne pas modifier cette valeur
if ($force_number) if ($force_number)
{ {
@@ -851,67 +755,98 @@ class Facture
$numfa = $this->getNextNumRef($soc); $numfa = $this->getNextNumRef($soc);
} }
$this->db->begin(); $this->updateprice($this->id);
/*
* Affectation de la remise exceptionnelle
*
* \todo Appliquer la remise avoir dans les lignes quand brouillon plutot
* qu'au moment de la validation
*/
$sql = 'SELECT rowid, rc.amount_ht, fk_soc, fk_user';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
$sql .= ' WHERE rc.fk_soc ='. $this->socidp;
$sql .= ' AND fk_facture IS NULL';
$resql = $this->db->query($sql) ;
if ($resql)
{
$nurmx = $this->db->num_rows($resql);
if ($nurmx > 0)
{
$row = $this->db->fetch_row($resql);
$this->remise_exceptionnelle = $row;
}
$this->db->free($resql);
}
else
{
dolibarr_syslog('Facture::Valide Erreur lecture Remise');
$error++;
}
if ( $this->_affect_remise_exceptionnelle() <> 0)
{
$error++;
}
else
{
$this->updateprice($this->id);
}
/* Validation de la facture */ // Validation de la facture
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture ';
$sql.= " SET facnumber='".$numfa."', fk_statut = 1, fk_user_valid = ".$user->id; $sql.= " SET facnumber='".$numfa."', fk_statut = 1, fk_user_valid = ".$user->id;
/* Si l'option est activ<69>e on force la date de facture */
if ($conf->global->FAC_FORCE_DATE_VALIDATION) if ($conf->global->FAC_FORCE_DATE_VALIDATION)
{ {
// Si l'option est activ<69>e, on force la date de facture
$this->date=time(); $this->date=time();
$datelim=$this->calculate_date_lim_reglement(); $datelim=$this->calculate_date_lim_reglement();
$sql .= ', datef='.$this->db->idate($this->date); $sql.= ', datef='.$this->db->idate($this->date);
$sql .= ', date_lim_reglement='.$this->db->idate($datelim); $sql.= ', date_lim_reglement='.$this->db->idate($datelim);
} }
$sql .= ' WHERE rowid = '.$rowid; $sql.= ' WHERE rowid = '.$rowid;
$resql = $this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->facnumber=$numfa; $this->facnumber=$numfa;
} }
else else
{ {
dolibarr_syslog("Facture::set_valid() Echec - 10"); dolibarr_syslog("Facture::set_valid() Echec update - 10");
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
$error++; $error++;
} }
/*
* Lit les avoirs / remises absolues en cours et les d<>cr<63>mente
*/
$remise_a_decrementee=$this->remise_absolue;
if ($remise_a_decrementee)
{
$sql = 'SELECT rowid, fk_soc, datec, rc.amount_ht as amount, fk_user, description';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
$sql.= ' WHERE rc.fk_soc ='. $this->socidp;
$sql.= ' AND fk_facture IS NULL';
$sql.= ' ORDER BY datec';
$resql = $this->db->query($sql) ;
if ($resql)
{
$nurmx = $this->db->num_rows($resql);
if ($nurmx > 0)
{
$i=0;
while ($i < $nurmx && $remise_a_decrementee && ! $error)
{
$obj = $this->db->fetch_object($resql);
$avoir=$obj->amount;
// On met <20> jour avoir comme affect<63> <20> facture
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql.= ' SET fk_facture = '.$this->id.',';
$sql.= " amount_ht = '".price2num(min($remise_a_decrementee,$avoir))."'";
$sql.= ' WHERE rowid ='.$obj->rowid;
dolibarr_syslog("Societe::set_valid Mise a jour avoir sql=$sql");
if (! $this->db->query($sql))
{
$error++;
}
if ($remise_a_decrementee < $avoir)
{
// L'avoir n'a pas <20>t<EFBFBD> compl<70>tement consomm<6D>e, on ins<6E>re ligne du reste
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'societe_remise_except';
$sql.= ' (fk_soc, datec, amount_ht, fk_user, fk_facture, description) ';
$sql.= ' VALUES ';
$sql.= ' ('.$this->socidp;
$sql.= ' ,'.$obj->datec;
$sql.= " ,'".price2num($avoir - $remise_a_decrementee)."'";
$sql.= ' ,'.$user->id;
$sql.= ' ,null';
$sql.= " ,'".addslashes($obj->description)."'";
$sql.= ')';
if (! $this->db->query( $sql))
{
$error++;
}
}
$remise_a_decrementee-=min($remise_a_decrementee,$avoir);
$i++;
}
}
$this->db->free($resql);
}
else
{
dolibarr_syslog('Facture::set_valid() Erreur lecture Remise');
$error++;
}
}
/* /*
* Pour chaque produit, on met a jour indicateur nbvente * Pour chaque produit, on met a jour indicateur nbvente
@@ -950,10 +885,9 @@ class Facture
$result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf);
// Fin appel triggers // Fin appel triggers
$this->db->commit();
/* /*
* Notify * Notify
* \todo Mettre notifications dans triggers
*/ */
$facref = sanitize_string($this->ref); $facref = sanitize_string($this->ref);
$filepdf = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf'; $filepdf = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf';
@@ -962,12 +896,14 @@ class Facture
$notify = New Notify($this->db); $notify = New Notify($this->db);
$notify->send($action_notify, $this->socidp, $mesg, 'facture', $rowid, $filepdf); $notify->send($action_notify, $this->socidp, $mesg, 'facture', $rowid, $filepdf);
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->db->rollback();
$this->error=$this->db->error(); $this->error=$this->db->error();
$this->db->rollback();
return -1; return -1;
} }
} }
@@ -1054,10 +990,12 @@ class Facture
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->socidp); $soc->fetch($this->socidp);
$remise_client = $soc->remise_client; $remise_client = $soc->remise_client;
/* La remise est client n'est pas a mettre au niveau ligne de produit mais globale
if ($remise_client > $remise_percent) if ($remise_client > $remise_percent)
{ {
$remise_percent = $remise_client ; $remise_percent = $remise_client ;
} }
*/
} }
if ($remise_percent > 0) if ($remise_percent > 0)
@@ -1204,14 +1142,18 @@ class Facture
} }
/** /**
* \brief Mise <20> jour des sommes de la facture * \brief Mise <20> jour des sommes de la facture
* \param facid id de la facture a modifier * \param facid id de la facture a modifier
*/ * \return int <0 si ko, >0 si ok
*/
function updateprice($facid) function updateprice($facid)
{ {
include_once DOL_DOCUMENT_ROOT . '/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT . '/lib/price.lib.php';
$err=0; $err=0;
$sql = 'SELECT price, qty, tva_taux FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$facid;
// Lit les lignes detail
$sql = 'SELECT qty, tva_taux, subprice, remise_percent, price';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$facid;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@@ -1220,6 +1162,7 @@ class Facture
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
// qty, tva_taux, sub_price = prix unitaire HT, remise_percent, price = prix unitaire HT apres remise %
$products[$i][0] = $obj->price; $products[$i][0] = $obj->price;
$products[$i][1] = $obj->qty; $products[$i][1] = $obj->qty;
$products[$i][2] = $obj->tva_taux; $products[$i][2] = $obj->tva_taux;
@@ -1230,7 +1173,7 @@ class Facture
/* /*
* *
*/ */
$calculs = calcul_price($products, $this->remise_percent); $calculs = calcul_price($products, $this->remise_percent, $this->remise_absolue);
$this->total_remise = $calculs[3]; $this->total_remise = $calculs[3];
$this->amount_ht = $calculs[4]; $this->amount_ht = $calculs[4];
$this->total_ht = $calculs[0]; $this->total_ht = $calculs[0];
@@ -1295,34 +1238,72 @@ class Facture
} }
/** /**
* \brief Applique une remise * \brief Applique une remise relative sur facture
* \param user * \param user User qui positionne la remise
* \param remise * \param remise
*/ * \return int <0 si ko, >0 si ok
*/
function set_remise($user, $remise) function set_remise($user, $remise)
{ {
$remise=trim($remise)?trim($remise):0;
if ($user->rights->facture->creer) if ($user->rights->facture->creer)
{ {
$this->remise_percent = $remise ; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET remise_percent = '.price2num($remise); $sql.= ' SET remise_percent = '.price2num($remise);
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
if ($this->db->query($sql) ) if ($this->db->query($sql))
{ {
$this->remise_percent = $remise;
$this->updateprice($this->id); $this->updateprice($this->id);
return 1; return 1;
} }
else else
{ {
dolibarr_print_error($this->db); $this->error=$this->db->error();
return -1;
} }
} }
} }
/** /**
* \brief Renvoie la liste des sommes de tva * \brief Applique une remise absolue sur facture
*/ * \param user User qui positionne la remise
* \param remise
* \return int <0 si ko, >0 si ok
*/
function set_remise_absolue($user, $remise)
{
$remise=trim($remise)?trim($remise):0;
if ($user->rights->facture->creer)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET remise_absolue = '.price2num($remise);
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
dolibarr_syslog("Facture::set_remise_absolue sql=$sql");
if ($this->db->query($sql))
{
$this->remise_absolue = $remise;
$this->updateprice($this->id);
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
}
/**
* \brief Renvoie la liste des sommes de tva
*/
function getSumTva() function getSumTva()
{ {
$sql = 'SELECT amount, tva_tx FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$this->id; $sql = 'SELECT amount, tva_tx FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$this->id;
@@ -2239,15 +2220,16 @@ class FactureLigne
// From llx_facturedet // From llx_facturedet
var $desc; var $desc;
var $qty; var $qty;
var $price; // Prix HT apres remise % var $price; // Prix unitaire HT apres remise % de ligne
var $price_ttc; //var $price_ttc;
var $subprice; // Prix unitaire HT var $subprice; // Prix unitaire HT
var $tva_taux; var $tva_taux; // Taux tva produit/service
var $remise; var $remise_percent; // % de la remise
var $remise_percent; var $remise; // Montant unitaire calcul<75> de la remise %
var $produit_id; var $produit_id;
var $date_start; var $date_start;
var $date_end; var $date_end;
var $info_bits;
/** /**
@@ -2268,7 +2250,8 @@ class FactureLigne
function fetch($rowid, $societe_id=0) function fetch($rowid, $societe_id=0)
{ {
$sql = 'SELECT fk_product, description, price, qty, rowid, tva_taux, remise, remise_percent,'; $sql = 'SELECT fk_product, description, price, qty, rowid, tva_taux, remise, remise_percent,';
$sql.= ' subprice, '.$this->db->pdate('date_start').' as date_start,'.$this->db->pdate('date_end').' as date_end'; $sql.= ' subprice, '.$this->db->pdate('date_start').' as date_start,'.$this->db->pdate('date_end').' as date_end,';
$sql.= ' info_bits';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@@ -2277,7 +2260,7 @@ class FactureLigne
$this->desc = stripslashes($objp->description); $this->desc = stripslashes($objp->description);
$this->qty = $objp->qty; $this->qty = $objp->qty;
$this->price = $objp->price; $this->price = $objp->price;
$this->price_ttc = $objp->price_ttc; //$this->price_ttc = $objp->price_ttc;
$this->subprice = $objp->subprice; $this->subprice = $objp->subprice;
$this->tva_taux = $objp->tva_taux; $this->tva_taux = $objp->tva_taux;
$this->remise = $objp->remise; $this->remise = $objp->remise;
@@ -2285,6 +2268,7 @@ class FactureLigne
$this->produit_id = $objp->fk_product; $this->produit_id = $objp->fk_product;
$this->date_start = $objp->date_start; $this->date_start = $objp->date_start;
$this->date_end = $objp->date_end; $this->date_end = $objp->date_end;
$this->info_bits = $objp->info_bits;
$this->db->free($result); $this->db->free($result);
} }
else else

View File

@@ -888,6 +888,7 @@ class Form
} }
print '</select>'; print '</select>';
} }
/** /**
* \brief Retourne la liste des modes de paiements possibles * \brief Retourne la liste des modes de paiements possibles
* \param selected Id du mode de paiement pr<70>s<EFBFBD>lectionn<6E> * \param selected Id du mode de paiement pr<70>s<EFBFBD>lectionn<6E>
@@ -917,9 +918,10 @@ class Form
if (eregi('[a-z]', $selected) && $selected == $code) print ' selected="true"'; if (eregi('[a-z]', $selected) && $selected == $code) print ' selected="true"';
elseif ($selected == $id) print ' selected="true"'; elseif ($selected == $id) print ' selected="true"';
print '>'; print '>';
if ($format == 0) print $this->cache_types_paiements_libelle[$id]; if ($format == 0) $value=$this->cache_types_paiements_libelle[$id];
if ($format == 1) print $code; if ($format == 1) $value=$code;
if ($format == 2) print $this->cache_types_paiements_libelle[$id]; if ($format == 2) $value=$this->cache_types_paiements_libelle[$id];
print $value?$value:'&nbsp;';
print '</option>'; print '</option>';
} }
print '</select>'; print '</select>';
@@ -1419,8 +1421,72 @@ class Form
} }
} }
} }
/**
* \brief Affiche formulaire de selection de la remise relative
* \param page Page
* \param selected Valeur remise
* \param htmlname Nom du formulaire select. Si none, non modifiable
*/
function form_remise_percent($page, $selected='', $htmlname='remise_percent')
{
global $langs;
if ($htmlname != "none")
{
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setremisepercent">';
print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<tr><td>';
print '<input type="text" name="'.$htmlname.'" size="1" value="'.$selected.'">%';
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
else
{
if ($selected)
{
print $selected;
} else {
print "0%";
}
}
}
/**
* \brief Affiche formulaire de selection de la remise avoir
* \param page Page
* \param selected Valeur <20> appliquer
* \param htmlname Nom du formulaire select. Si none, non modifiable
*/
function form_remise($page, $selected='', $htmlname='remise')
{
global $langs;
if ($htmlname != "none")
{
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setremise">';
print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<tr><td>';
print '<input type="text" name="'.$htmlname.'" size="1" value="'.$selected.'">';
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
else
{
if ($selected)
{
print $selected;
} else {
print "0";
}
}
}
/** /**
* \brief Affiche formulaire de selection des contacts * \brief Affiche formulaire de selection des contacts
* \param page Page * \param page Page

View File

@@ -64,10 +64,17 @@ Prospect=Prospect
CustomerCard=Customer Card CustomerCard=Customer Card
Customer=Customer Customer=Customer
CustomerDiscount=Customer Discount CustomerDiscount=Customer Discount
CustomerRelativeDiscount=Relative discount CustomerRelativeDiscount=Relative global discount
CustomerAbsoluteDiscount=Absolute discount CustomerAbsoluteDiscount=Absolute global discount
CustomerAbsoluteDiscountAllUsers=Absolute discount (all users) CustomerRelativeDiscountShort=Remise relative
CustomerAbsoluteDiscountMy=Absolute discount (my) CustomerAbsoluteDiscountShort=Remise absolue
CompanyHasRelativeDiscount=This customer has a discount of %s%%
CompanyHasNoRelativeDiscount=This customer has no discount by default
CompanyHasAbsoluteDiscount=This customer has a %s %s discount credit
CompanyHasNoAbsoluteDiscount=This customer has no discount credit available
CustomerAbsoluteDiscountAllUsers=Absolute discount (granted by all users)
CustomerAbsoluteDiscountMy=Absolute discount (granted by yourself)
DiscountNone=Aucune
Supplier=Supplier Supplier=Supplier
CompanyList=Companies' list CompanyList=Companies' list
AddContact=Add contact AddContact=Add contact

View File

@@ -64,10 +64,17 @@ Prospect=Prospect
CustomerCard=Fiche Client CustomerCard=Fiche Client
Customer=Client Customer=Client
CustomerDiscount=Remise client CustomerDiscount=Remise client
CustomerRelativeDiscount=Remise relative CustomerRelativeDiscount=Remise globale relative
CustomerAbsoluteDiscount=Remise avoirs CustomerAbsoluteDiscount=Remise globale absolue
CustomerRelativeDiscountShort=Remise relative
CustomerAbsoluteDiscountShort=Remise absolue
CompanyHasRelativeDiscount=Ce client a une remise par d<>faut de %s%%
CompanyHasNoRelativeDiscount=Ce client n'a pas de remise par d<>faut
CompanyHasAbsoluteDiscount=Ce client a %s %s d'avoirs disponibles
CompanyHasNoAbsoluteDiscount=Ce client n'a pas ou plus d'avoirs disponibles
CustomerAbsoluteDiscountAllUsers=Remise avoirs (accord<72>e par tout utilisateur) CustomerAbsoluteDiscountAllUsers=Remise avoirs (accord<72>e par tout utilisateur)
CustomerAbsoluteDiscountMy=Remise avoirs (accord<72> personnellement) CustomerAbsoluteDiscountMy=Remise avoirs (accord<72> personnellement)
DiscountNone=Aucune
Supplier=Fournisseur Supplier=Fournisseur
CompanyList=Liste des soci<63>t<EFBFBD>s CompanyList=Liste des soci<63>t<EFBFBD>s
AddContact=Ajouter contact AddContact=Ajouter contact

View File

@@ -728,7 +728,7 @@ function img_info($alt = "default")
{ {
global $conf,$langs; global $conf,$langs;
if ($alt=="default") $alt=$langs->trans("Informations"); if ($alt=="default") $alt=$langs->trans("Informations");
return '<img style="cursor: help;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/info.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/info.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
} }
/** /**

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -17,26 +18,29 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/*! \file htdocs/lib/price.lib.php /**
\brief librairie contenant les fonctions pour calculer un prix. \file htdocs/lib/price.lib.php
\author Rodolphe Quiedeville. \brief Librairie contenant les fonctions pour calculer un prix.
\version $Revision$ \author Rodolphe Quiedeville.
\version $Revision$
Ensemble des fonctions permettant de calculer un prix.
Ensemble des fonctions permettant de calculer un prix.
*/ */
/*! /**
\brief permet de calculer un prix. \brief Permet de calculer un prix.
\param products \param products
\param remise_percent \param remise_percent
\return result \param remise_absolue
\return result[0] total_ht
result[1] total_tva
result[2] total_ttc
result[5] tableau des totaux par tva
*/ */
function calcul_price($products, $remise_percent, $remise_absolue=0)
function calcul_price($products, $remise_percent)
{ {
$total_ht = 0; $total_ht = 0;
$amount_ht = 0; $amount_ht = 0;
@@ -49,7 +53,7 @@ function calcul_price($products, $remise_percent)
{ {
foreach ($products as $product) foreach ($products as $product)
{ {
$prod_price = $product[0]; $prod_price = $product[0]; // Prix unitaire HT apres remise % de ligne
$prod_qty = $product[1]; $prod_qty = $product[1];
$prod_txtva = $product[2]; $prod_txtva = $product[2];
@@ -59,7 +63,7 @@ function calcul_price($products, $remise_percent)
// incr<63>mentation montant HT hors remise de l'ensemble // incr<63>mentation montant HT hors remise de l'ensemble
$amount_ht += $line_price_ht; $amount_ht += $line_price_ht;
// si une remise est consentie sur l'ensemble // si une remise relative est consentie sur l'ensemble
if ($remise_percent > 0) if ($remise_percent > 0)
{ {
// calcul de la remise sur la ligne // calcul de la remise sur la ligne
@@ -77,6 +81,7 @@ function calcul_price($products, $remise_percent)
// incr<63>mentation du montant TTC de la valeur HT, on traite la TVA ensuite // incr<63>mentation du montant TTC de la valeur HT, on traite la TVA ensuite
$total_ttc += $line_price_ht; $total_ttc += $line_price_ht;
// traitement de la tva non per<65>ue r<>cup<75>rable // traitement de la tva non per<65>ue r<>cup<75>rable
if ( $prod_txtva >= 0 ) if ( $prod_txtva >= 0 )
{ {
@@ -84,8 +89,10 @@ function calcul_price($products, $remise_percent)
// donc on incr<63>mente le total TTC de l'ensemble, de la valeur de TVA de la ligne // donc on incr<63>mente le total TTC de l'ensemble, de la valeur de TVA de la ligne
$total_ttc += $line_tva; $total_ttc += $line_tva;
} }
// dans tous les cas, on incr<63>mente le total de TVA // dans tous les cas, on incr<63>mente le total de TVA
$total_tva += $line_tva; $total_tva += $line_tva;
// on incr<63>mente le tableau de diff<66>rentiation des taux de TVA // on incr<63>mente le tableau de diff<66>rentiation des taux de TVA
// s'il faut rassembler les tva facturables ou non, du m<>me taux // s'il faut rassembler les tva facturables ou non, du m<>me taux
// dans un m<>me ligne du tableau, remplacer la ligne suivante par : // dans un m<>me ligne du tableau, remplacer la ligne suivante par :
@@ -95,19 +102,26 @@ function calcul_price($products, $remise_percent)
$i++; $i++;
} }
} }
/*
* arrondis
*/
$total_ht = round($total_ht, 2);
$total_tva = round($total_tva, 2);
/* /*
* * Si remise absolue, on la retire
*/ */
$total_ht -= $remise_absolue;
/*
* Gestion des arrondis sur total des prix
*/
$total_ht = round($total_ht, 2);
$total_tva = round($total_tva, 2);
$total_ttc = $total_ht + $total_tva;
// Renvoi r<>ponse
$result[0] = $total_ht; $result[0] = $total_ht;
$result[1] = $total_tva; $result[1] = $total_tva;
$result[2] = $total_ttc; $result[2] = $total_ttc;
$result[3] = $total_remise;
$result[3] = $total_remise;
$result[4] = $amount_ht; $result[4] = $amount_ht;
return $result; return $result;

View File

@@ -907,9 +907,12 @@ class Societe
$sql = "SELECT SUM(rc.amount_ht) as amount"; $sql = "SELECT SUM(rc.amount_ht) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql.= " WHERE rc.fk_soc =". $this->id; $sql.= " WHERE rc.fk_soc =". $this->id;
if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id. if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id;
$sql.= " AND rc.fk_facture IS NULL"; $sql.= " AND rc.fk_facture IS NULL";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
dolibarr_syslog("Societe::getCurrentDiscount sql=$sql");
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);

View File

@@ -22,6 +22,7 @@ alter table llx_contrat add column note text;
alter table llx_contrat add column note_public text after note; alter table llx_contrat add column note_public text after note;
alter table llx_facture add column note_public text after note; alter table llx_facture add column note_public text after note;
alter table llx_facture add column remise_absolue real DEFAULT 0 after remise_percent;
alter table llx_propal add column note_public text after note; alter table llx_propal add column note_public text after note;

View File

@@ -31,11 +31,12 @@ create table llx_facture
date_valid date, -- date de validation date_valid date, -- date de validation
paye smallint DEFAULT 0 NOT NULL, paye smallint DEFAULT 0 NOT NULL,
amount real DEFAULT 0 NOT NULL, amount real DEFAULT 0 NOT NULL,
remise_percent real DEFAULT 0, -- remise globale en pourcent remise_percent real DEFAULT 0, -- remise relative
remise real DEFAULT 0, remise_absolute real DEFAULT 0, -- remise absolue
tva real DEFAULT 0, -- montant tva apres remise globale remise real DEFAULT 0, -- remise totale calculee
total real DEFAULT 0, -- montant total ht apres remise globale tva real DEFAULT 0, -- montant tva apres remise totale
total_ttc real DEFAULT 0, -- montant total ttc apres remise globale total real DEFAULT 0, -- montant total ht apres remise totale
total_ttc real DEFAULT 0, -- montant total ttc apres remise totale
fk_statut smallint DEFAULT 0 NOT NULL, fk_statut smallint DEFAULT 0 NOT NULL,