Debug report accountancy

This commit is contained in:
Laurent Destailleur 2021-03-31 17:59:42 +02:00
parent 32f9a04776
commit 27bc05a039
8 changed files with 31 additions and 25 deletions

View File

@ -727,7 +727,9 @@ if (!empty($arrayfields['t.piece_num']['checked'])) {
}
// Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) {
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.(is_array($search_ledger_code) ? join('|', $search_ledger_code) : $search_ledger_code).'"></td>';
print '<td class="liste_titre center">';
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
print '</td>';
}
// Date document
if (!empty($arrayfields['t.doc_date']['checked'])) {

View File

@ -301,6 +301,7 @@ if ($modecompta == 'CREANCES-DETTES') {
}
print '<td width="60" class="right"><b>'.$langs->trans("TotalHT").'</b></td></tr>';
// Sales invoices
$sql = "SELECT fd.tva_tx AS vatrate,";
$sql .= " fd.product_type AS product_type,";
$sql .= " cc.code, cc.label AS country,";
@ -324,7 +325,6 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label, cc.code ";
$sql .= " ORDER BY country, product_type, vatrate";
dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
@ -374,7 +374,6 @@ if ($modecompta == 'CREANCES-DETTES') {
print $db->lasterror(); // Show last sql error
}
print '<tr class="liste_titre"><td width="6%" class="right">'.$langs->trans("PurchasebyVatrate").'</td>';
print '<td class="left">'.$langs->trans("ProductOrService").'</td>';
print '<td class="left">'.$langs->trans("Country").'</td>';
@ -389,6 +388,7 @@ if ($modecompta == 'CREANCES-DETTES') {
}
print '<td width="60" class="right"><b>'.$langs->trans("TotalHT").'</b></td></tr>';
// Purchase invoices
$sql2 = "SELECT ffd.tva_tx AS vatrate,";
$sql2 .= " ffd.product_type AS product_type,";
$sql2 .= " cc.code, cc.label AS country,";

View File

@ -315,7 +315,7 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
if ($selected_type >= 0) {
$sql .= " AND l.product_type = ".$selected_type;
$sql .= " AND l.product_type = ".((int) $selected_type);
}
if ($selected_cat === -2) { // Without any category
$sql .= " AND cp.fk_product is null";
@ -342,7 +342,7 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql .= "))";
}
if ($selected_soc > 0) {
$sql .= " AND soc.rowid=".$selected_soc;
$sql .= " AND soc.rowid=".((int) $selected_soc);
}
$sql .= " AND f.entity IN (".getEntity('invoice').")";

View File

@ -243,7 +243,7 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($date_start && $date_end) {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
} else {
} elseif ($modecompta == "RECETTES-DEPENSES") {
/*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
* vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
@ -257,6 +257,8 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($date_start && $date_end) {
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
} elseif ($modecompta == "BOOKKEEPING") {
} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
}
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) {
@ -286,7 +288,7 @@ if ($result) {
}
// Adding old-version payments, non-bound by "paiement_facture" then without User
if ($modecompta != 'CREANCES-DETTES') {
if ($modecompta == 'RECETTES-DEPENSES') {
$sql = "SELECT -1 as rowidx, '' as name, '' as firstname, sum(DISTINCT p.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";

View File

@ -267,14 +267,14 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($selected_cat === -2) { // Without any category
$sql .= " AND cs.fk_soc is null";
} elseif ($selected_cat) { // Into a specific category
$sql .= " AND (c.rowid = ".$db->escape($selected_cat);
$sql .= " AND (c.rowid = ".((int) $selected_cat);
if ($subcat) {
$sql .= " OR c.fk_parent = ".$db->escape($selected_cat);
$sql .= " OR c.fk_parent = ".((int) $selected_cat);
}
$sql .= ")";
$sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
}
} else {
} elseif ($modecompta == "RECETTES-DEPENSES") {
/*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
* vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
@ -298,13 +298,15 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($selected_cat === -2) { // Without any category
$sql .= " AND cs.fk_soc is null";
} elseif ($selected_cat) { // Into a specific category
$sql .= " AND (c.rowid = ".$selected_cat;
$sql .= " AND (c.rowid = ".((int) $selected_cat);
if ($subcat) {
$sql .= " OR c.fk_parent = ".$selected_cat;
$sql .= " OR c.fk_parent = ".((int) $selected_cat);
}
$sql .= ")";
$sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
}
} elseif ($modecompta == "BOOKKEEPING") {
} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
}
if (!empty($search_societe)) {
$sql .= natural_search('s.nom', $search_societe);
@ -316,11 +318,11 @@ if (!empty($search_town)) {
$sql .= natural_search('s.town', $search_town);
}
if ($search_country > 0) {
$sql .= ' AND s.fk_pays = '.$search_country.'';
$sql .= ' AND s.fk_pays = '.((int) $search_country);
}
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) {
$sql .= " AND f.fk_soc = ".$socid;
$sql .= " AND f.fk_soc = ".((int) $socid);
}
$sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
$sql .= " ORDER BY s.rowid";
@ -350,7 +352,7 @@ if ($result) {
}
// On ajoute les paiements anciennes version, non lies par paiement_facture
if ($modecompta != 'CREANCES-DETTES') {
if ($modecompta == "RECETTES-DEPENSES") {
$sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";

View File

@ -209,7 +209,7 @@ if ($modecompta == 'CREANCES-DETTES') {
}
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) {
$sql .= " AND f.fk_soc = ".$socid;
$sql .= " AND f.fk_soc = ".((int) $socid);
}
} elseif ($modecompta == "RECETTES-DEPENSES") {
/*
@ -224,7 +224,7 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) {
$sql .= " AND f.fk_soc = ".$socid;
$sql .= " AND f.fk_soc = ".((int) $socid);
}
} elseif ($modecompta == "BOOKKEEPING") {
$sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc";

View File

@ -288,20 +288,20 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
if ($selected_type >= 0) {
$sql .= " AND l.product_type = ".$selected_type;
$sql .= " AND l.product_type = ".((int) $selected_type);
}
if ($selected_cat === -2) { // Without any category
$sql .= " AND cp.fk_product is null";
} elseif ($selected_cat) { // Into a specific category
$sql .= " AND (c.rowid = ".$selected_cat;
$sql .= " AND (c.rowid = ".((int) $selected_cat);
if ($subcat) {
$sql .= " OR c.fk_parent = ".$selected_cat;
$sql .= " OR c.fk_parent = ".((int) $selected_cat);
}
$sql .= ")";
$sql .= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid";
}
if ($selected_soc > 0) {
$sql .= " AND soc.rowid=".$selected_soc;
$sql .= " AND soc.rowid=".((int) $selected_soc);
}
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type";

View File

@ -251,9 +251,9 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($selected_cat === -2) { // Without any category
$sql .= " AND cs.fk_soc is null";
} elseif ($selected_cat) { // Into a specific category
$sql .= " AND (c.rowid = ".$db->escape($selected_cat);
$sql .= " AND (c.rowid = ".((int) $selected_cat);
if ($subcat) {
$sql .= " OR c.fk_parent = ".$db->escape($selected_cat);
$sql .= " OR c.fk_parent = ".((int) $selected_cat);
}
$sql .= ")";
$sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
@ -278,9 +278,9 @@ if ($modecompta == 'CREANCES-DETTES') {
if ($selected_cat === -2) { // Without any category
$sql .= " AND cs.fk_soc is null";
} elseif ($selected_cat) { // Into a specific category
$sql .= " AND (c.rowid = ".$selected_cat;
$sql .= " AND (c.rowid = ".((int) $selected_cat);
if ($subcat) {
$sql .= " OR c.fk_parent = ".$selected_cat;
$sql .= " OR c.fk_parent = ".((int) $selected_cat);
}
$sql .= ")";
$sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";