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