More code for #159

This commit is contained in:
James Cole
2016-04-03 11:07:51 +02:00
parent 23cc7be231
commit 885b56c465
8 changed files with 92 additions and 9 deletions

View File

@@ -33,7 +33,6 @@ class AccountRepository implements AccountRepositoryInterface
/** @var User */
private $user;
/** @var array */
private $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber'];
@@ -164,6 +163,31 @@ class AccountRepository implements AccountRepositoryInterface
return $set;
}
/**
* Returns a list of transactions TO the $account, not including transfers
* and/or expenses in the $accounts list.
*
* @param Account $account
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end)
{
$ids = $accounts->pluck('id')->toArray();
$journals = $this->user->transactionjournals()
->expanded()
->before($end)
->where('destination_account.id', $account->id)
->whereIn('source_account.id', $ids)
->after($start)
->get(TransactionJournal::QUERYFIELDS);
return $journals;
}
/**
* @param TransactionJournal $journal
* @param Account $account

View File

@@ -20,6 +20,19 @@ use Illuminate\Support\Collection;
interface AccountRepositoryInterface
{
/**
* Returns a list of transactions TO the $account, not including transfers
* and/or expenses in the $accounts list.
*
* @param Account $account
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end);
/**
* @param array $types
*