diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 3b9b9659a82..290ea389d08 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1886,6 +1886,13 @@ else if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline') { print '
'; + + // Récurrente + if (! defined('FACTURE_DISABLE_RECUR') || FACTURE_DISABLE_RECUR == 0) // Possibilité de désactiver les factures récurrentes + { + print ' '.$langs->trans("ChangeIntoRepeatableInvoice").''; + } + // Valider if ($fac->statut == 0 && $num_lignes > 0) { @@ -1947,15 +1954,6 @@ else print ' '.$langs->trans('ClassifyCanceled').''; } - // Récurrente - if (! defined('FACTURE_DISABLE_RECUR') || FACTURE_DISABLE_RECUR == 0) // Possibilité de désactiver les factures récurrentes - { - if ($fac->statut > 0) - { - print ' Récurrente'; - } - } - print '
'; } diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php index 0af3ef63413..57efee1616a 100644 --- a/htdocs/compta/facture/facture-rec.class.php +++ b/htdocs/compta/facture/facture-rec.class.php @@ -29,13 +29,14 @@ require_once(DOL_DOCUMENT_ROOT."/notify.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php"); +require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); /** \class FactureRec - \brief Classe de gestion des factures recurrentes + \brief Classe de gestion des factures recurrentes/Modèles */ -class FactureRec +class FactureRec extends Facture { var $id; var $db; @@ -53,8 +54,9 @@ class FactureRec var $propalid; var $projetid; + /** - * Initialisation de la class + * \brief Initialisation de la class * */ function FactureRec($DB, $facid=0) @@ -62,26 +64,37 @@ class FactureRec $this->db = $DB ; $this->facid = $facid; } + /** - * Créé la facture + * \brief Créé la facture recurrente/modele + * \return int <0 si ko, id facture rec crée si ok */ function create($user) { - $facsrc = new Facture($this->db); + global $langs; + + // Nettoyage parametere + $this->titre=trim($this->titre); - if ($facsrc->fetch($this->facid) > 0) + // Validation parameteres + if (! $this->titre) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Title")); + return -3; + } + + // Charge facture modele + $facsrc=new Facture($this->db); + $result=$facsrc->fetch($this->facid); + if ($result > 0) { - /* - * On positionne en mode brouillon la facture - */ + // On positionne en mode brouillon la facture $this->brouillon = 1; - if (! $facsrc->projetid) - { - $facsrc->projetid = "NULL"; - } $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (titre, fk_soc, datec, amount, remise, remise_percent, note, fk_user_author,fk_projet, fk_cond_reglement) "; - $sql .= " VALUES ('$this->titre', '$facsrc->socidp', now(), '$facsrc->amount', '$facsrc->remise', '$facsrc->remise_percent', '$this->note','$user->id', '$facsrc->projetid', '$facsrc->cond_reglement_id')"; + $sql.= " VALUES ('$this->titre', '$facsrc->socidp', now(), '$facsrc->amount', '$facsrc->remise', '$facsrc->remise_percent', '".addslashes($this->note)."','$user->id',"; + $sql.= " ".($facsrc->projetid?"'".$facsrc->projetid."'":"null").", "; + $sql.= " '".$facsrc->cond_reglement_id."')"; if ( $this->db->query($sql) ) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec"); @@ -97,7 +110,6 @@ class FactureRec $prod->fetch($facsrc->lignes[$i]->produit_id); } - $result_insert = $this->addline($this->id, addslashes($facsrc->lignes[$i]->desc), $facsrc->lignes[$i]->subprice, @@ -109,7 +121,7 @@ class FactureRec if ( $result_insert < 0) { - print '
' . $this->db->error() .'
'; + $this->error=$this->db->error().' sql='.$sql; } } @@ -117,8 +129,8 @@ class FactureRec } else { - print $this->db->error() . '
'.$sql; - return 0; + $this->error=$this->db->error().' sql='.$sql; + return -2; } } else diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 7945099443e..8a129084bd7 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -40,8 +40,19 @@ if (!$user->rights->facture->lire) $facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"]; $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; +if ($page == -1) +{ +$page = 0 ; +} +$limit = $conf->liste_limit; +$offset = $limit * $page ; + +if ($sortorder == "") +$sortorder="DESC"; + +if ($sortfield == "") +$sortfield="f.datef"; -llxHeader('','Facture récurrente','ch-facture.html#s-fac-facture-rec'); // Sécurité accés client if ($user->societe_id > 0) @@ -58,48 +69,55 @@ if ($user->societe_id > 0) // Ajout if ($_POST["action"] == 'add') { - $facturerec = new FactureRec($db, $facid); - $facturerec->titre = $_POST["titre"]; + $facturerec = new FactureRec($db, $facid); + $facturerec->titre = $_POST["titre"]; - if ($facturerec->create($user) > 0) - { - $facid = $facturerec->id; - $action = ''; - } - else - { - $action = "create"; - } + if ($facturerec->create($user) > 0) + { + $facid = $facturerec->id; + $action = ''; + } + else + { + $_GET["action"] = "create"; + $_GET["facid"] = $_POST["facid"]; + $mesg = '
'.$facturerec->error.'
'; + } } // Suppression -if ($_REQUEST["action"] == 'delete' && $user->rights->facture->supprimer) +if ($_REQUEST["action"] == 'delete' && $user->rights->facture->supprimer) { - $fac = new FactureRec($db); - $fac->delete($_REQUEST["facid"]); - $facid = 0 ; + $fac = new FactureRec($db); + $fac->delete($_REQUEST["facid"]); + $facid = 0 ; } + + /* - * + * Affichage page */ +llxHeader('','Facture récurrente','ch-facture.html#s-fac-facture-rec'); + $html = new Form($db); /********************************************************************* - * - * Mode creation - * - ************************************************************************/ +* +* Mode creation +* +************************************************************************/ if ($_GET["action"] == 'create') { - print_titre("Créer une facture récurrente"); + print_titre($langs->trans("CreateRepeatableInvoice")); + if ($mesg) print $mesg.'
'; + $facture = new Facture($db); if ($facture->fetch($_GET["facid"]) > 0) { - print '
'; print ''; print ''; @@ -241,7 +259,7 @@ if ($_GET["action"] == 'create') print ''; print ''; } - print ''; + print ''; print "
\n"; print "\n"; @@ -251,240 +269,208 @@ if ($_GET["action"] == 'create') print "Erreur facture $facture->id inexistante"; } } -else +else /* *************************************************************************** */ /* */ /* */ /* */ /* *************************************************************************** */ { - - if ($facid > 0) - { - $fac = New FactureRec($db,0); - if ( $fac->fetch($facid, $user->societe_id) > 0) - { - $soc = new Societe($db, $fac->socidp); - $soc->fetch($fac->socidp); - $author = new User($db); - $author->id = $fac->user_author; - $author->fetch(); - - print_titre("Facture : ".$fac->titre); - - /* - * Facture - */ - print ''; - print ''; - print "'; - - print ""; - - print ""; - - if ($fac->remise_percent > 0) - { - print '"; - - print ''; - print ''; - print ''; + if ($facid > 0) + { + $fac = New FactureRec($db,0); - print ''; - print ''; - print ''; - print ''; - if ($fac->note) - { - print '"; - } + if ( $fac->fetch($facid, $user->societe_id) > 0) + { + $soc = new Societe($db, $fac->socidp); + $soc->fetch($fac->socidp); + $author = new User($db); + $author->id = $fac->user_author; + $author->fetch(); - print "
'.$langs->trans("Customer").'"; - print ''.$soc->nom.'Conditions de réglement : " . $fac->cond_reglement ."
".$langs->trans("Author")."$author->fullname'; - } - else - { - print ''; - } - - print "
'.$langs->trans("AmountHT").''.price($fac->total_ht).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("VAT").''.price($fac->total_tva).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("TotalTTC").''.price($fac->total_ttc).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("Note").' : '.nl2br($fac->note)."

"; - /* - * Lignes - * - */ - print_titre($langs->trans("Products")); - - print ''; - print ''; - print ''; - - $num = sizeof($fac->lignes); - $i = 0; - $var=True; - while ($i < $num) - { - $var=!$var; - if ($fac->lignes[$i]->produit_id > 0) - { - $prod = New Product($db); - $prod->fetch($fac->lignes[$i]->produit_id); - print "'; - print ''; - } - else - { - print ""; - print ''; - } - print ""; - print ''; - print "\n"; - $i++; - } - print '
'.$langs->trans("Ref").''.$langs->trans("Product").''.$langs->trans("Price").''.$langs->trans("Discount").''.$langs->trans("Qty").'
"; - print ''; - print img_object($langs->trans("ShowProduct"),"product").' '.$prod->ref; - print ''; - print ''.$fac->lignes[$i]->desc.'
 '.$fac->lignes[$i]->desc.'".price($fac->lignes[$i]->price)."'.$fac->lignes[$i]->remise_percent.' %".$fac->lignes[$i]->qty."
'; + print_titre($langs->trans("PredefinedInvoices").': '.$fac->titre); - /* - * Actions - * - */ - if ($user->societe_id == 0 && $fac->paye == 0) - { - print '

'; - - if ($fac->statut == 0 && $user->rights->facture->supprimer) - { - print ""; - } - else - { - print ""; - } - + /* + * Facture + */ + print '
[Supprimer]-
'; + print ''; + print "'; - print ""; + print ""; - + print ""; - print ''; - print ''; + if ($fac->remise_percent > 0) + { + print '
'.$langs->trans("Customer").'"; + print ''.$soc->nom.'-Conditions de réglement : " . $fac->cond_reglement ."
".$langs->trans("Author")."$author->fullname--'; + } + else + { + print ''; + } - print "
"; - } - print "

\n"; + print ""; - /* - * - * - */ - } - else - { - /* Facture non trouvée */ - print "Facture inexistante ou accés refusé"; - } - } else { - /*************************************************************************** - * * - * Mode Liste * - * * - * * - ***************************************************************************/ - if ($page == -1) - { - $page = 0 ; - } + print ''.$langs->trans("AmountHT").''; + print ''.price($fac->total_ht).''; + print ''.$langs->trans("Currency".$conf->monnaie).''; - if ($user->rights->facture->lire) - { - $limit = $conf->liste_limit; - $offset = $limit * $page ; + print ''.$langs->trans("AmountVAT").''.price($fac->total_tva).''; + print ''.$langs->trans("Currency".$conf->monnaie).''; + print ''.$langs->trans("AmountTTC").''.price($fac->total_ttc).''; + print ''.$langs->trans("Currency".$conf->monnaie).''; + if ($fac->note) + { + print ''.$langs->trans("Note").' : '.nl2br($fac->note).""; + } - if ($sortorder == "") - $sortorder="DESC"; + print "
"; + /* + * Lignes + * + */ + print_titre($langs->trans("Products")); - if ($sortfield == "") - $sortfield="f.datef"; + print ''; + print ''; + print ''; - $sql = "SELECT s.nom,s.idp,f.titre,f.total,f.rowid as facid"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f WHERE f.fk_soc = s.idp"; - - if ($socidp) - $sql .= " AND s.idp = $socidp"; - - //$sql .= " ORDER BY $sortfield $sortorder, rowid DESC "; - // $sql .= $db->plimit($limit + 1,$offset); - - $result = $db->query($sql); - } - if ($result) - { - $num = $db->num_rows($result); - print_barre_liste($langs->trans("Bills"),$page,"fiche-rec.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); + $num = sizeof($fac->lignes); + $i = 0; + $var=True; + while ($i < $num) + { + $var=!$var; + if ($fac->lignes[$i]->produit_id > 0) + { + $prod = New Product($db); + $prod->fetch($fac->lignes[$i]->produit_id); + print "'; + print ''; + } + else + { + print ""; + print ''; + } + print ""; + print ''; + print "\n"; + $i++; + } + print '
'.$langs->trans("Ref").''.$langs->trans("Product").''.$langs->trans("Price").''.$langs->trans("Discount").''.$langs->trans("Qty").'
"; + print ''; + print img_object($langs->trans("ShowProduct"),"product").' '.$prod->ref; + print ''; + print ''.$fac->lignes[$i]->desc.'
 '.$fac->lignes[$i]->desc.'".price($fac->lignes[$i]->price)."'.$fac->lignes[$i]->remise_percent.' %".$fac->lignes[$i]->qty."
'; - $i = 0; - print ""; - print ''; - print ''; - print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socidp=$socidp"); - print ''; - print ''; - print "\n"; - - if ($num > 0) - { - $var=True; - while ($i < min($num,$limit)) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print '\n"; - print ''; - - print "\n"; - - if (! $objp->paye) - { - if ($objp->fk_statut == 0) - { - print ''; - } - else - { - print ''; - } - } + /** + * Barre d'actions + */ + print '
'; + + if ($fac->statut == 0 && $user->rights->facture->supprimer) + { + print ''.$langs->trans('Delete').''; + } + + print '
'; + } else - { - print ''; - } - - print "\n"; - $i++; - } - } - - print "
'.$langs->trans("Ref").''.$langs->trans("Amount").' 
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; - print "'.$objp->nom.'".price($objp->total)."brouillonimpayée 
"; - $db->free(); - } - else - { - dolibarr_print_error($db); - } - } - -} + { + /* Facture non trouvée */ + print "Facture inexistante ou accés refusé"; + } + } else { + /*************************************************************************** + * * + * Mode Liste * + * * + * * + ***************************************************************************/ -$db->close(); + if ($user->rights->facture->lire) + { -llxFooter('$Date$ - $Revision$'); -?> + $sql = "SELECT s.nom,s.idp,f.titre,f.total,f.rowid as facid"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f WHERE f.fk_soc = s.idp"; + + if ($socidp) + $sql .= " AND s.idp = $socidp"; + + //$sql .= " ORDER BY $sortfield $sortorder, rowid DESC "; + // $sql .= $db->plimit($limit + 1,$offset); + + $result = $db->query($sql); + } + if ($result) + { + $num = $db->num_rows($result); + print_barre_liste($langs->trans("RepeatableInvoice"),$page,"fiche-rec.php","&socidp=$socidp",$sortfield,$sortorder,'',$num); + + $i = 0; + print ""; + print ''; + print ''; + print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socidp=$socidp"); + print ''; + print ''; + print "\n"; + + if ($num > 0) + { + $var=True; + while ($i < min($num,$limit)) + { + $objp = $db->fetch_object($result); + $var=!$var; + + print ""; + + print '\n"; + print ''; + + print "\n"; + + if (! $objp->paye) + { + if ($objp->fk_statut == 0) + { + print ''; + } + else + { + print ''; + } + } + else + { + print ''; + } + + print "\n"; + $i++; + } + } + + print "
'.$langs->trans("Ref").''.$langs->trans("Amount").' 
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; + print "'.$objp->nom.'".price($objp->total)."brouillonimpayée 
"; + $db->free(); + } + else + { + dolibarr_print_error($db); + } + } + + } + + $db->close(); + + llxFooter('$Date$ - $Revision$'); + ?> diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index ed509b3f4fc..d0d70a650b8 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -307,11 +307,11 @@ class MenuLeft { { if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/clients.php?action=facturer",$langs->trans("NewBill"),2,$user->rights->facture->creer); } - if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"),2,$user->rights->facture->lire); if (! defined("FACTURE_DISABLE_RECUR") || ! FACTURE_DISABLE_RECUR) { - if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/fiche-rec.php","Récurrentes",2,$user->rights->facture->lire); + if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/fiche-rec.php",$langs->trans("Repeatable"),2,$user->rights->facture->lire); } + if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"),2,$user->rights->facture->lire); if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/liste.php?leftmenu=customers_bills_payments",$langs->trans("Payments"),2,$user->rights->facture->lire); if (eregi("customers_bills_payments",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/avalider.php",$langs->trans("MenuToValid"),3,$user->rights->facture->lire); diff --git a/htdocs/includes/menus/barre_left/eldy_frontoffice.php b/htdocs/includes/menus/barre_left/eldy_frontoffice.php index 67cbf9c152a..f45adefb221 100644 --- a/htdocs/includes/menus/barre_left/eldy_frontoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_frontoffice.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2006 Laurent Destailleur * * 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 @@ -317,11 +317,11 @@ class MenuLeft { { if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/clients.php?action=facturer",$langs->trans("NewBill"),2,$user->rights->facture->creer); } - if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"),2,$user->rights->facture->lire); if (! defined("FACTURE_DISABLE_RECUR") || ! FACTURE_DISABLE_RECUR) { - if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/fiche-rec.php","Récurrentes",2,$user->rights->facture->lire); + if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/fiche-rec.php",$langs->trans("Repeatable"),2,$user->rights->facture->lire); } + if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"),2,$user->rights->facture->lire); if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/liste.php?leftmenu=customers_bills_payments",$langs->trans("Payments"),2,$user->rights->facture->lire); if (eregi("customers_bills_payments",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/avalider.php",$langs->trans("MenuToValid"),3,$user->rights->facture->lire); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index da73084120f..8e3279a3cda 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -113,7 +113,11 @@ NonPercuRecuperable=Non per SetConditions=Set payment conditions SetMode=Set payment mode Billed=Billed -RecurringBills=Recurring invoices +RepeatableInvoice=Repeatable invoice +RepeatableInvoices=Repeatable invoices +Repeatable=Repeatable +ChangeIntoRepeatableInvoice=Change into repeatable +CreateRepeatableInvoice=Create repeatable invoice ExportDataset_invoice_1=Customer invoices list and invoices' lines ProformaBill=Proforma Bill: VATIsUsed=Using VAT diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 23bf54b055d..f8db665bf58 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -113,7 +113,11 @@ NonPercuRecuperable=Non per SetConditions=Définir conditions de règlement SetMode=Définir mode de règlement Billed=Facturé -RecurringBills=Factures récurrentes +RepeatableInvoice=Facture récurrente +RepeatableInvoices=Factures récurrentes +Repeatable=Récurrente +ChangeIntoRepeatableInvoice=Modifier en récurrente +CreateRepeatableInvoice=Créer facture récurrente ExportDataset_invoice_1=Factures clients et lignes de facture ProformaBill=Facture Proforma : VATIsUsed=Assujéti à TVA diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 048673a88f1..765d84cfafd 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -167,3 +167,16 @@ delete from llx_document_model where nom='azur' and type='order'; delete from llx_document_model where nom='orange' and type='propal'; alter table llx_actioncomm add column fk_commande integer after propalrowid; + + +ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber); + + +ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_soc (fk_soc); +ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_user_author (fk_user_author); +ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_projet (fk_projet); + +ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); +ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); + +ALTER TABLE llx_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre); diff --git a/mysql/tables/llx_facture.key.sql b/mysql/tables/llx_facture.key.sql index 8e101198d63..93b8d12ec7f 100644 --- a/mysql/tables/llx_facture.key.sql +++ b/mysql/tables/llx_facture.key.sql @@ -31,3 +31,5 @@ ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); + +ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber); diff --git a/mysql/tables/llx_facture.sql b/mysql/tables/llx_facture.sql index ec8554f92f9..39d5a9d0687 100644 --- a/mysql/tables/llx_facture.sql +++ b/mysql/tables/llx_facture.sql @@ -1,5 +1,6 @@ -- =========================================================================== -- Copyright (C) 2001-2005 Rodolphe Quiedeville +-- Copyright (C) 2006 Laurent Destailleur -- -- 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 @@ -52,6 +53,4 @@ create table llx_facture note text, note_public text, model varchar(50), - - UNIQUE INDEX (facnumber) )type=innodb; diff --git a/mysql/tables/llx_facture_rec.sql b/mysql/tables/llx_facture_rec.sql index 5fe633782ef..85c8fb6fda2 100644 --- a/mysql/tables/llx_facture_rec.sql +++ b/mysql/tables/llx_facture_rec.sql @@ -1,5 +1,6 @@ -- =========================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2006 Laurent Destailleur -- -- 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 @@ -29,6 +30,7 @@ create table llx_facture_rec amount real DEFAULT 0 NOT NULL, remise real DEFAULT 0, remise_percent real DEFAULT 0, + remise_absolue real DEFAULT 0, tva real DEFAULT 0, total real DEFAULT 0, total_ttc real DEFAULT 0, @@ -36,8 +38,11 @@ create table llx_facture_rec fk_user_author integer, -- createur fk_projet integer, -- projet auquel est associé la facture fk_cond_reglement integer, -- condition de reglement + fk_mode_reglement integer, -- mode de reglement (Virement, Prélèvement) + date_lim_reglement date, -- date limite de reglement note text, + note_public text, frequency char(2) DEFAULT NULL, last_gen varchar(7) DEFAULT NULL,