Fixed bug in real income
This commit is contained in:
@@ -225,20 +225,16 @@ class EventResource extends JsonResource{
|
||||
}
|
||||
|
||||
public function calculateIncomes(array $participants, Amount $supportPerPerson) : array {
|
||||
$expectedAmount = $supportPerPerson;
|
||||
$expectedAmount = new Amount($supportPerPerson->getAmount(), 'Euro');
|
||||
$expectedAmount->addAmount($this->event->support_flat);
|
||||
|
||||
$realAmount = $supportPerPerson;
|
||||
$realAmount = new Amount($supportPerPerson->getAmount(), 'Euro');
|
||||
$realAmount->addAmount($this->event->support_flat);
|
||||
|
||||
|
||||
foreach ($participants as $participationType => $participantData) {
|
||||
$expectedAmount->addAmount(new Amount($participantData['amount']['expected']['value'], 'Euro'));
|
||||
$realAmount->addAmount(new Amount($participantData['amount']['paid']['value'], 'Euro'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ['real' => [
|
||||
'amount' => $realAmount,
|
||||
'readable' => $realAmount->toString()
|
||||
@@ -252,7 +248,11 @@ class EventResource extends JsonResource{
|
||||
|
||||
public function getParticipants(string $participationType) : array {
|
||||
$returnData = [];
|
||||
$returnData['amount'] = ['expected' => new Amount(0, 'Euro'), 'paid' => new Amount(0, 'Euro')];
|
||||
$returnData['amount'] = [
|
||||
'expected' => new Amount(0, 'Euro'),
|
||||
'paid' => new Amount(0, 'Euro')
|
||||
];
|
||||
|
||||
$returnData['count'] = 0;
|
||||
|
||||
foreach ($this->event->participants()->where(
|
||||
@@ -288,7 +288,6 @@ class EventResource extends JsonResource{
|
||||
'readable' => $returnData['amount']['paid']->toString()
|
||||
];
|
||||
|
||||
|
||||
return $returnData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user