From ae11ab12f6a689550b4dfd6784941130b422f555 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 25 Jan 2015 06:54:17 +0100 Subject: [PATCH 1/3] FIXED Accounting module - Align core & module 3.6 --- htdocs/accountancy/admin/export.php | 19 +++-- htdocs/core/modules/modAccounting.class.php | 73 +++++++++++++------ .../install/mysql/migration/3.6.0-3.7.0.sql | 11 ++- 3 files changed, 69 insertions(+), 34 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index d0eef1dc2f4..8fd0795c262 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -44,7 +44,13 @@ $action = GETPOST('action', 'alpha'); // Other parameters ACCOUNTING_* $list = array ( - 'ACCOUNTING_SEPARATORCSV' + 'ACCOUNTING_EXPORT_SEPARATORCSV', + 'ACCOUNTING_EXPORT_DATE', + 'ACCOUNTING_EXPORT_PIECE', + 'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT', + 'ACCOUNTING_EXPORT_LABEL', + 'ACCOUNTING_EXPORT_AMOUNT', + 'ACCOUNTING_EXPORT_DEVISE' ); /* @@ -57,7 +63,7 @@ if ($action == 'update') { if (! empty($modelcsv)) { - if (! dolibarr_set_const($db, 'ACCOUNTING_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { + if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { $error ++; } } else { @@ -112,12 +118,12 @@ print "" . $langs->trans("Selectmodelcsv") . ""; print ""; print ''; + print '
'; print ''; @@ -171,7 +171,7 @@ else { print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", 'align="center"', $sortfield, $sortorder); @@ -231,4 +231,4 @@ else { } llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index 0829f792130..26f0469c1a0 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -56,12 +56,11 @@ $offset = $conf->liste_limit * $page; llxHeader('', $langs->trans("Bookkeeping")); -$textprevyear = "" . img_previous() . ""; -$textnextyear = " " . img_next() . ""; +$textprevyear = '' . img_previous() . ''; +$textnextyear = ' ' . img_next() . ''; /* - * Mode Liste - * + * Mode List */ $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens, bk.code_journal"; diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 46a34698785..24031b683b4 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -53,7 +53,6 @@ class AccountingAccount * @param DoliDB $db Database handle */ function __construct($db) - { $this->db = $db; } diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index 33bb33a2353..4e833862bd8 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -128,7 +128,7 @@ class FormVentilation extends Form $label = $obj->account_number . ' - ' . $obj->label; // Remember guy's we store in database llx_facturedet the rowid of accountingaccount and not the account_number - // Bacause same account_number can be share between different accounting_system and do have the same meaning + // Because same account_number can be share between different accounting_system and do have the same meaning if (($selectid != '') && $selectid == $obj->rowid) { // $out .= ''; $out .= ''; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 28d3d0c1f79..9eb546ec89d 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -45,8 +45,7 @@ if ($user->societe_id > 0) * Actions */ -if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) -{ +if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { if (! GETPOST('cancel', 'alpha')) { $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; @@ -127,8 +126,8 @@ if (! empty($id)) { print ''; print ''; - print '
    '; - print '
    '; + print '
