@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return Builder|Relation |
50 | 50 | */ |
51 | - public function getQuery(Pool $pool, string $search, ?bool $filter): Builder|Relation |
|
51 | + public function getQuery(Pool $pool, string $search, ?bool $filter): Builder | Relation |
|
52 | 52 | { |
53 | 53 | return $this->tenantService->tontine()->members()->active() |
54 | 54 | ->when($filter === true, function(Builder $query) use($pool) { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | ->withCount('receivables') |
157 | 157 | ->get() |
158 | 158 | ->sortBy('receivables_count'); |
159 | - if($subscriptions->count() === 0) |
|
159 | + if ($subscriptions->count() === 0) |
|
160 | 160 | { |
161 | 161 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
162 | 162 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function unsetPayableSession(Subscription $subscription) |
207 | 207 | { |
208 | - if(($subscription->payable->session_id)) |
|
208 | + if (($subscription->payable->session_id)) |
|
209 | 209 | { |
210 | 210 | $subscription->payable->session()->dissociate(); |
211 | 211 | $subscription->payable->save(); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | private function canChangeBeneficiary(Session $session, ?Subscription $subscription): bool |
222 | 222 | { |
223 | 223 | // Can't change the beneficiary if the session is closed, |
224 | - if($session->closed) |
|
224 | + if ($session->closed) |
|
225 | 225 | { |
226 | 226 | return false; |
227 | 227 | } |
@@ -246,17 +246,17 @@ discard block |
||
246 | 246 | $session = $pool->sessions()->find($sessionId); |
247 | 247 | $currSubscription = null; |
248 | 248 | $nextSubscription = null; |
249 | - if($currSubscriptionId > 0) |
|
249 | + if ($currSubscriptionId > 0) |
|
250 | 250 | { |
251 | 251 | $currSubscription = $pool->subscriptions() |
252 | 252 | ->with('payable') |
253 | 253 | ->find($currSubscriptionId); |
254 | - if(!$this->canChangeBeneficiary($session, $currSubscription)) |
|
254 | + if (!$this->canChangeBeneficiary($session, $currSubscription)) |
|
255 | 255 | { |
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | } |
259 | - if($nextSubscriptionId > 0) |
|
259 | + if ($nextSubscriptionId > 0) |
|
260 | 260 | { |
261 | 261 | $nextSubscription = $pool->subscriptions() |
262 | 262 | ->with('payable') |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | |
266 | 266 | DB::transaction(function() use($session, $currSubscription, $nextSubscription) { |
267 | 267 | // If the beneficiary already has a session assigned, first remove it. |
268 | - if($currSubscription !== null) |
|
268 | + if ($currSubscription !== null) |
|
269 | 269 | { |
270 | 270 | $this->unsetPayableSession($currSubscription); |
271 | 271 | } |
272 | 272 | // If there is a new session assigned to the beneficiary, then save it. |
273 | - if($nextSubscription !== null) |
|
273 | + if ($nextSubscription !== null) |
|
274 | 274 | { |
275 | 275 | $this->setPayableSession($nextSubscription, $session); |
276 | 276 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return Builder|Relation |
31 | 31 | */ |
32 | - private function getQuery(Pool $pool, Session $session): Builder|Relation |
|
32 | + private function getQuery(Pool $pool, Session $session): Builder | Relation |
|
33 | 33 | { |
34 | 34 | return $session->receivables() |
35 | 35 | ->select('receivables.*') |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public function createDeposit(Pool $pool, Session $session, int $receivableId): void |
101 | 101 | { |
102 | 102 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
103 | - if(!$receivable || $receivable->deposit || !$pool->deposit_fixed) |
|
103 | + if (!$receivable || $receivable->deposit || !$pool->deposit_fixed) |
|
104 | 104 | { |
105 | 105 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
106 | 106 | } |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | public function saveDepositAmount(Pool $pool, Session $session, int $receivableId, int $amount): void |
125 | 125 | { |
126 | 126 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
127 | - if(!$receivable || $pool->deposit_fixed) |
|
127 | + if (!$receivable || $pool->deposit_fixed) |
|
128 | 128 | { |
129 | 129 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
130 | 130 | } |
131 | 131 | |
132 | - if($receivable->deposit !== null) |
|
132 | + if ($receivable->deposit !== null) |
|
133 | 133 | { |
134 | - if((!$receivable->deposit->editable)) |
|
134 | + if ((!$receivable->deposit->editable)) |
|
135 | 135 | { |
136 | 136 | throw new MessageException(trans('tontine.errors.editable')); |
137 | 137 | } |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | public function deleteDeposit(Pool $pool, Session $session, int $receivableId): void |
161 | 161 | { |
162 | 162 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
163 | - if(!$receivable || !$receivable->deposit) |
|
163 | + if (!$receivable || !$receivable->deposit) |
|
164 | 164 | { |
165 | 165 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
166 | 166 | } |
167 | - if((!$receivable->deposit->editable)) |
|
167 | + if ((!$receivable->deposit->editable)) |
|
168 | 168 | { |
169 | 169 | throw new MessageException(trans('tontine.errors.editable')); |
170 | 170 | } |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | public function createAllDeposits(Pool $pool, Session $session): void |
183 | 183 | { |
184 | 184 | $receivables = $this->getQuery($pool, $session)->whereDoesntHave('deposit')->get(); |
185 | - if($receivables->count() === 0) |
|
185 | + if ($receivables->count() === 0) |
|
186 | 186 | { |
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
190 | 190 | DB::transaction(function() use($session, $receivables) { |
191 | - foreach($receivables as $receivable) |
|
191 | + foreach ($receivables as $receivable) |
|
192 | 192 | { |
193 | 193 | $deposit = new Deposit(); |
194 | 194 | $deposit->receivable()->associate($receivable); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ->filter(function($receivable) { |
216 | 216 | return $receivable->deposit->editable; |
217 | 217 | }); |
218 | - if($receivables->count() === 0) |
|
218 | + if ($receivables->count() === 0) |
|
219 | 219 | { |
220 | 220 | return; |
221 | 221 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return Builder|Relation |
41 | 41 | */ |
42 | - private function getQuery(Pool $pool, Session $session): Builder|Relation |
|
42 | + private function getQuery(Pool $pool, Session $session): Builder | Relation |
|
43 | 43 | { |
44 | 44 | return $session->payables() |
45 | 45 | ->select('payables.*') |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | ->each(function($payable) use($amount) { |
80 | 80 | $payable->amount = $amount; |
81 | 81 | }); |
82 | - if(!$pool->remit_planned) |
|
82 | + if (!$pool->remit_planned) |
|
83 | 83 | { |
84 | 84 | return $payables; |
85 | 85 | } |
86 | 86 | |
87 | 87 | // When the number of remitments is planned, the list is padded to the expected number. |
88 | 88 | $remitmentCount = $this->summaryService->getSessionRemitmentCount($pool, $session); |
89 | - $emptyPayable = (object)[ |
|
89 | + $emptyPayable = (object) [ |
|
90 | 90 | 'id' => 0, |
91 | 91 | 'member' =>trans('tontine.remitment.labels.not-assigned'), |
92 | 92 | 'amount' => $amount, |
@@ -122,18 +122,18 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function savePlannedRemitment(Pool $pool, Session $session, int $payableId): void |
124 | 124 | { |
125 | - if(!$pool->remit_planned || $pool->remit_auction) |
|
125 | + if (!$pool->remit_planned || $pool->remit_auction) |
|
126 | 126 | { |
127 | 127 | // Only when remitments are planned and without auctions. |
128 | 128 | return; |
129 | 129 | } |
130 | 130 | // The payable is supposed to already have been associated to the session. |
131 | 131 | $payable = $this->getPayable($pool, $session, $payableId); |
132 | - if(!$payable) |
|
132 | + if (!$payable) |
|
133 | 133 | { |
134 | 134 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
135 | 135 | } |
136 | - if($payable->remitment) |
|
136 | + if ($payable->remitment) |
|
137 | 137 | { |
138 | 138 | return; |
139 | 139 | } |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | ->whereDoesntHave('remitment') |
159 | 159 | ->whereIn('subscription_id', $pool->subscriptions()->pluck('id')) |
160 | 160 | ->find($payableId); |
161 | - if(!$payable) |
|
161 | + if (!$payable) |
|
162 | 162 | { |
163 | 163 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
164 | 164 | } |
165 | - if($payable->session_id !== null && $payable->session_id !== $session->id) |
|
165 | + if ($payable->session_id !== null && $payable->session_id !== $session->id) |
|
166 | 166 | { |
167 | 167 | // The selected member is already planned on another session. |
168 | 168 | throw new MessageException(trans('tontine.remitment.errors.planning')); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | // Create the remitment. |
176 | 176 | $remitment = $payable->remitment()->create([]); |
177 | 177 | |
178 | - if($pool->remit_auction && $auction > 0) |
|
178 | + if ($pool->remit_auction && $auction > 0) |
|
179 | 179 | { |
180 | 180 | // Create the corresponding auction. |
181 | 181 | Auction::create([ |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $payable = $this->getQuery($pool, $session) |
203 | 203 | ->with(['remitment', 'remitment.auction']) |
204 | 204 | ->find($payableId); |
205 | - if(!$payable || !($remitment = $payable->remitment)) |
|
205 | + if (!$payable || !($remitment = $payable->remitment)) |
|
206 | 206 | { |
207 | 207 | return; |
208 | 208 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $remitment->auction()->delete(); |
213 | 213 | $remitment->delete(); |
214 | 214 | // Detach from the session, but only if the remitment was not planned. |
215 | - if(!$pool->remit_planned || $pool->remit_auction) |
|
215 | + if (!$pool->remit_planned || $pool->remit_auction) |
|
216 | 216 | { |
217 | 217 | $payable->session()->dissociate(); |
218 | 218 | $payable->save(); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | ->with(['payable', 'member']) |
238 | 238 | ->select('subscriptions.*') |
239 | 239 | ->get(); |
240 | - if($pool->remit_planned && !$pool->remit_auction) |
|
240 | + if ($pool->remit_planned && !$pool->remit_auction) |
|
241 | 241 | { |
242 | 242 | // Only the beneficiaries that are not yet planned. |
243 | 243 | return $subscriptions |
@@ -34,13 +34,13 @@ |
||
34 | 34 | 'amount' => 'required|regex:/^\d+(\.\d{1,2})?$/', |
35 | 35 | 'fund' => 'required|integer|min:0', |
36 | 36 | ]); |
37 | - if($validator->fails()) |
|
37 | + if ($validator->fails()) |
|
38 | 38 | { |
39 | 39 | throw new ValidationException($validator); |
40 | 40 | } |
41 | 41 | |
42 | 42 | $validated = $validator->validated(); |
43 | - $validated['amount'] = $this->localeService->convertMoneyToInt((float)$validated['amount']); |
|
43 | + $validated['amount'] = $this->localeService->convertMoneyToInt((float) $validated['amount']); |
|
44 | 44 | return $validated; |
45 | 45 | } |
46 | 46 | } |
@@ -46,9 +46,8 @@ discard block |
||
46 | 46 | |
47 | 47 | protected function getFundId() |
48 | 48 | { |
49 | - $this->fundId = (int)($this->target()->method() === 'home' ? |
|
50 | - $this->target()->args()[0] : |
|
51 | - $this->bag('meeting.saving')->get('fund.id', 0)); |
|
49 | + $this->fundId = (int) ($this->target()->method() === 'home' ? |
|
50 | + $this->target()->args()[0] : $this->bag('meeting.saving')->get('fund.id', 0)); |
|
52 | 51 | } |
53 | 52 | |
54 | 53 | /** |
@@ -137,7 +136,7 @@ discard block |
||
137 | 136 | */ |
138 | 137 | public function editSaving(int $memberId) |
139 | 138 | { |
140 | - if($this->session->closed) |
|
139 | + if ($this->session->closed) |
|
141 | 140 | { |
142 | 141 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
143 | 142 | return $this->response; |
@@ -170,14 +169,14 @@ discard block |
||
170 | 169 | */ |
171 | 170 | public function saveSaving(int $memberId, string $amount) |
172 | 171 | { |
173 | - if($this->session->closed) |
|
172 | + if ($this->session->closed) |
|
174 | 173 | { |
175 | 174 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
176 | 175 | return $this->response; |
177 | 176 | } |
178 | 177 | |
179 | 178 | $amount = str_replace(',', '.', trim($amount)); |
180 | - if($amount === '') |
|
179 | + if ($amount === '') |
|
181 | 180 | { |
182 | 181 | $this->savingService->deleteSaving($this->session, 0, $memberId); |
183 | 182 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $html = $this->render('pages.meeting.saving.home', [ |
50 | 50 | 'session' => $this->session, |
51 | - 'fundId' => (int)$this->bag('meeting.saving')->get('fund.id', -1), |
|
51 | + 'fundId' => (int) $this->bag('meeting.saving')->get('fund.id', -1), |
|
52 | 52 | 'funds' => $this->fundService->getFundList()->prepend('', -1), |
53 | 53 | ]); |
54 | 54 | $this->response->html('meeting-savings', $html); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public function page(int $pageNumber = 0) |
65 | 65 | { |
66 | - $fundId = (int)$this->bag('meeting.saving')->get('fund.id', -1); |
|
66 | + $fundId = (int) $this->bag('meeting.saving')->get('fund.id', -1); |
|
67 | 67 | $savingCount = $this->savingService->getSavingCount($this->session, $fundId); |
68 | 68 | $savingSum = $this->savingService->getSavingSum($this->session, $fundId); |
69 | 69 | [$pageNumber, $perPage] = $this->pageNumber($pageNumber, $savingCount, |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | public function editSaving(int $savingId) |
99 | 99 | { |
100 | - if($this->session->closed) |
|
100 | + if ($this->session->closed) |
|
101 | 101 | { |
102 | 102 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
103 | 103 | return $this->response; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | 'title' => trans('common.actions.cancel'), |
115 | 115 | 'class' => 'btn btn-tertiary', |
116 | 116 | 'click' => 'close', |
117 | - ],[ |
|
117 | + ], [ |
|
118 | 118 | 'title' => trans('common.actions.save'), |
119 | 119 | 'class' => 'btn btn-primary', |
120 | 120 | 'click' => $this->rq()->updateSaving($savingId, pm()->form('saving-form')), |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function updateSaving(int $savingId, array $formValues) |
132 | 132 | { |
133 | - if($this->session->closed) |
|
133 | + if ($this->session->closed) |
|
134 | 134 | { |
135 | 135 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
136 | 136 | return $this->response; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function deleteSaving(int $savingId) |
151 | 151 | { |
152 | - if($this->session->closed) |
|
152 | + if ($this->session->closed) |
|
153 | 153 | { |
154 | 154 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
155 | 155 | return $this->response; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | $figures = new stdClass(); |
64 | 64 | // Expected figures only for pools with fixed deposit amount |
65 | - if($pool->remit_planned /*$pool->deposit_fixed*/) |
|
65 | + if ($pool->remit_planned /*$pool->deposit_fixed*/) |
|
66 | 66 | { |
67 | 67 | $depositCount = $subscriptions->count(); |
68 | 68 | $figures->expected = $this->getExpectedFigures($pool, $sessions, $depositCount); |
@@ -71,11 +71,10 @@ discard block |
||
71 | 71 | // Set the subscriptions that will be pay at each session. |
72 | 72 | // Pad with 0's when the beneficiaries are not yet set. |
73 | 73 | $sessions->each(function($session) use($figures, $pool) { |
74 | - if($session->enabled($pool)) |
|
74 | + if ($session->enabled($pool)) |
|
75 | 75 | { |
76 | 76 | // Pick the subscriptions ids, and fill with 0's to the max available. |
77 | - $remitmentCount = !$pool->deposit_fixed ? 1 : |
|
78 | - $figures->expected[$session->id]->remitment->count; |
|
77 | + $remitmentCount = !$pool->deposit_fixed ? 1 : $figures->expected[$session->id]->remitment->count; |
|
79 | 78 | $session->beneficiaries = $session->payables->map(function($payable) { |
80 | 79 | return $payable->subscription_id; |
81 | 80 | })->pad($remitmentCount, 0); |
@@ -89,7 +88,7 @@ discard block |
||
89 | 88 | }); |
90 | 89 | $beneficiaries = $beneficiaries->pluck('member.name', 'id'); |
91 | 90 | // Do not show the list of subscriptions for pools with auctions |
92 | - if($pool->remit_auction) |
|
91 | + if ($pool->remit_auction) |
|
93 | 92 | { |
94 | 93 | $subscriptions = collect([]); |
95 | 94 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return Builder|Relation |
38 | 38 | */ |
39 | - private function getSavingQuery(Session $session, int $fundId): Builder|Relation |
|
39 | + private function getSavingQuery(Session $session, int $fundId): Builder | Relation |
|
40 | 40 | { |
41 | 41 | // $fundId < 0 => all the savings |
42 | 42 | // $fundId === 0 => savings of the default fund |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $saving->amount = $amount; |
141 | 141 | $saving->member()->associate($member); |
142 | 142 | $saving->session()->associate($session); |
143 | - if($fund !== null) |
|
143 | + if ($fund !== null) |
|
144 | 144 | { |
145 | 145 | $saving->fund()->associate($fund); |
146 | 146 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function createSaving(Session $session, array $values): void |
163 | 163 | { |
164 | - if(!($member = $this->getMember($values['member']))) |
|
164 | + if (!($member = $this->getMember($values['member']))) |
|
165 | 165 | { |
166 | 166 | throw new MessageException(trans('tontine.member.errors.not_found')); |
167 | 167 | } |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function updateSaving(Session $session, int $savingId, array $values): void |
184 | 184 | { |
185 | - if(!($member = $this->getMember($values['member']))) |
|
185 | + if (!($member = $this->getMember($values['member']))) |
|
186 | 186 | { |
187 | 187 | throw new MessageException(trans('tontine.member.errors.not_found')); |
188 | 188 | } |
189 | 189 | $saving = $session->savings()->find($savingId); |
190 | - if(!$saving) |
|
190 | + if (!$saving) |
|
191 | 191 | { |
192 | 192 | throw new MessageException(trans('meeting.saving.errors.not_found')); |
193 | 193 | } |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function saveSaving(Session $session, int $fundId, int $memberId, int $amount): void |
210 | 210 | { |
211 | - if(!($member = $this->getMember($memberId))) |
|
211 | + if (!($member = $this->getMember($memberId))) |
|
212 | 212 | { |
213 | 213 | throw new MessageException(trans('tontine.member.errors.not_found')); |
214 | 214 | } |
215 | 215 | $fund = !$fundId ? null : $this->fundService->getFund($fundId); |
216 | 216 | $saving = $this->findSaving($session, !$fund ? 0 : $fund->id, $member->id); |
217 | - if(!$saving) |
|
217 | + if (!$saving) |
|
218 | 218 | { |
219 | 219 | $saving = new Saving(); |
220 | 220 | } |
@@ -234,8 +234,7 @@ discard block |
||
234 | 234 | public function deleteSaving(Session $session, int $savingId, int $memberId = 0): void |
235 | 235 | { |
236 | 236 | $savingId > 0 ? |
237 | - $session->savings()->where('id', $savingId)->delete() : |
|
238 | - $session->savings()->where('member_id', $memberId)->delete(); |
|
237 | + $session->savings()->where('id', $savingId)->delete() : $session->savings()->where('member_id', $memberId)->delete(); |
|
239 | 238 | } |
240 | 239 | |
241 | 240 | /** |
@@ -252,8 +251,7 @@ discard block |
||
252 | 251 | $query->where('session_id', $session->id) |
253 | 252 | ->where(function(Builder $query) use($fundId) { |
254 | 253 | $fundId > 0 ? |
255 | - $query->where('fund_id', $fundId) : |
|
256 | - $query->whereNull('fund_id'); |
|
254 | + $query->where('fund_id', $fundId) : $query->whereNull('fund_id'); |
|
257 | 255 | }); |
258 | 256 | }; |
259 | 257 | } |
@@ -267,7 +265,7 @@ discard block |
||
267 | 265 | * @return Builder|Relation |
268 | 266 | */ |
269 | 267 | private function getMembersQuery(Session $session, int $fundId, |
270 | - string $search, ?bool $filter): Builder|Relation |
|
268 | + string $search, ?bool $filter): Builder | Relation |
|
271 | 269 | { |
272 | 270 | $savingsFilter = $this->getMemberSavingsFilter($session, $fundId); |
273 | 271 | return $this->tenantService->tontine()->members()->active() |
@@ -391,10 +389,10 @@ discard block |
||
391 | 389 | { |
392 | 390 | $tontine = $this->tenantService->tontine(); |
393 | 391 | $properties = $tontine->properties; |
394 | - if(isset($properties['closings'][$session->id][$fundId])) |
|
392 | + if (isset($properties['closings'][$session->id][$fundId])) |
|
395 | 393 | { |
396 | 394 | unset($properties['closings'][$session->id][$fundId]); |
397 | - if(count($properties['closings'][$session->id]) == 0) |
|
395 | + if (count($properties['closings'][$session->id]) == 0) |
|
398 | 396 | { |
399 | 397 | unset($properties['closings'][$session->id]); |
400 | 398 | } |
@@ -35,25 +35,25 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) |