Work on reports per date

This commit is contained in:
Laurent Destailleur 2017-09-05 02:13:02 +02:00
parent 987303a6ca
commit e1fa37f7ff
5 changed files with 98 additions and 22 deletions

View File

@ -52,7 +52,7 @@ $langs->load("hrm");
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int');
$id=32;
$rowid=GETPOST('rowid','alpha');
$code=GETPOST('code','alpha');

View File

@ -488,13 +488,19 @@ class AccountancyCategory
// calcule
/* I try to replace this with dol_eval()
const PATTERN = '/(?:\-?\d+(?:\.?\d+)?[\+\-\*\/])+\-?\d+(?:\.?\d+)?/';
const PARENTHESIS_DEPTH = 10;
public function calculate($input){
public function calculate($input)
{
global $langs;
if(strpos($input, '+') != null || strpos($input, '-') != null || strpos($input, '/') != null || strpos($input, '*') != null){
// Remove white spaces and invalid math chars
$input = str_replace($langs->trans("ThousandSeparator"), '', $input);
$input = str_replace(',', '.', $input);
$input = preg_replace('[^0-9\.\+\-\*\/\(\)]', '', $input);
@ -536,6 +542,8 @@ class AccountancyCategory
return 0;
}
*/
/**
* get cpts of category

View File

@ -37,12 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array('compta','bills','donation','salaries'));
$date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday');
$date_startyear=GETPOST('date_startyear');
$date_endmonth=GETPOST('date_endmonth');
$date_endday=GETPOST('date_endday');
$date_endyear=GETPOST('date_endyear');
$date_startmonth=GETPOST('date_startmonth','int');
$date_startday=GETPOST('date_startday','int');
$date_startyear=GETPOST('date_startyear','int');
$date_endmonth=GETPOST('date_endmonth','int');
$date_endday=GETPOST('date_endday','int');
$date_endyear=GETPOST('date_endyear','int');
$showaccountdetail = GETPOST('showaccountdetail','aZ09');
// Security check
$socid = GETPOST('socid','int');
@ -170,8 +171,10 @@ elseif ($modecompta=="BOOKKEEPING")
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','</a>').')';
//$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$period.=' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '. $form->selectyesno('showaccountdetail',$showaccountdetail,0);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesResultBookkeepingPredefined", $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("Chartofaccounts"));
$description=$langs->trans("RulesResultBookkeepingPredefined");
$description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("Chartofaccounts")).')';
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
@ -196,8 +199,8 @@ if ($date_endyear) $param.='&date_endyear='.$date_startyear;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre("Groups", $_SERVER["PHP_SELF"], 's.nom, s.rowid','',$param,'',$sortfield,$sortorder);
print_liste_field_titre('');
print_liste_field_titre("Groups", $_SERVER["PHP_SELF"],'s.nom, s.rowid','',$param,'',$sortfield,$sortorder);
if ($modecompta == 'BOOKKEEPING')
{
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"],'amount','',$param,'align="right"',$sortfield,$sortorder);
@ -220,7 +223,12 @@ if ($modecompta == 'BOOKKEEPING')
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f";
$sql.= ", ".MAIN_DB_PREFIX."accounting_account as aa";
$sql.= " WHERE f.numero_compte = aa.account_number";
$sql.= " AND pcg_type in ('EXPENSE','INCOME')";
//$sql.= " AND fk_statut in (1,2)";
$sql.= " AND (";
$sql.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))";
$sql.= " OR ";
$sql.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))";
$sql.= ")";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY name, socid, pcg_type, pcg_subtype";
@ -254,6 +262,60 @@ if ($modecompta == 'BOOKKEEPING')
$total_ht += (isset($objp->amount)?$objp->amount:0);
$total_ttc += (isset($objp->amount)?$objp->amount:0);
// Loop on detail of all accounts
// This make 14 calls for each detail of account (NP, N and month m)
if ($showaccountdetail == 'yes')
{ /*
foreach($cpts as $i => $cpt)
{
// N-1
$return = $AccCat->getResult($cpt['account_number'], 0, $date_start_previous, $date_end_previous, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultNP=0;
} else {
$resultNP=$AccCat->sdc;
}
//N
$return = $AccCat->getResult($cpt['account_number'], 0, $date_start, $date_end, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultN=0;
} else {
$resultN=$AccCat->sdc;
}
$sommes[$code]['NP'] += $resultNP;
$sommes[$code]['N'] += $resultN;
print '<tr>';
print '<td> &nbsp; &nbsp; ' . length_accountg($cpt['account_number']) . '</td>';
print '<td>' . $cpt['name_cpt'] . '</td>';
print '<td align="right">' . price($resultNP) . '</td>';
print '<td align="right">' . price($resultN) . '</td>';
foreach($months as $k => $v)
{
$return = $AccCat->getResult($cpt['account_number'], $k+1, $date_start, $date_end, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultM=0;
} else {
$resultM=$AccCat->sdc;
}
$sommes[$code]['M'][$k] += $resultM;
if ($showaccountdetail == 'yes') {
print '<td align="right">' . price($resultM) . '</td>';
}
}
print "</tr>\n";
}
*/
}
$i++;
}
}

