New: early development of multi-company module

This commit is contained in:
Regis Houssin 2009-04-30 10:54:07 +00:00
parent faf854169c
commit 8df1eb1fd6
4 changed files with 104 additions and 52 deletions

View File

@ -190,16 +190,29 @@ class Facture extends CommonObject
$totalht = ($amount - $remise); $totalht = ($amount - $remise);
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture ('; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture (";
$sql.= ' facnumber, type, fk_soc, datec, amount, remise_absolue, remise_percent,'; $sql.= " facnumber";
$sql.= ' datef,'; $sql.= ", entity";
$sql.= ' note,'; $sql.= ", type";
$sql.= ' note_public,'; $sql.= ", fk_soc";
$sql.= ' ref_client,'; $sql.= ", datec";
$sql.= ' fk_facture_source, fk_user_author, fk_projet,'; $sql.= ", amount";
$sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf)'; $sql.= ", remise_absolue";
$sql.= ' VALUES ('; $sql.= ", remise_percent";
$sql.= "'(PROV)', '".$this->type."', '".$socid."', ".$this->db->idate(gmmktime()).", '".$totalht."'"; $sql.= ", datef";
$sql.= ", note";
$sql.= ", note_public";
$sql.= ", ref_client";
$sql.= ", fk_facture_source, fk_user_author, fk_projet";
$sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"
$sql.= ")";
$sql.= " VALUES (";
$sql.= "'(PROV)'";
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->type."'";
$sql.= ", '".$socid."'";
$sql.= ", ".$this->db->idate(gmmktime());
$sql.= ", '".$totalht."'";
$sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL'); $sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL');
$sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL'); $sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL');
$sql.= ",".$this->db->idate($this->date); $sql.= ",".$this->db->idate($this->date);
@ -507,8 +520,9 @@ class Facture extends CommonObject
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as c ON f.fk_cond_reglement = c.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_fa as cf ON cf.fk_facture = f.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_fa as cf ON cf.fk_facture = f.rowid';
if ($ref) $sql.= " WHERE f.facnumber='".$ref."'"; $sql.= ' WHERE f.entity = '.$conf->entity;
else $sql.= " WHERE f.rowid=".$rowid; if ($ref) $sql.= " AND f.facnumber='".$ref."'";
else $sql.= " AND f.rowid=".$rowid;
dol_syslog("Facture::Fetch sql=".$sql, LOG_DEBUG); dol_syslog("Facture::Fetch sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1117,9 +1131,9 @@ class Facture extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null'; $sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null';
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
$resql = $this->db->query($sql);
dol_syslog("Facture::set_unpayed sql=".$sql); dol_syslog("Facture::set_unpayed sql=".$sql);
$resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0); $this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
@ -1163,7 +1177,9 @@ class Facture extends CommonObject
// On désaffecte de la facture les remises liées // On désaffecte de la facture les remises liées
// car elles n'ont pas été utilisées vu que la facture est abandonnée. // car elles n'ont pas été utilisées vu que la facture est abandonnée.
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql.= ' SET fk_facture = NULL WHERE fk_facture = '.$this->id; $sql.= ' SET fk_facture = NULL';
$sql.= ' WHERE fk_facture = '.$this->id;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -1397,7 +1413,8 @@ class Facture extends CommonObject
if ($this->statut != 0) if ($this->statut != 0)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_statut = 0"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture";
$sql.= " SET fk_statut = 0";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog("Facture::set_draft sql=".$sql, LOG_DEBUG); dol_syslog("Facture::set_draft sql=".$sql, LOG_DEBUG);
@ -1692,7 +1709,9 @@ class Facture extends CommonObject
// Libere remise liee a ligne de facture // Libere remise liee a ligne de facture
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql.= ' SET fk_facture_line = NULL where fk_facture_line = '.$rowid; $sql.= ' SET fk_facture_line = NULL';
$sql.= ' WHERE fk_facture_line = '.$rowid;
dol_syslog("Facture::Deleteline sql=".$sql); dol_syslog("Facture::Deleteline sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) if (! $result)
@ -1704,7 +1723,9 @@ class Facture extends CommonObject
} }
// Efface ligne de facture // Efface ligne de facture
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet';
$sql.= ' WHERE rowid = '.$rowid;
dol_syslog("Facture::Deleteline sql=".$sql); dol_syslog("Facture::Deleteline sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) if (! $result)
@ -1745,7 +1766,8 @@ class Facture extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET remise_percent = '.$remise; $sql.= ' SET remise_percent = '.$remise;
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; $sql.= ' WHERE rowid = '.$this->id;
$sql.= ' AND fk_statut = 0 ;';
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -1778,7 +1800,8 @@ class Facture extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET remise_absolue = '.$remise; $sql.= ' SET remise_absolue = '.$remise;
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; $sql.= ' WHERE rowid = '.$this->id;
$sql.= ' AND fk_statut = 0 ;';
dol_syslog("Facture::set_remise_absolue sql=$sql"); dol_syslog("Facture::set_remise_absolue sql=$sql");
@ -2309,6 +2332,7 @@ class Facture extends CommonObject
// pour ne pas avoir de trou dans la numérotation // pour ne pas avoir de trou dans la numérotation
$sql = "SELECT MAX(facnumber)"; $sql = "SELECT MAX(facnumber)";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE entity = ".$conf->entity;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@ -2351,6 +2375,7 @@ class Facture extends CommonObject
$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"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source";
$sql.= " WHERE (f.fk_statut = 1 OR (f.fk_statut = 3 AND f.close_code = 'abandon'))"; $sql.= " WHERE (f.fk_statut = 1 OR (f.fk_statut = 3 AND f.close_code = 'abandon'))";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.paye = 0"; // Pas classée payée complètement $sql.= " AND f.paye = 0"; // Pas classée payée complètement
$sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait
$sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement
@ -2388,14 +2413,16 @@ class Facture extends CommonObject
*/ */
function list_qualified_avoir_invoices($socid=0) function list_qualified_avoir_invoices($socid=0)
{ {
global $conf;
$return = array(); $return = array();
$sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, pf.fk_paiement"; $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, pf.fk_paiement";
$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 "; $sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " f.fk_statut in (1,2)"; $sql.= " AND f.fk_statut in (1,2)";
// $sql.= " WHERE f.fk_statut >= 1"; // $sql.= " WHERE f.fk_statut >= 1";
// $sql.= " AND (f.paye = 1"; // Classée payée complètement // $sql.= " AND (f.paye = 1"; // Classée payée complètement
// $sql.= " OR f.close_code IS NOT NULL)"; // Classée payée partiellement // $sql.= " OR f.close_code IS NOT NULL)"; // Classée payée partiellement
@ -2447,9 +2474,11 @@ class Facture extends CommonObject
if ($this->statut > 0 && $this->paye == 0 && $this->mode_reglement_id == 3) if ($this->statut > 0 && $this->paye == 0 && $this->mode_reglement_id == 3)
{ {
$sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; $sql = 'SELECT count(*)';
$sql .= ' WHERE fk_facture='.$this->id; $sql.= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
$sql .= ' AND traite = 0'; $sql.= ' WHERE fk_facture = '.$this->id;
$sql.= ' AND traite = 0';
if ( $this->db->query( $sql) ) if ( $this->db->query( $sql) )
{ {
$row = $this->db->fetch_row(); $row = $this->db->fetch_row();
@ -2534,7 +2563,6 @@ class Facture extends CommonObject
$sql = "SELECT f.rowid, f.date_lim_reglement as datefin"; $sql = "SELECT f.rowid, f.date_lim_reglement as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->societe_id) if (!$user->rights->societe->client->voir && !$user->societe_id)
{ {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc";
@ -2542,8 +2570,7 @@ class Facture extends CommonObject
$clause = " AND"; $clause = " AND";
} }
$sql.= $clause." f.paye=0"; $sql.= $clause." f.paye=0";
$sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND f.fk_statut = 1"; $sql.= " AND f.fk_statut = 1";
if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id;
@ -2593,11 +2620,17 @@ class Facture extends CommonObject
*/ */
function initAsSpecimen() function initAsSpecimen()
{ {
global $user,$langs; global $user,$langs,$conf;
// Charge tableau des id de société socids // Charge tableau des id de société socids
$socids = array(); $socids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE client = 1";
$sql.= " AND entity = ".$conf->entity;
$sql.= " LIMIT 10";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -2614,7 +2647,12 @@ class Facture extends CommonObject
// Charge tableau des produits prodids // Charge tableau des produits prodids
$prodids = array(); $prodids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
$sql.= " WHERE envente = 1";
$sql.= " AND entity = ".$conf->entity;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -2686,7 +2724,7 @@ class Facture extends CommonObject
$sql.= " WHERE sc.fk_user = " .$user->id; $sql.= " WHERE sc.fk_user = " .$user->id;
$clause = "AND"; $clause = "AND";
} }
$sql.= " ".$clause." s.entity = ".$conf->entity; $sql.= " ".$clause." f.entity = ".$conf->entity;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)

View File

@ -27,6 +27,7 @@ ALTER TABLE llx_propal ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
ALTER TABLE llx_commande ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_commande ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
ALTER TABLE llx_commande_fournisseur ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_commande_fournisseur ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
ALTER TABLE llx_product_fournisseur ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref_fourn; ALTER TABLE llx_product_fournisseur ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref_fourn;
ALTER TABLE llx_facture ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER facnumber;
ALTER TABLE llx_rights_def DROP PRIMARY KEY; ALTER TABLE llx_rights_def DROP PRIMARY KEY;
ALTER TABLE llx_user_param DROP INDEX fk_user; ALTER TABLE llx_user_param DROP INDEX fk_user;
@ -43,6 +44,7 @@ ALTER TABLE llx_commande DROP INDEX ref;
ALTER TABLE llx_commande_fournisseur DROP INDEX uk_commande_fournisseur_ref; ALTER TABLE llx_commande_fournisseur DROP INDEX uk_commande_fournisseur_ref;
ALTER TABLE llx_product_fournisseur DROP INDEX fk_product; ALTER TABLE llx_product_fournisseur DROP INDEX fk_product;
ALTER TABLE llx_product_fournisseur DROP INDEX fk_soc; ALTER TABLE llx_product_fournisseur DROP INDEX fk_soc;
ALTER TABLE llx_facture DROP INDEX idx_facture_uk_facnumber;
ALTER TABLE llx_rights_def ADD PRIMARY KEY (id, entity); ALTER TABLE llx_rights_def ADD PRIMARY KEY (id, entity);
ALTER TABLE llx_user_param ADD UNIQUE INDEX uk_user_param (fk_user,param,entity); ALTER TABLE llx_user_param ADD UNIQUE INDEX uk_user_param (fk_user,param,entity);
@ -59,4 +61,5 @@ ALTER TABLE llx_commande ADD UNIQUE INDEX uk_commande_ref (ref, entity);
ALTER TABLE llx_commande_fournisseur ADD UNIQUE INDEX uk_commande_fournisseur_ref (ref, fk_soc, entity); ALTER TABLE llx_commande_fournisseur ADD UNIQUE INDEX uk_commande_fournisseur_ref (ref, fk_soc, entity);
ALTER TABLE llx_product_fournisseur ADD UNIQUE INDEX uk_product_fournisseur_ref (ref_fourn, fk_soc, entity); ALTER TABLE llx_product_fournisseur ADD UNIQUE INDEX uk_product_fournisseur_ref (ref_fourn, fk_soc, entity);
ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_product (fk_product, entity); ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_product (fk_product, entity);
ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_soc (fk_soc, entity); ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_soc (fk_soc, entity);
ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber, entity);

View File

@ -1,6 +1,7 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
-- --
-- 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
@ -20,6 +21,8 @@
-- ============================================================================ -- ============================================================================
ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber, entity);
ALTER TABLE llx_facture ADD INDEX idx_facture_fk_soc (fk_soc); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_soc (fk_soc);
ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_author (fk_user_author); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_author (fk_user_author);
ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_valid (fk_user_valid); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_valid (fk_user_valid);
@ -31,5 +34,3 @@ ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY
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_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_facture_source FOREIGN KEY (fk_facture_source) REFERENCES llx_facture (rowid); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_facture_source FOREIGN KEY (fk_facture_source) REFERENCES llx_facture (rowid);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (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);

View File

@ -1,6 +1,7 @@
-- =========================================================================== -- ===========================================================================
-- Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
-- --
-- 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
@ -24,33 +25,34 @@ create table llx_facture
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
facnumber varchar(30) NOT NULL, facnumber varchar(30) NOT NULL,
type smallint DEFAULT 0 NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id
type smallint DEFAULT 0 NOT NULL,
ref_client varchar(30), ref_client varchar(30),
increment varchar(10), increment varchar(10),
fk_soc integer NOT NULL, fk_soc integer NOT NULL,
datec datetime, -- date de creation de la facture datec datetime, -- date de creation de la facture
datef date, -- date de la facture datef date, -- date de la 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 relative remise_percent real DEFAULT 0, -- remise relative
remise_absolue real DEFAULT 0, -- remise absolue remise_absolue real DEFAULT 0, -- remise absolue
remise real DEFAULT 0, -- remise totale calculee remise real DEFAULT 0, -- remise totale calculee
close_code varchar(16), -- Code motif cloture sans paiement complet close_code varchar(16), -- Code motif cloture sans paiement complet
close_note varchar(128), -- Commentaire cloture sans paiement complet close_note varchar(128), -- Commentaire cloture sans paiement complet
tva real DEFAULT 0, -- montant tva apres remise totale tva real DEFAULT 0, -- montant tva apres remise totale
total real DEFAULT 0, -- montant total ht apres remise totale total real DEFAULT 0, -- montant total ht apres remise totale
total_ttc real DEFAULT 0, -- montant total ttc 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,
fk_user_author integer, -- createur de la facture fk_user_author integer, -- createur de la facture
fk_user_valid integer, -- valideur de la facture fk_user_valid integer, -- valideur de la facture
fk_facture_source integer, -- facture origine si facture avoir fk_facture_source integer, -- facture origine si facture avoir
fk_projet integer, -- projet auquel est associée la facture fk_projet integer, -- projet auquel est associée la facture
fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...) fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...)
fk_mode_reglement integer, -- mode de reglement (Virement, Prélèvement) fk_mode_reglement integer, -- mode de reglement (Virement, Prélèvement)
@ -62,3 +64,11 @@ create table llx_facture
import_key varchar(14) import_key varchar(14)
)type=innodb; )type=innodb;
--
-- List of codes for the field entity
--
-- 1 : first company invoice
-- 2 : second company invoice
-- 3 : etc...
--