This commit is contained in:
4 files changed
+99
-30
No files matched your search
@@ -59,32 +59,21 @@ class CommunityController implements IAuthenticationRequired
|
||||
|
||||
\Container::$persistentDataManager->loadRelationsFromDb($community, false, ['main_currency']);
|
||||
|
||||
$balanceCalculator = new BalanceCalculator($community);
|
||||
$debts = $balanceCalculator->calculate();
|
||||
$debtItems = [];
|
||||
$debtBalance = 0.0;
|
||||
$outstandingItems = [];
|
||||
$outstandingBalance = 0.0;
|
||||
foreach ($debts as $debt) {
|
||||
if ($debt['payer']->getId() === \Container::$request->user()->getUniqueId()) {
|
||||
$debtBalance += $debt['amount'];
|
||||
$debtItems[] = $debt;
|
||||
}
|
||||
if ($debt['payee']->getId() === \Container::$request->user()->getUniqueId()) {
|
||||
$outstandingBalance += $debt['amount'];
|
||||
$outstandingItems[] = $debt;
|
||||
}
|
||||
}
|
||||
$balance = $outstandingBalance - $debtBalance;
|
||||
/**
|
||||
* @var User $user
|
||||
*/
|
||||
$user = \Container::$request->user();
|
||||
$balanceCalculator = new BalanceCalculator($community, $user);
|
||||
$balance = $balanceCalculator->calculate();
|
||||
|
||||
return new HtmlContent('communities/community', [
|
||||
'community' => $community,
|
||||
'upcomingAndRecentEvents' => iterator_to_array($this->eventRepository->getUpcomingAndRecentByCommunity($community, new DateTime(), 30, 3)),
|
||||
'debtItems' => $debtItems,
|
||||
'debtBalance' => $debtBalance,
|
||||
'outstandingItems' => $outstandingItems,
|
||||
'outstandingBalance' => $outstandingBalance,
|
||||
'balance' => $balance,
|
||||
'debtItems' => $balance['debtItems'],
|
||||
'debtBalance' => $balance['debtBalance'],
|
||||
'outstandingItems' => $balance['outstandingItems'],
|
||||
'outstandingBalance' => $balance['outstandingBalance'],
|
||||
'balance' => $balance['absoluteBalance'],
|
||||
'editPermission' => $ownCommunityMember->getOwner()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Container;
|
||||
use DateTime;
|
||||
use RVR\Finance\BalanceCalculator;
|
||||
use RVR\Finance\ExchangeRateCalculator;
|
||||
use RVR\PersistentData\Model\Community;
|
||||
use RVR\PersistentData\Model\CommunityMember;
|
||||
@@ -105,10 +106,22 @@ class EventController implements IAuthenticationRequired, ISecured
|
||||
}
|
||||
Container::$persistentDataManager->loadRelationsFromDb($this->community, true, ['main_currency']);
|
||||
|
||||
/**
|
||||
* @var User $user
|
||||
*/
|
||||
$user = \Container::$request->user();
|
||||
$balanceCalculator = new BalanceCalculator($this->community, $user, $event);
|
||||
$balance = $balanceCalculator->calculate();
|
||||
|
||||
return new HtmlContent('events/event', [
|
||||
'community' => $this->community,
|
||||
'event' => $event,
|
||||
'totalCost' => $this->sumTransactions($event)
|
||||
'totalCost' => $this->sumTransactions($event),
|
||||
'debtItems' => $balance['debtItems'],
|
||||
'debtBalance' => $balance['debtBalance'],
|
||||
'outstandingItems' => $balance['outstandingItems'],
|
||||
'outstandingBalance' => $balance['outstandingBalance'],
|
||||
'balance' => $balance['absoluteBalance'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user