From 5816c86e0772b1d13d7706e56a0d94765bf03bdd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2016 17:51:10 +0100 Subject: [PATCH] Debug accountancy module --- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/customer/index.php | 79 +++++++++++++- htdocs/accountancy/expensereport/index.php | 116 +++++++++++++++++---- htdocs/accountancy/supplier/index.php | 87 +++++++++++++++- htdocs/langs/en_US/accountancy.lang | 3 + 5 files changed, 255 insertions(+), 32 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 00bbbd81e76..a650100918e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -307,7 +307,7 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } -$num=count($this->lines); +$num=count($object->lines); if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 86e3ce9eb5d..28b3b9e7a22 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -171,12 +171,10 @@ print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevye print $langs->trans("DescVentilCustomer") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; print '
'; -print '
'; -print '' . $langs->trans("ValidateHistory") . ''; -print '' . $langs->trans("CleanHistory", $year_current) . ''; +//print '
'; // TODO Remove this. Should be done into the repair.php script if ($conf->global->MAIN_FEATURES_LEVEL > 0) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; -print '
'; +//print '
'; $sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " , " . MAIN_DB_PREFIX . "facture as f"; @@ -193,8 +191,16 @@ if ($result) { $y = $year_current; +$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; + + + + $var = true; +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); + print ''; print ''; print ''; @@ -215,7 +221,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy - +$sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); @@ -241,6 +247,69 @@ if ($resql) { } print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '
\n"; + +print '
'; + + +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); + +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " SUM(fd.total_ht) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy +$sql .= " AND aa.account_number IS NOT NULL"; +$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; + +dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + $var = ! $var; + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; + + + + + +print '
'; +print '
'; + + +print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; print ''; print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 2f378fa2e11..7ead3a9940e 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -165,29 +165,39 @@ print $langs->trans("DescVentilExpenseReport") . '
'; print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; print '
'; -print '
'; -print '' . $langs->trans("ValidateHistory") . ''; -print '' . $langs->trans("CleanHistory", $year_current) . ''; +//print '
'; // TODO Remove this. Should be done always. if ($conf->global->MAIN_FEATURES_LEVEL > 0) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; -print '
'; +//print '
'; + + +$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; + + $y = $year_current; $var = true; + +print '
'; + +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); + + print '
' . $langs->trans("TotalVente") . '
'; print ''; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } print ''; $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } $sql .= " ROUND(SUM(erd.total_ht),2) as total"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; @@ -197,32 +207,96 @@ $sql .= " WHERE er.date_create >= '" . $db->idate(dol_get_first_day($y, 1, false $sql .= " AND er.date_create <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy - $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ( $row = $db->fetch_row($resql)) { - $var = ! $var; - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - print ''; - } - $db->free($resql); + $var = ! $var; + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; + + +print '
'; + +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); + + +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " ROUND(SUM(erd.total_ht),2) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " WHERE er.date_create >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND er.date_create <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " AND er.fk_statut > 0 "; +$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy +$sql .= " AND aa.account_number IS NULL"; +$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; + +dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + $var = ! $var; + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; + + + + +print '
'; +print '
'; + + +print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + + print "
\n"; print ''; print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 5b96e38d379..48ea8019a9d 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -165,17 +165,25 @@ print $langs->trans("DescVentilSupplier") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; print '
'; -print '
'; -print '' . $langs->trans("ValidateHistory") . ''; -print '' . $langs->trans("CleanHistory", $year_current) . ''; +//print '
'; // TODO Remove this. Should be done always. if ($conf->global->MAIN_FEATURES_LEVEL > 0) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; -print '
'; +//print '
'; + +$buttonbind = '' . $langs->trans("ValidateHistory") . ''; +$buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; + + $y = $year_current; $var = true; + +print '
'; + +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); + print '
' . $langs->trans("Total") . '
'; print ''; print ''; @@ -197,7 +205,7 @@ $sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . " $sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; $sql .= " AND ff.fk_statut > 0 "; $sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy - +$sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); @@ -223,6 +231,75 @@ if ($resql) { } print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '
\n"; + + + +print '
'; + + +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); + +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " ROUND(SUM(ffd.total_ht),2) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation"; +$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " AND ff.fk_statut > 0 "; +$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy +$sql .= " AND aa.account_number IS NOT NULL"; +$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; + +dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + $var = ! $var; + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; + + + + + +print '
'; +print '
'; + + +print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + + + + print "
\n"; print ''; print ''; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8159e61fb2f..1dee42cd39d 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -23,6 +23,9 @@ Chartofaccounts=Chart of accounts CurrentDedicatedAccountingAccount=Current dedicated account AssignDedicatedAccountingAccount=New account to assign InvoiceLabel=Invoice label +OverviewOfAmountOfLinesNotBound=Overview of amount of lines not bound to accounting account +OverviewOfAmountOfLinesBound=Overview of amount of lines already bound to accounting account +OtherInfo=Other information AccountancyArea=Accountancy area AccountancyAreaDescIntro=Usage of the accountancy module is done in several step:
' . $langs->trans("Total") . '