From 551256b77936fc4d24b5f3b7fd93c91603ae1eb0 Mon Sep 17 00:00:00 2001
From: Muhammad Aboelfotoh <>
Date: Wed, 25 Nov 2020 15:11:09 +0000
Subject: [PATCH 1/2] FIX #13067 including opening balance in calculation of
displayed balance
---
htdocs/accountancy/bookkeeping/balance.php | 30 ++++++++++++++--------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php
index 456da29d954..ef19a6ae330 100644
--- a/htdocs/accountancy/bookkeeping/balance.php
+++ b/htdocs/accountancy/bookkeeping/balance.php
@@ -265,10 +265,16 @@ if ($action != 'export_csv')
$total_credit = 0;
$sous_total_debit = 0;
$sous_total_credit = 0;
+ $total_opening_balance = 0;
+ $sous_total_opening_balance = 0;
$displayed_account = "";
- $sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity;
- $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte";
+ $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
+ $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
+ $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features
+ $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'";
+ $sql .= " GROUP BY t.numero_compte";
+
$resql = $db->query($sql);
$nrows = $resql->num_rows;
$opening_balances = array();
@@ -284,17 +290,19 @@ if ($action != 'export_csv')
$total_credit += $line->credit;
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account
$root_account_description = $object->get_compte_racine($line->numero_compte);
+ $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0;
+ $total_opening_balance += $opening_balance;
if (empty($description)) {
$link = ''.img_edit_add().'';
}
print '
';
- // Permet d'afficher le compte comptable
+ // Display the accounting account
if (empty($displayed_account) || $root_account_description != $displayed_account)
{
- // Affiche un Sous-Total par compte comptable
+ // Display a sub-total per account
if ($displayed_account != "") {
- print '
| '.$langs->trans("SubTotal").': | '.price($sous_total_debit).' | '.price($sous_total_credit).' | '.price(price2num($sous_total_credit - $sous_total_debit)).' | ';
+ print '
| '.$langs->trans("SubTotal").': | '.price($sous_total_opening_balance).' | '.price($sous_total_debit).' | '.price($sous_total_credit).' | '.price(price2num($sous_total_credit - $sous_total_debit)).' | ';
print " | \n";
print '
';
}
@@ -307,30 +315,32 @@ if ($action != 'export_csv')
$displayed_account = $root_account_description;
$sous_total_debit = 0;
$sous_total_credit = 0;
+ $sous_total_opening_balance = 0;
}
// $object->get_compte_racine($line->numero_compte);
print ''.length_accountg($line->numero_compte).' | ';
print ''.$description.' | ';
- print ''.price($opening_balances["'".$line->numero_compte."'"]).' | ';
+ print ''.price($opening_balance).' | ';
print ''.price($line->debit).' | ';
print ''.price($line->credit).' | ';
- print ''.price($line->debit - $line->credit).' | ';
+ print ''.price($opening_balance + $line->debit - $line->credit).' | ';
print ''.$link;
print ' | ';
print "\n";
- // Comptabilise le sous-total
+ // Records the sub-total
$sous_total_debit += $line->debit;
$sous_total_credit += $line->credit;
+ $sous_total_opening_balance += $opening_balance;
}
- print '| '.$langs->trans("SubTotal").': | '.price($sous_total_debit).' | '.price($sous_total_credit).' | '.price(price2num($sous_total_debit - $sous_total_credit)).' | ';
+ print '
| '.$langs->trans("SubTotal").': | '.price($sous_total_opening_balance).' | '.price($sous_total_debit).' | '.price($sous_total_credit).' | '.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)).' | ';
print " | \n";
print '
';
- print '| '.$langs->trans("AccountBalance").': | '.price($total_debit).' | '.price($total_credit).' | '.price(price2num($total_debit - $total_credit)).' | ';
+ print '
| '.$langs->trans("AccountBalance").': | '.price($total_opening_balance).' | '.price($total_debit).' | '.price($total_credit).' | '.price(price2num($total_opening_balance + $total_debit - $total_credit)).' | ';
print " | \n";
print '
';
From bd780a8c5113a34ee49dc7c59bcdfa7d46216b56 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Thu, 26 Nov 2020 15:29:18 +0100
Subject: [PATCH 2/2] FIX Warning on late purchase order delivery
---
.travis.yml | 50 ++++---------------
.../class/fournisseur.commande.class.php | 2 +-
2 files changed, 12 insertions(+), 40 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 082847d8c30..3a89572148b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,53 +31,25 @@ addons:
# We need pgloader for import mysql database into pgsql
- pgloader
-php:
-- '5.6'
-- '7.0'
-- '7.1'
-- '7.2'
-- '7.3'
-- '7.4'
-- nightly
-
env:
global:
# Set to true for very verbose output
- DEBUG=false
- jobs:
- # MariaDB overrides MySQL installation so it's not possible to test both yet
- #- DB=mariadb
- - DB=mysql
- - DB=postgresql
- # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP
- #- WS=apache
- # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test
- #- WS=nginx
jobs:
fast_finish: true
allow_failures:
- php: nightly
- # We exclude some combinations not usefull to save Travis CPU
- exclude:
- - php: '7.0'
- env: DB=mysql
- - php: '7.1'
- env: DB=mysql
- - php: '7.2'
- env: DB=mysql
- - php: '7.3'
- env: DB=mysql
- - php: '7.0'
- env: DB=postgresql
- - php: '7.1'
- env: DB=postgresql
- - php: '7.2'
- env: DB=postgresql
- - php: '7.3'
- env: DB=postgresql
- - php: nightly
- env: DB=postgresql
+ include:
+ - if: type = push
+ php: '5.6'
+ env: DB=postgresql
+ - if: type = pull_request OR type = push
+ php: '7.4'
+ env: DB=mysql
+ - if: type = push AND branch = develop
+ php: nightly
+ env: DB=mysql
notifications:
email:
@@ -110,8 +82,8 @@ install:
echo "Updating Composer"
rm $TRAVIS_BUILD_DIR/composer.json
rm $TRAVIS_BUILD_DIR/composer.lock
+ composer -V
composer self-update
- # To have composer making parallel downloads
composer -n init
composer -n config vendor-dir htdocs/includes
composer -n config -g vendor-dir htdocs/includes
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 21399b7d674..eb5a2e26de0 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -3175,7 +3175,7 @@ class CommandeFournisseur extends CommonOrder
if (empty($this->date_delivery) && !empty($this->date_livraison)) $this->date_delivery = $this->date_livraison; // For backward compatibility
$now = dol_now();
- $date_to_test = empty($this->date_livraison) ? $this->date_commande : $this->date_livraison;
+ $date_to_test = empty($this->date_delivery) ? $this->date_commande : $this->date_delivery;
return ($this->statut > 0 && $this->statut < 5) && $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
}