Passed
Pull Request — main (#49)
by Thierry
14:14
created
app/Ajax/Web/Faker.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $count = intval($this->bag('faker')->get('charge.count'));
52 52
         $charges = $this->chargeService->getFakeCharges($count);
53
-        for($i = 0; $i < $count; $i++)
53
+        for ($i = 0; $i < $count; $i++)
54 54
         {
55 55
             $this->jq("#charge_type_$i")->val($charges[$i]->type);
56 56
             $this->jq("#charge_period_$i")->val($charges[$i]->period);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     {
70 70
         $count = intval($this->bag('faker')->get('pool.count'));
71 71
         $pools = $this->poolService->getFakePools($count);
72
-        for($i = 0; $i < $count; $i++)
72
+        for ($i = 0; $i < $count; $i++)
73 73
         {
74 74
             $this->jq("#pool_title_$i")->val($pools[$i]->title);
75 75
             $this->jq("#pool_amount_$i")->val($pools[$i]->amount);
Please login to merge, or discard this patch.
app/Console/Commands/CreateAnnotationsDir.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
     /**
28 28
      * Execute the console command.
29 29
      *
30
-      * @return mixed
30
+     * @return mixed
31 31
      */
32 32
     public function handle()
33 33
     {
Please login to merge, or discard this patch.
src/Service/Tontine/MemberService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
             $tontine = $this->tenantService->tontine();
95 95
             $members = $tontine->members()->createMany($values);
96 96
             // Create members bills
97
-            foreach($members as $member)
97
+            foreach ($members as $member)
98 98
             {
99 99
                 $this->memberCreated($tontine, $member);
100 100
             }
Please login to merge, or discard this patch.
src/Service/Tontine/TontineService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@
 block discarded – undo
185 185
     public function deleteTontine(int $id)
186 186
     {
187 187
         $tontine = $this->tenantService->user()->tontines()->find($id);
188
-        if(!$tontine)
188
+        if (!$tontine)
189 189
         {
190 190
             return;
191 191
         }
Please login to merge, or discard this patch.
src/Service/Tontine/ChargeService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
      */
142 142
     public function deleteCharge(Charge $charge)
143 143
     {
144
-        if($charge->bills_count > 0)
144
+        if ($charge->bills_count > 0)
145 145
         {
146 146
             throw new MessageException(trans('tontine.charge.errors.cannot_delete'));
147 147
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Pool/AuctionService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                         $query->where('session_id', $sessionId);
64 64
                     });
65 65
                 });
66
-                if($prevSessions->count() === 0)
66
+                if ($prevSessions->count() === 0)
67 67
                 {
68 68
                     return;
69 69
                 }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         $prevSessions = $this->tenantService->round()->sessions()
141 141
             ->where('start_at', '<', $session->start_at)->pluck('id');
142 142
         $auction = $this->getQuery($session->id, $prevSessions)->find($auctionId);
143
-        if(($auction))
143
+        if (($auction))
144 144
         {
145 145
             $auction->update(['paid' => !$auction->paid]);
146 146
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Credit/LoanService.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     public function createLoan(Session $session, array $values): void
193 193
     {
194 194
         $member = $this->getMember($values['member']);
195
-        if(!$member)
195
+        if (!$member)
196 196
         {
197 197
             throw new MessageException(trans('tontine.member.errors.not_found'));
198 198
         }
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
             $principal = $values['principal'];
209 209
             $interest = $values['interest'];
210 210
             // Create an entry for each type of debt
211
-            if($principal > 0)
211
+            if ($principal > 0)
212 212
             {
213 213
                 $loan->debts()->create(['type' => Debt::TYPE_PRINCIPAL, 'amount' => $principal]);
214 214
             }
215
-            if($interest > 0)
215
+            if ($interest > 0)
216 216
             {
217 217
                 $loan->debts()->create(['type' => Debt::TYPE_INTEREST, 'amount' => $interest]);
218 218
             }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             $interest = $values['interest'];
240 240
             $loan->debts()->principal()->update(['amount' => $principal]);
241 241
             // The interest debt may need to be created or deleted.
242
-            if($interest <= 0)
242
+            if ($interest <= 0)
243 243
             {
244 244
                 $loan->debts()->where('type', Debt::TYPE_INTEREST)->delete();
245 245
                 return;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function deleteLoan(Session $session, int $loanId): void
260 260
     {
261
-        if(($loan = $session->loans()->find($loanId)) !== null)
261
+        if (($loan = $session->loans()->find($loanId)) !== null)
262 262
         {
263 263
             DB::transaction(function() use($loan) {
264 264
                 $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
@@ -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->online))
210
+        if (($refund->online))
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->online)
323
+        if ($refund->debt->refund !== null || $refund->online)
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/Credit/DebtCalculator.php 1 patch
Spacing   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function debtIsEditable(Session $session, Debt $debt): bool
35 35
     {
36
-        if(!$session->opened ||
36
+        if (!$session->opened ||
37 37
             ($debt->is_principal && $debt->loan->session->id === $session->id))
38 38
         {
39 39
             // Cannot refund the principal debt in the same session.
40 40
             return false;
41 41
         }
42 42
         // Refunded
43
-        if($debt->refund !== null)
43
+        if ($debt->refund !== null)
44 44
         {
45 45
             // Editable only if refunded in the current session
46 46
             return $debt->refund->session_id === $session->id;
47 47
         }
48
-        if($debt->is_interest && !$debt->loan->fixed_interest)
48
+        if ($debt->is_interest && !$debt->loan->fixed_interest)
49 49
         {
50 50
             // Cannot refund the interest debt before the principal.
51 51
             return $debt->loan->principal_debt->refund !== null;
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
                 return $refund->session->start_at < $session->start_at;
113 113
             })
114 114
             ->sortBy('session.start_at');
115
-        foreach($partialRefunds as $refund)
115
+        foreach ($partialRefunds as $refund)
116 116
         {
117 117
             $sessionCount = $this->getSessionCount($fromSession, $refund->session);
118
-            $interestAmount += (int)($loanAmount * $interestRate * $sessionCount);
118
+            $interestAmount += (int) ($loanAmount * $interestRate * $sessionCount);
119 119
             // For the next loop
120 120
             $loanAmount -= $refund->amount;
121 121
             $fromSession = $refund->session;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $lastSession = $this->getLastSession($session, $principalDebt);
125 125
         $sessionCount = $this->getSessionCount($fromSession, $lastSession);
126 126
 
127
-        return $interestAmount + (int)($loanAmount * $interestRate * $sessionCount);
127
+        return $interestAmount + (int) ($loanAmount * $interestRate * $sessionCount);
128 128
     }
129 129
 
130 130
     /**
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
                 return $refund->session->start_at < $session->start_at;
150 150
             })
151 151
             ->sortBy('session.start_at');
152
-        foreach($partialRefunds as $refund)
152
+        foreach ($partialRefunds as $refund)
153 153
         {
154 154
             $sessionCount = $this->getSessionCount($fromSession, $refund->session);
155
-            $interestAmount += (int)($loanAmount * (pow(1 + $interestRate, $sessionCount) - 1));
155
+            $interestAmount += (int) ($loanAmount * (pow(1 + $interestRate, $sessionCount) - 1));
156 156
             // For the next loop
157 157
             $loanAmount -= $refund->amount - $interestAmount;
158 158
             $fromSession = $refund->session;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         $lastSession = $this->getLastSession($session, $principalDebt);
162 162
         $sessionCount = $this->getSessionCount($fromSession, $lastSession);
163 163
 
164
-        return $interestAmount + (int)($loanAmount * (pow(1 + $interestRate, $sessionCount) - 1));
164
+        return $interestAmount + (int) ($loanAmount * (pow(1 + $interestRate, $sessionCount) - 1));
165 165
     }
166 166
 
167 167
     /**
@@ -174,14 +174,13 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function getDebtAmount(Session $session, Debt $debt): int
176 176
     {
177
-        if($debt->is_principal || $debt->refund || $debt->loan->fixed_interest)
177
+        if ($debt->is_principal || $debt->refund || $debt->loan->fixed_interest)
178 178
         {
179 179
             return $debt->amount;
180 180
         }
181 181
 
182 182
         return $debt->loan->simple_interest ?
183
-            $this->getSimpleInterestAmount($session, $debt) :
184
-            $this->getCompoundInterestAmount($session, $debt);
183
+            $this->getSimpleInterestAmount($session, $debt) : $this->getCompoundInterestAmount($session, $debt);
185 184
     }
186 185
 
187 186
     /**
Please login to merge, or discard this patch.