Passed
Pull Request — main (#51)
by Thierry
13:39
created
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/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.
src/Service/Meeting/Cash/FundingService.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public function createFunding(Session $session, array $values): void
120 120
     {
121 121
         $member = $this->getMember($values['member']);
122
-        if(!$member)
122
+        if (!$member)
123 123
         {
124 124
             throw new MessageException(trans('tontine.member.errors.not_found'));
125 125
         }
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
     public function updateFunding(Session $session, int $fundingId, array $values): void
143 143
     {
144 144
         $member = $this->getMember($values['member']);
145
-        if(!$member)
145
+        if (!$member)
146 146
         {
147 147
             throw new MessageException(trans('tontine.member.errors.not_found'));
148 148
         }
149 149
         $funding = $session->fundings()->find($fundingId);
150
-        if(!$funding)
150
+        if (!$funding)
151 151
         {
152 152
             throw new MessageException(trans('meeting.funding.errors.not_found'));
153 153
         }
Please login to merge, or discard this patch.
src/Service/Meeting/Cash/DisbursementService.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $member = $this->getMember($values['member']);
215 215
         $charge = $this->getCharge($values['charge']);
216 216
         $category = $this->getCategory($values['category']);
217
-        if(!$category)
217
+        if (!$category)
218 218
         {
219 219
             throw new MessageException(trans('meeting.category.errors.not_found'));
220 220
         }
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
         $disbursement = new Disbursement();
223 223
         $disbursement->amount = $values['amount'];
224 224
         $disbursement->comment = trim($values['comment']);
225
-        if(($member))
225
+        if (($member))
226 226
         {
227 227
             $disbursement->member()->associate($member);
228 228
         }
229
-        if(($charge))
229
+        if (($charge))
230 230
         {
231 231
             $disbursement->charge_lendable = $charge->lendable;
232 232
             $disbursement->charge()->associate($charge);
@@ -254,19 +254,19 @@  discard block
 block discarded – undo
254 254
         $member = $this->getMember($values['member']);
255 255
         $charge = $this->getCharge($values['charge']);
256 256
         $category = $this->getCategory($values['category']);
257
-        if(!$category)
257
+        if (!$category)
258 258
         {
259 259
             throw new MessageException(trans('meeting.category.errors.not_found'));
260 260
         }
261 261
         $disbursement = $session->disbursements()->find($disbursementId);
262
-        if(!$disbursement)
262
+        if (!$disbursement)
263 263
         {
264 264
             throw new MessageException(trans('meeting.disbursement.errors.not_found'));
265 265
         }
266 266
 
267 267
         $disbursement->amount = $values['amount'];
268 268
         $disbursement->comment = trim($values['comment']);
269
-        if(($member))
269
+        if (($member))
270 270
         {
271 271
             $disbursement->member()->associate($member);
272 272
         }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         {
275 275
             $disbursement->member()->dissociate();
276 276
         }
277
-        if(($charge))
277
+        if (($charge))
278 278
         {
279 279
             $disbursement->charge_lendable = $charge->lendable;
280 280
             $disbursement->charge()->associate($charge);
Please login to merge, or discard this patch.
src/Service/Planning/RoundService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
      */
63 63
     public function getRounds(int $page = 0): Collection
64 64
     {
65
-        if(!($tontine = $this->tenantService->tontine()))
65
+        if (!($tontine = $this->tenantService->tontine()))
66 66
         {
67 67
             return collect([]);
68 68
         }
Please login to merge, or discard this patch.
src/Service/Planning/PoolService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
             // Delete the pool
139 139
             $pool->delete();
140 140
         }
141
-        catch(Exception $e)
141
+        catch (Exception $e)
142 142
         {
143 143
             throw new MessageException(trans('tontine.errors.action') .
144 144
                 '<br/>' . trans('tontine.pool.errors.subscription'));
Please login to merge, or discard this patch.
src/Service/Planning/SummaryService.php 1 patch
Spacing   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
         $figures = new stdClass();
70 70
         // Expected figures only for pools with fixed deposit amount
71
-        if($pool->remit_planned /*$pool->deposit_fixed*/)
71
+        if ($pool->remit_planned /*$pool->deposit_fixed*/)
72 72
         {
73 73
             $figures->expected = $this->getExpectedFigures($pool, $sessions, $subscriptions);
74 74
         }
@@ -76,11 +76,10 @@  discard block
 block discarded – undo
76 76
         // Set the subscriptions that will be pay at each session.
77 77
         // Pad with 0's when the beneficiaries are not yet set.
78 78
         $sessions->each(function($session) use($figures, $pool) {
79
-            if($session->enabled($pool))
79
+            if ($session->enabled($pool))
80 80
             {
81 81
                 // Pick the subscriptions ids, and fill with 0's to the max available.
82
-                $remitmentCount = !$pool->deposit_fixed ? 1 :
83
-                    $figures->expected[$session->id]->remitment->count;
82
+                $remitmentCount = !$pool->deposit_fixed ? 1 : $figures->expected[$session->id]->remitment->count;
84 83
                 $session->beneficiaries = $session->payables->map(function($payable) {
85 84
                     return $payable->subscription_id;
86 85
                 })->pad($remitmentCount, 0);
@@ -94,7 +93,7 @@  discard block
 block discarded – undo
94 93
         });
95 94
         $beneficiaries = $beneficiaries->pluck('member.name', 'id');
96 95
         // Do not show the list of subscriptions for pools with auctions
97
-        if($pool->remit_auction)
96
+        if ($pool->remit_auction)
98 97
         {
99 98
             $subscriptions = collect([]);
100 99
         }
Please login to merge, or discard this patch.