Passed
Pull Request — main (#51)
by Thierry
13:39
created
src/Service/Meeting/Charge/BillService.php 1 patch
Spacing   +2 added lines, -5 removed lines patch added patch discarded remove patch
@@ -93,9 +93,7 @@  discard block
 block discarded – undo
93 93
     private function getBillRelation(Charge $charge): string
94 94
     {
95 95
         // The intermediate relation to reach the member model.
96
-        return $charge->is_variable ? 'libre_bill' :
97
-            ($charge->period_session ? 'session_bill' :
98
-            ($charge->period_round ? 'round_bill' : 'tontine_bill'));
96
+        return $charge->is_variable ? 'libre_bill' : ($charge->period_session ? 'session_bill' : ($charge->period_round ? 'round_bill' : 'tontine_bill'));
99 97
     }
100 98
 
101 99
     /**
@@ -111,8 +109,7 @@  discard block
 block discarded – undo
111 109
         string $search = '', ?bool $onlyPaid = null, int $page = 0): Collection
112 110
     {
113 111
         $billRelation = $this->getBillRelation($charge);
114
-        $billRelations = !$charge->is_variable ? [$billRelation . '.member', 'settlement'] :
115
-            ['libre_bill.session', 'libre_bill.member', 'settlement'];
112
+        $billRelations = !$charge->is_variable ? [$billRelation . '.member', 'settlement'] : ['libre_bill.session', 'libre_bill.member', 'settlement'];
116 113
         $query = $this->getBillsQuery($charge, $session, $billRelation, $search, $onlyPaid);
117 114
 
118 115
         return $query->with($billRelations)
Please login to merge, or discard this patch.
src/Service/Meeting/SessionService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function checkPoolsSubscriptions()
85 85
     {
86
-        if($this->tenantService->round()->pools()->whereDoesntHave('subscriptions')->count() > 0)
86
+        if ($this->tenantService->round()->pools()->whereDoesntHave('subscriptions')->count() > 0)
87 87
         {
88 88
             throw new MessageException(trans('tontine.errors.action') .
89 89
                 '<br/>' . trans('tontine.pool.errors.no_subscription'));
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function openSession(Session $session)
131 131
     {
132
-        if($session->opened)
132
+        if ($session->opened)
133 133
         {
134 134
             return;
135 135
         }
Please login to merge, or discard this patch.
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.
src/Service/Planning/SubscriptionService.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
     {
114 114
         // When the remitments are planned, don't create a subscription
115 115
         // if receivables already exist on the pool.
116
-        if($pool->remit_planned &&
116
+        if ($pool->remit_planned &&
117 117
             $pool->subscriptions()->whereHas('receivables')->count() > 0)
118 118
         {
119 119
             throw new MessageException(trans('tontine.subscription.errors.create'));
120 120
         }
121 121
         // Enforce unique subscription per member in pool with libre deposit amount.
122
-        if(!$pool->deposit_fixed &&
122
+        if (!$pool->deposit_fixed &&
123 123
             $pool->subscriptions()->where('member_id', $memberId)->count() > 0)
124 124
         {
125 125
             throw new MessageException(trans('tontine.subscription.errors.create'));
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
     {
150 150
         // When the remitments are planned, don't delete a subscription
151 151
         // if receivables already exist on the pool.
152
-        if($pool->remit_planned &&
152
+        if ($pool->remit_planned &&
153 153
             $pool->subscriptions()->whereHas('receivables')->count() > 0)
154 154
         {
155 155
             throw new MessageException(trans('tontine.subscription.errors.delete'));
156 156
         }
157 157
         $subscription = $pool->subscriptions()->where('member_id', $memberId)
158 158
             ->with(['payable', 'payable.remitment'])->first();
159
-        if(!$subscription)
159
+        if (!$subscription)
160 160
         {
161 161
             throw new MessageException(trans('tontine.subscription.errors.not_found'));
162 162
         }
163
-        if($subscription->payable->remitment !== null)
163
+        if ($subscription->payable->remitment !== null)
164 164
         {
165 165
             throw new MessageException(trans('tontine.subscription.errors.delete'));
166 166
         }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public function unsetPayableSession(Subscription $subscription)
206 206
     {
207
-        if(($subscription->payable->session_id))
207
+        if (($subscription->payable->session_id))
208 208
         {
209 209
             $subscription->payable->session()->dissociate();
210 210
             $subscription->payable->save();
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
     {
227 227
         $session = $this->tenantService->getSession($sessionId);
228 228
         $currSubscription = null;
229
-        if($currSubscriptionId > 0)
229
+        if ($currSubscriptionId > 0)
230 230
         {
231 231
             $currSubscription = $pool->subscriptions()->find($currSubscriptionId);
232
-            if(($currSubscription !== null && $currSubscription->payable !== null &&
232
+            if (($currSubscription !== null && $currSubscription->payable !== null &&
233 233
                 $currSubscription->payable->remitment !== null) || $session->closed)
234 234
             {
235 235
                 // Can't chage the beneficiary if the session is closed or if
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
 
243 243
         DB::transaction(function() use($session, $currSubscription, $nextSubscription) {
244 244
             // If the beneficiary already has a session assigned, first remove it.
245
-            if($currSubscription !== null)
245
+            if ($currSubscription !== null)
246 246
             {
247 247
                 $this->unsetPayableSession($currSubscription);
248 248
             }
249 249
             // If there is a new session assigned to the beneficiary, then save it.
250
-            if($nextSubscription !== null)
250
+            if ($nextSubscription !== null)
251 251
             {
252 252
                 $this->setPayableSession($nextSubscription, $session);
253 253
             }
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/Charge/SettlementService.php 1 patch
Spacing   +10 added lines, -12 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);
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
             ->filter(function($bill) {
176 176
                 return $bill->settlement->editable;
177 177
             });
178
-        if($bills->count() === 0)
178
+        if ($bills->count() === 0)
179 179
         {
180 180
             return;
181 181
         }
@@ -193,9 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function getSettlement(Charge $charge, Session $session): object
195 195
     {
196
-        $billTable = $charge->is_variable ? 'libre_bills' :
197
-            ($charge->period_session ? 'session_bills' :
198
-            ($charge->period_round ? 'round_bills' : 'tontine_bills'));
196
+        $billTable = $charge->is_variable ? 'libre_bills' : ($charge->period_session ? 'session_bills' : ($charge->period_round ? 'round_bills' : 'tontine_bills'));
199 197
 
200 198
         return DB::table('settlements')
201 199
             ->select(DB::raw('count(*) as total'), DB::raw('sum(bills.amount) as amount'))
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.