First attempt at new month report.

This commit is contained in:
James Cole
2014-12-25 09:50:01 +01:00
parent 1659904f81
commit 290f25f1a0
9 changed files with 221 additions and 57 deletions

View File

@@ -5,6 +5,7 @@ namespace FireflyIII\Report;
use Carbon\Carbon;
use FireflyIII\Database\Account\Account as AccountRepository;
use FireflyIII\Database\SwitchUser;
use FireflyIII\Database\TransactionJournal\TransactionJournal as JournalRepository;
use Illuminate\Support\Collection;
// todo add methods to itnerface
@@ -23,12 +24,16 @@ class Report implements ReportInterface
/** @var AccountRepository */
protected $_accounts;
/** @var JournalRepository */
protected $_journals;
/**
* @param AccountRepository $accounts
*/
public function __construct(AccountRepository $accounts)
public function __construct(AccountRepository $accounts, JournalRepository $journals)
{
$this->_accounts = $accounts;
$this->_journals = $journals;
}
@@ -75,6 +80,30 @@ class Report implements ReportInterface
}
/**
* @param Carbon $date
* @param bool $shared
*
* @return Collection
*/
public function getIncomeForMonth(Carbon $date, $shared = false)
{
$start = clone $date;
$start->startOfMonth();
$end = clone $date;
$end->endOfMonth();
$userId = $this->_accounts->getUser()->id;
$list = \TransactionJournal::withRelevantData()
->transactionTypes(['Deposit'])
->where('user_id', $userId)
->orderBy('date','DESC')
->before($end)->after($start)->get(['transaction_journals.*']);
return $list;
}
/**
* @param Carbon $start
*

View File

@@ -50,4 +50,12 @@ interface ReportInterface
* @return array
*/
public function yearBalanceReport(Carbon $date);
/**
* @param Carbon $date
* @param bool $shared
*
* @return Collection
*/
public function getIncomeForMonth(Carbon $date, $shared = false);
}