New: Add some hooks for financial reports

This commit is contained in:
Juanjo Menent 2014-03-28 18:31:43 +01:00
parent 638e90eb67
commit a1fb21114b
8 changed files with 82 additions and 6 deletions

View File

@ -65,6 +65,7 @@ For developers:
action buttons into an element. action buttons into an element.
- New: Normalize code for barcode generation to match other modules. - New: Normalize code for barcode generation to match other modules.
- New: Uniformize code for contacts forms. - New: Uniformize code for contacts forms.
- New: Add some hooks for financial reports.
WARNING: Following change may create regression for some external modules, but was necessary to make WARNING: Following change may create regression for some external modules, but was necessary to make
Dolibarr better: Dolibarr better:

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> /* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* *
* 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
@ -153,6 +154,17 @@ print "<td align=\"right\">".$vatcust."</td>";
print "</tr>\n"; print "</tr>\n";
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell');
$action = "tvaclient";
$object = &$coll_list;
$parameters["mode"] = $modetax;
$parameters["start"] = $date_start;
$parameters["end"] = $date_end;
$parameters["direction"] = 'sell';
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (is_array($coll_list)) if (is_array($coll_list))
{ {
$var=true; $var=true;
@ -160,7 +172,7 @@ if (is_array($coll_list))
$i = 1; $i = 1;
foreach($coll_list as $coll) foreach($coll_list as $coll)
{ {
if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2>0) if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2!=0)
{ {
$var=!$var; $var=!$var;
$intra = str_replace($find,$replace,$coll->tva_intra); $intra = str_replace($find,$replace,$coll->tva_intra);
@ -222,6 +234,8 @@ print "</tr>\n";
$company_static=new Societe($db); $company_static=new Societe($db);
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy');
$parameters["direction"] = 'buy';
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (is_array($coll_list)) if (is_array($coll_list))
{ {
$var=true; $var=true;
@ -229,7 +243,7 @@ if (is_array($coll_list))
$i = 1; $i = 1;
foreach($coll_list as $coll) foreach($coll_list as $coll)
{ {
if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2>0) if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2!=0)
{ {
$var=!$var; $var=!$var;
$intra = str_replace($find,$replace,$coll->tva_intra); $intra = str_replace($find,$replace,$coll->tva_intra);

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> /* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* *
* 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
@ -134,6 +135,15 @@ for ($m = 1 ; $m < 13 ; $m++ )
{ {
$coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m);
$coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m);
$action = "tva";
$object = array(&$coll_listsell, &$coll_listbuy);
$parameters["mode"] = $modetax;
$parameters["year"] = $y;
$parameters["month"] = $m;
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (! is_array($coll_listbuy) && $coll_listbuy == -1) if (! is_array($coll_listbuy) && $coll_listbuy == -1)
{ {
@ -181,7 +191,7 @@ for ($m = 1 ; $m < 13 ; $m++ )
print '<td align="right">'.$langs->trans("SubTotal").':</td>'; print '<td align="right">'.$langs->trans("SubTotal").':</td>';
print '<td class="nowrap" align="right">'.price($subtotalcoll).'</td>'; print '<td class="nowrap" align="right">'.price($subtotalcoll).'</td>';
print '<td class="nowrap" align="right">'.price($subtotalpaye).'</td>'; print '<td class="nowrap" align="right">'.price($subtotalpaye).'</td>';
print '<td class="nowrap" align="right">'.price($subtotalpaye).'</td>'; print '<td class="nowrap" align="right">'.price($subtotal).'</td>';
print '<td>&nbsp;</td></tr>'; print '<td>&nbsp;</td></tr>';
$i = 0; $i = 0;
$subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0;

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* *
* 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
@ -729,6 +730,16 @@ if ($mysoc->tva_assuj != 'franchise') // Assujeti
print '</tr>'; print '</tr>';
} }
$action = "balanceclient";
$object = array(&$total_ht, &$total_ttc);
$parameters["mode"] = $modecompta;
$parameters["date_start"] = $date_start;
$parameters["date_end"] = $date_end;
$parameters["bc"] = $bc;
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint;
if ($mysoc->tva_assuj != 'franchise') // Assujeti if ($mysoc->tva_assuj != 'franchise') // Assujeti
{ {

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* *
* 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
@ -461,8 +462,12 @@ if ($result) {
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$action = "balance";
$object = array(&$encaiss, &$encaiss_ttc, &$decaiss, &$decaiss_ttc);
$parameters["mode"] = $modecompta;
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
/* /*
* Show result array * Show result array

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Yannick Warnier <ywarnier@beeznest.org> * Copyright (C) 2006 Yannick Warnier <ywarnier@beeznest.org>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* *
* 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
@ -185,6 +186,17 @@ print "<td align=\"right\">".$vatcust."</td>";
print "</tr>\n"; print "</tr>\n";
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell');
$action = "tvaclient";
$object = &$coll_list;
$parameters["mode"] = $modetax;
$parameters["start"] = $date_start;
$parameters["end"] = $date_end;
$parameters["direction"] = 'sell';
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (is_array($coll_list)) if (is_array($coll_list))
{ {
$var=true; $var=true;
@ -263,6 +275,9 @@ print "</tr>\n";
$company_static=new Societe($db); $company_static=new Societe($db);
$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy');
$parameters["direction"] = 'buy';
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (is_array($coll_list)) if (is_array($coll_list))
{ {
$var=true; $var=true;

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* *
* 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
@ -153,6 +154,15 @@ for ($m = 1 ; $m < 13 ; $m++ )
{ {
$coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m);
$coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m);
$action = "tva";
$object = array(&$coll_listsell, &$coll_listbuy);
$parameters["mode"] = $modetax;
$parameters["year"] = $y;
$parameters["month"] = $m;
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (! is_array($coll_listbuy) && $coll_listbuy == -1) if (! is_array($coll_listbuy) && $coll_listbuy == -1)
{ {

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org> * Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* *
* 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
@ -318,7 +319,16 @@ else
print '<td align="right">'.$langs->trans("AmountHTVATRealReceived").'</td>'; print '<td align="right">'.$langs->trans("AmountHTVATRealReceived").'</td>';
print '<td align="right">'.$vatcust.'</td>'; print '<td align="right">'.$vatcust.'</td>';
print '</tr>'; print '</tr>';
$action = "tvadetail";
$parameters["mode"] = $modetax;
$parameters["start"] = $date_start;
$parameters["end"] = $date_end;
$object = array(&$x_coll, &$x_paye, &$x_both);
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
foreach(array_keys($x_coll) as $rate) foreach(array_keys($x_coll) as $rate)
{ {
$subtot_coll_total_ht = 0; $subtot_coll_total_ht = 0;