Passed
Pull Request — main (#55)
by Thierry
05:38
created
src/Service/Meeting/Charge/SettlementService.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,25 +35,25 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @return Builder|Relation
37 37
      */
38
-    private function getQuery(Charge $charge, Session $session): Builder|Relation
38
+    private function getQuery(Charge $charge, Session $session): Builder | Relation
39 39
     {
40 40
         // The select('bills.*') is important here, otherwise Eloquent overrides the
41 41
         // Bill model id fields with those of another model, then making the dataset incorrect.
42 42
         $query = Bill::select('bills.*');
43
-        if($charge->is_variable)
43
+        if ($charge->is_variable)
44 44
         {
45 45
             return $query->join('libre_bills', 'libre_bills.bill_id', '=', 'bills.id')
46 46
                 ->join('sessions', 'sessions.id', '=', 'libre_bills.session_id')
47 47
                 ->where('libre_bills.charge_id', $charge->id)
48 48
                 ->where('sessions.round_id', $session->round_id);
49 49
         }
50
-        if($charge->period_session)
50
+        if ($charge->period_session)
51 51
         {
52 52
             return $query->join('session_bills', 'session_bills.bill_id', '=', 'bills.id')
53 53
                 ->where('session_bills.charge_id', $charge->id)
54 54
                 ->where('session_bills.session_id', $session->id);
55 55
         }
56
-        if($charge->period_round)
56
+        if ($charge->period_round)
57 57
         {
58 58
             return $query->join('round_bills', 'round_bills.bill_id', '=', 'bills.id')
59 59
                 ->where('round_bills.charge_id', $charge->id)
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     {
78 78
         $bill = $this->getQuery($charge, $session)->with('settlement')->find($billId);
79 79
         // Return if the bill is not found or the bill is already settled.
80
-        if(!$bill || ($bill->settlement))
80
+        if (!$bill || ($bill->settlement))
81 81
         {
82 82
             throw new MessageException(trans('tontine.bill.errors.not_found'));
83 83
         }
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
     {
101 101
         $bill = $this->getQuery($charge, $session)->with('settlement')->find($billId);
102 102
         // Return if the bill is not found or the bill is not settled.
103
-        if(!$bill || !($bill->settlement))
103
+        if (!$bill || !($bill->settlement))
104 104
         {
105 105
             throw new MessageException(trans('tontine.bill.errors.not_found'));
106 106
         }
107
-        if((!$bill->settlement->editable))
107
+        if ((!$bill->settlement->editable))
108 108
         {
109 109
             throw new MessageException(trans('tontine.errors.editable'));
110 110
         }
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
     public function createAllSettlements(Charge $charge, Session $session): void
123 123
     {
124 124
         $bills = $this->getQuery($charge, $session)->whereDoesntHave('settlement')->get();
125
-        if($bills->count() === 0)
125
+        if ($bills->count() === 0)
126 126
         {
127 127
             return;
128 128
         }
129 129
 
130 130
         DB::transaction(function() use($bills, $session) {
131
-            foreach($bills as $bill)
131
+            foreach ($bills as $bill)
132 132
             {
133 133
                 $settlement = new Settlement();
134 134
                 $settlement->bill()->associate($bill);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             ->filter(function($bill) {
156 156
                 return $bill->settlement->editable;
157 157
             });
158
-        if($bills->count() === 0)
158
+        if ($bills->count() === 0)
159 159
         {
160 160
             return;
161 161
         }
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
         $query = DB::table('settlements')
177 177
             ->select(DB::raw('count(*) as total'), DB::raw('sum(bills.amount) as amount'))
178 178
             ->join('bills', 'settlements.bill_id', '=', 'bills.id');
179
-        if($charge->is_variable)
179
+        if ($charge->is_variable)
180 180
         {
181 181
             return $query->join('libre_bills', 'libre_bills.bill_id', '=', 'bills.id')
182 182
                 ->where('settlements.session_id', $session->id)
183 183
                 ->where('libre_bills.charge_id', $charge->id)
184 184
                 ->first();
185 185
         }
186
-        if($charge->period_session)
186
+        if ($charge->period_session)
187 187
         {
188 188
             // For session charges, count the bills in the current session that are settled.
189 189
             return $query->join('session_bills', 'session_bills.bill_id', '=', 'bills.id')
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                 ->where('session_bills.session_id', $session->id)
192 192
                 ->first();
193 193
         }
194
-        if($charge->period_round)
194
+        if ($charge->period_round)
195 195
         {
196 196
             return $query->join('round_bills', 'round_bills.bill_id', '=', 'bills.id')
197 197
                 ->where('settlements.session_id', $session->id)
Please login to merge, or discard this patch.
app/Ajax/Web/Meeting/Charge/Libre/Member.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
     private function convertAmount(string $amount): float
134 134
     {
135 135
         $amount = str_replace(',', '.', trim($amount));
136
-        if($amount !== '' && filter_var($amount, FILTER_VALIDATE_FLOAT) === false)
136
+        if ($amount !== '' && filter_var($amount, FILTER_VALIDATE_FLOAT) === false)
137 137
         {
138 138
             throw new MessageException(trans('meeting.errors.amount.invalid', [
139 139
                 'amount' => $amount,
140 140
             ]));
141 141
         }
142
-        return $amount === '' ? 0 : (float)$amount;
142
+        return $amount === '' ? 0 : (float) $amount;
143 143
     }
144 144
 
145 145
     /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function addBill(int $memberId, bool $paid, string $amount = '')
152 152
     {
153
-        if($this->session->closed)
153
+        if ($this->session->closed)
154 154
         {
155 155
             $this->notify->warning(trans('meeting.warnings.session.closed'));
156 156
             return $this->response;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      */
170 170
     public function delBill(int $memberId)
171 171
     {
172
-        if($this->session->closed)
172
+        if ($this->session->closed)
173 173
         {
174 174
             $this->notify->warning(trans('meeting.warnings.session.closed'));
175 175
             return $this->response;
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function editBill(int $memberId)
190 190
     {
191
-        if($this->session->closed)
191
+        if ($this->session->closed)
192 192
         {
193 193
             $this->notify->warning(trans('meeting.warnings.session.closed'));
194 194
             return $this->response;
195 195
         }
196 196
         $bill = $this->feeService->getBill($this->charge, $this->session, $memberId);
197
-        if($bill === null)
197
+        if ($bill === null)
198 198
         {
199 199
             return $this->response;
200 200
         }
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function saveBill(int $memberId, string $amount)
223 223
     {
224
-        if($this->session->closed)
224
+        if ($this->session->closed)
225 225
         {
226 226
             $this->notify->warning(trans('meeting.warnings.session.closed'));
227 227
             return $this->response;
228 228
         }
229 229
 
230 230
         $amount = $this->convertAmount($amount);
231
-        if(!$amount)
231
+        if (!$amount)
232 232
         {
233 233
             $this->feeService->deleteBill($this->charge, $this->session, $memberId);
234 234
             return $this->page();
Please login to merge, or discard this patch.
app/Http/Controllers/ReportController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $session = $this->sessionService->getSession($sessionId);
60 60
         view()->share($this->reportService->getSessionReport($session));
61 61
         // Show the html page
62
-        if($request->has('html'))
62
+        if ($request->has('html'))
63 63
         {
64 64
             return view($this->printerService->getSessionReportPath());
65 65
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $session = $this->sessionService->getSession($sessionId);
98 98
         view()->share($this->reportService->getSavingsReport($session));
99 99
         // Show the html page
100
-        if($request->has('html'))
100
+        if ($request->has('html'))
101 101
         {
102 102
             return view($this->printerService->getSavingsReportPath());
103 103
         }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $round = $this->roundService->getRound($roundId);
120 120
         view()->share($this->reportService->getRoundReport($round));
121 121
         // Show the html page
122
-        if($request->has('html'))
122
+        if ($request->has('html'))
123 123
         {
124 124
             return view($this->printerService->getRoundReportPath());
125 125
         }
Please login to merge, or discard this patch.
src/Service/Planning/RoundService.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function getRounds(int $page = 0): Collection
35 35
     {
36
-        if(!($tontine = $this->tenantService->tontine()))
36
+        if (!($tontine = $this->tenantService->tontine()))
37 37
         {
38 38
             return collect([]);
39 39
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                 $tontine->rounds()->where('id', $roundId)->delete();
116 116
             });
117 117
         }
118
-        catch(Exception $e)
118
+        catch (Exception $e)
119 119
         {
120 120
             throw new MessageException(trans('tontine.round.errors.delete'));
121 121
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -114,8 +114,7 @@
 block discarded – undo
114 114
                 $tontine->sessions()->where('round_id', $roundId)->delete();
115 115
                 $tontine->rounds()->where('id', $roundId)->delete();
116 116
             });
117
-        }
118
-        catch(Exception $e)
117
+        } catch(Exception $e)
119 118
         {
120 119
             throw new MessageException(trans('tontine.round.errors.delete'));
121 120
         }
Please login to merge, or discard this patch.
src/Service/Meeting/SummaryService.php 1 patch
Spacing   +7 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@  discard block
 block discarded – undo
46 46
         $figures->cashier->recv = $cashier;
47 47
 
48 48
         $depositCount = !$deposit ? 0 : $deposit->total;
49
-        $depositAmount = $pool->deposit_fixed ? $pool->amount * $depositCount :
50
-            (!$deposit ? 0 : $deposit->amount);
49
+        $depositAmount = $pool->deposit_fixed ? $pool->amount * $depositCount : (!$deposit ? 0 : $deposit->amount);
51 50
 
52 51
         $figures->deposit->amount += $depositAmount;
53 52
         $figures->cashier->recv += $depositAmount;
@@ -55,8 +54,7 @@  discard block
 block discarded – undo
55 54
 
56 55
         $sessionCount = $pool->counter->sessions - $pool->counter->disabled_sessions;
57 56
         $remitmentCount = !$remitment ? 0 : $remitment->total;
58
-        $remitmentAmount = !$pool->deposit_fixed ? $depositAmount :
59
-            $pool->amount * $sessionCount * $remitmentCount;
57
+        $remitmentAmount = !$pool->deposit_fixed ? $depositAmount : $pool->amount * $sessionCount * $remitmentCount;
60 58
 
61 59
         $figures->cashier->end = $figures->cashier->recv;
62 60
         $figures->remitment->amount += $remitmentAmount;
@@ -80,9 +78,9 @@  discard block
 block discarded – undo
80 78
     {
81 79
         $cashier = 0;
82 80
         $collectedFigures = [];
83
-        foreach($sessions as $session)
81
+        foreach ($sessions as $session)
84 82
         {
85
-            if(($disabledSessions && $disabledSessions->has($session->id)) || $session->pending)
83
+            if (($disabledSessions && $disabledSessions->has($session->id)) || $session->pending)
86 84
             {
87 85
                 $collectedFigures[$session->id] = $this->makeFigures(' ');
88 86
                 continue;
@@ -149,11 +147,10 @@  discard block
 block discarded – undo
149 147
         return $pools->map(function($pool) use($allSessions, $deposits, $remitments, $disabledSessions) {
150 148
             $disabledSessions = $disabledSessions[$pool->id] ?? null;
151 149
             // Enabled sessions
152
-            $sessions = !$disabledSessions ? $allSessions :
153
-                $allSessions->filter(fn($session) => !$disabledSessions->has($session->id));
150
+            $sessions = !$disabledSessions ? $allSessions : $allSessions->filter(fn($session) => !$disabledSessions->has($session->id));
154 151
 
155 152
             $figures = new stdClass();
156
-            if($pool->remit_planned)
153
+            if ($pool->remit_planned)
157 154
             {
158 155
                 $depositCount = $pool->subscriptions()->count();
159 156
                 $figures->expected = $this->getExpectedFigures($pool, $sessions, $depositCount);
@@ -172,7 +169,7 @@  discard block
 block discarded – undo
172 169
      */
173 170
     public function getSessionRemitmentCount(Pool $pool, Session $session): int
174 171
     {
175
-        if(!$pool->deposit_fixed)
172
+        if (!$pool->deposit_fixed)
176 173
         {
177 174
             return 1;
178 175
         }
Please login to merge, or discard this patch.
app/Ajax/Web/Tontine/Select.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             'title' => trans('common.actions.close'),
34 34
             'class' => 'btn btn-tertiary',
35 35
             'click' => 'close',
36
-        ],[
36
+        ], [
37 37
             'title' => trans('common.actions.save'),
38 38
             'class' => 'btn btn-primary',
39 39
             'click' => $this->rq()->saveTontine(pm()->select('tontine_id')->toInt()),
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function saveTontine(int $tontineId)
47 47
     {
48
-        if(!($tontine = $this->tontineService->getTontine($tontineId)))
48
+        if (!($tontine = $this->tontineService->getTontine($tontineId)))
49 49
         {
50 50
             return $this->response;
51 51
         }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
         $this->selectTontine($tontine);
57 57
 
58
-        if(($round = $tontine->rounds->first()))
58
+        if (($round = $tontine->rounds->first()))
59 59
         {
60 60
             return $this->saveRound($round->id);
61 61
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     public function showRounds()
71 71
     {
72
-        if(!($tontine = $this->tenantService->tontine()))
72
+        if (!($tontine = $this->tenantService->tontine()))
73 73
         {
74 74
             return $this->response;
75 75
         }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             'title' => trans('common.actions.close'),
81 81
             'class' => 'btn btn-tertiary',
82 82
             'click' => 'close',
83
-        ],[
83
+        ], [
84 84
             'title' => trans('common.actions.save'),
85 85
             'class' => 'btn btn-primary',
86 86
             'click' => $this->rq()->saveRound(pm()->select('round_id')->toInt()),
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 
93 93
     public function saveRound(int $roundId)
94 94
     {
95
-        if(!($tontine = $this->tenantService->tontine()))
95
+        if (!($tontine = $this->tenantService->tontine()))
96 96
         {
97 97
             return $this->response;
98 98
         }
99
-        if(!($round = $this->roundService->getRound($roundId)))
99
+        if (!($round = $this->roundService->getRound($roundId)))
100 100
         {
101 101
             return $this->response;
102 102
         }
Please login to merge, or discard this patch.
app/Ajax/Web/Planning/Round.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             'title' => trans('common.actions.cancel'),
69 69
             'class' => 'btn btn-tertiary',
70 70
             'click' => 'close',
71
-        ],[
71
+        ], [
72 72
             'title' => trans('common.actions.save'),
73 73
             'class' => 'btn btn-primary',
74 74
             'click' => $this->rq()->create(pm()->form('round-form')),
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             'title' => trans('common.actions.cancel'),
100 100
             'class' => 'btn btn-tertiary',
101 101
             'click' => 'close',
102
-        ],[
102
+        ], [
103 103
             'title' => trans('common.actions.save'),
104 104
             'class' => 'btn btn-primary',
105 105
             'click' => $this->rq()->update($round->id, pm()->form('round-form')),
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         $this->notify->success(trans('tontine.round.messages.deleted'), trans('common.titles.success'));
129 129
 
130 130
         $currentRound = $this->tenantService->round();
131
-        if($currentRound !== null && $currentRound->id === $roundId)
131
+        if ($currentRound !== null && $currentRound->id === $roundId)
132 132
         {
133 133
             // If the currently selected round is deleted, then choose another.
134 134
             $this->cl(Select::class)->setTenantService($this->tenantService)
Please login to merge, or discard this patch.
app/Ajax/Web/Report/Session/Saving.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
     public function home(int $fundId)
50 50
     {
51 51
         $funds = $this->fundService->getFundList();
52
-        if(!isset($funds[$fundId]))
52
+        if (!isset($funds[$fundId]))
53 53
         {
54 54
             return $this->response;
55 55
         }
Please login to merge, or discard this patch.
src/Service/Tontine/MemberService.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return Builder|Relation
49 49
      */
50
-    private function getQuery(string $search = ''): Builder|Relation
50
+    private function getQuery(string $search = ''): Builder | Relation
51 51
     {
52 52
         return $this->tenantService->tontine()->members()
53 53
             ->when($this->filterActive, fn(Builder $query) => $query->active())
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     private function saveActiveMembers()
118 118
     {
119
-        if(!($tontine = $this->tenantService->tontine()) ||
119
+        if (!($tontine = $this->tenantService->tontine()) ||
120 120
             !($round = $this->tenantService->round()))
121 121
         {
122 122
             return;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         // The number of active members is saved in the round, so its current
137 137
         // value can be retrieved forever, even when the membership will change.
138 138
         $round = $this->tenantService->round();
139
-        if(!isset($round->properties['members']))
139
+        if (!isset($round->properties['members']))
140 140
         {
141 141
             // Create and save the property with the content
142 142
             $this->saveActiveMembers();
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             $tontine = $this->tenantService->tontine();
180 180
             $members = $tontine->members()->createMany($values);
181 181
             // Create members bills
182
-            foreach($members as $member)
182
+            foreach ($members as $member)
183 183
             {
184 184
                 $this->memberCreated($tontine, $member);
185 185
             }
Please login to merge, or discard this patch.