'; print ''; } else { diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 663e763a9d3..1760f8360a9 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -22,7 +22,7 @@ /** * \file htdocs/accountancy/customer/index.php * \ingroup Accounting Expert - * \brief Page accueil clients ventilation comptable + * \brief Home customer ventilation */ require '../../main.inc.php'; @@ -75,6 +75,8 @@ if ($action == 'validatehistory') { $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; } + + dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $resql1 = $db->query($sql1); if (! $resql1) { @@ -93,7 +95,7 @@ if ($action == 'validatehistory') { llxHeader('', $langs->trans("CustomersVentilation")); $textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textnextyear = ' ' . img_next() . ''; print_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); @@ -105,6 +107,7 @@ $sql .= " , " . MAIN_DB_PREFIX . "facture as f"; $sql .= " WHERE fd.fk_code_ventilation = 0"; $sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; +dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { $row = $db->fetch_row($result); @@ -160,6 +163,7 @@ if (! empty($conf->multicompany->enabled)) { $sql .= " GROUP BY fd.fk_code_ventilation"; +dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $i = 0; @@ -194,7 +198,7 @@ print "\n"; print "
\n"; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -232,6 +236,7 @@ if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity = '" . $conf->entity . "'"; } +dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { $i = 0; @@ -303,7 +308,8 @@ if (! empty($conf->margin->enabled)) { if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity = '" . $conf->entity . "'"; } - + + dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { $i = 0; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 9215d5a9d98..01806db8332 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -133,7 +133,7 @@ if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { } $sql .= $db->plimit($limit + 1, $offset); -dol_syslog("/accountancy/customer/linges.php sql=" . $sql, LOG_DEBUG); +dol_syslog("/accountancy/customer/lines.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); @@ -220,5 +220,5 @@ if ($result) { print "
' . $langs->trans("Total") . '
' . $langs->trans("TotalVente") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '
"; -$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 ""; print "" . $date . ""; print "" . $invoicestatic->getNomUrl(1) . ""; print "" . length_accountg($k) . ""; - print "" . $invoicestatic->description . ""; + print "" . $accountingaccount->label . ""; print '' . ($mt >= 0 ? price($mt) : '') . ""; print '' . ($mt < 0 ? price(- $mt) : '') . ""; print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 5bb1f989a92..892272d6a5a 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -140,7 +140,7 @@ if ($result) { $tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["ref"] = $obj->facnumber; $tabfac[$obj->rowid]["type"] = $obj->type; - $tabfac[$obj->rowid]["description"] = $obj->description; + $tabfac[$obj->rowid]["description"] = $obj->label_compte; $tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid; if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; @@ -196,8 +196,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"]; @@ -207,7 +207,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($val["description"], 128); + $bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -247,14 +247,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_ventes.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 ( $tabfac as $key => $val ) { $companystatic->id = $tabcompany[$key]['id']; @@ -324,11 +324,14 @@ 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"; @@ -436,12 +439,15 @@ if ($action == 'export_csv') { // Product / Service foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); + if ($mt) { print ""; print "" . $date . ""; print "" . $invoicestatic->getNomUrl(1) . ""; print "" . length_accountg($k) . ""; - print "" . $invoicestatic->description . ""; + print "" . $accountingaccount->label . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; print ""; @@ -467,8 +473,8 @@ if ($action == 'export_csv') { } print ""; - - // End of page - llxFooter(); } +// End of page +llxFooter(); + $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 45c8de9b165..1acd5829c45 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2014 Juanjo Menent s + * Copyright (C) 2014 Juanjo Menent * * 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 diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index edebcfd9d46..85d1c04cf53 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -21,7 +21,7 @@ /** * \file htdocs/accountancy/supplier/index.php * \ingroup Accounting Expert - * \brief Page accueil ventilation + * \brief Home supplier ventilation */ require '../../main.inc.php'; @@ -93,9 +93,9 @@ if ($action == 'validatehistory') { llxHeader('', $langs->trans("SuppliersVentilation")); $textprevyear = '' . img_previous() . ''; -$textnextyear = ' ' . img_next() . ''; +$textnextyear = ' ' . img_next() . ''; -print_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); +print_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear); print '' . $langs->trans("DescVentilSupplier") . ''; print ''; @@ -105,7 +105,7 @@ $y = $year_current; $var = true; print ''; -print ''; +print ''; print ''; print ''; 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 "
' . $langs->trans("Account") . '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '
"; -$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 ""; // Ref facture @@ -191,7 +224,7 @@ if ($result) { print price($objp->price); print ''; - print ''; + print ''; print $objp->code_buy; print ''; @@ -216,4 +249,4 @@ if ($result) { } llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file From 68764ccea3333cd437bf4f911c734f3f33689d5c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 25 Jan 2015 15:35:34 +0100 Subject: [PATCH 3/3] Debug --- htdocs/accountancy/bookkeeping/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 83ff8cdad14..f1dc892c10f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -171,7 +171,7 @@ else { print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", 'align="center"', $sortfield, $sortorder);