@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return Builder|Relation |
| 94 | 94 | */ |
| 95 | - private function getSessionsQuery($query, ?Session $currSession, bool $getAfter, bool $withCurr): Builder|Relation |
|
| 95 | + private function getSessionsQuery($query, ?Session $currSession, bool $getAfter, bool $withCurr): Builder | Relation |
|
| 96 | 96 | { |
| 97 | 97 | $operator = $getAfter ? ($withCurr ? '>=' : '>') : ($withCurr ? '<=' : '<'); |
| 98 | 98 | $currSessionDate = !$currSession ? '' : $currSession->start_at->format('Y-m-d'); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return Builder|Relation |
| 109 | 109 | */ |
| 110 | - private function getRoundSessionsQuery(?Session $currSession, bool $getAfter, bool $withCurr): Builder|Relation |
|
| 110 | + private function getRoundSessionsQuery(?Session $currSession, bool $getAfter, bool $withCurr): Builder | Relation |
|
| 111 | 111 | { |
| 112 | 112 | $query = $this->tenantService->round()->sessions(); |
| 113 | 113 | return $this->getSessionsQuery($query, $currSession, $getAfter, $withCurr); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return Builder|Relation |
| 150 | 150 | */ |
| 151 | - private function getTontineSessionsQuery(?Session $currSession, bool $getAfter, bool $withCurr): Builder|Relation |
|
| 151 | + private function getTontineSessionsQuery(?Session $currSession, bool $getAfter, bool $withCurr): Builder | Relation |
|
| 152 | 152 | { |
| 153 | 153 | $query = $this->tenantService->tontine()->sessions(); |
| 154 | 154 | return $this->getSessionsQuery($query, $currSession, $getAfter, $withCurr); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return Builder|Relation |
| 50 | 50 | */ |
| 51 | - public function getQuery(Pool $pool, string $search, ?bool $filter): Builder|Relation |
|
| 51 | + public function getQuery(Pool $pool, string $search, ?bool $filter): Builder | Relation |
|
| 52 | 52 | { |
| 53 | 53 | return $this->tenantService->tontine()->members()->active() |
| 54 | 54 | ->when($filter === true, function(Builder $query) use($pool) { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | ->withCount('receivables') |
| 157 | 157 | ->get() |
| 158 | 158 | ->sortBy('receivables_count'); |
| 159 | - if($subscriptions->count() === 0) |
|
| 159 | + if ($subscriptions->count() === 0) |
|
| 160 | 160 | { |
| 161 | 161 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 162 | 162 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function unsetPayableSession(Subscription $subscription) |
| 207 | 207 | { |
| 208 | - if(($subscription->payable->session_id)) |
|
| 208 | + if (($subscription->payable->session_id)) |
|
| 209 | 209 | { |
| 210 | 210 | $subscription->payable->session()->dissociate(); |
| 211 | 211 | $subscription->payable->save(); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | private function canChangeBeneficiary(Session $session, ?Subscription $subscription): bool |
| 222 | 222 | { |
| 223 | 223 | // Can't change the beneficiary if the session is closed or pending, |
| 224 | - if($session->closed || $session->pending) |
|
| 224 | + if ($session->closed || $session->pending) |
|
| 225 | 225 | { |
| 226 | 226 | return false; |
| 227 | 227 | } |
@@ -246,17 +246,17 @@ discard block |
||
| 246 | 246 | $session = $pool->sessions()->find($sessionId); |
| 247 | 247 | $currSubscription = null; |
| 248 | 248 | $nextSubscription = null; |
| 249 | - if($currSubscriptionId > 0) |
|
| 249 | + if ($currSubscriptionId > 0) |
|
| 250 | 250 | { |
| 251 | 251 | $currSubscription = $pool->subscriptions() |
| 252 | 252 | ->with('payable') |
| 253 | 253 | ->find($currSubscriptionId); |
| 254 | - if(!$this->canChangeBeneficiary($session, $currSubscription)) |
|
| 254 | + if (!$this->canChangeBeneficiary($session, $currSubscription)) |
|
| 255 | 255 | { |
| 256 | 256 | return false; |
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | - if($nextSubscriptionId > 0) |
|
| 259 | + if ($nextSubscriptionId > 0) |
|
| 260 | 260 | { |
| 261 | 261 | $nextSubscription = $pool->subscriptions() |
| 262 | 262 | ->with('payable') |
@@ -265,12 +265,12 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | DB::transaction(function() use($session, $currSubscription, $nextSubscription) { |
| 267 | 267 | // If the beneficiary already has a session assigned, first remove it. |
| 268 | - if($currSubscription !== null) |
|
| 268 | + if ($currSubscription !== null) |
|
| 269 | 269 | { |
| 270 | 270 | $this->unsetPayableSession($currSubscription); |
| 271 | 271 | } |
| 272 | 272 | // If there is a new session assigned to the beneficiary, then save it. |
| 273 | - if($nextSubscription !== null) |
|
| 273 | + if ($nextSubscription !== null) |
|
| 274 | 274 | { |
| 275 | 275 | $this->setPayableSession($nextSubscription, $session); |
| 276 | 276 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @return Builder|Relation |
| 26 | 26 | */ |
| 27 | - private function getQuery(): Builder|Relation |
|
| 27 | + private function getQuery(): Builder | Relation |
|
| 28 | 28 | { |
| 29 | 29 | return Pool::ofRound($this->tenantService->round()); |
| 30 | 30 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $pool->delete(); |
| 123 | 123 | }); |
| 124 | 124 | } |
| 125 | - catch(Exception $e) |
|
| 125 | + catch (Exception $e) |
|
| 126 | 126 | { |
| 127 | 127 | throw new MessageException(trans('tontine.errors.action') . |
| 128 | 128 | '<br/>' . trans('tontine.pool.errors.subscription')); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | // return; |
| 213 | 213 | // } |
| 214 | 214 | $session = $pool->sessions()->find($sessionId); |
| 215 | - if(!$session || $session->enabled($pool)) |
|
| 215 | + if (!$session || $session->enabled($pool)) |
|
| 216 | 216 | { |
| 217 | 217 | return; |
| 218 | 218 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | // return; |
| 240 | 240 | // } |
| 241 | 241 | $session = $pool->sessions()->find($sessionId); |
| 242 | - if(!$session || $session->disabled($pool)) |
|
| 242 | + if (!$session || $session->disabled($pool)) |
|
| 243 | 243 | { |
| 244 | 244 | return; |
| 245 | 245 | } |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return Builder|Relation |
| 35 | 35 | */ |
| 36 | - private function getFundSessionsQuery(Session $currentSession, int $fundId): Builder|Relation |
|
| 36 | + private function getFundSessionsQuery(Session $currentSession, int $fundId): Builder | Relation |
|
| 37 | 37 | { |
| 38 | 38 | $lastSessionDate = $currentSession->start_at->format('Y-m-d'); |
| 39 | 39 | // The closing sessions ids |
| 40 | 40 | $closingSessionIds = array_keys($this->savingService->getFundClosings($fundId)); |
| 41 | - if(count($closingSessionIds) === 0) |
|
| 41 | + if (count($closingSessionIds) === 0) |
|
| 42 | 42 | { |
| 43 | 43 | // No closing session yet |
| 44 | 44 | return $this->tenantService->tontine()->sessions() |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | ->whereDate('sessions.start_at', '<', $lastSessionDate) |
| 52 | 52 | ->orderByDesc('sessions.start_at') |
| 53 | 53 | ->get(); |
| 54 | - if($closingSessions->count() === 0) |
|
| 54 | + if ($closingSessions->count() === 0) |
|
| 55 | 55 | { |
| 56 | 56 | // All the closing sessions are after the current session. |
| 57 | 57 | return $this->tenantService->tontine()->sessions() |
@@ -119,31 +119,31 @@ discard block |
||
| 119 | 119 | int $profitAmount): Collection |
| 120 | 120 | { |
| 121 | 121 | // Set savings durations and distributions |
| 122 | - foreach($savings as $saving) |
|
| 122 | + foreach ($savings as $saving) |
|
| 123 | 123 | { |
| 124 | 124 | $saving->duration = $this->getSavingDuration($sessions, $saving); |
| 125 | 125 | $saving->distribution = $saving->amount * $saving->duration; |
| 126 | 126 | $saving->profit = 0; |
| 127 | 127 | } |
| 128 | 128 | // Reduce the distributions |
| 129 | - $distributionGcd = (int)$savings->reduce(function($gcd, $saving) { |
|
| 130 | - if($gcd === 0) |
|
| 129 | + $distributionGcd = (int) $savings->reduce(function($gcd, $saving) { |
|
| 130 | + if ($gcd === 0) |
|
| 131 | 131 | { |
| 132 | 132 | return $saving->distribution; |
| 133 | 133 | } |
| 134 | - if($saving->duration === 0) |
|
| 134 | + if ($saving->duration === 0) |
|
| 135 | 135 | { |
| 136 | 136 | return $gcd; |
| 137 | 137 | } |
| 138 | 138 | return gmp_gcd($gcd, $saving->distribution); |
| 139 | 139 | }, $savings->first()->distribution); |
| 140 | - if($distributionGcd > 0) |
|
| 140 | + if ($distributionGcd > 0) |
|
| 141 | 141 | { |
| 142 | - $sum = (int)($savings->sum('distribution') / $distributionGcd); |
|
| 143 | - foreach($savings as $saving) |
|
| 142 | + $sum = (int) ($savings->sum('distribution') / $distributionGcd); |
|
| 143 | + foreach ($savings as $saving) |
|
| 144 | 144 | { |
| 145 | 145 | $saving->distribution /= $distributionGcd; |
| 146 | - $saving->profit = (int)($profitAmount * $saving->distribution / $sum); |
|
| 146 | + $saving->profit = (int) ($profitAmount * $saving->distribution / $sum); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
@@ -171,9 +171,8 @@ discard block |
||
| 171 | 171 | ->orderBy('sessions.start_at', 'asc') |
| 172 | 172 | ->with(['session', 'member']); |
| 173 | 173 | $savings = $fundId > 0 ? |
| 174 | - $query->where('savings.fund_id', $fundId)->get() : |
|
| 175 | - $query->whereNull('savings.fund_id')->get(); |
|
| 176 | - if($savings->count() === 0) |
|
| 174 | + $query->where('savings.fund_id', $fundId)->get() : $query->whereNull('savings.fund_id')->get(); |
|
| 175 | + if ($savings->count() === 0) |
|
| 177 | 176 | { |
| 178 | 177 | return $savings; |
| 179 | 178 | } |
@@ -193,13 +192,13 @@ discard block |
||
| 193 | 192 | // The part value makes sense only iwhen there is more than 2 savings |
| 194 | 193 | // with distribution greater than 0. |
| 195 | 194 | $savings = $savings->filter(fn($saving) => $saving->distribution > 0); |
| 196 | - if($savings->count() < 2) |
|
| 195 | + if ($savings->count() < 2) |
|
| 197 | 196 | { |
| 198 | 197 | return 0; |
| 199 | 198 | } |
| 200 | 199 | |
| 201 | 200 | $saving = $savings->first(); |
| 202 | - return (int)($saving->amount * $saving->duration / $saving->distribution); |
|
| 201 | + return (int) ($saving->amount * $saving->duration / $saving->distribution); |
|
| 203 | 202 | } |
| 204 | 203 | |
| 205 | 204 | /** |
@@ -226,8 +225,7 @@ discard block |
||
| 226 | 225 | ->select(DB::raw("sum(amount) as total")) |
| 227 | 226 | ->whereIn('session_id', $sessionIds); |
| 228 | 227 | $saving = $fundId > 0 ? |
| 229 | - $query->where('savings.fund_id', $fundId)->first() : |
|
| 230 | - $query->whereNull('savings.fund_id')->first(); |
|
| 228 | + $query->where('savings.fund_id', $fundId)->first() : $query->whereNull('savings.fund_id')->first(); |
|
| 231 | 229 | return $saving->total ?? 0; |
| 232 | 230 | } |
| 233 | 231 | |
@@ -248,8 +246,7 @@ discard block |
||
| 248 | 246 | ->where('debts.type', Debt::TYPE_INTEREST) |
| 249 | 247 | ->whereIn('refunds.session_id', $sessionIds); |
| 250 | 248 | $refund = $fundId > 0 ? |
| 251 | - $query->where('loans.fund_id', $fundId)->first() : |
|
| 252 | - $query->whereNull('loans.fund_id')->first(); |
|
| 249 | + $query->where('loans.fund_id', $fundId)->first() : $query->whereNull('loans.fund_id')->first(); |
|
| 253 | 250 | return $refund->total ?? 0; |
| 254 | 251 | } |
| 255 | 252 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return Builder|Relation |
| 35 | 35 | */ |
| 36 | - private function getSavingQuery(Session $session, int $fundId): Builder|Relation |
|
| 36 | + private function getSavingQuery(Session $session, int $fundId): Builder | Relation |
|
| 37 | 37 | { |
| 38 | 38 | return $session->savings() |
| 39 | 39 | ->when($fundId === 0, function(Builder $query) { |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | $saving->amount = $values['amount']; |
| 103 | 103 | $saving->member()->associate($member); |
| 104 | 104 | $saving->session()->associate($session); |
| 105 | - if($values['fund_id'] !== 0) |
|
| 105 | + if ($values['fund_id'] !== 0) |
|
| 106 | 106 | { |
| 107 | 107 | $fund = $this->fundService->getFund($values['fund_id']); |
| 108 | - if($fund !== null) |
|
| 108 | + if ($fund !== null) |
|
| 109 | 109 | { |
| 110 | 110 | $saving->fund()->associate($fund); |
| 111 | 111 | } |
@@ -125,17 +125,17 @@ discard block |
||
| 125 | 125 | public function updateSaving(Member $member, Session $session, int $savingId, array $values): void |
| 126 | 126 | { |
| 127 | 127 | $saving = $session->savings()->find($savingId); |
| 128 | - if(!$saving) |
|
| 128 | + if (!$saving) |
|
| 129 | 129 | { |
| 130 | 130 | throw new MessageException(trans('meeting.saving.errors.not_found')); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $saving->amount = $values['amount']; |
| 134 | 134 | $saving->member()->associate($member); |
| 135 | - if($values['fund_id'] !== 0) |
|
| 135 | + if ($values['fund_id'] !== 0) |
|
| 136 | 136 | { |
| 137 | 137 | $fund = $this->fundService->getFund($values['fund_id']); |
| 138 | - if($fund !== null) |
|
| 138 | + if ($fund !== null) |
|
| 139 | 139 | { |
| 140 | 140 | $saving->fund()->associate($fund); |
| 141 | 141 | } |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | $tontine = $this->tenantService->tontine(); |
| 219 | 219 | $properties = $tontine->properties; |
| 220 | - if(isset($properties['closings'][$session->id][$fundId])) |
|
| 220 | + if (isset($properties['closings'][$session->id][$fundId])) |
|
| 221 | 221 | { |
| 222 | 222 | unset($properties['closings'][$session->id][$fundId]); |
| 223 | - if(count($properties['closings'][$session->id]) == 0) |
|
| 223 | + if (count($properties['closings'][$session->id]) == 0) |
|
| 224 | 224 | { |
| 225 | 225 | unset($properties['closings'][$session->id]); |
| 226 | 226 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return Builder|Relation |
| 31 | 31 | */ |
| 32 | - private function getQuery(Session $session, ?bool $onlyPaid = null): Builder|Relation |
|
| 32 | + private function getQuery(Session $session, ?bool $onlyPaid = null): Builder | Relation |
|
| 33 | 33 | { |
| 34 | 34 | $sessionId = $session->id; |
| 35 | 35 | $prevSessions = $this->sessionService->getRoundSessionIds($session, withCurr: false); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $query->where('session_id', $sessionId); |
| 45 | 45 | }); |
| 46 | 46 | }); |
| 47 | - if($prevSessions->count() === 0) |
|
| 47 | + if ($prevSessions->count() === 0) |
|
| 48 | 48 | { |
| 49 | 49 | return; |
| 50 | 50 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | public function toggleAuctionPayment(Session $session, int $auctionId) |
| 114 | 114 | { |
| 115 | 115 | $auction = $this->getQuery($session)->find($auctionId); |
| 116 | - if(($auction)) |
|
| 116 | + if (($auction)) |
|
| 117 | 117 | { |
| 118 | 118 | $auction->update(['paid' => !$auction->paid]); |
| 119 | 119 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @return Builder|Relation |
| 31 | 31 | */ |
| 32 | - private function getQuery(Pool $pool, Session $session): Builder|Relation |
|
| 32 | + private function getQuery(Pool $pool, Session $session): Builder | Relation |
|
| 33 | 33 | { |
| 34 | 34 | return $session->receivables() |
| 35 | 35 | ->whereIn('subscription_id', $pool->subscriptions()->pluck('id')); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function createDeposit(Pool $pool, Session $session, int $receivableId): void |
| 96 | 96 | { |
| 97 | 97 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
| 98 | - if(!$receivable || $receivable->deposit || !$pool->deposit_fixed) |
|
| 98 | + if (!$receivable || $receivable->deposit || !$pool->deposit_fixed) |
|
| 99 | 99 | { |
| 100 | 100 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 101 | 101 | } |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | public function saveDepositAmount(Pool $pool, Session $session, int $receivableId, int $amount): void |
| 120 | 120 | { |
| 121 | 121 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
| 122 | - if(!$receivable || $pool->deposit_fixed) |
|
| 122 | + if (!$receivable || $pool->deposit_fixed) |
|
| 123 | 123 | { |
| 124 | 124 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if($receivable->deposit !== null) |
|
| 127 | + if ($receivable->deposit !== null) |
|
| 128 | 128 | { |
| 129 | - if((!$receivable->deposit->editable)) |
|
| 129 | + if ((!$receivable->deposit->editable)) |
|
| 130 | 130 | { |
| 131 | 131 | throw new MessageException(trans('tontine.errors.editable')); |
| 132 | 132 | } |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | public function deleteDeposit(Pool $pool, Session $session, int $receivableId): void |
| 156 | 156 | { |
| 157 | 157 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
| 158 | - if(!$receivable || !$receivable->deposit) |
|
| 158 | + if (!$receivable || !$receivable->deposit) |
|
| 159 | 159 | { |
| 160 | 160 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 161 | 161 | } |
| 162 | - if((!$receivable->deposit->editable)) |
|
| 162 | + if ((!$receivable->deposit->editable)) |
|
| 163 | 163 | { |
| 164 | 164 | throw new MessageException(trans('tontine.errors.editable')); |
| 165 | 165 | } |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | public function createAllDeposits(Pool $pool, Session $session): void |
| 178 | 178 | { |
| 179 | 179 | $receivables = $this->getQuery($pool, $session)->whereDoesntHave('deposit')->get(); |
| 180 | - if($receivables->count() === 0) |
|
| 180 | + if ($receivables->count() === 0) |
|
| 181 | 181 | { |
| 182 | 182 | return; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | DB::transaction(function() use($session, $receivables) { |
| 186 | - foreach($receivables as $receivable) |
|
| 186 | + foreach ($receivables as $receivable) |
|
| 187 | 187 | { |
| 188 | 188 | $deposit = new Deposit(); |
| 189 | 189 | $deposit->receivable()->associate($receivable); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | ->filter(function($receivable) { |
| 211 | 211 | return $receivable->deposit->editable; |
| 212 | 212 | }); |
| 213 | - if($receivables->count() === 0) |
|
| 213 | + if ($receivables->count() === 0) |
|
| 214 | 214 | { |
| 215 | 215 | return; |
| 216 | 216 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | * |
| 45 | 45 | * @return Builder|Relation |
| 46 | 46 | */ |
| 47 | - private function getQuery(Session $session): Builder|Relation |
|
| 47 | + private function getQuery(Session $session): Builder | Relation |
|
| 48 | 48 | { |
| 49 | 49 | return Pool::ofSession($session) |
| 50 | 50 | ->whereHas('subscriptions', function(Builder $query) use($session) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return Builder|Relation |
| 41 | 41 | */ |
| 42 | - private function getQuery(Pool $pool, Session $session): Builder|Relation |
|
| 42 | + private function getQuery(Pool $pool, Session $session): Builder | Relation |
|
| 43 | 43 | { |
| 44 | 44 | return $session->payables()->whereIn('subscription_id', $pool->subscriptions()->pluck('id')); |
| 45 | 45 | } |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | ->each(function($payable) use($session) { |
| 74 | 74 | $payable->amount = $this->balanceCalculator->getPayableAmount($payable, $session); |
| 75 | 75 | }); |
| 76 | - if(!$pool->remit_planned) |
|
| 76 | + if (!$pool->remit_planned) |
|
| 77 | 77 | { |
| 78 | 78 | return $payables; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // When the number of remitments is planned, the list is padded to the expected number. |
| 82 | 82 | $remitmentCount = $this->summaryService->getSessionRemitmentCount($pool, $session); |
| 83 | - $emptyPayable = (object)[ |
|
| 83 | + $emptyPayable = (object) [ |
|
| 84 | 84 | 'id' => 0, |
| 85 | 85 | 'amount' => $pool->amount * $this->poolService->getEnabledSessionCount($pool), |
| 86 | 86 | 'remitment' => null, |
@@ -115,18 +115,18 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function savePlannedRemitment(Pool $pool, Session $session, int $payableId): void |
| 117 | 117 | { |
| 118 | - if(!$pool->remit_planned || $pool->remit_auction) |
|
| 118 | + if (!$pool->remit_planned || $pool->remit_auction) |
|
| 119 | 119 | { |
| 120 | 120 | // Only when remitments are planned and without auctions. |
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | // The payable is supposed to already have been associated to the session. |
| 124 | 124 | $payable = $this->getPayable($pool, $session, $payableId); |
| 125 | - if(!$payable) |
|
| 125 | + if (!$payable) |
|
| 126 | 126 | { |
| 127 | 127 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 128 | 128 | } |
| 129 | - if($payable->remitment) |
|
| 129 | + if ($payable->remitment) |
|
| 130 | 130 | { |
| 131 | 131 | return; |
| 132 | 132 | } |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | ->whereDoesntHave('remitment') |
| 152 | 152 | ->whereIn('subscription_id', $pool->subscriptions()->pluck('id')) |
| 153 | 153 | ->find($payableId); |
| 154 | - if(!$payable) |
|
| 154 | + if (!$payable) |
|
| 155 | 155 | { |
| 156 | 156 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 157 | 157 | } |
| 158 | - if($payable->session_id !== null && $payable->session_id !== $session->id) |
|
| 158 | + if ($payable->session_id !== null && $payable->session_id !== $session->id) |
|
| 159 | 159 | { |
| 160 | 160 | // The selected member is already planned on another session. |
| 161 | 161 | throw new MessageException(trans('tontine.remitment.errors.planning')); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | // Create the remitment. |
| 169 | 169 | $remitment = $payable->remitment()->create([]); |
| 170 | 170 | |
| 171 | - if($pool->remit_auction && $auction > 0) |
|
| 171 | + if ($pool->remit_auction && $auction > 0) |
|
| 172 | 172 | { |
| 173 | 173 | // Create the corresponding auction. |
| 174 | 174 | Auction::create([ |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $payable = $this->getQuery($pool, $session) |
| 196 | 196 | ->with(['remitment', 'remitment.auction']) |
| 197 | 197 | ->find($payableId); |
| 198 | - if(!$payable || !($remitment = $payable->remitment)) |
|
| 198 | + if (!$payable || !($remitment = $payable->remitment)) |
|
| 199 | 199 | { |
| 200 | 200 | return; |
| 201 | 201 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $remitment->auction()->delete(); |
| 206 | 206 | $remitment->delete(); |
| 207 | 207 | // Detach from the session, but only if the remitment was not planned. |
| 208 | - if(!$pool->remit_planned || $pool->remit_auction) |
|
| 208 | + if (!$pool->remit_planned || $pool->remit_auction) |
|
| 209 | 209 | { |
| 210 | 210 | $payable->session()->dissociate(); |
| 211 | 211 | $payable->save(); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | ->with(['payable', 'member']) |
| 231 | 231 | ->select('subscriptions.*') |
| 232 | 232 | ->get(); |
| 233 | - if($pool->remit_planned && !$pool->remit_auction) |
|
| 233 | + if ($pool->remit_planned && !$pool->remit_auction) |
|
| 234 | 234 | { |
| 235 | 235 | // Only the beneficiaries planned for this session. |
| 236 | 236 | return $subscriptions |