where('type', JournalEntryType::Debit) ->sum(static function (JournalEntry $item) { return $item->rawValue('amount'); }); return new Money($total, CurrencyAccessor::getDefaultCurrency()); } public function sumCredits(): Money { $total = $this->where('type', JournalEntryType::Credit) ->sum(static function (JournalEntry $item) { return $item->rawValue('amount'); }); return new Money($total, CurrencyAccessor::getDefaultCurrency()); } public function areBalanced(): bool { return $this->sumDebits()->getAmount() === $this->sumCredits()->getAmount(); } }