@@ -55,26 +55,26 @@ discard block |
||
| 55 | 55 | private function setDistributions(Session $session, Collection $fundings): Collection |
| 56 | 56 | { |
| 57 | 57 | // Set fundings durations and distributions |
| 58 | - foreach($fundings as $funding) |
|
| 58 | + foreach ($fundings as $funding) |
|
| 59 | 59 | { |
| 60 | 60 | $funding->duration = $this->getFundingDuration($session, $funding); |
| 61 | 61 | $funding->distribution = $funding->amount * $funding->duration; |
| 62 | 62 | } |
| 63 | 63 | // Reduce the distributions |
| 64 | - $distributionGcd = (int)$fundings->reduce(function($gcd, $funding) { |
|
| 65 | - if($gcd === 0) |
|
| 64 | + $distributionGcd = (int) $fundings->reduce(function($gcd, $funding) { |
|
| 65 | + if ($gcd === 0) |
|
| 66 | 66 | { |
| 67 | 67 | return $funding->distribution; |
| 68 | 68 | } |
| 69 | - if($funding->duration === 0) |
|
| 69 | + if ($funding->duration === 0) |
|
| 70 | 70 | { |
| 71 | 71 | return $gcd; |
| 72 | 72 | } |
| 73 | 73 | return gmp_gcd($gcd, $funding->distribution); |
| 74 | 74 | }, $fundings->first()->distribution); |
| 75 | - if($distributionGcd > 0) |
|
| 75 | + if ($distributionGcd > 0) |
|
| 76 | 76 | { |
| 77 | - foreach($fundings as $funding) |
|
| 77 | + foreach ($fundings as $funding) |
|
| 78 | 78 | { |
| 79 | 79 | $funding->distribution /= $distributionGcd; |
| 80 | 80 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | ->orderBy('members.name', 'asc') |
| 102 | 102 | ->orderBy('sessions.start_at', 'asc') |
| 103 | 103 | ->with(['session', 'member'])->get(); |
| 104 | - if($fundings->count() === 0) |
|
| 104 | + if ($fundings->count() === 0) |
|
| 105 | 105 | { |
| 106 | 106 | return $fundings; |
| 107 | 107 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | 'amount' => $profitAmount, |
| 149 | 149 | ]; |
| 150 | 150 | $round = $this->tenantService->round(); |
| 151 | - if($round->property !== null) |
|
| 151 | + if ($round->property !== null) |
|
| 152 | 152 | { |
| 153 | 153 | $content = $round->property->content; |
| 154 | 154 | $content['profit'] = $profit; |
@@ -93,9 +93,7 @@ discard block |
||
| 93 | 93 | private function getBillRelation(Charge $charge): string |
| 94 | 94 | { |
| 95 | 95 | // The intermediate relation to reach the member model. |
| 96 | - return $charge->is_variable ? 'fine_bill' : |
|
| 97 | - ($charge->period_session ? 'session_bill' : |
|
| 98 | - ($charge->period_round ? 'round_bill' : 'tontine_bill')); |
|
| 96 | + return $charge->is_variable ? 'fine_bill' : ($charge->period_session ? 'session_bill' : ($charge->period_round ? 'round_bill' : 'tontine_bill')); |
|
| 99 | 97 | } |
| 100 | 98 | |
| 101 | 99 | /** |
@@ -111,8 +109,7 @@ discard block |
||
| 111 | 109 | string $search = '', ?bool $onlyPaid = null, int $page = 0): Collection |
| 112 | 110 | { |
| 113 | 111 | $billRelation = $this->getBillRelation($charge); |
| 114 | - $billRelations = !$charge->is_variable ? [$billRelation . '.member', 'settlement'] : |
|
| 115 | - ['fine_bill.session', 'fine_bill.member', 'settlement']; |
|
| 112 | + $billRelations = !$charge->is_variable ? [$billRelation . '.member', 'settlement'] : ['fine_bill.session', 'fine_bill.member', 'settlement']; |
|
| 116 | 113 | $query = $this->getBillsQuery($charge, $session, $billRelation, $search, $onlyPaid); |
| 117 | 114 | |
| 118 | 115 | return $query->with($billRelations) |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function getDisbursedAmounts(Collection $chargeIds, Collection $sessionIds): Collection |
| 202 | 202 | { |
| 203 | - if($chargeIds->count() === 0) |
|
| 203 | + if ($chargeIds->count() === 0) |
|
| 204 | 204 | { |
| 205 | 205 | return collect(); |
| 206 | 206 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | // value can be retrieved forever, even when the membership will change. |
| 255 | 255 | $tontine = $this->tenantService->tontine(); |
| 256 | 256 | $round = $this->tenantService->round(); |
| 257 | - if($round->property === null) |
|
| 257 | + if ($round->property === null) |
|
| 258 | 258 | { |
| 259 | 259 | // Create and save the property with the content |
| 260 | 260 | $memberIds = $tontine->members()->active()->pluck('id')->all(); |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $content = $round->property->content; |
| 267 | - if(isset($content['members']) && is_array($content['members'])) |
|
| 267 | + if (isset($content['members']) && is_array($content['members'])) |
|
| 268 | 268 | { |
| 269 | 269 | // Return the existing content value |
| 270 | 270 | return count($content['members']); |
@@ -300,12 +300,12 @@ discard block |
||
| 300 | 300 | ->concat($this->getFineBills($settlementFilter, $member)) |
| 301 | 301 | ->keyBy('charge_id'); |
| 302 | 302 | $disbursements = $this->getDisbursedAmounts($charges->pluck('id'), $sessionIds); |
| 303 | - if($member !== null) |
|
| 303 | + if ($member !== null) |
|
| 304 | 304 | { |
| 305 | 305 | // The disbursement part of each member id calculated by dividing each amount |
| 306 | 306 | // by the number of members. |
| 307 | 307 | $memberCount = $this->countActiveMembers(); |
| 308 | - foreach($disbursements as $disbursement) |
|
| 308 | + foreach ($disbursements as $disbursement) |
|
| 309 | 309 | { |
| 310 | 310 | $disbursement->total_amount /= $memberCount; |
| 311 | 311 | } |
@@ -333,11 +333,11 @@ discard block |
||
| 333 | 333 | ->select(DB::raw("sum($principal) as principal"), DB::raw("sum($interest) as interest")) |
| 334 | 334 | ->where('loans.session_id', $session->id) |
| 335 | 335 | ->first(); |
| 336 | - if(!$loan->principal) |
|
| 336 | + if (!$loan->principal) |
|
| 337 | 337 | { |
| 338 | 338 | $loan->principal = 0; |
| 339 | 339 | } |
| 340 | - if(!$loan->interest) |
|
| 340 | + if (!$loan->interest) |
|
| 341 | 341 | { |
| 342 | 342 | $loan->interest = 0; |
| 343 | 343 | } |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | ->select(DB::raw("sum($principal) as principal"), DB::raw("sum($interest) as interest")) |
| 360 | 360 | ->where('refunds.session_id', $session->id) |
| 361 | 361 | ->first(); |
| 362 | - if(!$refund->principal) |
|
| 362 | + if (!$refund->principal) |
|
| 363 | 363 | { |
| 364 | 364 | $refund->principal = 0; |
| 365 | 365 | } |
| 366 | - if(!$refund->interest) |
|
| 366 | + if (!$refund->interest) |
|
| 367 | 367 | { |
| 368 | 368 | $refund->interest = 0; |
| 369 | 369 | } |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | ->select(DB::raw('sum(amount) as total_amount'), DB::raw('count(id) as total_count')) |
| 383 | 383 | ->where('session_id', $session->id) |
| 384 | 384 | ->first(); |
| 385 | - if(!$funding->total_amount) |
|
| 385 | + if (!$funding->total_amount) |
|
| 386 | 386 | { |
| 387 | 387 | $funding->total_amount = 0; |
| 388 | 388 | } |
| 389 | - if(!$funding->total_count) |
|
| 389 | + if (!$funding->total_count) |
|
| 390 | 390 | { |
| 391 | 391 | $funding->total_count = 0; |
| 392 | 392 | } |
@@ -405,11 +405,11 @@ discard block |
||
| 405 | 405 | ->select(DB::raw('sum(amount) as total_amount'), DB::raw('count(id) as total_count')) |
| 406 | 406 | ->where('session_id', $session->id) |
| 407 | 407 | ->first(); |
| 408 | - if(!$disbursement->total_amount) |
|
| 408 | + if (!$disbursement->total_amount) |
|
| 409 | 409 | { |
| 410 | 410 | $disbursement->total_amount = 0; |
| 411 | 411 | } |
| 412 | - if(!$disbursement->total_count) |
|
| 412 | + if (!$disbursement->total_count) |
|
| 413 | 413 | { |
| 414 | 414 | $disbursement->total_count = 0; |
| 415 | 415 | } |