View File

@ -32,12 +32,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array('compta','bills','donation','salaries'));
$date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday');
$date_startyear=GETPOST('date_startyear');
$date_endmonth=GETPOST('date_endmonth');
$date_endday=GETPOST('date_endday');
$date_endyear=GETPOST('date_endyear');
$date_startmonth=GETPOST('date_startmonth','int');
$date_startday=GETPOST('date_startday','int');
$date_startyear=GETPOST('date_startyear','int');
$date_endmonth=GETPOST('date_endmonth','int');
$date_endday=GETPOST('date_endday','int');
$date_endyear=GETPOST('date_endyear','int');
$nbofyear=4;
@ -152,7 +152,8 @@ else if ($modecompta=="BOOKKEEPING")
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesAmountOnInOutBookkeepingRecord", $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("AccountingCategory"));
$description=$langs->trans("RulesAmountOnInOutBookkeepingRecord");
$description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("Chartofaccounts")).')';
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
@ -817,7 +818,11 @@ if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING'))
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_account as aa";
$sql.= " WHERE b.numero_compte = aa.account_number AND b.entity = ".$conf->entity;
//$sql.= " AND fk_statut in (1,2)";
$sql.= " AND pcg_type in ('INCOME', 'EXPENSE')";
$sql.= " AND (";
$sql.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))";
$sql.= " OR ";
$sql.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))";
$sql.= ")";
//$sql.= " AND code_journal in ('VT', 'AC')";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND b.doc_date >= '".$db->idate($date_start)."' AND b.doc_date <= '".$db->idate($date_end)."'";

View File

@ -154,9 +154,10 @@ RulesResultDue=- It includes outstanding invoices, expenses, VAT, donations whet
RulesResultInOut=- It includes the real payments made on invoices, expenses, VAT and salaries. <br>- It is based on the payment dates of the invoices, expenses, VAT and salaries. The donation date for donation.
RulesCADue=- It includes the client's due invoices whether they are paid or not. <br>- It is based on the validation date of these invoices.<br>
RulesCAIn=- It includes all the effective payments of invoices received from clients.<br>- It is based on the payment date of these invoices<br>
RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" (See <b>%s</b>)
RulesResultBookkeepingPredefined=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" (See <b>%s</b>)
RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting accounts <b>grouped by personalized groups</b> (See menu <b>%s</b> to define accounting account groups)
RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE/PRODUCT|SERVICE" or "INCOME/PRODUCT|SERVICE"
RulesResultBookkeepingPredefined=It includes record in your Ledger with accounting accounts that has the group "EXPENSE/PRODUCT|SERVICE" or "INCOME/PRODUCT|SERVICE"
RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting accounts <b>grouped by personalized groups</b>
SeePageForSetup=See menu <a href="%s">%s</a> for setup.
DepositsAreNotIncluded=- Down payment invoices are nor included
DepositsAreIncluded=- Down payment invoices are included
LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF