FIX: Accountancy - Update balance to add description of the accounting account + bugfix
This commit is contained in:
parent
6096c8c49a
commit
f8bc456807
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
/* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
*
|
*
|
||||||
* 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,7 +20,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/accountancy/bookkeeping/balance.php
|
* \file htdocs/accountancy/bookkeeping/balance.php
|
||||||
* \ingroup Accounting Expert
|
* \ingroup Advanced accountancy
|
||||||
* \brief Balance of book keeping
|
* \brief Balance of book keeping
|
||||||
*/
|
*/
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
@ -137,7 +137,6 @@ else {
|
|||||||
/*
|
/*
|
||||||
* List
|
* List
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$nbtotalofrecords = 0;
|
$nbtotalofrecords = 0;
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
|
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
|
||||||
@ -151,12 +150,11 @@ else {
|
|||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords);
|
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result);
|
||||||
|
|
||||||
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
|
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||||
print '<div class="tabsAction">' . "\n";
|
print '<div class="tabsAction">' . "\n";
|
||||||
print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>';
|
print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>';
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '<div class="liste_titre">';
|
print '<div class="liste_titre">';
|
||||||
@ -169,6 +167,7 @@ else {
|
|||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder);
|
||||||
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
|
||||||
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
|
||||||
print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
|
||||||
@ -176,11 +175,11 @@ else {
|
|||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>';
|
print '<td colspan="2">';
|
||||||
print $langs->trans('From');
|
print $langs->trans('From');
|
||||||
print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '');
|
print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '');
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print $langs->trans('To');
|
print $langs->trans('to');
|
||||||
print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, '');
|
print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, '');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
@ -203,23 +202,28 @@ else {
|
|||||||
|
|
||||||
foreach ( $object->lines as $line ) {
|
foreach ( $object->lines as $line ) {
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
|
$link = '';
|
||||||
$total_debit += $line->debit;
|
$total_debit += $line->debit;
|
||||||
$total_credit += $line->credit;
|
$total_credit += $line->credit;
|
||||||
|
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account
|
||||||
|
if(empty($description)){
|
||||||
|
$link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() .'</a>';
|
||||||
|
}
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
|
|
||||||
print '<td>' . length_accountg($line->numero_compte) . '</td>';
|
print '<td>' . length_accountg($line->numero_compte) . '</td>';
|
||||||
print '<td align="right">' . price($line->debit) . '</td>';
|
print '<td>' . $description . '</td>';
|
||||||
print '<td align="right">' . price($line->credit) . '</td>';
|
print '<td align="right">' . number_format($line->debit, 2, ',', ' ') . '</td>';
|
||||||
print '<td align="right">' . price($line->credit - $line->debit) . '</td>';
|
print '<td align="right">' . number_format($line->credit, 2, ',', ' ') . '</td>';
|
||||||
print '<td align="center">';
|
print '<td align="right">' . number_format($line->credit - $line->debit, 2, ',', ' ') . '</td>';
|
||||||
|
print '<td align="center">' . $link;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total">';
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
|
print '<td></td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
print price($total_debit);
|
print price($total_debit);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2015-2016 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2015-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||||
@ -1207,6 +1207,48 @@ class BookKeeping extends CommonObject
|
|||||||
return - 1;
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of accounting account
|
||||||
|
*
|
||||||
|
* @param string $account Accounting account
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function get_compte_desc($account = null)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||||
|
|
||||||
|
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
|
||||||
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa ";
|
||||||
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||||
|
$sql .= " AND aa.account_number = '" . $account . "'";
|
||||||
|
$sql .= " AND asy.rowid = " . $pcgver;
|
||||||
|
$sql .= " AND aa.active = 1";
|
||||||
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$obj = '';
|
||||||
|
if ($this->db->num_rows($resql)) {
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($obj->category)){
|
||||||
|
return $obj->label;
|
||||||
|
}else{
|
||||||
|
return $obj->label.' ('.$obj->category.')';
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->error = "Error " . $this->db->lasterror();
|
||||||
|
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -18,8 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/core/lib/account.lib.php
|
* \file htdocs/core/lib/accounting.lib.php
|
||||||
* \ingroup Accounting Expert
|
* \ingroup Advanced accountancy
|
||||||
* \brief Library of accountancy functions
|
* \brief Library of accountancy functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ function length_accountg($account)
|
|||||||
// Clean parameters
|
// Clean parameters
|
||||||
$i = strlen($account);
|
$i = strlen($account);
|
||||||
|
|
||||||
if ($i >= 2) {
|
if ($i >= 1) {
|
||||||
while ( $i < $g ) {
|
while ( $i < $g ) {
|
||||||
$account .= '0';
|
$account .= '0';
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ function length_accounta($accounta)
|
|||||||
// Clean parameters
|
// Clean parameters
|
||||||
$i = strlen($accounta);
|
$i = strlen($accounta);
|
||||||
|
|
||||||
if ($i >= 2) {
|
if ($i >= 1) {
|
||||||
while ( $i < $a ) {
|
while ( $i < $a ) {
|
||||||
$accounta .= '0';
|
$accounta .= '0';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user