NEW : solde() function evolution to be able to get solde until a chosen date

This commit is contained in:
Gauthier PC portable 024 2022-02-24 15:26:11 +01:00
parent e96061dd18
commit 517562b465

View File

@ -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);