src/Money/DataMapper/Mapper/Money/BudgetMapper.php
public function findAllByDate(Account $account, \DateTimeImmutable $dateStart)
    {
        $query = '
        SELECT ' . $this->getQueryFields(true, 'bud') . ',
               MAX(budget_month_amount) AS budget_month_amount,
               SUM(transaction_amount) AS transactions_amount
          FROM money_budget          AS bud
    INNER JOIN money_budget_month    AS bum USING(budget_id)
     LEFT JOIN money_budget_category AS buc USING(budget_id)
     LEFT JOIN money_transaction     AS tra 
            ON tra.category_id    = buc.category_id
           AND transaction_date  >= :date_start 
           AND transaction_date  <  :date_end
         WHERE bud.account_id     = :account_id
           AND budget_month_date  = :budget_date
      GROUP BY budget_id
      ORDER BY budget_parent_id ASC, budget_name ASC';

        $this->clear();
        $this->bind(array(
            ':date_start'  => $dateStart->format('Y-m-d'),
            ':date_end'    => $dateStart->add(new \DateInterval('P1M'))->format('Y-m-d'),
            ':account_id'  => $account->getId(),
            ':budget_date' => $dateStart->format('Y-m-01'),
        ));

        $statement = $this->db->prepare($query);
        $statement->execute($this->binds);

        $this->clear();

        $budgets = array();

        while (false !== ($row = $statement->fetchObject())) {

            $budget = $this->newDataInstance();
            $budget->setId((int) $row->budget_id);
            $budget->setAccountId($account->getId());
            $budget->setAmountDefault($row->budget_amount_default);
            $budget->setDateStart($row->budget_date_start);
            $budget->setIsRecurrent((bool) $row->budget_is_recurrent);
            $budget->setName($row->budget_name);
            $budget->setParentId((int) $row->budget_parent_id);

            $budget->setTransactionsAmount((float) $row->transactions_amount);
            $budget->setAmount((float) $row->budget_month_amount);

            $budget->setExists(true);

            if ($budget->getParentId() > 0 && isset($budgets[$budget->getParentId()])) {
                $budgets[$budget->getParentId()]->addChild($budget);
            } else {
                $budgets[$budget->getId()] = $budget;
            }

        }

        return $budgets;
    }
public function findAllByDate(Account $account, \DateTimeImmutable $dateStart)
    {
        $query = '
        SELECT ' . $this->getQueryFields(true, 'bud') . ',
               MAX(budget_month_amount) AS budget_month_amount,
               SUM(transaction_amount) AS transactions_amount
          FROM money_budget          AS bud
    INNER JOIN money_budget_month    AS bum USING(budget_id)
     LEFT JOIN money_budget_category AS buc USING(budget_id)
     LEFT JOIN money_transaction     AS tra 
            ON tra.category_id    = buc.category_id
           AND transaction_date  >= :date_start 
           AND transaction_date  <  :date_end
         WHERE bud.account_id     = :account_id
           AND budget_month_date  = :budget_date
      GROUP BY budget_id
      ORDER BY budget_parent_id ASC, budget_name ASC';

        $this->clear();
        $this->bind(array(
            ':date_start'  => $dateStart->format('Y-m-d'),
            ':date_end'    => $dateStart->add(new \DateInterval('P1M'))->format('Y-m-d'),
            ':account_id'  => $account->getId(),
            ':budget_date' => $dateStart->format('Y-m-01'),
        ));

        $statement = $this->db->prepare($query);
        $statement->execute($this->binds);

        $this->clear();

        $budgets = array();

        while (false !== ($row = $statement->fetchObject())) {

            $budget = $this->newDataInstance();
            $budget->setId((int) $row->budget_id);
            $budget->setAccountId($account->getId());
            $budget->setAmountDefault($row->budget_amount_default);
            $budget->setDateStart($row->budget_date_start);
            $budget->setIsRecurrent((bool) $row->budget_is_recurrent);
            $budget->setName($row->budget_name);
            $budget->setParentId((int) $row->budget_parent_id);

            $budget->setTransactionsAmount((float) $row->transactions_amount);
            $budget->setAmount((float) $row->budget_month_amount);

            $budget->setExists(true);

            if ($budget->getParentId() > 0 && isset($budgets[$budget->getParentId()])) {
                $budgets[$budget->getParentId()]->addChild($budget);
            } else {
                $budgets[$budget->getId()] = $budget;
            }

        }

        return $budgets;
    }
Budgets

@param Account            $account
@param \DateTimeImmutable $dateStart
@return Budget[]