@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return Builder|Relation |
38 | 38 | */ |
39 | - private function getQuery(Session $session, ?bool $onlyPaid = null): Builder|Relation |
|
39 | + private function getQuery(Session $session, ?bool $onlyPaid = null): Builder | Relation |
|
40 | 40 | { |
41 | 41 | $sessionId = $session->id; |
42 | 42 | $prevSessions = $this->sessionService->getTontineSessionIds($session, withCurr: false); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $query->where('session_id', $sessionId); |
55 | 55 | }); |
56 | 56 | }); |
57 | - if($prevSessions->count() === 0) |
|
57 | + if ($prevSessions->count() === 0) |
|
58 | 58 | { |
59 | 59 | return; |
60 | 60 | } |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | public function createRefund(Session $session, int $debtId): void |
146 | 146 | { |
147 | 147 | $debt = $this->getDebt($session, $debtId); |
148 | - if(!$debt || $debt->refund) |
|
148 | + if (!$debt || $debt->refund) |
|
149 | 149 | { |
150 | 150 | throw new MessageException(trans('tontine.loan.errors.not_found')); |
151 | 151 | } |
152 | - if(!$this->debtCalculator->debtIsEditable($session, $debt)) |
|
152 | + if (!$this->debtCalculator->debtIsEditable($session, $debt)) |
|
153 | 153 | { |
154 | 154 | throw new MessageException(trans('meeting.refund.errors.cannot_refund')); |
155 | 155 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | DB::transaction(function() use($session, $debt, $refund) { |
161 | 161 | $refund->save(); |
162 | 162 | // For simple or compound interest, also save the final amount. |
163 | - if($debt->is_interest && !$debt->loan->fixed_interest) |
|
163 | + if ($debt->is_interest && !$debt->loan->fixed_interest) |
|
164 | 164 | { |
165 | 165 | $debt->amount = $this->debtCalculator->getDebtAmount($session, $debt); |
166 | 166 | $debt->save(); |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | { |
181 | 181 | $refund = Refund::with('debt')->where('session_id', $session->id) |
182 | 182 | ->where('debt_id', $debtId)->first(); |
183 | - if(!$refund) |
|
183 | + if (!$refund) |
|
184 | 184 | { |
185 | 185 | throw new MessageException(trans('meeting.refund.errors.not_found')); |
186 | 186 | } |
187 | - if((!$refund->editable)) |
|
187 | + if ((!$refund->editable)) |
|
188 | 188 | { |
189 | 189 | throw new MessageException(trans('meeting.refund.errors.cannot_delete')); |
190 | 190 | } |
191 | - if(!$this->debtCalculator->debtIsEditable($session, $refund->debt)) |
|
191 | + if (!$this->debtCalculator->debtIsEditable($session, $refund->debt)) |
|
192 | 192 | { |
193 | 193 | throw new MessageException(trans('meeting.refund.errors.cannot_refund')); |
194 | 194 | } |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | public function createPartialRefund(Session $session, int $debtId, int $amount): void |
262 | 262 | { |
263 | 263 | $debt = $this->getDebt($session, $debtId); |
264 | - if(!$debt || $debt->refund) |
|
264 | + if (!$debt || $debt->refund) |
|
265 | 265 | { |
266 | 266 | throw new MessageException(trans('meeting.refund.errors.not_found')); |
267 | 267 | } |
268 | 268 | // A partial refund must not totally refund a debt |
269 | - if($amount >= $debt->due_amount) |
|
269 | + if ($amount >= $debt->due_amount) |
|
270 | 270 | { |
271 | 271 | throw new MessageException(trans('meeting.refund.errors.pr_amount')); |
272 | 272 | } |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | { |
291 | 291 | $refund = PartialRefund::where('session_id', $session->id) |
292 | 292 | ->with(['debt.refund'])->find($refundId); |
293 | - if(!$refund) |
|
293 | + if (!$refund) |
|
294 | 294 | { |
295 | 295 | throw new MessageException(trans('meeting.refund.errors.not_found')); |
296 | 296 | } |
297 | - if($refund->debt->refund !== null || !$refund->editable) |
|
297 | + if ($refund->debt->refund !== null || !$refund->editable) |
|
298 | 298 | { |
299 | 299 | throw new MessageException(trans('meeting.refund.errors.cannot_delete')); |
300 | 300 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | * |
58 | 58 | * @return Builder|Relation |
59 | 59 | */ |
60 | - private function getMembersQuery(string $search = ''): Builder|Relation |
|
60 | + private function getMembersQuery(string $search = ''): Builder | Relation |
|
61 | 61 | { |
62 | 62 | return $this->tenantService->tontine()->members()->active() |
63 | 63 | ->when($search !== '', function($query) use($search) { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return Builder |
35 | 35 | */ |
36 | 36 | private function getBillsQuery(Charge $charge, Session $session, |
37 | - string $relation, string $search, ?bool $onlyPaid): Builder|Relation |
|
37 | + string $relation, string $search, ?bool $onlyPaid): Builder | Relation |
|
38 | 38 | { |
39 | 39 | $relationFilter = function(Builder $query) use($charge, $session, $relation) { |
40 | 40 | $query->where('charge_id', $charge->id) |
@@ -90,9 +90,7 @@ discard block |
||
90 | 90 | private function getBillRelation(Charge $charge): string |
91 | 91 | { |
92 | 92 | // The intermediate relation to reach the member model. |
93 | - return $charge->is_variable ? 'libre_bill' : |
|
94 | - ($charge->period_session ? 'session_bill' : |
|
95 | - ($charge->period_round ? 'round_bill' : 'tontine_bill')); |
|
93 | + return $charge->is_variable ? 'libre_bill' : ($charge->period_session ? 'session_bill' : ($charge->period_round ? 'round_bill' : 'tontine_bill')); |
|
96 | 94 | } |
97 | 95 | |
98 | 96 | /** |
@@ -108,8 +106,7 @@ discard block |
||
108 | 106 | string $search = '', ?bool $onlyPaid = null, int $page = 0): Collection |
109 | 107 | { |
110 | 108 | $billRelation = $this->getBillRelation($charge); |
111 | - $billRelations = !$charge->is_variable ? [$billRelation . '.member', 'settlement'] : |
|
112 | - ['libre_bill.session', 'libre_bill.member', 'settlement']; |
|
109 | + $billRelations = !$charge->is_variable ? [$billRelation . '.member', 'settlement'] : ['libre_bill.session', 'libre_bill.member', 'settlement']; |
|
113 | 110 | $query = $this->getBillsQuery($charge, $session, $billRelation, $search, $onlyPaid); |
114 | 111 | |
115 | 112 | return $query->with($billRelations) |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @return Builder|Relation |
177 | 177 | */ |
178 | 178 | private function getMembersQuery(Charge $charge, Session $session, |
179 | - string $search = '', ?bool $filter): Builder|Relation |
|
179 | + string $search = '', ?bool $filter): Builder | Relation |
|
180 | 180 | { |
181 | 181 | $filterFunction = function($query) use($charge, $session) { |
182 | 182 | $query->where('charge_id', $charge->id)->where('session_id', $session->id); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $member->libre_bills->first()->bill : null; |
222 | 222 | }); |
223 | 223 | // Check if there is a settlement target. |
224 | - if(!($target = $this->targetService->getTarget($charge, $session))) |
|
224 | + if (!($target = $this->targetService->getTarget($charge, $session))) |
|
225 | 225 | { |
226 | 226 | return $members; |
227 | 227 | } |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | int $memberId, bool $paid, float $amount = 0): void |
263 | 263 | { |
264 | 264 | $member = $this->tenantService->tontine()->members()->find($memberId); |
265 | - if(!$member) |
|
265 | + if (!$member) |
|
266 | 266 | { |
267 | 267 | throw new MessageException(trans('tontine.member.errors.not_found')); |
268 | 268 | } |
269 | 269 | |
270 | - if($amount !== 0) |
|
270 | + if ($amount !== 0) |
|
271 | 271 | { |
272 | 272 | $amount = $this->localeService->convertMoneyToInt($amount); |
273 | 273 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $libreBill->session()->associate($session); |
285 | 285 | $libreBill->bill()->associate($bill); |
286 | 286 | $libreBill->save(); |
287 | - if($paid) |
|
287 | + if ($paid) |
|
288 | 288 | { |
289 | 289 | $settlement = new Settlement(); |
290 | 290 | $settlement->bill()->associate($bill); |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function getBill(Charge $charge, Session $session, int $memberId): ?LibreBill |
305 | 305 | { |
306 | - if(!($member = $this->tenantService->tontine()->members()->find($memberId))) |
|
306 | + if (!($member = $this->tenantService->tontine()->members()->find($memberId))) |
|
307 | 307 | { |
308 | 308 | throw new MessageException(trans('tontine.member.errors.not_found')); |
309 | 309 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public function updateBill(Charge $charge, Session $session, int $memberId, float $amount): void |
327 | 327 | { |
328 | - if(!($libreBill = $this->getBill($charge, $session, $memberId))) |
|
328 | + if (!($libreBill = $this->getBill($charge, $session, $memberId))) |
|
329 | 329 | { |
330 | 330 | return; // throw new MessageException(trans('tontine.bill.errors.not_found')); |
331 | 331 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function deleteBill(Charge $charge, Session $session, int $memberId): void |
346 | 346 | { |
347 | - if(!($libreBill = $this->getBill($charge, $session, $memberId))) |
|
347 | + if (!($libreBill = $this->getBill($charge, $session, $memberId))) |
|
348 | 348 | { |
349 | 349 | return; // throw new MessageException(trans('tontine.bill.errors.not_found')); |
350 | 350 | } |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | DB::transaction(function() use($libreBill, $session) { |
353 | 353 | $bill = $libreBill->bill; |
354 | 354 | $libreBill->delete(); |
355 | - if($bill !== null) |
|
355 | + if ($bill !== null) |
|
356 | 356 | { |
357 | 357 | // Delete the settlement only if it is on the same session |
358 | - if($bill->settlement !== null && $bill->settlement->session_id === $session->id) |
|
358 | + if ($bill->settlement !== null && $bill->settlement->session_id === $session->id) |
|
359 | 359 | { |
360 | 360 | $bill->settlement->delete(); |
361 | 361 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function addLoan() |
75 | 75 | { |
76 | - if($this->session->closed) |
|
76 | + if ($this->session->closed) |
|
77 | 77 | { |
78 | 78 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
79 | 79 | return $this->response; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'title' => trans('common.actions.cancel'), |
92 | 92 | 'class' => 'btn btn-tertiary', |
93 | 93 | 'click' => 'close', |
94 | - ],[ |
|
94 | + ], [ |
|
95 | 95 | 'title' => trans('common.actions.save'), |
96 | 96 | 'class' => 'btn btn-primary', |
97 | 97 | 'click' => $this->rq()->createLoan(pm()->form('loan-form')), |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function createLoan(array $formValues) |
110 | 110 | { |
111 | - if($this->session->closed) |
|
111 | + if ($this->session->closed) |
|
112 | 112 | { |
113 | 113 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
114 | 114 | return $this->response; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $values = $this->validator->validateItem($formValues); |
118 | - if(!($member = $this->memberService->getMember($values['member']))) |
|
118 | + if (!($member = $this->memberService->getMember($values['member']))) |
|
119 | 119 | { |
120 | 120 | $this->notify->warning(trans('tontine.member.errors.not_found')); |
121 | 121 | return $this->response; |
@@ -133,19 +133,19 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function editLoan(int $loanId) |
135 | 135 | { |
136 | - if($this->session->closed) |
|
136 | + if ($this->session->closed) |
|
137 | 137 | { |
138 | 138 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
139 | 139 | return $this->response; |
140 | 140 | } |
141 | 141 | $loan = $this->loanService->getSessionLoan($this->session, $loanId); |
142 | - if(!$loan) |
|
142 | + if (!$loan) |
|
143 | 143 | { |
144 | 144 | $this->notify->warning(trans('meeting.loan.errors.not_found')); |
145 | 145 | return $this->response; |
146 | 146 | } |
147 | 147 | // A refunded loan cannot be updated. |
148 | - if($loan->refunds_count > 0) |
|
148 | + if ($loan->refunds_count > 0) |
|
149 | 149 | { |
150 | 150 | $this->notify->warning(trans('meeting.loan.errors.update')); |
151 | 151 | return $this->response; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'title' => trans('common.actions.cancel'), |
163 | 163 | 'class' => 'btn btn-tertiary', |
164 | 164 | 'click' => 'close', |
165 | - ],[ |
|
165 | + ], [ |
|
166 | 166 | 'title' => trans('common.actions.save'), |
167 | 167 | 'class' => 'btn btn-primary', |
168 | 168 | 'click' => $this->rq()->updateLoan($loanId, pm()->form('loan-form')), |
@@ -179,26 +179,26 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function updateLoan(int $loanId, array $formValues) |
181 | 181 | { |
182 | - if($this->session->closed) |
|
182 | + if ($this->session->closed) |
|
183 | 183 | { |
184 | 184 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
185 | 185 | return $this->response; |
186 | 186 | } |
187 | 187 | $loan = $this->loanService->getSessionLoan($this->session, $loanId); |
188 | - if(!$loan) |
|
188 | + if (!$loan) |
|
189 | 189 | { |
190 | 190 | $this->notify->warning(trans('meeting.loan.errors.not_found')); |
191 | 191 | return $this->response; |
192 | 192 | } |
193 | 193 | // A refunded loan cannot be updated. |
194 | - if($loan->refunds_count > 0) |
|
194 | + if ($loan->refunds_count > 0) |
|
195 | 195 | { |
196 | 196 | $this->notify->warning(trans('meeting.loan.errors.update')); |
197 | 197 | return $this->response; |
198 | 198 | } |
199 | 199 | |
200 | 200 | $values = $this->validator->validateItem($formValues); |
201 | - if(!($member = $this->memberService->getMember($values['member']))) |
|
201 | + if (!($member = $this->memberService->getMember($values['member']))) |
|
202 | 202 | { |
203 | 203 | $this->notify->warning(trans('tontine.member.errors.not_found')); |
204 | 204 | return $this->response; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function deleteLoan(int $loanId) |
218 | 218 | { |
219 | - if($this->session->closed) |
|
219 | + if ($this->session->closed) |
|
220 | 220 | { |
221 | 221 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
222 | 222 | return $this->response; |
@@ -32,8 +32,8 @@ |
||
32 | 32 | public function envelope() |
33 | 33 | { |
34 | 34 | return new Envelope( |
35 | - from: new Address(env('MAIL_FROM_ADDRESS', ''), env('MAIL_FROM_NAME')), |
|
36 | - subject: 'Feedback Received', |
|
35 | + from : new Address(env('MAIL_FROM_ADDRESS', ''), env('MAIL_FROM_NAME')), |
|
36 | + subject : 'Feedback Received', |
|
37 | 37 | ); |
38 | 38 | } |
39 | 39 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | public function handle(NewFeedback $event) |
19 | 19 | { |
20 | - if(!($mailTo = env('MAIL_FEEDBACK_TO'))) |
|
20 | + if (!($mailTo = env('MAIL_FEEDBACK_TO'))) |
|
21 | 21 | { |
22 | 22 | return; |
23 | 23 | } |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function register() |
84 | 84 | { |
85 | - $this->reportable(function (Throwable $e) { |
|
85 | + $this->reportable(function(Throwable $e) { |
|
86 | 86 | // |
87 | 87 | }); |
88 | 88 | |
89 | 89 | // Redirect to the login page |
90 | - $this->renderable(function (AuthenticationException $e) { |
|
90 | + $this->renderable(function(AuthenticationException $e) { |
|
91 | 91 | $jaxon = app()->make(Jaxon::class); |
92 | 92 | $ajaxResponse = $jaxon->ajaxResponse(); |
93 | 93 | $ajaxResponse->redirect(route('login')); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | }); |
97 | 97 | |
98 | 98 | // Show the error message in a dialog |
99 | - $this->renderable(function (MessageException $e) { |
|
99 | + $this->renderable(function(MessageException $e) { |
|
100 | 100 | $jaxon = app()->make(Jaxon::class); |
101 | 101 | $ajaxResponse = $jaxon->ajaxResponse(); |
102 | 102 | $ajaxResponse->dialog->error($e->getMessage(), trans('common.titles.error')); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | }); |
106 | 106 | |
107 | 107 | // Show the warning message in a dialog, and show the sessions page. |
108 | - $this->renderable(function (PlanningRoundException $e) { |
|
108 | + $this->renderable(function(PlanningRoundException $e) { |
|
109 | 109 | $this->getCallableObject(Round::class)->home(); |
110 | 110 | |
111 | 111 | $jaxon = app()->make(Jaxon::class); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | }); |
117 | 117 | |
118 | 118 | // Show the warning message in a dialog, and show the pools page. |
119 | - $this->renderable(function (PlanningPoolException $e) { |
|
119 | + $this->renderable(function(PlanningPoolException $e) { |
|
120 | 120 | $this->getCallableObject(Pool::class)->home(); |
121 | 121 | |
122 | 122 | $jaxon = app()->make(Jaxon::class); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | }); |
128 | 128 | |
129 | 129 | // Show the warning message in a dialog, and show the members page. |
130 | - $this->renderable(function (TontineMemberException $e) { |
|
130 | + $this->renderable(function(TontineMemberException $e) { |
|
131 | 131 | $this->getCallableObject(Member::class)->home(); |
132 | 132 | |
133 | 133 | $jaxon = app()->make(Jaxon::class); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | }); |
139 | 139 | |
140 | 140 | // Show the warning message in a dialog, and show the sessions page. |
141 | - $this->renderable(function (MeetingRoundException $e) { |
|
141 | + $this->renderable(function(MeetingRoundException $e) { |
|
142 | 142 | $this->getCallableObject(Session::class)->home(); |
143 | 143 | |
144 | 144 | $jaxon = app()->make(Jaxon::class); |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | string $bagName, string $attrName = 'page'): array |
57 | 57 | { |
58 | 58 | $perPage = 10; |
59 | - $pageCount = (int)floor($itemCount / $perPage) + ($itemCount % $perPage > 0 ? 1 : 0); |
|
60 | - if($pageNumber < 1) |
|
59 | + $pageCount = (int) floor($itemCount / $perPage) + ($itemCount % $perPage > 0 ? 1 : 0); |
|
60 | + if ($pageNumber < 1) |
|
61 | 61 | { |
62 | 62 | $pageNumber = $this->bag($bagName)->get($attrName, 1); |
63 | 63 | } |
64 | - if($pageNumber > $pageCount) |
|
64 | + if ($pageNumber > $pageCount) |
|
65 | 65 | { |
66 | 66 | $pageNumber = $pageCount; |
67 | 67 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | protected function checkRoundSessions() |
152 | 152 | { |
153 | 153 | $round = $this->tenantService->round(); |
154 | - if(!$round || $round->sessions->count() === 0) |
|
154 | + if (!$round || $round->sessions->count() === 0) |
|
155 | 155 | { |
156 | 156 | throw new PlanningRoundException(trans('tontine.errors.checks.sessions')); |
157 | 157 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $this->checkRoundSessions(); |
166 | 166 | |
167 | 167 | $round = $this->tenantService->round(); |
168 | - if(!$round || $round->pools->count() === 0) |
|
168 | + if (!$round || $round->pools->count() === 0) |
|
169 | 169 | { |
170 | 170 | throw new PlanningPoolException(trans('tontine.errors.checks.pools')); |
171 | 171 | } |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | $this->checkRoundSessions(); |
181 | 181 | |
182 | 182 | $tontine = $this->tenantService->tontine(); |
183 | - if(!$tontine || $tontine->members()->active()->count() === 0) |
|
183 | + if (!$tontine || $tontine->members()->active()->count() === 0) |
|
184 | 184 | { |
185 | 185 | throw new TontineMemberException(trans('tontine.errors.checks.members')); |
186 | 186 | } |
187 | 187 | |
188 | 188 | $round = $this->tenantService->round(); |
189 | - if(!$round || $round->sessions->filter(fn($session) => |
|
189 | + if (!$round || $round->sessions->filter(fn($session) => |
|
190 | 190 | ($session->opened || $session->closed))->count() === 0) |
191 | 191 | { |
192 | 192 | throw new MeetingRoundException(trans('tontine.errors.checks.opened_sessions')); |