From 4e118ba1ae30d6396eda536bd8e167ff2d904585 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Wed, 1 Jun 2022 22:54:05 +0200 Subject: [PATCH 1/4] Fix deposit management on accountancy supplier index --- htdocs/accountancy/supplier/index.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 9ea8fd0a307..3d5a5e99f8d 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -299,10 +299,14 @@ $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.")"; +} else { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.")"; +} $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; -$sql .= ' ORDER BY aa.account_number'; -dol_syslog('htdocs/accountancy/supplier/index.php'); +dol_syslog('htdocs/accountancy/supplier/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -375,11 +379,17 @@ $sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'"; if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } +$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; -$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.")"; +} else { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.", ".FactureFournisseur::TYPE_DEPOSIT.")"; +} $sql .= " AND aa.account_number IS NOT NULL"; $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; +$sql .= ' ORDER BY aa.account_number'; dol_syslog('htdocs/accountancy/supplier/index.php'); $resql = $db->query($sql); @@ -394,6 +404,7 @@ if ($resql) { print length_accountg($row[0]); } print ''; + print ''; if ($row[0] == 'tobind') { print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); @@ -401,6 +412,7 @@ if ($resql) { print $row[1]; } print ''; + for ($i = 2; $i <= 12; $i++) { print ''.price($row[$i]).''; } @@ -416,7 +428,6 @@ print "\n"; print ''; - if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ? print '
'; print '
'; @@ -453,9 +464,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } + $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; - $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.")"; + } else { + $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.", ".FactureFournisseur::TYPE_DEPOSIT.")"; + } dol_syslog('htdocs/accountancy/supplier/index.php'); $resql = $db->query($sql); From dd96f6d8d224c6fa7d8d02c47c681310d6e3dfa3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Jun 2022 17:17:29 +0200 Subject: [PATCH 2/4] Update index.php --- htdocs/accountancy/supplier/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 3d5a5e99f8d..008316e7cf4 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -299,7 +299,7 @@ $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND aa.account_number IS NULL"; -if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { +if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.")"; } else { $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.")"; @@ -382,7 +382,7 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; -if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { +if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.")"; } else { $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.", ".FactureFournisseur::TYPE_DEPOSIT.")"; @@ -467,7 +467,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy $sql .= " AND ff.fk_statut > 0"; $sql .= " AND ffd.product_type <= 2"; - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.")"; } else { $sql .= " AND ff.type IN (".FactureFournisseur::TYPE_STANDARD.", ".FactureFournisseur::TYPE_REPLACEMENT.", ".FactureFournisseur::TYPE_CREDIT_NOTE.", ".FactureFournisseur::TYPE_DEPOSIT.")"; From 75b50023bf7a27d3a3b53156cd32364cd255d263 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Jun 2022 17:18:05 +0200 Subject: [PATCH 3/4] Update index.php --- htdocs/accountancy/supplier/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 008316e7cf4..cf21ac86c0b 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -306,7 +306,8 @@ if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { } $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; -dol_syslog('htdocs/accountancy/supplier/index.php sql='.$sql, LOG_DEBUG); +dol_syslog('htdocs/accountancy/supplier/index.php', LOG_DEBUG); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); From 614ebfeadc8ab7f5c8f32e0b05e8f92f2b3659ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Jun 2022 17:20:12 +0200 Subject: [PATCH 4/4] Update index.php --- htdocs/accountancy/supplier/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index cf21ac86c0b..e8c832a97e2 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -307,7 +307,6 @@ if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog('htdocs/accountancy/supplier/index.php', LOG_DEBUG); - $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql);