";
-$db->close();
-llxFooter();
\ No newline at end of file
+llxFooter();
+$db->close();
\ No newline at end of file
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 3b68bd6b69e..8ee5eb41eb5 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -52,9 +52,25 @@ $formventilation = new FormVentilation($db);
llxHeader('', $langs->trans("Ventilation"));
+print '';
/*
* Action
-*/
+ */
if ($action == 'ventil') {
print '
' . $langs->trans("Processing") . '...
';
@@ -113,8 +129,8 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_fac
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_sell = aa.account_number";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
-$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
-$sql .= " AND (accsys.rowid='".$conf->global->CHARTOFACCOUNTS."' OR p.accountancy_code_sell IS NULL)";
+$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation <= 0";
+$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
@@ -147,7 +163,7 @@ if ($result) {
print '
' . $langs->trans("Amount") . '
';
print '
' . $langs->trans("AccountAccounting") . '
';
print '
' . $langs->trans("IntoAccount") . '
';
- print '
' . $langs->trans("Ventilate") . '
';
+ print '
' . $langs->trans("Ventilate") . ' /'.'
';
print '';
$facture_static = new Facture($db);
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index 1f9b0549121..95a00eaf950 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -404,14 +404,14 @@ if ($action == 'writeBookKeeping')
// export csv
if ($action == 'export_csv')
{
- $sep = $conf->global->ACCOUNTING_SEPARATORCSV;
+ $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=journal_banque.csv');
$companystatic = new Client($db);
- if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) // Modèle Export Cegid Expert
{
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
diff --git a/htdocs/accountancy/journal/cashjournal.php b/htdocs/accountancy/journal/cashjournal.php
index fb5a15a513c..51b8625f9b3 100644
--- a/htdocs/accountancy/journal/cashjournal.php
+++ b/htdocs/accountancy/journal/cashjournal.php
@@ -367,12 +367,12 @@ if ($action == 'writeBookKeeping') {
}
// export csv
if ($action == 'export_csv') {
- $sep = $conf->global->ACCOUNTING_SEPARATORCSV;
+ $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
header('Content-Type: text/csv');
header('Content-Disposition:attachment;filename=journal_caisse.csv');
- if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) // Modèle Export Cegid Expert
{
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index d2f204c6b8c..68bcdaa394f 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -185,8 +185,8 @@ if ($action == 'writebookkeeping') {
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
- $compte = new AccountingAccount($db);
- if ($compte->fetch(null, $k)) {
+ $accountingaccount = new AccountingAccount($db);
+ if ($accountingaccount->fetch(null, $k)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@@ -195,7 +195,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
$bookkeeping->code_tiers = '';
- $bookkeeping->label_compte = dol_trunc($val["description"], 128);
+ $bookkeeping->label_compte = $accountingaccount->label;
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
@@ -213,7 +213,6 @@ if ($action == 'writebookkeeping') {
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
-
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@@ -246,12 +245,12 @@ $companystatic = new Societe($db);
// export csv
if ($action == 'export_csv')
{
- $sep = $conf->global->ACCOUNTING_SEPARATORCSV;
+ $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=journal_achats.csv');
- if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) // Modèle Export Cegid Expert
{
foreach ( $tabfac as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
@@ -314,11 +313,13 @@ if ($action == 'export_csv')
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
+ $accountingaccount = new AccountingAccount($db);
+ $accountingaccount->fetch(null, $k);
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
- print '"' . dol_trunc($val["description"], 32) . '"' . $sep;
+ print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
@@ -418,12 +419,15 @@ if ($action == 'export_csv')
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
+ $accountingaccount = new AccountingAccount($db);
+ $accountingaccount->fetch(null, $k);
+
if ($mt) {
print "
';
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index 8b2a870220d..5df5ee0c06f 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -1,7 +1,5 @@
- * Copyright (C) 2005 Simon TOSSER
- * Copyright (C) 2013-2014 Olivier Geffroy
+/* Copyright (C) 2013-2014 Olivier Geffroy
* Copyright (C) 2013-2014 Alexandre Spangaro
* Copyright (C) 2014 Ari Elbaz (elarifr)
* Copyright (C) 2013-2014 Florian Henry
@@ -48,6 +46,7 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->ventilation->dispatch)
accessforbidden();
+
$formventilation = new FormVentilation($db);
$changeaccount = GETPOST('changeaccount');
@@ -107,7 +106,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product
$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
$sql .= " AND aa.rowid = l.fk_code_ventilation";
if (strlen(trim($_GET["search_facture"]))) {
- $sql .= " AND f.facnumber like '%" . $_GET["search_facture"] . "%'";
+ $sql .= " AND f.ref like '%" . $_GET["search_facture"] . "%'";
}
if (strlen(trim($_GET["search_ref"]))) {
$sql .= " AND p.ref like '%" . $_GET["search_ref"] . "%'";
@@ -218,7 +217,8 @@ if ($result) {
print $db->error();
}
+
print "
";
-$db->close();
-llxFooter();
\ No newline at end of file
+llxFooter();
+$db->close();
\ No newline at end of file
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index f932fbfc8af..a85dd7a17d4 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -22,7 +22,7 @@
/**
* \file htdocs/accountancy/supplier/list.php
* \ingroup Accounting Expert
- * \brief Page de ventilation des lignes de facture
+ * \brief Ventilation page from suppliers invoices
*/
require '../../main.inc.php';
@@ -53,6 +53,22 @@ $formventilation = new FormVentilation($db);
llxHeader('', $langs->trans("Ventilation"));
+print '';
/*
* Action
*/
@@ -115,8 +131,8 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_buy = aa.account_number";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
-$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
-$sql .= " AND (accsys.rowid='".$conf->global->CHARTOFACCOUNTS."' OR p.accountancy_code_sell IS NULL)";
+$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation <= 0";
+$sql .= " AND (accsys.rowid='".$conf->global->CHARTOFACCOUNTS."' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='')";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
@@ -150,7 +166,7 @@ if ($result) {
print '
' . $langs->trans("Amount") . '
';
print '
' . $langs->trans("Compte") . '
';
print '
' . $langs->trans("IntoAccount") . '
';
- print '
' . $langs->trans("Ventilate") . '
';
+ print '
' . $langs->trans("Ventilate") . ' /'.'
';
print "\n";
$facturefourn_static = new FactureFournisseur($db);
@@ -161,6 +177,23 @@ if ($result) {
while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
+
+ // product_type: 0 = service ? 1 = product
+ // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service
+ // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB !
+ $code_buy_notset = '';
+
+ if (empty($objp->code_buy)) {
+ $code_buy_notset = 'color:red';
+ if ($objp->type == 1) {
+ $objp->code_buy = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
+ } else {
+ $objp->code_buy = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
+ }
+ }else {
+ $code_buy_notset = 'color:blue';
+ }
+
print "