Passed
Pull Request — main (#54)
by Thierry
13:54
created
app/Ajax/Web/Meeting/Charge/Libre/Settlement.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function addSettlement(int $billId)
118 118
     {
119
-        if($this->session->closed)
119
+        if ($this->session->closed)
120 120
         {
121 121
             $this->notify->warning(trans('meeting.warnings.session.closed'));
122 122
             return $this->response;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function delSettlement(int $billId)
137 137
     {
138
-        if($this->session->closed)
138
+        if ($this->session->closed)
139 139
         {
140 140
             $this->notify->warning(trans('meeting.warnings.session.closed'));
141 141
             return $this->response;
Please login to merge, or discard this patch.
app/Ajax/Web/Meeting/Charge/Fixed/Settlement.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function addSettlement(int $billId)
124 124
     {
125
-        if($this->session->closed)
125
+        if ($this->session->closed)
126 126
         {
127 127
             $this->notify->warning(trans('meeting.warnings.session.closed'));
128 128
             return $this->response;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function delSettlement(int $billId)
146 146
     {
147
-        if($this->session->closed)
147
+        if ($this->session->closed)
148 148
         {
149 149
             $this->notify->warning(trans('meeting.warnings.session.closed'));
150 150
             return $this->response;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function addAllSettlements()
166 166
     {
167
-        if($this->session->closed)
167
+        if ($this->session->closed)
168 168
         {
169 169
             $this->notify->warning(trans('meeting.warnings.session.closed'));
170 170
             return $this->response;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function delAllSettlements()
186 186
     {
187
-        if($this->session->closed)
187
+        if ($this->session->closed)
188 188
         {
189 189
             $this->notify->warning(trans('meeting.warnings.session.closed'));
190 190
             return $this->response;
Please login to merge, or discard this patch.
app/Ajax/CallableClass.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,12 +55,12 @@
 block discarded – undo
55 55
     protected function pageNumber(int $pageNumber, int $itemCount, string $bagName, string $attrName = 'page'): array
56 56
     {
57 57
         $perPage = 10;
58
-        $pageCount = (int)floor($itemCount / $perPage) + ($itemCount % $perPage > 0 ? 1 : 0);
59
-        if($pageNumber < 1)
58
+        $pageCount = (int) floor($itemCount / $perPage) + ($itemCount % $perPage > 0 ? 1 : 0);
59
+        if ($pageNumber < 1)
60 60
         {
61 61
             $pageNumber = $this->bag($bagName)->get($attrName, 1);
62 62
         }
63
-        if($pageNumber > $pageCount)
63
+        if ($pageNumber > $pageCount)
64 64
         {
65 65
             $pageNumber = $pageCount;
66 66
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Credit/RefundService.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                         $query->where('session_id', $sessionId);
81 81
                     });
82 82
                 });
83
-                if($prevSessions->count() === 0)
83
+                if ($prevSessions->count() === 0)
84 84
                 {
85 85
                     return;
86 86
                 }
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
         $debt = Debt::whereHas('loan', function(Builder $query) use($sessionIds) {
169 169
             $query->whereIn('session_id', $sessionIds);
170 170
         })->with(['partial_refunds'])->find($debtId);
171
-        if(!$debt || $debt->refund)
171
+        if (!$debt || $debt->refund)
172 172
         {
173 173
             throw new MessageException(trans('tontine.loan.errors.not_found'));
174 174
         }
175
-        if(!$this->debtCalculator->debtIsEditable($session, $debt))
175
+        if (!$this->debtCalculator->debtIsEditable($session, $debt))
176 176
         {
177 177
             throw new MessageException(trans('meeting.refund.errors.cannot_refund'));
178 178
         }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         DB::transaction(function() use($session, $debt, $refund) {
184 184
             $refund->save();
185 185
             // For simple or compound interest, also save the final amount.
186
-            if($debt->is_interest && !$debt->loan->fixed_interest)
186
+            if ($debt->is_interest && !$debt->loan->fixed_interest)
187 187
             {
188 188
                 $debt->amount = $this->debtCalculator->getDebtAmount($session, $debt);
189 189
                 $debt->save();
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
     {
204 204
         $refund = Refund::with('debt')->where('session_id', $session->id)
205 205
             ->where('debt_id', $debtId)->first();
206
-        if(!$refund)
206
+        if (!$refund)
207 207
         {
208 208
             throw new MessageException(trans('meeting.refund.errors.not_found'));
209 209
         }
210
-        if((!$refund->editable))
210
+        if ((!$refund->editable))
211 211
         {
212 212
             throw new MessageException(trans('meeting.refund.errors.cannot_delete'));
213 213
         }
214
-        if(!$this->debtCalculator->debtIsEditable($session, $refund->debt))
214
+        if (!$this->debtCalculator->debtIsEditable($session, $refund->debt))
215 215
         {
216 216
             throw new MessageException(trans('meeting.refund.errors.cannot_refund'));
217 217
         }
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
         $debt = Debt::whereHas('loan', function(Builder $query) use($sessionIds) {
288 288
             $query->whereIn('session_id', $sessionIds);
289 289
         })->find($debtId);
290
-        if(!$debt || $debt->refund)
290
+        if (!$debt || $debt->refund)
291 291
         {
292 292
             throw new MessageException(trans('meeting.refund.errors.not_found'));
293 293
         }
294 294
         // A partial refund must not totally refund a debt
295
-        if($amount >= $debt->due_amount)
295
+        if ($amount >= $debt->due_amount)
296 296
         {
297 297
             throw new MessageException(trans('meeting.refund.errors.pr_amount'));
298 298
         }
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
     {
317 317
         $refund = PartialRefund::where('session_id', $session->id)
318 318
             ->with(['debt.refund'])->find($refundId);
319
-        if(!$refund)
319
+        if (!$refund)
320 320
         {
321 321
             throw new MessageException(trans('meeting.refund.errors.not_found'));
322 322
         }
323
-        if($refund->debt->refund !== null || !$refund->editable)
323
+        if ($refund->debt->refund !== null || !$refund->editable)
324 324
         {
325 325
             throw new MessageException(trans('meeting.refund.errors.cannot_delete'));
326 326
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Pool/DepositService.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     public function createDeposit(Pool $pool, Session $session, int $receivableId): void
124 124
     {
125 125
         $receivable = $this->getReceivable($pool, $session, $receivableId);
126
-        if(!$receivable || $receivable->deposit || !$pool->deposit_fixed)
126
+        if (!$receivable || $receivable->deposit || !$pool->deposit_fixed)
127 127
         {
128 128
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
129 129
         }
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
     public function saveDepositAmount(Pool $pool, Session $session, int $receivableId, int $amount): void
148 148
     {
149 149
         $receivable = $this->getReceivable($pool, $session, $receivableId);
150
-        if(!$receivable || $pool->deposit_fixed)
150
+        if (!$receivable || $pool->deposit_fixed)
151 151
         {
152 152
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
153 153
         }
154 154
 
155
-        if($receivable->deposit !== null)
155
+        if ($receivable->deposit !== null)
156 156
         {
157
-            if((!$receivable->deposit->editable))
157
+            if ((!$receivable->deposit->editable))
158 158
             {
159 159
                 throw new MessageException(trans('tontine.errors.editable'));
160 160
             }
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
     public function deleteDeposit(Pool $pool, Session $session, int $receivableId): void
184 184
     {
185 185
         $receivable = $this->getReceivable($pool, $session, $receivableId);
186
-        if(!$receivable || !$receivable->deposit)
186
+        if (!$receivable || !$receivable->deposit)
187 187
         {
188 188
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
189 189
         }
190
-        if((!$receivable->deposit->editable))
190
+        if ((!$receivable->deposit->editable))
191 191
         {
192 192
             throw new MessageException(trans('tontine.errors.editable'));
193 193
         }
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
     public function createAllDeposits(Pool $pool, Session $session): void
206 206
     {
207 207
         $receivables = $this->getQuery($pool, $session)->whereDoesntHave('deposit')->get();
208
-        if($receivables->count() === 0)
208
+        if ($receivables->count() === 0)
209 209
         {
210 210
             return;
211 211
         }
212 212
 
213 213
         DB::transaction(function() use($session, $receivables) {
214
-            foreach($receivables as $receivable)
214
+            foreach ($receivables as $receivable)
215 215
             {
216 216
                 $deposit = new Deposit();
217 217
                 $deposit->receivable()->associate($receivable);
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             ->filter(function($receivable) {
239 239
                 return $receivable->deposit->editable;
240 240
             });
241
-        if($receivables->count() === 0)
241
+        if ($receivables->count() === 0)
242 242
         {
243 243
             return;
244 244
         }
Please login to merge, or discard this patch.
src/Service/Planning/SessionService.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -178,8 +178,7 @@
 block discarded – undo
178 178
                 $session->disabledPools()->detach();
179 179
                 $session->delete();
180 180
             });
181
-        }
182
-        catch(Exception $e)
181
+        } catch(Exception $e)
183 182
         {
184 183
             throw new MessageException(trans('tontine.session.errors.delete'));
185 184
         }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function createSessions(array $values): bool
109 109
     {
110
-        foreach($values as &$value)
110
+        foreach ($values as &$value)
111 111
         {
112 112
             $value['start_at'] = $value['date'] . ' ' . $value['start'] . ':00';
113 113
             $value['end_at'] = $value['date'] . ' ' . $value['end'] . ':00';
114 114
         }
115 115
         DB::transaction(function() use($values) {
116 116
             $sessions = $this->tenantService->round()->sessions()->createMany($values);
117
-            foreach($sessions as $session)
117
+            foreach ($sessions as $session)
118 118
             {
119 119
                 $this->disableSessionOnPools($session);
120 120
             }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         // Make sure the host belongs to the same tontine
139 139
         $hostId = intval($values['host_id']);
140 140
         $values['host_id'] = null;
141
-        if($hostId > 0)
141
+        if ($hostId > 0)
142 142
         {
143 143
             $values['host_id'] = $this->tenantService->tontine()->members()->find($hostId)->id;
144 144
         }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 $session->delete();
180 180
             });
181 181
         }
182
-        catch(Exception $e)
182
+        catch (Exception $e)
183 183
         {
184 184
             throw new MessageException(trans('tontine.session.errors.delete'));
185 185
         }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         // {
214 214
         //     return;
215 215
         // }
216
-        if($session->enabled($pool))
216
+        if ($session->enabled($pool))
217 217
         {
218 218
             return;
219 219
         }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
         // {
240 240
         //     return;
241 241
         // }
242
-        if($session->disabled($pool))
242
+        if ($session->disabled($pool))
243 243
         {
244 244
             return;
245 245
         }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         $year = now()->format('Y');
265 265
         $date = Carbon::createFromDate($year, 1, 5, 'Africa/Douala')->locale('fr');
266 266
         $sessions = [];
267
-        for($i = 0; $i < 12; $i++)
267
+        for ($i = 0; $i < 12; $i++)
268 268
         {
269 269
             $session = new \stdClass();
270 270
             $session->title = 'Séance de ' . $date->isoFormat('MMMM YYYY');
Please login to merge, or discard this patch.
src/Service/Meeting/Charge/LibreFeeService.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                     $member->libre_bills->first()->bill : null;
247 247
             });
248 248
         // Check if there is a settlement target.
249
-        if(!($target = $this->targetService->getTarget($charge, $session)))
249
+        if (!($target = $this->targetService->getTarget($charge, $session)))
250 250
         {
251 251
             return $members;
252 252
         }
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
         int $memberId, bool $paid, float $amount = 0): void
288 288
     {
289 289
         $member = $this->tenantService->tontine()->members()->find($memberId);
290
-        if(!$member)
290
+        if (!$member)
291 291
         {
292 292
             throw new MessageException(trans('tontine.member.errors.not_found'));
293 293
         }
294 294
 
295
-        if($amount !== 0)
295
+        if ($amount !== 0)
296 296
         {
297 297
             $amount = $this->localeService->convertMoneyToInt($amount);
298 298
         }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             $libreBill->session()->associate($session);
310 310
             $libreBill->bill()->associate($bill);
311 311
             $libreBill->save();
312
-            if($paid)
312
+            if ($paid)
313 313
             {
314 314
                 $settlement = new Settlement();
315 315
                 $settlement->bill()->associate($bill);
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
      */
329 329
     public function getBill(Charge $charge, Session $session, int $memberId): ?LibreBill
330 330
     {
331
-        if(!($member = $this->tenantService->tontine()->members()->find($memberId)))
331
+        if (!($member = $this->tenantService->tontine()->members()->find($memberId)))
332 332
         {
333 333
             throw new MessageException(trans('tontine.member.errors.not_found'));
334 334
         }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
      */
351 351
     public function updateBill(Charge $charge, Session $session, int $memberId, float $amount): void
352 352
     {
353
-        if(!($libreBill = $this->getBill($charge, $session, $memberId)))
353
+        if (!($libreBill = $this->getBill($charge, $session, $memberId)))
354 354
         {
355 355
             return; // throw new MessageException(trans('tontine.bill.errors.not_found'));
356 356
         }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      */
370 370
     public function deleteBill(Charge $charge, Session $session, int $memberId): void
371 371
     {
372
-        if(!($libreBill = $this->getBill($charge, $session, $memberId)))
372
+        if (!($libreBill = $this->getBill($charge, $session, $memberId)))
373 373
         {
374 374
             return; // throw new MessageException(trans('tontine.bill.errors.not_found'));
375 375
         }
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
         DB::transaction(function() use($libreBill, $session) {
378 378
             $bill = $libreBill->bill;
379 379
             $libreBill->delete();
380
-            if($bill !== null)
380
+            if ($bill !== null)
381 381
             {
382 382
                 // Delete the settlement only if it is on the same session
383
-                if($bill->settlement !== null && $bill->settlement->session_id === $session->id)
383
+                if ($bill->settlement !== null && $bill->settlement->session_id === $session->id)
384 384
                 {
385 385
                     $bill->settlement->delete();
386 386
                 }
Please login to merge, or discard this patch.
src/Validation/Meeting/TargetValidator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,13 +36,13 @@
 block discarded – undo
36 36
             'amount' => 'required|regex:/^\d+(\.\d{1,2})?$/',
37 37
             'deadline' => 'required|integer|min:1',
38 38
         ]);
39
-        if($validator->fails())
39
+        if ($validator->fails())
40 40
         {
41 41
             throw new ValidationException($validator);
42 42
         }
43 43
 
44 44
         $validated = $validator->validated();
45
-        $validated['amount'] = $this->localeService->convertMoneyToInt((float)$validated['amount']);
45
+        $validated['amount'] = $this->localeService->convertMoneyToInt((float) $validated['amount']);
46 46
         return $validated;
47 47
     }
48 48
 }
Please login to merge, or discard this patch.
app/Ajax/Web/Meeting/Charge/Libre/Target.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             $this->target()->args()[0] : $this->bag('meeting')->get('charge.id');
68 68
         $this->session = $this->chargeService->getSession($sessionId);
69 69
         $this->charge = $this->chargeService->getCharge($chargeId);
70
-        if($this->session !== null && $this->charge !== null)
70
+        if ($this->session !== null && $this->charge !== null)
71 71
         {
72 72
             $this->target = $this->targetService->getTarget($this->charge, $this->session);
73 73
         }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function page(int $pageNumber = 0)
105 105
     {
106
-        if($this->target === null)
106
+        if ($this->target === null)
107 107
         {
108 108
             return $this->response;
109 109
         }
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function add()
145 145
     {
146
-        if($this->session->closed)
146
+        if ($this->session->closed)
147 147
         {
148 148
             $this->notify->warning(trans('meeting.warnings.session.closed'));
149 149
             return $this->response;
150 150
         }
151
-        if($this->session === null || $this->charge === null)
151
+        if ($this->session === null || $this->charge === null)
152 152
         {
153 153
             return $this->response;
154 154
         }
155
-        if($this->target !== null)
155
+        if ($this->target !== null)
156 156
         {
157 157
             return $this->response;
158 158
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             'title' => trans('common.actions.cancel'),
166 166
             'class' => 'btn btn-tertiary',
167 167
             'click' => 'close',
168
-        ],[
168
+        ], [
169 169
             'title' => trans('common.actions.save'),
170 170
             'class' => 'btn btn-primary',
171 171
             'click' => $this->rq()->create(pm()->form('target-form')),
@@ -184,16 +184,16 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function create(array $formValues)
186 186
     {
187
-        if($this->session->closed)
187
+        if ($this->session->closed)
188 188
         {
189 189
             $this->notify->warning(trans('meeting.warnings.session.closed'));
190 190
             return $this->response;
191 191
         }
192
-        if($this->session === null || $this->charge === null)
192
+        if ($this->session === null || $this->charge === null)
193 193
         {
194 194
             return $this->response;
195 195
         }
196
-        if($this->target !== null)
196
+        if ($this->target !== null)
197 197
         {
198 198
             return $this->response;
199 199
         }
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public function edit()
217 217
     {
218
-        if($this->session->closed)
218
+        if ($this->session->closed)
219 219
         {
220 220
             $this->notify->warning(trans('meeting.warnings.session.closed'));
221 221
             return $this->response;
222 222
         }
223
-        if($this->target === null)
223
+        if ($this->target === null)
224 224
         {
225 225
             return $this->response;
226 226
         }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             'title' => trans('common.actions.cancel'),
235 235
             'class' => 'btn btn-tertiary',
236 236
             'click' => 'close',
237
-        ],[
237
+        ], [
238 238
             'title' => trans('common.actions.save'),
239 239
             'class' => 'btn btn-primary',
240 240
             'click' => $this->rq()->update(pm()->form('target-form')),
@@ -254,12 +254,12 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function update(array $formValues)
256 256
     {
257
-        if($this->session->closed)
257
+        if ($this->session->closed)
258 258
         {
259 259
             $this->notify->warning(trans('meeting.warnings.session.closed'));
260 260
             return $this->response;
261 261
         }
262
-        if($this->target === null)
262
+        if ($this->target === null)
263 263
         {
264 264
             return $this->response;
265 265
         }
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function remove()
283 283
     {
284
-        if($this->session === null || $this->charge === null)
284
+        if ($this->session === null || $this->charge === null)
285 285
         {
286 286
             return $this->response;
287 287
         }
288
-        if($this->target === null)
288
+        if ($this->target === null)
289 289
         {
290 290
             return $this->response;
291 291
         }
Please login to merge, or discard this patch.