@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return Builder|Relation |
| 34 | 34 | */ |
| 35 | - private function getQuery(Pool $pool, Session $session): Builder|Relation |
|
| 35 | + private function getQuery(Pool $pool, Session $session): Builder | Relation |
|
| 36 | 36 | { |
| 37 | 37 | return $session->receivables() |
| 38 | 38 | ->select('receivables.*') |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | public function createDeposit(Pool $pool, Session $session, int $receivableId): void |
| 104 | 104 | { |
| 105 | 105 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
| 106 | - if(!$receivable || $receivable->deposit || !$pool->deposit_fixed) |
|
| 106 | + if (!$receivable || $receivable->deposit || !$pool->deposit_fixed) |
|
| 107 | 107 | { |
| 108 | 108 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 109 | 109 | } |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | public function saveDepositAmount(Pool $pool, Session $session, int $receivableId, int $amount): void |
| 128 | 128 | { |
| 129 | 129 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
| 130 | - if(!$receivable || $pool->deposit_fixed) |
|
| 130 | + if (!$receivable || $pool->deposit_fixed) |
|
| 131 | 131 | { |
| 132 | 132 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if($receivable->deposit !== null) |
|
| 135 | + if ($receivable->deposit !== null) |
|
| 136 | 136 | { |
| 137 | - if(!$this->paymentService->isEditable($receivable->deposit)) |
|
| 137 | + if (!$this->paymentService->isEditable($receivable->deposit)) |
|
| 138 | 138 | { |
| 139 | 139 | throw new MessageException(trans('tontine.errors.editable')); |
| 140 | 140 | } |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | public function deleteDeposit(Pool $pool, Session $session, int $receivableId): void |
| 164 | 164 | { |
| 165 | 165 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
| 166 | - if(!$receivable || !$receivable->deposit) |
|
| 166 | + if (!$receivable || !$receivable->deposit) |
|
| 167 | 167 | { |
| 168 | 168 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
| 169 | 169 | } |
| 170 | - if(!$this->paymentService->isEditable($receivable->deposit)) |
|
| 170 | + if (!$this->paymentService->isEditable($receivable->deposit)) |
|
| 171 | 171 | { |
| 172 | 172 | throw new MessageException(trans('tontine.errors.editable')); |
| 173 | 173 | } |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | public function createAllDeposits(Pool $pool, Session $session): void |
| 186 | 186 | { |
| 187 | 187 | $receivables = $this->getQuery($pool, $session)->whereDoesntHave('deposit')->get(); |
| 188 | - if($receivables->count() === 0) |
|
| 188 | + if ($receivables->count() === 0) |
|
| 189 | 189 | { |
| 190 | 190 | return; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | DB::transaction(function() use($session, $receivables) { |
| 194 | - foreach($receivables as $receivable) |
|
| 194 | + foreach ($receivables as $receivable) |
|
| 195 | 195 | { |
| 196 | 196 | $deposit = new Deposit(); |
| 197 | 197 | $deposit->receivable()->associate($receivable); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | ->filter(function($receivable) { |
| 219 | 219 | return $this->paymentService->isEditable($receivable->deposit); |
| 220 | 220 | }); |
| 221 | - if($receivables->count() === 0) |
|
| 221 | + if ($receivables->count() === 0) |
|
| 222 | 222 | { |
| 223 | 223 | return; |
| 224 | 224 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return Builder|Relation |
| 41 | 41 | */ |
| 42 | - private function getQuery(Session $session, ?bool $onlyPaid = null): Builder|Relation |
|
| 42 | + private function getQuery(Session $session, ?bool $onlyPaid = null): Builder | Relation |
|
| 43 | 43 | { |
| 44 | 44 | $sessionId = $session->id; |
| 45 | 45 | $prevSessions = $this->sessionService->getTontineSessionIds($session, withCurr: false); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $query->where('session_id', $sessionId); |
| 58 | 58 | }); |
| 59 | 59 | }); |
| 60 | - if($prevSessions->count() === 0) |
|
| 60 | + if ($prevSessions->count() === 0) |
|
| 61 | 61 | { |
| 62 | 62 | return; |
| 63 | 63 | } |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | public function createRefund(Session $session, int $debtId): void |
| 149 | 149 | { |
| 150 | 150 | $debt = $this->getDebt($session, $debtId); |
| 151 | - if(!$debt || $debt->refund) |
|
| 151 | + if (!$debt || $debt->refund) |
|
| 152 | 152 | { |
| 153 | 153 | throw new MessageException(trans('tontine.loan.errors.not_found')); |
| 154 | 154 | } |
| 155 | - if(!$this->debtCalculator->debtIsEditable($session, $debt)) |
|
| 155 | + if (!$this->debtCalculator->debtIsEditable($session, $debt)) |
|
| 156 | 156 | { |
| 157 | 157 | throw new MessageException(trans('meeting.refund.errors.cannot_refund')); |
| 158 | 158 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | DB::transaction(function() use($session, $debt, $refund) { |
| 164 | 164 | $refund->save(); |
| 165 | 165 | // For simple or compound interest, also save the final amount. |
| 166 | - if($debt->is_interest && !$debt->loan->fixed_interest) |
|
| 166 | + if ($debt->is_interest && !$debt->loan->fixed_interest) |
|
| 167 | 167 | { |
| 168 | 168 | $debt->amount = $this->debtCalculator->getDebtAmount($session, $debt); |
| 169 | 169 | $debt->save(); |
@@ -183,15 +183,15 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $refund = Refund::with('debt')->where('session_id', $session->id) |
| 185 | 185 | ->where('debt_id', $debtId)->first(); |
| 186 | - if(!$refund) |
|
| 186 | + if (!$refund) |
|
| 187 | 187 | { |
| 188 | 188 | throw new MessageException(trans('meeting.refund.errors.not_found')); |
| 189 | 189 | } |
| 190 | - if(!$this->paymentService->isEditable($refund)) |
|
| 190 | + if (!$this->paymentService->isEditable($refund)) |
|
| 191 | 191 | { |
| 192 | 192 | throw new MessageException(trans('meeting.refund.errors.cannot_delete')); |
| 193 | 193 | } |
| 194 | - if(!$this->debtCalculator->debtIsEditable($session, $refund->debt)) |
|
| 194 | + if (!$this->debtCalculator->debtIsEditable($session, $refund->debt)) |
|
| 195 | 195 | { |
| 196 | 196 | throw new MessageException(trans('meeting.refund.errors.cannot_refund')); |
| 197 | 197 | } |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | public function createPartialRefund(Session $session, int $debtId, int $amount): void |
| 265 | 265 | { |
| 266 | 266 | $debt = $this->getDebt($session, $debtId); |
| 267 | - if(!$debt || $debt->refund) |
|
| 267 | + if (!$debt || $debt->refund) |
|
| 268 | 268 | { |
| 269 | 269 | throw new MessageException(trans('meeting.refund.errors.not_found')); |
| 270 | 270 | } |
| 271 | 271 | // A partial refund must not totally refund a debt |
| 272 | - if($amount >= $debt->due_amount) |
|
| 272 | + if ($amount >= $debt->due_amount) |
|
| 273 | 273 | { |
| 274 | 274 | throw new MessageException(trans('meeting.refund.errors.pr_amount')); |
| 275 | 275 | } |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | { |
| 294 | 294 | $refund = PartialRefund::where('session_id', $session->id) |
| 295 | 295 | ->with(['debt.refund'])->find($refundId); |
| 296 | - if(!$refund) |
|
| 296 | + if (!$refund) |
|
| 297 | 297 | { |
| 298 | 298 | throw new MessageException(trans('meeting.refund.errors.not_found')); |
| 299 | 299 | } |
| 300 | - if($refund->debt->refund !== null || !$this->paymentService->isEditable($refund)) |
|
| 300 | + if ($refund->debt->refund !== null || !$this->paymentService->isEditable($refund)) |
|
| 301 | 301 | { |
| 302 | 302 | throw new MessageException(trans('meeting.refund.errors.cannot_delete')); |
| 303 | 303 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $bill = $this->billService->getBill($charge, $session, $billId); |
| 39 | 39 | // Return if the bill is not found or the bill is already settled. |
| 40 | - if(!$bill || ($bill->settlement)) |
|
| 40 | + if (!$bill || ($bill->settlement)) |
|
| 41 | 41 | { |
| 42 | 42 | throw new MessageException(trans('tontine.bill.errors.not_found')); |
| 43 | 43 | } |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $bill = $this->billService->getBill($charge, $session, $billId); |
| 62 | 62 | // Return if the bill is not found or the bill is not settled. |
| 63 | - if(!$bill || !($bill->settlement)) |
|
| 63 | + if (!$bill || !($bill->settlement)) |
|
| 64 | 64 | { |
| 65 | 65 | throw new MessageException(trans('tontine.bill.errors.not_found')); |
| 66 | 66 | } |
| 67 | - if((!$this->paymentService->isEditable($bill->settlement))) |
|
| 67 | + if ((!$this->paymentService->isEditable($bill->settlement))) |
|
| 68 | 68 | { |
| 69 | 69 | throw new MessageException(trans('tontine.errors.editable')); |
| 70 | 70 | } |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | public function createAllSettlements(Charge $charge, Session $session): void |
| 83 | 83 | { |
| 84 | 84 | $bills = $this->billService->getBills($charge, $session, '', false); |
| 85 | - if($bills->count() === 0) |
|
| 85 | + if ($bills->count() === 0) |
|
| 86 | 86 | { |
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | DB::transaction(function() use($bills, $session) { |
| 91 | - foreach($bills as $bill) |
|
| 91 | + foreach ($bills as $bill) |
|
| 92 | 92 | { |
| 93 | 93 | $settlement = new Settlement(); |
| 94 | 94 | $settlement->bill()->associate($bill); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | ->filter(function($bill) { |
| 113 | 113 | return $this->paymentService->isEditable($bill->settlement); |
| 114 | 114 | }); |
| 115 | - if($bills->count() === 0) |
|
| 115 | + if ($bills->count() === 0) |
|
| 116 | 116 | { |
| 117 | 117 | return; |
| 118 | 118 | } |