2
0
forked from Wavyzz/dolibarr

Merge pull request #10160 from aspangaro/10.0_accoutancy_stats

NEW: Add stats on entries & movements by fiscal year
This commit is contained in:
Laurent Destailleur
2018-12-15 15:17:46 +01:00
committed by GitHub
5 changed files with 89 additions and 27 deletions

View File

@@ -18,9 +18,9 @@
*/
/**
* \file htdocs/accountancy/admin/card.php
* \ingroup Advanced accountancy
* \brief Card of accounting account
* \file htdocs/accountancy/admin/card.php
* \ingroup Advanced accountancy
* \brief Card of accounting account
*/
require '../../main.inc.php';

View File

@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
/* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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
@@ -16,9 +16,9 @@
*/
/**
* \file htdocs/accountancy/admin/fiscalyear.php
* \ingroup Advanced accountancy
* \brief Setup page to configure fiscal year
* \file htdocs/accountancy/admin/fiscalyear.php
* \ingroup Advanced accountancy
* \brief Setup page to configure fiscal year
*/
require '../../main.inc.php';
@@ -45,8 +45,8 @@ $langs->loadLangs(array("admin","compta"));
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we shoul be able to see fiscal year.
accessforbidden();
if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we should be able to see fiscal year.
accessforbidden();
$error = 0;
@@ -113,23 +113,26 @@ if ($result)
if (! empty($user->rights->accounting->fiscalyear))
{
$addbutton = '<a class="butAction" href="fiscalyear_card.php?action=create">' . $langs->trans("NewFiscalYear") . '</a>';
$addbutton = '<a class="butActionNew" href="fiscalyear_card.php?action=create"><span class="valignmiddle">' . $langs->trans("NewFiscalYear") .'</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
}
else
{
$addbutton = '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">' . $langs->trans("NewFiscalYear") . '</a>';
$addbutton = '<a class="butActionRefused classfortooltip" href="#"><span class="valignmiddle" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">' . $langs->trans("NewFiscalYear") .'</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
}
$title = $langs->trans('AccountingPeriods');
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1);
// Load attribute_label
print '<table class="noborder" width="100%">';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Ref") . '</td>';
print '<td>' . $langs->trans("Label") . '</td>';
print '<td>' . $langs->trans("DateStart") . '</td>';
print '<td>' . $langs->trans("DateEnd") . '</td>';
print '<td align="center">' . $langs->trans("NumberOfAccountancyEntries") . '</td>';
print '<td align="center">' . $langs->trans("NumberOfAccountancyMovements") . '</td>';
print '<td align="right">' . $langs->trans("Statut") . '</td>';
print '</tr>';
@@ -144,6 +147,8 @@ if ($result)
print '<td align="left">' . $obj->label . '</td>';
print '<td align="left">' . dol_print_date($db->jdate($obj->date_start), 'day') . '</td>';
print '<td align="left">' . dol_print_date($db->jdate($obj->date_end), 'day') . '</td>';
print '<td align="center">' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
print '<td align="center">' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
print '<td align="right">' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '</td>';
print '</tr>';
$i++;
@@ -152,6 +157,7 @@ if ($result)
print '<tr class="oddeven"><td colspan="5" class="opacitymedium">' . $langs->trans("None") . '</td></tr>';
}
print '</table>';
print '</div>';
} else {
dol_print_error($db);
}

View File

@@ -256,7 +256,7 @@ class Account extends CommonObject
}
/**
* Shows the account number in the appropiate format
* Shows the account number in the appropriate format
*
* @return string
*/
@@ -419,7 +419,7 @@ class Account extends CommonObject
*/
function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='', $datev=null)
{
// Deprecatîon warning
// Deprecation warning
if (is_numeric($oper)) {
dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING);
}
@@ -430,7 +430,7 @@ class Account extends CommonObject
$now=dol_now();
if (is_numeric($oper)) // Clean oper to have a code instead of a rowid
if (is_numeric($oper)) // Clean operation to have a code instead of a rowid
{
$sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement";
$sql.= " WHERE id=".$oper;

View File

@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@zendsi.com>
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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
@@ -21,7 +21,7 @@
* \brief File of class to manage fiscal years
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
/**
* Class to manage fiscal year
@@ -60,9 +60,9 @@ class Fiscalyear extends CommonObject
public $rowid;
/**
* @var string fiscal year label
*/
public $label;
* @var string fiscal year label
*/
public $label;
public $date_start;
public $date_end;
@@ -82,8 +82,10 @@ class Fiscalyear extends CommonObject
*
* @param DoliDB $db Database handler
*/
function __construct($db)
function __construct(DoliDB $db)
{
global $langs;
$this->db = $db;
$this->statuts_short = array(0 => 'Opened', 1 => 'Closed');
@@ -163,10 +165,10 @@ class Fiscalyear extends CommonObject
// Check parameters
if (empty($this->date_start) && empty($this->date_end))
{
$this->error='ErrorBadParameter';
return -1;
}
{
$this->error='ErrorBadParameter';
return -1;
}
$this->db->begin();
@@ -267,7 +269,7 @@ class Fiscalyear extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Give a label from a status
*
@@ -277,7 +279,7 @@ class Fiscalyear extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
// phpcs:enable
// phpcs:enable
global $langs;
if ($mode == 0)
@@ -354,4 +356,56 @@ class Fiscalyear extends CommonObject
dol_print_error($this->db);
}
}
/**
* Return the number of entries by fiscal year
*
* @param int $datestart Date start to scan
* @param int $dateend Date end to scan
* @return string Number of entries
*/
function getAccountancyEntriesByFiscalYear($datestart, $dateend)
{
global $conf;
$sql = "SELECT count(DISTINCT piece_num) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping ";
$sql.= " WHERE doc_date >= '".$datestart."' and doc_date <= '".$dateend."'";
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$nb = $obj->nb;
}
else dol_print_error($this->db);
return $nb;
}
/**
* Return the number of movements by fiscal year
*
* @param int $datestart Date start to scan
* @param int $dateend Date end to scan
* @return string Number of movements
*/
function getAccountancyMovementsByFiscalYear($datestart, $dateend)
{
global $conf;
$sql = "SELECT count(rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping ";
$sql.= " WHERE doc_date >= '".$datestart."' AND doc_date <= '".$dateend."'";
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$nb = $obj->nb;
}
else dol_print_error($this->db);
return $nb;
}
}

View File

@@ -254,6 +254,8 @@ AccountingJournalType8=Inventory
AccountingJournalType9=Has-new
ErrorAccountingJournalIsAlreadyUse=This journal is already use
AccountingAccountForSalesTaxAreDefinedInto=Note: Accounting account for Sales tax are defined into menu <b>%s</b> - <b>%s</b>
NumberOfAccountancyEntries=Number of entries
NumberOfAccountancyMovements=Number of movements
## Export
ExportDraftJournal=Export draft journal