@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | 'interest' => 'required|regex:/^\d+(\.\d{1,2})?$/', |
| 32 | 32 | ]); |
| 33 | 33 | $validator->after(function($validator) use($values) { |
| 34 | - if((float)$values['principal'] <= 0) |
|
| 34 | + if ((float) $values['principal'] <= 0) |
|
| 35 | 35 | { |
| 36 | 36 | $validator->errors()->add('principal', trans('validation.gt.numeric', [ |
| 37 | 37 | 'attribute' => trans('meeting.loan.labels.principal'), |
@@ -39,19 +39,18 @@ discard block |
||
| 39 | 39 | ])); |
| 40 | 40 | } |
| 41 | 41 | }); |
| 42 | - if($validator->fails()) |
|
| 42 | + if ($validator->fails()) |
|
| 43 | 43 | { |
| 44 | 44 | throw new ValidationException($validator); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $validated = $validator->validated(); |
| 48 | - $validated['principal'] = $this->localeService->convertMoneyToInt((float)$validated['principal']); |
|
| 48 | + $validated['principal'] = $this->localeService->convertMoneyToInt((float) $validated['principal']); |
|
| 49 | 49 | // Interest rates must be saved as int, so the value is multiplied by 100. |
| 50 | 50 | $validated['interest_rate'] = $validated['interest_type'] === 'f' ? |
| 51 | - 0 : (int)(100 * $validated['interest']); |
|
| 51 | + 0 : (int) (100 * $validated['interest']); |
|
| 52 | 52 | $validated['interest'] = $validated['interest_type'] === 'f' ? |
| 53 | - $this->localeService->convertMoneyToInt((float)$validated['interest']) : |
|
| 54 | - (int)($validated['principal'] * $validated['interest'] / 100); |
|
| 53 | + $this->localeService->convertMoneyToInt((float) $validated['interest']) : (int) ($validated['principal'] * $validated['interest'] / 100); |
|
| 55 | 54 | |
| 56 | 55 | return $validated; |
| 57 | 56 | } |
@@ -33,13 +33,13 @@ |
||
| 33 | 33 | 'member' => 'required|integer|min:1', |
| 34 | 34 | 'amount' => 'required|regex:/^\d+(\.\d{1,2})?$/', |
| 35 | 35 | ]); |
| 36 | - if($validator->fails()) |
|
| 36 | + if ($validator->fails()) |
|
| 37 | 37 | { |
| 38 | 38 | throw new ValidationException($validator); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $validated = $validator->validated(); |
| 42 | - $validated['amount'] = $this->localeService->convertMoneyToInt((float)$validated['amount']); |
|
| 42 | + $validated['amount'] = $this->localeService->convertMoneyToInt((float) $validated['amount']); |
|
| 43 | 43 | return $validated; |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -42,13 +42,13 @@ |
||
| 42 | 42 | 'properties.remit.auction' => 'required|boolean', |
| 43 | 43 | 'properties.remit.lendable' => 'required|boolean', |
| 44 | 44 | ]); |
| 45 | - if($validator->fails()) |
|
| 45 | + if ($validator->fails()) |
|
| 46 | 46 | { |
| 47 | 47 | throw new ValidationException($validator); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $validated = $validator->validated(); |
| 51 | - $validated['amount'] = $this->localeService->convertMoneyToInt((float)$validated['amount']); |
|
| 51 | + $validated['amount'] = $this->localeService->convertMoneyToInt((float) $validated['amount']); |
|
| 52 | 52 | return $validated; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | 'end' => 'required|date_format:H:i', |
| 23 | 23 | 'host_id' => 'integer|min:0', |
| 24 | 24 | ]); |
| 25 | - if($validator->fails()) |
|
| 25 | + if ($validator->fails()) |
|
| 26 | 26 | { |
| 27 | 27 | throw new ValidationException($validator); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $validated = $validator->validated(); |
| 31 | - if(!$validated['host_id']) |
|
| 31 | + if (!$validated['host_id']) |
|
| 32 | 32 | { |
| 33 | 33 | $validated['host_id'] = null; |
| 34 | 34 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | 'venue' => 'nullable|string', |
| 47 | 47 | 'notes' => 'nullable|string', |
| 48 | 48 | ]); |
| 49 | - if($validator->fails()) |
|
| 49 | + if ($validator->fails()) |
|
| 50 | 50 | { |
| 51 | 51 | throw new ValidationException($validator); |
| 52 | 52 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | protected function values(array $values): array |
| 19 | 19 | { |
| 20 | 20 | return array_map(function($value) { |
| 21 | - if(!is_string($value)) |
|
| 21 | + if (!is_string($value)) |
|
| 22 | 22 | { |
| 23 | 23 | return $value; |
| 24 | 24 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function getReceivableAmount(Receivable $receivable): int |
| 37 | 37 | { |
| 38 | - if($receivable->subscription->pool->deposit_fixed) |
|
| 38 | + if ($receivable->subscription->pool->deposit_fixed) |
|
| 39 | 39 | { |
| 40 | 40 | return $receivable->subscription->pool->amount; |
| 41 | 41 | } |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | public function getPayableAmount(Payable $payable, Session $session): int |
| 99 | 99 | { |
| 100 | 100 | $pool = $payable->subscription->pool; |
| 101 | - if($pool->remit_fixed) |
|
| 101 | + if ($pool->remit_fixed) |
|
| 102 | 102 | { |
| 103 | - if($pool->deposit_fixed) |
|
| 103 | + if ($pool->deposit_fixed) |
|
| 104 | 104 | { |
| 105 | 105 | return $pool->amount * $this->tenantService->countEnabledSessions($pool); |
| 106 | 106 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function getPoolRemitmentAmount(Pool $pool, Session $session): int |
| 129 | 129 | { |
| 130 | - if(!$pool->remit_fixed) |
|
| 130 | + if (!$pool->remit_fixed) |
|
| 131 | 131 | { |
| 132 | 132 | // Sum the amounts for all remitments |
| 133 | 133 | return $this->getRemitmentQuery(false) |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | ->where('subscriptions.pool_id', $pool->id) |
| 136 | 136 | ->sum('remitments.amount'); |
| 137 | 137 | } |
| 138 | - if(!$pool->deposit_fixed) |
|
| 138 | + if (!$pool->deposit_fixed) |
|
| 139 | 139 | { |
| 140 | 140 | // Sum the amounts for all deposits |
| 141 | 141 | return $this->getPoolDepositAmount($pool, $session); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | return DB::table('partial_refunds') |
| 276 | 276 | ->join('debts', 'partial_refunds.debt_id', '=', 'debts.id') |
| 277 | 277 | ->whereIn('partial_refunds.session_id', $sessionIds) |
| 278 | - ->whereNotExists(function (Builder $query) { |
|
| 278 | + ->whereNotExists(function(Builder $query) { |
|
| 279 | 279 | $query->select(DB::raw(1))->from('refunds') |
| 280 | 280 | ->whereColumn('refunds.debt_id', 'debts.id'); |
| 281 | 281 | }) |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $cashier = 0; |
| 59 | 59 | $collectedFigures = []; |
| 60 | - foreach($sessions as $session) |
|
| 60 | + foreach ($sessions as $session) |
|
| 61 | 61 | { |
| 62 | - if($session->disabled($pool) || $session->pending) |
|
| 62 | + if ($session->disabled($pool) || $session->pending) |
|
| 63 | 63 | { |
| 64 | 64 | $collectedFigures[$session->id] = $this->makeFigures(' '); |
| 65 | 65 | continue; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | }); |
| 110 | 110 | $sessions = $this->_getSessions($pool, ['payables.remitment']); |
| 111 | 111 | $figures = new stdClass(); |
| 112 | - if($pool->remit_planned) |
|
| 112 | + if ($pool->remit_planned) |
|
| 113 | 113 | { |
| 114 | 114 | $figures->expected = $this->getExpectedFigures($pool, $sessions, $subscriptions); |
| 115 | 115 | } |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | $figures = []; |
| 135 | 135 | $position = 0; |
| 136 | - foreach($sessions as $session) |
|
| 136 | + foreach ($sessions as $session) |
|
| 137 | 137 | { |
| 138 | 138 | $figures[$session->id] = new stdClass(); |
| 139 | 139 | $figures[$session->id]->payables = $session->payables; |
| 140 | 140 | $figures[$session->id]->count = 0; |
| 141 | 141 | $figures[$session->id]->amount = ''; |
| 142 | - if($session->enabled($pool)) |
|
| 142 | + if ($session->enabled($pool)) |
|
| 143 | 143 | { |
| 144 | 144 | $figures[$session->id]->count = |
| 145 | 145 | $this->getRemitmentCount($sessionCount, $subscriptionCount, $position++); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function getSessionRemitmentCount(Pool $pool, Session $session): int |
| 160 | 160 | { |
| 161 | - if(!$pool->deposit_fixed) |
|
| 161 | + if (!$pool->deposit_fixed) |
|
| 162 | 162 | { |
| 163 | 163 | return 1; |
| 164 | 164 | } |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | ->each(function($payable) use($session) { |
| 120 | 120 | $payable->amount = $this->balanceCalculator->getPayableAmount($payable, $session); |
| 121 | 121 | }); |
| 122 | - if(!$pool->remit_planned) |
|
| 122 | + if (!$pool->remit_planned) |
|
| 123 | 123 | { |
| 124 | 124 | return $payables; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // When the number of remitments is planned, the list is padded to the expected number. |
| 128 | 128 | $remitmentCount = $this->summaryService->getSessionRemitmentCount($pool, $session); |
| 129 | - $emptyPayable = (object)[ |
|
| 129 | + $emptyPayable = (object) [ |
|
| 130 | 130 | 'id' => 0, |
| 131 | 131 | 'amount' => $pool->amount * $this->tenantService->countEnabledSessions($pool), |
| 132 | 132 | 'remitment' => null, |
@@ -161,18 +161,18 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function savePlannedRemitment(Pool $pool, Session $session, int $payableId): void |
| 163 | 163 | { |
| 164 | - if(!$pool->remit_planned || $pool->remit_auction) |
|
| 164 | + if (!$pool->remit_planned || $pool->remit_auction) |
|
| 165 | 165 | { |
| 166 | 166 | // Only when remitments are planned and without auctions. |
| 167 | 167 | return; |
| 168 | 168 | } |
| 169 | 169 | // The payable is supposed to already have been associated to the session. |
| 170 | 170 | $payable = $this->getPayable($pool, $session, $payableId); |
| 171 | - if(!$payable) |
|
| 171 | + if (!$payable) |
|
| 172 | 172 | { |
| 173 | 173 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 174 | 174 | } |
| 175 | - if($payable->remitment) |
|
| 175 | + if ($payable->remitment) |
|
| 176 | 176 | { |
| 177 | 177 | return; |
| 178 | 178 | } |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | ->whereDoesntHave('remitment') |
| 200 | 200 | ->whereIn('subscription_id', $pool->subscriptions()->pluck('id')) |
| 201 | 201 | ->find($payableId); |
| 202 | - if(!$payable) |
|
| 202 | + if (!$payable) |
|
| 203 | 203 | { |
| 204 | 204 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 205 | 205 | } |
| 206 | - if($payable->session_id !== null && $payable->session_id !== $session->id) |
|
| 206 | + if ($payable->session_id !== null && $payable->session_id !== $session->id) |
|
| 207 | 207 | { |
| 208 | 208 | // The selected member is already planned on another session. |
| 209 | 209 | throw new MessageException(trans('tontine.remitment.errors.planning')); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | // Create the remitment. |
| 217 | 217 | $remitment = $payable->remitment()->create(['amount' => $amount]); |
| 218 | 218 | |
| 219 | - if($pool->remit_auction && $auction > 0) |
|
| 219 | + if ($pool->remit_auction && $auction > 0) |
|
| 220 | 220 | { |
| 221 | 221 | // Create the corresponding auction. |
| 222 | 222 | Auction::create([ |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $payable = $this->getQuery($pool, $session) |
| 244 | 244 | ->with(['remitment', 'remitment.auction']) |
| 245 | 245 | ->find($payableId); |
| 246 | - if(!$payable || !($remitment = $payable->remitment)) |
|
| 246 | + if (!$payable || !($remitment = $payable->remitment)) |
|
| 247 | 247 | { |
| 248 | 248 | return; |
| 249 | 249 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $remitment->auction()->delete(); |
| 254 | 254 | $remitment->delete(); |
| 255 | 255 | // Detach from the session, but only if the remitment was not planned. |
| 256 | - if(!$pool->remit_planned || $pool->remit_auction) |
|
| 256 | + if (!$pool->remit_planned || $pool->remit_auction) |
|
| 257 | 257 | { |
| 258 | 258 | $payable->session()->dissociate(); |
| 259 | 259 | $payable->save(); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | public function getSubscriptions(Pool $pool, Session $session): Collection |
| 273 | 273 | { |
| 274 | 274 | $subscriptions = $pool->subscriptions()->with(['payable', 'member'])->get(); |
| 275 | - if($pool->remit_planned && !$pool->remit_auction) |
|
| 275 | + if ($pool->remit_planned && !$pool->remit_auction) |
|
| 276 | 276 | { |
| 277 | 277 | // Only the beneficiaries planned for this session. |
| 278 | 278 | return $subscriptions |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | return $session->opened; |
| 35 | 35 | }) |
| 36 | 36 | ->pluck('title', 'id'); |
| 37 | - if($sessions->count() === 0) |
|
| 37 | + if ($sessions->count() === 0) |
|
| 38 | 38 | { |
| 39 | 39 | return $this->response; |
| 40 | 40 | } |
| 41 | 41 | $members = $this->tontineService->getMembers(); |
| 42 | - if($members->count() === 0) |
|
| 42 | + if ($members->count() === 0) |
|
| 43 | 43 | { |
| 44 | 44 | return $this->response; |
| 45 | 45 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function showSession(int $sessionId) |
| 70 | 70 | { |
| 71 | - if(!($session = $this->tenantService->getSession($sessionId))) |
|
| 71 | + if (!($session = $this->tenantService->getSession($sessionId))) |
|
| 72 | 72 | { |
| 73 | 73 | return $this->response; |
| 74 | 74 | } |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | public function showMember(int $sessionId, int $memberId) |
| 83 | 83 | { |
| 84 | - if(!($session = $this->tenantService->getSession($sessionId))) |
|
| 84 | + if (!($session = $this->tenantService->getSession($sessionId))) |
|
| 85 | 85 | { |
| 86 | 86 | return $this->response; |
| 87 | 87 | } |
| 88 | - if(!($member = $this->tontineService->getMember($memberId))) |
|
| 88 | + if (!($member = $this->tontineService->getMember($memberId))) |
|
| 89 | 89 | { |
| 90 | 90 | return $this->response; |
| 91 | 91 | } |