show transactions in pirep

This commit is contained in:
Nabeel Shahzad
2018-03-02 16:09:48 -06:00
parent 9d65515290
commit 2df09c533b
5 changed files with 77 additions and 5 deletions

View File

@@ -171,16 +171,21 @@ class JournalRepository extends BaseRepository implements CacheableInterface
/**
* Return all transactions for a given object
* @param $object
* @param null $journal
* @return array
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/
public function getAllForObject($object)
public function getAllForObject($object, $journal=null)
{
$transactions = $this->findWhere([
$where = [
'ref_class' => \get_class($object),
'ref_class_id' => $object->id,
]);
];
if($journal) {
$where['journal_id'] = $journal->id;
}
$transactions = $this->findWhere($where);
return [
'credits' => new Money($transactions->sum('credit')),