\n";
// Value
diff --git a/htdocs/compta/journaux/index.php b/htdocs/compta/journaux/index.php
new file mode 100644
index 00000000000..ac11326a838
--- /dev/null
+++ b/htdocs/compta/journaux/index.php
@@ -0,0 +1,76 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+require("../../main.inc.php");
+
+
+$langs->load("companies");
+$langs->load("other");
+$langs->load("compta");
+
+// Protection if external user
+if ($user->societe_id > 0)
+{
+ accessforbidden();
+}
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+
+/***************************************************
+* PAGE
+*
+* Put here all code to build page
+****************************************************/
+
+llxHeader('','MyPageName','');
+
+$form=new Form($db);
+
+
+// Put here content of your page
+// ...
+
+/***************************************************
+* LINKED OBJECT BLOCK
+*
+* Put here code to view linked object
+****************************************************/
+/*
+
+$myobject->load_object_linked($myobject->id,$myobject->element);
+
+foreach($myobject->linked_object as $linked_object => $linked_objectid)
+{
+ if ($conf->$linked_object->enabled)
+ {
+ $somethingshown=$myobject->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
+ }
+}
+*/
+
+// End of page
+$db->close();
+llxFooter('$Date$ - $Revision$');
+?>
\ No newline at end of file
diff --git a/htdocs/compta/journaux/journalachat.php b/htdocs/compta/journaux/journalachat.php
new file mode 100644
index 00000000000..d76f1a8e2a2
--- /dev/null
+++ b/htdocs/compta/journaux/journalachat.php
@@ -0,0 +1,195 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
+
+$langs->load("companies");
+$langs->load("other");
+$langs->load("compta");
+
+// Protection if external user
+if ($user->societe_id > 0)
+{
+ accessforbidden();
+}
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+
+/***************************************************
+* PAGE
+*
+* Put here all code to build page
+****************************************************/
+
+llxHeader('','','');
+
+$html=new Form($db);
+
+
+// Put here content of your page
+// ...
+
+
+$year_current = strftime("%Y",dol_now());
+$pastmonth = strftime("%m",dol_now()) - 1;
+if ($pastmonth == 0) $pastmonth = 12;
+
+$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
+$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
+
+if (empty($date_start) || empty($date_end)) // We define date_start and date_end
+{
+ $date_start=dol_get_first_day($year_current,$pastmonth,false); $date_end=dol_get_last_day($year_current,$pastmonth,false);
+}
+
+$nom=$langs->trans("JournalAchat");
+//$nomlink=;
+$builddate=time();
+$description=$langs->trans("DescJournalAchat");
+$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
+
+$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS);
+$idpays = $p[0];
+
+$sql = "SELECT f.rowid, f.facnumber, f.datef, f.libelle, f.total_ttc, ";
+$sql .= "fd.tva_tx, fd.total_ht, fd.tva, fd.product_type ";
+$sql .= " ,s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code";
+$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd ";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product ";
+$sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn f ON f.rowid = fd.fk_facture_fourn ";
+$sql .= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc" ;
+$sql .= " WHERE f.fk_statut > 0 AND f.entity IN (0,".$conf->entity.")";
+if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
+
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows($result);
+ // les variables
+ $cptfour = isset($conf->global->COMPTA_ACCOUNT_SUPPLIER)?$conf->global->COMPTA_ACCOUNT_SUPPLIER:$langs->trans("CodeNotDef");
+ $cpttva = isset($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef");
+
+ $tabfac = array();
+ $tabht = array();
+ $tabtva = array();
+ $tabttc = array();
+
+ $i=0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($result);
+ // contrôles
+ $compta_soc = isset($obj->code_compta_fournisseur)?$obj->code_compta_fournisseur:$cptfour;
+ $compta_prod = $obj->accountancy_code_buy;
+ if (!isset($compta_prod) || empty($compta_prod))
+ {
+ if($obj->product_type == 0) $compta_prod = isset($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT)?$conf->global->COMPTA_PRODUCT_BUY_ACCOUNT:$langs->trans("CodeNotDef") ;
+ else $compta_prod = isset($conf->global->COMPTA_SERVICE_BUY_ACCOUNT)?$conf->global->COMPTA_SERVICE_BUY_ACCOUNT:$langs->trans("CodeNotDef") ;
+ }
+ $compta_tva = isset($obj->accountancy_code)?$obj->accountancy_code:$cpttva;
+
+ $tabfac[$obj->rowid]["date"] = $obj->datef;
+ $tabfac[$obj->rowid]["ref"] = $obj->facnumber;
+ $tabfac[$obj->rowid]["piece"] = ''; // todo
+ $tabfac[$obj->rowid]["lib"] = $obj->libelle;
+ $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
+ $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
+ $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
+
+ $i++;
+ }
+ }
+ else {
+ dol_print_error($db);
+ }
+
+/*
+ * Show result array
+ */
+$i = 0;
+print "
";
+
+/***************************************************
+* LINKED OBJECT BLOCK
+*
+* Put here code to view linked object
+****************************************************/
+/*
+
+$myobject->load_object_linked($myobject->id,$myobject->element);
+
+foreach($myobject->linked_object as $linked_object => $linked_objectid)
+{
+ if ($conf->$linked_object->enabled)
+ {
+ $somethingshown=$myobject->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
+ }
+}
+*/
+
+// End of page
+$db->close();
+llxFooter('$Date$ - $Revision$');
+?>
\ No newline at end of file
diff --git a/htdocs/compta/journaux/journalvente.php b/htdocs/compta/journaux/journalvente.php
new file mode 100644
index 00000000000..96a3ffd0a65
--- /dev/null
+++ b/htdocs/compta/journaux/journalvente.php
@@ -0,0 +1,197 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
+
+
+$langs->load("companies");
+$langs->load("other");
+$langs->load("compta");
+
+// Protection if external user
+if ($user->societe_id > 0)
+{
+ accessforbidden();
+}
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+
+/***************************************************
+* PAGE
+*
+* Put here all code to build page
+****************************************************/
+
+llxHeader('','','');
+
+$html=new Form($db);
+
+// Put here content of your page
+// ...
+
+$year_current = strftime("%Y",dol_now());
+$pastmonth = strftime("%m",dol_now()) - 1;
+if ($pastmonth == 0) $pastmonth = 12;
+
+$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
+$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
+
+if (empty($date_start) || empty($date_end)) // We define date_start and date_end
+{
+ $date_start=dol_get_first_day($year_current,$pastmonth,false); $date_end=dol_get_last_day($year_current,$pastmonth,false);
+}
+
+$nom=$langs->trans("JournalVente");
+//$nomlink=;
+$builddate=time();
+$description=$langs->trans("DescJournalvente");
+$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
+
+$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS);
+$idpays = $p[0];
+
+$sql = "SELECT f.rowid, f.facnumber, f.datef, f.ref_client , fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx ";
+$sql .= " , fd.total_ttc,p.accountancy_code_sell, s.code_compta , ct.accountancy_code";
+$sql .= " FROM ".MAIN_DB_PREFIX."facturedet fd ";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product ";
+$sql .= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture ";
+$sql .= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'";
+$sql .= " WHERE f.fk_statut > 0 AND f.entity IN (0,".$conf->entity.")";
+if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
+$sql .= " order by f.rowid";
+
+$result = $db->query($sql);
+if ($result)
+{
+ $tabfac = array();
+ $tabht = array();
+ $tabtva = array();
+ $tabttc = array();
+
+ $num = $db->num_rows($result);
+ $i=0;
+ $resligne=array();
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($result);
+ // les variables
+ $cptcli = isset($conf->global->COMPTA_ACCOUNT_CUSTOMER)?$conf->global->COMPTA_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef");
+ $compta_soc = isset($obj->code_compta)?$obj->code_compta:$cptcli;
+ $compta_prod = $obj->accountancy_code_sell;
+ if (!isset($compta_prod))
+ {
+ if($obj->product_type == 0) $compta_prod = isset($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT)?$conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT:$langs->trans("CodeNotDef") ;
+ else $compta_prod = isset($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT)?$conf->global->COMPTA_SERVICE_SOLD_ACCOUNT:$langs->trans("CodeNotDef") ;
+ }
+ $cpttva = isset($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef");
+ $compta_tva = isset($obj->accountancy_code)?$obj->accountancy_code:$cpttva;
+
+ //la ligne facture
+ $tabfac[$obj->rowid]["date"] = $obj->datef;
+ $tabfac[$obj->rowid]["ref"] = $obj->facnumber;
+ $tabfac[$obj->rowid]["piece"] = ''; // todo
+ $tabfac[$obj->rowid]["lib"] = $obj->ref_client;
+ $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
+ $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
+ $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
+
+ $i++;
+ }
+}
+else {
+ dol_print_error($db);
+}
+
+
+/*
+ * Show result array
+ */
+
+
+$i = 0;
+print "
";
+
+/***************************************************
+* LINKED OBJECT BLOCK
+*
+* Put here code to view linked object
+****************************************************/
+/*
+
+$myobject->load_object_linked($myobject->id,$myobject->element);
+
+foreach($myobject->linked_object as $linked_object => $linked_objectid)
+{
+ if ($conf->$linked_object->enabled)
+ {
+ $somethingshown=$myobject->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
+ }
+}
+*/
+
+// End of page
+$db->close();
+llxFooter('$Date$ - $Revision$');
+?>
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_c_tva.sql b/htdocs/install/mysql/tables/llx_c_tva.sql
index 20b1eea1d21..ad03d573acd 100644
--- a/htdocs/install/mysql/tables/llx_c_tva.sql
+++ b/htdocs/install/mysql/tables/llx_c_tva.sql
@@ -28,7 +28,8 @@ create table llx_c_tva
localtax2 double NOT NULL DEFAULT 0,
recuperableonly integer NOT NULL DEFAULT 0,
note varchar(128),
- active tinyint DEFAULT 1 NOT NULL
+ active tinyint DEFAULT 1 NOT NULL,
+ accountancy_code varchar(15) DEFAULT NULL
)type=innodb;
diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang
index 940c38b3b66..e0b39f4e07c 100644
--- a/htdocs/langs/fr_FR/compta.lang
+++ b/htdocs/langs/fr_FR/compta.lang
@@ -117,4 +117,26 @@ OrderStats=Statistiques sur les commandes
Dispatch=Ventilation
Dispatched=Ventilés
ToDispatch=A ventiler
-ThirdPartyMustBeEditAsCustomer=Le tiers doit être défini comme client
\ No newline at end of file
+ThirdPartyMustBeEditAsCustomer=Le tiers doit être défini comme client
+JournalVente=Journal des ventes
+JournalAchat=Journal des achats
+Journaux=Journaux
+Invoicedate=Date Facture
+InvoiceRef=Référence Fourn.
+Piece=Piece compta
+InvoiceLib=Libellé
+AmountDbt=Débit
+AmountCdt=Crédit
+DescJournalAchat=Journal des Achats Fournisseurs
+DescJournalvente=Journal des ventes
+JournalNum=Journal
+CodeNotDef=Non Déf.
+COMPTA_JOURNAL_SELL=Numéro compotable du Journal des Achats
+COMPTA_JOURNAL_BUY=Numéro comptable du Journal des Ventes
+COMPTA_PRODUCT_BUY_ACCOUNT=Compte par défaut pour produits achetés (si non défini sur fiche produit)
+COMPTA_PRODUCT_SOLD_ACCOUNT=Compte par défaut pour produits vendus (si non défini sur fiche produit)
+COMPTA_SERVICE_BUY_ACCOUNT=Compte par défaut pour services achetés (si non défini sur fiche service)
+COMPTA_SERVICE_SOLD_ACCOUNT1=Compte par défaut pour services vendus (si non défini sur fiche service)
+COMPTA_VAT_ACCOUNT=Compte par défaut pour TVA (si non défini dans dictionnaire)
+COMPTA_ACCOUNT_CUSTOMER=Compte client par défaut (si non défini sur fiche tiers)
+COMPTA_ACCOUNT_SUPPLIER=Compte fournisseur par défaut (si non défini sur fiche tiers)
\ No newline at end of file