Passed
Push — main ( 936852...10149e )
by Thierry
15:09
created
src/Service/Meeting/Pool/AuctionService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                         $query->where('session_id', $sessionId);
42 42
                     });
43 43
                 });
44
-                if($prevSessions->count() === 0)
44
+                if ($prevSessions->count() === 0)
45 45
                 {
46 46
                     return;
47 47
                 }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             ->whereDate('start_at', '<', $session->start_at->format('Y-m-d'))
116 116
             ->pluck('id');
117 117
         $auction = $this->getQuery($session->id, $prevSessions)->find($auctionId);
118
-        if(($auction))
118
+        if (($auction))
119 119
         {
120 120
             $auction->update(['paid' => !$auction->paid]);
121 121
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Pool/RemitmentService.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
             ->each(function($payable) use($session) {
72 72
                 $payable->amount = $this->balanceCalculator->getPayableAmount($payable, $session);
73 73
             });
74
-        if(!$pool->remit_planned)
74
+        if (!$pool->remit_planned)
75 75
         {
76 76
             return $payables;
77 77
         }
78 78
 
79 79
         // When the number of remitments is planned, the list is padded to the expected number.
80 80
         $remitmentCount = $this->summaryService->getSessionRemitmentCount($pool, $session);
81
-        $emptyPayable = (object)[
81
+        $emptyPayable = (object) [
82 82
             'id' => 0,
83 83
             'amount' => $pool->amount * $this->poolService->getEnabledSessionCount($pool),
84 84
             'remitment' => null,
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function savePlannedRemitment(Pool $pool, Session $session, int $payableId): void
115 115
     {
116
-        if(!$pool->remit_planned || $pool->remit_auction)
116
+        if (!$pool->remit_planned || $pool->remit_auction)
117 117
         {
118 118
             // Only when remitments are planned and without auctions.
119 119
             return;
120 120
         }
121 121
         // The payable is supposed to already have been associated to the session.
122 122
         $payable = $this->getPayable($pool, $session, $payableId);
123
-        if(!$payable)
123
+        if (!$payable)
124 124
         {
125 125
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
126 126
         }
127
-        if($payable->remitment)
127
+        if ($payable->remitment)
128 128
         {
129 129
             return;
130 130
         }
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
             ->whereDoesntHave('remitment')
150 150
             ->whereIn('subscription_id', $pool->subscriptions()->pluck('id'))
151 151
             ->find($payableId);
152
-        if(!$payable)
152
+        if (!$payable)
153 153
         {
154 154
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
155 155
         }
156
-        if($payable->session_id !== null && $payable->session_id !== $session->id)
156
+        if ($payable->session_id !== null && $payable->session_id !== $session->id)
157 157
         {
158 158
             // The selected member is already planned on another session.
159 159
             throw new MessageException(trans('tontine.remitment.errors.planning'));
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             // Create the remitment.
167 167
             $remitment = $payable->remitment()->create([]);
168 168
 
169
-            if($pool->remit_auction && $auction > 0)
169
+            if ($pool->remit_auction && $auction > 0)
170 170
             {
171 171
                 // Create the corresponding auction.
172 172
                 Auction::create([
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         $payable = $this->getQuery($pool, $session)
194 194
             ->with(['remitment', 'remitment.auction'])
195 195
             ->find($payableId);
196
-        if(!$payable || !($remitment = $payable->remitment))
196
+        if (!$payable || !($remitment = $payable->remitment))
197 197
         {
198 198
             return;
199 199
         }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             $remitment->auction()->delete();
204 204
             $remitment->delete();
205 205
             // Detach from the session, but only if the remitment was not planned.
206
-            if(!$pool->remit_planned || $pool->remit_auction)
206
+            if (!$pool->remit_planned || $pool->remit_auction)
207 207
             {
208 208
                 $payable->session()->dissociate();
209 209
                 $payable->save();
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             ->with(['payable', 'member'])
229 229
             ->select('subscriptions.*')
230 230
             ->get();
231
-        if($pool->remit_planned && !$pool->remit_auction)
231
+        if ($pool->remit_planned && !$pool->remit_auction)
232 232
         {
233 233
             // Only the beneficiaries planned for this session.
234 234
             return $subscriptions
Please login to merge, or discard this patch.
src/Service/Meeting/Credit/LoanService.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $loan->interest_rate = $values['interest_rate'];
139 139
         $loan->member()->associate($member);
140 140
         $loan->session()->associate($session);
141
-        if($fund !== null)
141
+        if ($fund !== null)
142 142
         {
143 143
             $loan->fund()->associate($fund);
144 144
         }
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
             $principal = $values['principal'];
149 149
             $interest = $values['interest'];
150 150
             // Create an entry for each type of debt
151
-            if($principal > 0)
151
+            if ($principal > 0)
152 152
             {
153 153
                 $loan->debts()->create(['type' => Debt::TYPE_PRINCIPAL, 'amount' => $principal]);
154 154
             }
155
-            if($interest > 0)
155
+            if ($interest > 0)
156 156
             {
157 157
                 $loan->debts()->create(['type' => Debt::TYPE_INTEREST, 'amount' => $interest]);
158 158
             }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         $loan->interest_type = $values['interest_type'];
176 176
         $loan->interest_rate = $values['interest_rate'];
177 177
         $loan->member()->associate($member);
178
-        if($fund !== null)
178
+        if ($fund !== null)
179 179
         {
180 180
             $loan->fund()->associate($fund);
181 181
         }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
             $interest = $values['interest'];
191 191
             $loan->debts()->principal()->update(['amount' => $principal]);
192 192
             // The interest debt may need to be created or deleted.
193
-            if($interest <= 0)
193
+            if ($interest <= 0)
194 194
             {
195 195
                 $loan->debts()->where('type', Debt::TYPE_INTEREST)->delete();
196 196
                 return;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function deleteLoan(Session $session, int $loanId): void
211 211
     {
212
-        if(($loan = $session->loans()->find($loanId)) !== null)
212
+        if (($loan = $session->loans()->find($loanId)) !== null)
213 213
         {
214 214
             DB::transaction(function() use($loan) {
215 215
                 $loan->refunds()->delete();
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
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                         $query->where('session_id', $sessionId);
52 52
                     });
53 53
                 });
54
-                if($prevSessions->count() === 0)
54
+                if ($prevSessions->count() === 0)
55 55
                 {
56 56
                     return;
57 57
                 }
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
     public function createRefund(Session $session, int $debtId): void
150 150
     {
151 151
         $debt = $this->getDebt($debtId);
152
-        if(!$debt || $debt->refund)
152
+        if (!$debt || $debt->refund)
153 153
         {
154 154
             throw new MessageException(trans('tontine.loan.errors.not_found'));
155 155
         }
156
-        if(!$this->debtCalculator->debtIsEditable($session, $debt))
156
+        if (!$this->debtCalculator->debtIsEditable($session, $debt))
157 157
         {
158 158
             throw new MessageException(trans('meeting.refund.errors.cannot_refund'));
159 159
         }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         DB::transaction(function() use($session, $debt, $refund) {
165 165
             $refund->save();
166 166
             // For simple or compound interest, also save the final amount.
167
-            if($debt->is_interest && !$debt->loan->fixed_interest)
167
+            if ($debt->is_interest && !$debt->loan->fixed_interest)
168 168
             {
169 169
                 $debt->amount = $this->debtCalculator->getDebtAmount($session, $debt);
170 170
                 $debt->save();
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
     {
185 185
         $refund = Refund::with('debt')->where('session_id', $session->id)
186 186
             ->where('debt_id', $debtId)->first();
187
-        if(!$refund)
187
+        if (!$refund)
188 188
         {
189 189
             throw new MessageException(trans('meeting.refund.errors.not_found'));
190 190
         }
191
-        if((!$refund->editable))
191
+        if ((!$refund->editable))
192 192
         {
193 193
             throw new MessageException(trans('meeting.refund.errors.cannot_delete'));
194 194
         }
195
-        if(!$this->debtCalculator->debtIsEditable($session, $refund->debt))
195
+        if (!$this->debtCalculator->debtIsEditable($session, $refund->debt))
196 196
         {
197 197
             throw new MessageException(trans('meeting.refund.errors.cannot_refund'));
198 198
         }
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
     public function createPartialRefund(Session $session, int $debtId, int $amount): void
266 266
     {
267 267
         $debt = $this->getDebt($debtId);
268
-        if(!$debt || $debt->refund)
268
+        if (!$debt || $debt->refund)
269 269
         {
270 270
             throw new MessageException(trans('meeting.refund.errors.not_found'));
271 271
         }
272 272
         // A partial refund must not totally refund a debt
273
-        if($amount >= $debt->due_amount)
273
+        if ($amount >= $debt->due_amount)
274 274
         {
275 275
             throw new MessageException(trans('meeting.refund.errors.pr_amount'));
276 276
         }
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
     {
295 295
         $refund = PartialRefund::where('session_id', $session->id)
296 296
             ->with(['debt.refund'])->find($refundId);
297
-        if(!$refund)
297
+        if (!$refund)
298 298
         {
299 299
             throw new MessageException(trans('meeting.refund.errors.not_found'));
300 300
         }
301
-        if($refund->debt->refund !== null || !$refund->editable)
301
+        if ($refund->debt->refund !== null || !$refund->editable)
302 302
         {
303 303
             throw new MessageException(trans('meeting.refund.errors.cannot_delete'));
304 304
         }
Please login to merge, or discard this patch.
src/Service/TenantService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $this->localeService->setCurrency($tontine->currency_code);
57 57
         // Save as latest tontine id if it has changed.
58 58
         $tontineId = $this->user->properties['latest']['tontine'] ?? 0;
59
-        if($tontineId === $tontine->id)
59
+        if ($tontineId === $tontine->id)
60 60
         {
61 61
             return;
62 62
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $this->round = $round;
76 76
         // Save as latest round id if it has changed.
77 77
         $roundId = $this->user->properties['latest']['round'] ?? 0;
78
-        if($roundId === $round->id)
78
+        if ($roundId === $round->id)
79 79
         {
80 80
             return;
81 81
         }
Please login to merge, or discard this patch.
src/Model/Pool.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     protected static function booted()
92 92
     {
93
-        static::addGlobalScope('dates', function (Builder $query) {
93
+        static::addGlobalScope('dates', function(Builder $query) {
94 94
             $query->addSelect(['pools.*', 'v.end_at', 'v.start_at', 'v.tontine_id'])
95 95
                 ->join(DB::raw('v_pools as v'), 'v.id', '=', 'pools.id');
96 96
         });
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
     public function sessions()
212 212
     {
213
-        if(!$this->pool_round)
213
+        if (!$this->pool_round)
214 214
         {
215 215
             return $this->round->sessions();
216 216
         }
Please login to merge, or discard this patch.
src/Model/Base.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
      */
17 17
     public function scopePage(Builder $query, int $page, int $limit): Builder
18 18
     {
19
-        return $page < 1 || $limit < 1 ? $query :
20
-            $query->take($limit)->skip($limit * ($page - 1));
19
+        return $page < 1 || $limit < 1 ? $query : $query->take($limit)->skip($limit * ($page - 1));
21 20
     }
22 21
 }
Please login to merge, or discard this patch.
src/Validation/Planning/PoolRoundValidator.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,34 +31,34 @@
 block discarded – undo
31 31
         ]);
32 32
         $validator->after(function($validator) use($values) {
33 33
             // No more check if there's already an error.
34
-            if($validator->errors()->count() > 0)
34
+            if ($validator->errors()->count() > 0)
35 35
             {
36 36
                 return;
37 37
             }
38 38
 
39
-            $startSession = $this->sessionService->getTontineSession((int)$values['start_session']);
40
-            if(!$startSession)
39
+            $startSession = $this->sessionService->getTontineSession((int) $values['start_session']);
40
+            if (!$startSession)
41 41
             {
42 42
                 $validator->errors()->add('start_session', trans('tontine.pool.errors.start_session'));
43 43
             }
44
-            $endSession = $this->sessionService->getTontineSession((int)$values['end_session']);
45
-            if(!$endSession)
44
+            $endSession = $this->sessionService->getTontineSession((int) $values['end_session']);
45
+            if (!$endSession)
46 46
             {
47 47
                 $validator->errors()->add('end_session', trans('tontine.pool.errors.end_session'));
48 48
             }
49
-            if($endSession->id === $startSession->id || $endSession->start_at <= $startSession->start_at)
49
+            if ($endSession->id === $startSession->id || $endSession->start_at <= $startSession->start_at)
50 50
             {
51 51
                 $validator->errors()->add('end_session', trans('tontine.pool.errors.session_dates'));
52 52
             }
53 53
         });
54
-        if($validator->fails())
54
+        if ($validator->fails())
55 55
         {
56 56
             throw new ValidationException($validator);
57 57
         }
58 58
 
59 59
         return [
60
-            'start_session_id' => (int)$values['start_session'],
61
-            'end_session_id' => (int)$values['end_session'],
60
+            'start_session_id' => (int) $values['start_session'],
61
+            'end_session_id' => (int) $values['end_session'],
62 62
         ];
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
src/Validation/Planning/RoundValidator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
             'title' => 'required|string|min:5',
20 20
             'notes' => 'nullable|string',
21 21
         ]);
22
-        if($validator->fails())
22
+        if ($validator->fails())
23 23
         {
24 24
             throw new ValidationException($validator);
25 25
         }
Please login to merge, or discard this patch.