diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php
index d8f93ee1af5..de31b673f12 100644
--- a/htdocs/accountancy/admin/categories_list.php
+++ b/htdocs/accountancy/admin/categories_list.php
@@ -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');
diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php
index 819a46d138a..19f34d856ab 100644
--- a/htdocs/accountancy/class/accountancycategory.class.php
+++ b/htdocs/accountancy/class/accountancycategory.class.php
@@ -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
diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php
index 927774e82d9..524f993ba3b 100644
--- a/htdocs/compta/resultat/clientfourn.php
+++ b/htdocs/compta/resultat/clientfourn.php
@@ -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.='
('.$langs->trans("SeeReportInDueDebtMode",'0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','').')';
//$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.=' '.$langs->trans("DetailByAccount").' '. $form->selectyesno('showaccountdetail',$showaccountdetail,0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
- $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 '
';
print '';
+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 '
';
+ print '| ' . length_accountg($cpt['account_number']) . ' | ';
+ print '' . $cpt['name_cpt'] . ' | ';
+ print '' . price($resultNP) . ' | ';
+ print '' . price($resultN) . ' | ';
+
+ 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 '' . price($resultM) . ' | ';
+ }
+ }
+
+ print "
\n";
+ }
+ */
+ }
+
$i++;
}
}
diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php
index cf07c7886f9..8bf7a1faaea 100644
--- a/htdocs/compta/resultat/index.php
+++ b/htdocs/compta/resultat/index.php
@@ -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.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
$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?"".img_previous()." ".img_next()."":"");
- $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)."'";
diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang
index 394541e4dd1..8cc98f82def 100644
--- a/htdocs/langs/en_US/compta.lang
+++ b/htdocs/langs/en_US/compta.lang
@@ -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.
- 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.
- It is based on the validation date of these invoices.
RulesCAIn=- It includes all the effective payments of invoices received from clients.
- It is based on the payment date of these invoices
-RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" (See %s)
-RulesResultBookkeepingPredefined=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" (See %s)
-RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting accounts grouped by personalized groups (See menu %s 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 grouped by personalized groups
+SeePageForSetup=See menu %s for setup.
DepositsAreNotIncluded=- Down payment invoices are nor included
DepositsAreIncluded=- Down payment invoices are included
LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF