From 517562b465eee56d3b1df297086e4fe39cfe091d Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 24 Feb 2022 15:26:11 +0100 Subject: [PATCH] NEW : solde() function evolution to be able to get solde until a chosen date --- htdocs/compta/bank/class/account.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index cb2de5aca46..655c49bcc44 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1188,9 +1188,11 @@ class Account extends CommonObject * Return current sold * * @param int $option 1=Exclude future operation date (this is to exclude input made in advance and have real account sold) - * @return int Current sold (value date <= today) + * @param tms $date_end Date until we want to get bank account sold + * @param string $field dateo or datev + * @return int current sold (value date <= today) */ - public function solde($option = 0) + public function solde($option = 0, $date_end='', $field='dateo') { $solde = 0; @@ -1198,7 +1200,7 @@ class Account extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."bank"; $sql .= " WHERE fk_account = ".((int) $this->id); if ($option == 1) { - $sql .= " AND dateo <= '".$this->db->idate(dol_now())."'"; + $sql .= " AND ".$this->db->escape($field)." <= '".(!empty($date_end) ? $this->db->idate($date_end) : $this->db->idate(dol_now()))."'"; } $resql = $this->db->query($sql);