Passed
Push — main ( 25adab...078388 )
by Thierry
06:09
created
src/Service/Meeting/Pool/DepositService.php 2 patches
Spacing   +11 added lines, -11 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,16 +147,16 @@  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
-        if((!$receivable->deposit->editable))
154
+        if ((!$receivable->deposit->editable))
155 155
         {
156 156
             throw new MessageException(trans('tontine.errors.editable'));
157 157
         }
158 158
 
159
-        if($receivable->deposit !== null)
159
+        if ($receivable->deposit !== null)
160 160
         {
161 161
             $receivable->deposit->amount = $amount;
162 162
             $receivable->deposit->save();
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
     public function deleteDeposit(Pool $pool, Session $session, int $receivableId): void
183 183
     {
184 184
         $receivable = $this->getReceivable($pool, $session, $receivableId);
185
-        if(!$receivable || !$receivable->deposit)
185
+        if (!$receivable || !$receivable->deposit)
186 186
         {
187 187
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
188 188
         }
189
-        if((!$receivable->deposit->editable))
189
+        if ((!$receivable->deposit->editable))
190 190
         {
191 191
             throw new MessageException(trans('tontine.errors.editable'));
192 192
         }
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
     public function createAllDeposits(Pool $pool, Session $session): void
205 205
     {
206 206
         $receivables = $this->getQuery($pool, $session)->whereDoesntHave('deposit')->get();
207
-        if($receivables->count() === 0)
207
+        if ($receivables->count() === 0)
208 208
         {
209 209
             return;
210 210
         }
211 211
 
212 212
         DB::transaction(function() use($session, $receivables) {
213
-            foreach($receivables as $receivable)
213
+            foreach ($receivables as $receivable)
214 214
             {
215 215
                 $deposit = new Deposit();
216 216
                 $deposit->receivable()->associate($receivable);
@@ -232,19 +232,19 @@  discard block
 block discarded – undo
232 232
     {
233 233
         $receivables = $this->getQuery($pool, $session)
234 234
             ->with(['deposit'])->whereHas('deposit')->get();
235
-        if($receivables->count() === 0)
235
+        if ($receivables->count() === 0)
236 236
         {
237 237
             return;
238 238
         }
239 239
 
240 240
         DB::transaction(function() use($session, $receivables) {
241
-            foreach($receivables as $receivable)
241
+            foreach ($receivables as $receivable)
242 242
             {
243 243
                 try
244 244
                 {
245 245
                     $receivable->deposit()->where('session_id', $session->id)->delete();
246 246
                 }
247
-                catch(\Exception $e){}
247
+                catch (\Exception $e) {}
248 248
             }
249 249
         });
250 250
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -243,8 +243,7 @@
 block discarded – undo
243 243
                 try
244 244
                 {
245 245
                     $receivable->deposit()->where('session_id', $session->id)->delete();
246
-                }
247
-                catch(\Exception $e){}
246
+                } catch(\Exception $e){}
248 247
             }
249 248
         });
250 249
     }
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/Charge/SettlementService.php 1 patch
Spacing   +11 added lines, -13 removed lines patch added patch discarded remove patch
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
         // The select('bills.*') is important here, otherwise Eloquent overrides the
63 63
         // Bill model id fields with those of another model, then making the dataset incorrect.
64 64
         $query = Bill::select('bills.*');
65
-        if($charge->is_variable)
65
+        if ($charge->is_variable)
66 66
         {
67 67
             return $query->join('libre_bills', 'libre_bills.bill_id', '=', 'bills.id')
68 68
                 ->where('libre_bills.charge_id', $charge->id)
69 69
                 ->where('libre_bills.session_id', $session->id);
70 70
         }
71
-        if($charge->period_session)
71
+        if ($charge->period_session)
72 72
         {
73 73
             return $query->join('session_bills', 'session_bills.bill_id', '=', 'bills.id')
74 74
                 ->where('session_bills.charge_id', $charge->id)
75 75
                 ->where('session_bills.session_id', $session->id);
76 76
         }
77
-        if($charge->period_round)
77
+        if ($charge->period_round)
78 78
         {
79 79
             return $query->join('round_bills', 'round_bills.bill_id', '=', 'bills.id')
80 80
                 ->where('round_bills.charge_id', $charge->id);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         $bill = $this->getQuery($charge, $session)->with('settlement')->find($billId);
99 99
         // Return if the bill is not found or the bill is already settled.
100
-        if(!$bill || ($bill->settlement))
100
+        if (!$bill || ($bill->settlement))
101 101
         {
102 102
             throw new MessageException(trans('tontine.bill.errors.not_found'));
103 103
         }
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $bill = $this->getQuery($charge, $session)->with('settlement')->find($billId);
122 122
         // Return if the bill is not found or the bill is not settled.
123
-        if(!$bill || !($bill->settlement))
123
+        if (!$bill || !($bill->settlement))
124 124
         {
125 125
             throw new MessageException(trans('tontine.bill.errors.not_found'));
126 126
         }
127
-        if((!$bill->settlement->editable))
127
+        if ((!$bill->settlement->editable))
128 128
         {
129 129
             throw new MessageException(trans('tontine.errors.editable'));
130 130
         }
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
     public function createAllSettlements(Charge $charge, Session $session): void
143 143
     {
144 144
         $bills = $this->getQuery($charge, $session)->whereDoesntHave('settlement')->get();
145
-        if($bills->count() === 0)
145
+        if ($bills->count() === 0)
146 146
         {
147 147
             return;
148 148
         }
149 149
 
150 150
         DB::transaction(function() use($bills, $session) {
151
-            foreach($bills as $bill)
151
+            foreach ($bills as $bill)
152 152
             {
153 153
                 $settlement = new Settlement();
154 154
                 $settlement->bill()->associate($bill);
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
             ->filter(function($bill) {
175 175
                 return $bill->settlement->editable;
176 176
             });
177
-        if($bills->count() === 0)
177
+        if ($bills->count() === 0)
178 178
         {
179 179
             return;
180 180
         }
181 181
         DB::transaction(function() use($bills, $session) {
182
-            foreach($bills as $bill)
182
+            foreach ($bills as $bill)
183 183
             {
184 184
                 $bill->settlement()->where('session_id', $session->id)->delete();
185 185
             }
@@ -194,9 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     public function getSettlement(Charge $charge, Session $session): object
196 196
     {
197
-        $billTable = $charge->is_variable ? 'libre_bills' :
198
-            ($charge->period_session ? 'session_bills' :
199
-            ($charge->period_round ? 'round_bills' : 'tontine_bills'));
197
+        $billTable = $charge->is_variable ? 'libre_bills' : ($charge->period_session ? 'session_bills' : ($charge->period_round ? 'round_bills' : 'tontine_bills'));
200 198
 
201 199
         return DB::table('settlements')
202 200
             ->select(DB::raw('count(*) as total'), DB::raw('sum(bills.amount) as amount'))
Please login to merge, or discard this patch.