@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->target()->args()[0] : $this->bag('meeting')->get('pool.id'); |
54 | 54 | $this->pool = $this->poolService->getPool($poolId); |
55 | 55 | |
56 | - if(!$this->session || !$this->pool || $this->session->disabled($this->pool)) |
|
56 | + if (!$this->session || !$this->pool || $this->session->disabled($this->pool)) |
|
57 | 57 | { |
58 | 58 | $this->notify->error(trans('tontine.session.errors.disabled'), trans('common.titles.error')); |
59 | 59 | $this->pool = null; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ]); |
74 | 74 | $this->response->html('meeting-remitments', $html); |
75 | 75 | |
76 | - if(!$this->pool->remit_planned) |
|
76 | + if (!$this->pool->remit_planned) |
|
77 | 77 | { |
78 | 78 | $this->jq('#btn-add-remitment')->click($this->rq()->addRemitment(0)); |
79 | 79 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function createRemitment(int $payableId) |
106 | 106 | { |
107 | - if($this->session->closed) |
|
107 | + if ($this->session->closed) |
|
108 | 108 | { |
109 | 109 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
110 | 110 | return $this->response; |
111 | 111 | } |
112 | - if(!$this->pool->remit_planned || $this->pool->remit_auction) |
|
112 | + if (!$this->pool->remit_planned || $this->pool->remit_auction) |
|
113 | 113 | { |
114 | 114 | // Only when remitments are planned and without auctions. |
115 | 115 | return $this->response; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | public function addRemitment(int $payableId) |
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; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | 'title' => trans('common.actions.cancel'), |
144 | 144 | 'class' => 'btn btn-tertiary', |
145 | 145 | 'click' => 'close', |
146 | - ],[ |
|
146 | + ], [ |
|
147 | 147 | 'title' => trans('common.actions.save'), |
148 | 148 | 'class' => 'btn btn-primary', |
149 | 149 | 'click' => $this->rq()->saveRemitment(pm()->form('remitment-form')), |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function saveRemitment(array $formValues) |
161 | 161 | { |
162 | - if($this->session->closed) |
|
162 | + if ($this->session->closed) |
|
163 | 163 | { |
164 | 164 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
165 | 165 | $this->dialog->hide(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function deleteRemitment(int $payableId) |
191 | 191 | { |
192 | - if($this->session->closed) |
|
192 | + if ($this->session->closed) |
|
193 | 193 | { |
194 | 194 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
195 | 195 | return $this->response; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function addRefund() |
84 | 84 | { |
85 | - if($this->session->closed) |
|
85 | + if ($this->session->closed) |
|
86 | 86 | { |
87 | 87 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
88 | 88 | return $this->response; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'title' => trans('common.actions.cancel'), |
96 | 96 | 'class' => 'btn btn-tertiary', |
97 | 97 | 'click' => 'close', |
98 | - ],[ |
|
98 | + ], [ |
|
99 | 99 | 'title' => trans('common.actions.save'), |
100 | 100 | 'class' => 'btn btn-primary', |
101 | 101 | 'click' => $this->rq()->createRefund(pm()->form('refund-form')), |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function createRefund(array $formValues) |
113 | 113 | { |
114 | - if($this->session->closed) |
|
114 | + if ($this->session->closed) |
|
115 | 115 | { |
116 | 116 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
117 | 117 | return $this->response; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function deleteRefund(int $refundId) |
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; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function createRefund(string $debtId) |
94 | 94 | { |
95 | - if($this->session->closed) |
|
95 | + if ($this->session->closed) |
|
96 | 96 | { |
97 | 97 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
98 | 98 | return $this->response; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function deleteRefund(int $debtId) |
111 | 111 | { |
112 | - if($this->session->closed) |
|
112 | + if ($this->session->closed) |
|
113 | 113 | { |
114 | 114 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
115 | 115 | return $this->response; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $chargeId = $this->target()->method() === 'home' ? |
61 | 61 | $this->target()->args()[0] : $this->bag('meeting')->get('charge.id'); |
62 | 62 | $this->charge = $this->chargeService->getCharge($chargeId); |
63 | - if($this->session !== null && $this->charge !== null) |
|
63 | + if ($this->session !== null && $this->charge !== null) |
|
64 | 64 | { |
65 | 65 | $this->target = $this->targetService->getTarget($this->charge, $this->session); |
66 | 66 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function page(int $pageNumber = 0) |
98 | 98 | { |
99 | - if($this->target === null) |
|
99 | + if ($this->target === null) |
|
100 | 100 | { |
101 | 101 | return $this->response; |
102 | 102 | } |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function add() |
138 | 138 | { |
139 | - if($this->session->closed) |
|
139 | + if ($this->session->closed) |
|
140 | 140 | { |
141 | 141 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
142 | 142 | return $this->response; |
143 | 143 | } |
144 | - if($this->session === null || $this->charge === null) |
|
144 | + if ($this->session === null || $this->charge === null) |
|
145 | 145 | { |
146 | 146 | return $this->response; |
147 | 147 | } |
148 | - if($this->target !== null) |
|
148 | + if ($this->target !== null) |
|
149 | 149 | { |
150 | 150 | return $this->response; |
151 | 151 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | 'title' => trans('common.actions.cancel'), |
159 | 159 | 'class' => 'btn btn-tertiary', |
160 | 160 | 'click' => 'close', |
161 | - ],[ |
|
161 | + ], [ |
|
162 | 162 | 'title' => trans('common.actions.save'), |
163 | 163 | 'class' => 'btn btn-primary', |
164 | 164 | 'click' => $this->rq()->create(pm()->form('target-form')), |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function create(array $formValues) |
179 | 179 | { |
180 | - if($this->session->closed) |
|
180 | + if ($this->session->closed) |
|
181 | 181 | { |
182 | 182 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
183 | 183 | return $this->response; |
184 | 184 | } |
185 | - if($this->session === null || $this->charge === null) |
|
185 | + if ($this->session === null || $this->charge === null) |
|
186 | 186 | { |
187 | 187 | return $this->response; |
188 | 188 | } |
189 | - if($this->target !== null) |
|
189 | + if ($this->target !== null) |
|
190 | 190 | { |
191 | 191 | return $this->response; |
192 | 192 | } |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function edit() |
210 | 210 | { |
211 | - if($this->session->closed) |
|
211 | + if ($this->session->closed) |
|
212 | 212 | { |
213 | 213 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
214 | 214 | return $this->response; |
215 | 215 | } |
216 | - if($this->target === null) |
|
216 | + if ($this->target === null) |
|
217 | 217 | { |
218 | 218 | return $this->response; |
219 | 219 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'title' => trans('common.actions.cancel'), |
228 | 228 | 'class' => 'btn btn-tertiary', |
229 | 229 | 'click' => 'close', |
230 | - ],[ |
|
230 | + ], [ |
|
231 | 231 | 'title' => trans('common.actions.save'), |
232 | 232 | 'class' => 'btn btn-primary', |
233 | 233 | 'click' => $this->rq()->update(pm()->form('target-form')), |
@@ -247,12 +247,12 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function update(array $formValues) |
249 | 249 | { |
250 | - if($this->session->closed) |
|
250 | + if ($this->session->closed) |
|
251 | 251 | { |
252 | 252 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
253 | 253 | return $this->response; |
254 | 254 | } |
255 | - if($this->target === null) |
|
255 | + if ($this->target === null) |
|
256 | 256 | { |
257 | 257 | return $this->response; |
258 | 258 | } |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function remove() |
276 | 276 | { |
277 | - if($this->session === null || $this->charge === null) |
|
277 | + if ($this->session === null || $this->charge === null) |
|
278 | 278 | { |
279 | 279 | return $this->response; |
280 | 280 | } |
281 | - if($this->target === null) |
|
281 | + if ($this->target === null) |
|
282 | 282 | { |
283 | 283 | return $this->response; |
284 | 284 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function addDisbursement() |
63 | 63 | { |
64 | - if($this->session->closed) |
|
64 | + if ($this->session->closed) |
|
65 | 65 | { |
66 | 66 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
67 | 67 | return $this->response; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'title' => trans('common.actions.cancel'), |
77 | 77 | 'class' => 'btn btn-tertiary', |
78 | 78 | 'click' => 'close', |
79 | - ],[ |
|
79 | + ], [ |
|
80 | 80 | 'title' => trans('common.actions.save'), |
81 | 81 | 'class' => 'btn btn-primary', |
82 | 82 | 'click' => $this->rq()->createDisbursement(pm()->form('disbursement-form')), |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function createDisbursement(array $formValues) |
94 | 94 | { |
95 | - if($this->session->closed) |
|
95 | + if ($this->session->closed) |
|
96 | 96 | { |
97 | 97 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
98 | 98 | return $this->response; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | public function editDisbursement(int $disbursementId) |
110 | 110 | { |
111 | - if($this->session->closed) |
|
111 | + if ($this->session->closed) |
|
112 | 112 | { |
113 | 113 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
114 | 114 | return $this->response; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | 'title' => trans('common.actions.cancel'), |
126 | 126 | 'class' => 'btn btn-tertiary', |
127 | 127 | 'click' => 'close', |
128 | - ],[ |
|
128 | + ], [ |
|
129 | 129 | 'title' => trans('common.actions.save'), |
130 | 130 | 'class' => 'btn btn-primary', |
131 | 131 | 'click' => $this->rq()->updateDisbursement($disbursementId, pm()->form('disbursement-form')), |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function updateDisbursement(int $disbursementId, array $formValues) |
143 | 143 | { |
144 | - if($this->session->closed) |
|
144 | + if ($this->session->closed) |
|
145 | 145 | { |
146 | 146 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
147 | 147 | return $this->response; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function deleteDisbursement(int $disbursementId) |
162 | 162 | { |
163 | - if($this->session->closed) |
|
163 | + if ($this->session->closed) |
|
164 | 164 | { |
165 | 165 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
166 | 166 | return $this->response; |
@@ -29,7 +29,7 @@ |
||
29 | 29 | public function handle() |
30 | 30 | { |
31 | 31 | $pools = Pool::get(); |
32 | - foreach($pools as $pool) |
|
32 | + foreach ($pools as $pool) |
|
33 | 33 | { |
34 | 34 | $currProperties = $pool->properties; |
35 | 35 | $nextProperties = ['deposit' => [], 'remit' => []]; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @return Builder|Relation |
26 | 26 | */ |
27 | - private function getQuery(): Builder|Relation |
|
27 | + private function getQuery(): Builder | Relation |
|
28 | 28 | { |
29 | 29 | return Pool::ofRound($this->tenantService->round()); |
30 | 30 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $pool->delete(); |
123 | 123 | }); |
124 | 124 | } |
125 | - catch(Exception $e) |
|
125 | + catch (Exception $e) |
|
126 | 126 | { |
127 | 127 | throw new MessageException(trans('tontine.errors.action') . |
128 | 128 | '<br/>' . trans('tontine.pool.errors.subscription')); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | // return; |
213 | 213 | // } |
214 | 214 | $session = $pool->sessions()->find($sessionId); |
215 | - if(!$session || $session->enabled($pool)) |
|
215 | + if (!$session || $session->enabled($pool)) |
|
216 | 216 | { |
217 | 217 | return; |
218 | 218 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | // return; |
240 | 240 | // } |
241 | 241 | $session = $pool->sessions()->find($sessionId); |
242 | - if(!$session || $session->disabled($pool)) |
|
242 | + if (!$session || $session->disabled($pool)) |
|
243 | 243 | { |
244 | 244 | return; |
245 | 245 | } |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return Builder|Relation |
35 | 35 | */ |
36 | - private function getFundSessionsQuery(Session $currentSession, int $fundId): Builder|Relation |
|
36 | + private function getFundSessionsQuery(Session $currentSession, int $fundId): Builder | Relation |
|
37 | 37 | { |
38 | 38 | $lastSessionDate = $currentSession->start_at->format('Y-m-d'); |
39 | 39 | // The closing sessions ids |
40 | 40 | $closingSessionIds = array_keys($this->savingService->getFundClosings($fundId)); |
41 | - if(count($closingSessionIds) === 0) |
|
41 | + if (count($closingSessionIds) === 0) |
|
42 | 42 | { |
43 | 43 | // No closing session yet |
44 | 44 | return $this->tenantService->tontine()->sessions() |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | ->whereDate('sessions.start_at', '<', $lastSessionDate) |
52 | 52 | ->orderByDesc('sessions.start_at') |
53 | 53 | ->get(); |
54 | - if($closingSessions->count() === 0) |
|
54 | + if ($closingSessions->count() === 0) |
|
55 | 55 | { |
56 | 56 | // All the closing sessions are after the current session. |
57 | 57 | return $this->tenantService->tontine()->sessions() |
@@ -119,31 +119,31 @@ discard block |
||
119 | 119 | int $profitAmount): Collection |
120 | 120 | { |
121 | 121 | // Set savings durations and distributions |
122 | - foreach($savings as $saving) |
|
122 | + foreach ($savings as $saving) |
|
123 | 123 | { |
124 | 124 | $saving->duration = $this->getSavingDuration($sessions, $saving); |
125 | 125 | $saving->distribution = $saving->amount * $saving->duration; |
126 | 126 | $saving->profit = 0; |
127 | 127 | } |
128 | 128 | // Reduce the distributions |
129 | - $distributionGcd = (int)$savings->reduce(function($gcd, $saving) { |
|
130 | - if($gcd === 0) |
|
129 | + $distributionGcd = (int) $savings->reduce(function($gcd, $saving) { |
|
130 | + if ($gcd === 0) |
|
131 | 131 | { |
132 | 132 | return $saving->distribution; |
133 | 133 | } |
134 | - if($saving->duration === 0) |
|
134 | + if ($saving->duration === 0) |
|
135 | 135 | { |
136 | 136 | return $gcd; |
137 | 137 | } |
138 | 138 | return gmp_gcd($gcd, $saving->distribution); |
139 | 139 | }, $savings->first()->distribution); |
140 | - if($distributionGcd > 0) |
|
140 | + if ($distributionGcd > 0) |
|
141 | 141 | { |
142 | - $sum = (int)($savings->sum('distribution') / $distributionGcd); |
|
143 | - foreach($savings as $saving) |
|
142 | + $sum = (int) ($savings->sum('distribution') / $distributionGcd); |
|
143 | + foreach ($savings as $saving) |
|
144 | 144 | { |
145 | 145 | $saving->distribution /= $distributionGcd; |
146 | - $saving->profit = (int)($profitAmount * $saving->distribution / $sum); |
|
146 | + $saving->profit = (int) ($profitAmount * $saving->distribution / $sum); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
@@ -171,9 +171,8 @@ discard block |
||
171 | 171 | ->orderBy('sessions.start_at', 'asc') |
172 | 172 | ->with(['session', 'member']); |
173 | 173 | $savings = $fundId > 0 ? |
174 | - $query->where('savings.fund_id', $fundId)->get() : |
|
175 | - $query->whereNull('savings.fund_id')->get(); |
|
176 | - if($savings->count() === 0) |
|
174 | + $query->where('savings.fund_id', $fundId)->get() : $query->whereNull('savings.fund_id')->get(); |
|
175 | + if ($savings->count() === 0) |
|
177 | 176 | { |
178 | 177 | return $savings; |
179 | 178 | } |
@@ -193,13 +192,13 @@ discard block |
||
193 | 192 | // The part value makes sense only iwhen there is more than 2 savings |
194 | 193 | // with distribution greater than 0. |
195 | 194 | $savings = $savings->filter(fn($saving) => $saving->distribution > 0); |
196 | - if($savings->count() < 2) |
|
195 | + if ($savings->count() < 2) |
|
197 | 196 | { |
198 | 197 | return 0; |
199 | 198 | } |
200 | 199 | |
201 | 200 | $saving = $savings->first(); |
202 | - return (int)($saving->amount * $saving->duration / $saving->distribution); |
|
201 | + return (int) ($saving->amount * $saving->duration / $saving->distribution); |
|
203 | 202 | } |
204 | 203 | |
205 | 204 | /** |
@@ -226,8 +225,7 @@ discard block |
||
226 | 225 | ->select(DB::raw("sum(amount) as total")) |
227 | 226 | ->whereIn('session_id', $sessionIds); |
228 | 227 | $saving = $fundId > 0 ? |
229 | - $query->where('savings.fund_id', $fundId)->first() : |
|
230 | - $query->whereNull('savings.fund_id')->first(); |
|
228 | + $query->where('savings.fund_id', $fundId)->first() : $query->whereNull('savings.fund_id')->first(); |
|
231 | 229 | return $saving->total ?? 0; |
232 | 230 | } |
233 | 231 | |
@@ -248,8 +246,7 @@ discard block |
||
248 | 246 | ->where('debts.type', Debt::TYPE_INTEREST) |
249 | 247 | ->whereIn('refunds.session_id', $sessionIds); |
250 | 248 | $refund = $fundId > 0 ? |
251 | - $query->where('loans.fund_id', $fundId)->first() : |
|
252 | - $query->whereNull('loans.fund_id')->first(); |
|
249 | + $query->where('loans.fund_id', $fundId)->first() : $query->whereNull('loans.fund_id')->first(); |
|
253 | 250 | return $refund->total ?? 0; |
254 | 251 | } |
255 | 252 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return Builder|Relation |
31 | 31 | */ |
32 | - private function getQuery(Session $session, ?bool $onlyPaid = null): Builder|Relation |
|
32 | + private function getQuery(Session $session, ?bool $onlyPaid = null): Builder | Relation |
|
33 | 33 | { |
34 | 34 | $sessionId = $session->id; |
35 | 35 | $prevSessions = $this->sessionService->getRoundSessionIds($session, withCurr: false); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $query->where('session_id', $sessionId); |
45 | 45 | }); |
46 | 46 | }); |
47 | - if($prevSessions->count() === 0) |
|
47 | + if ($prevSessions->count() === 0) |
|
48 | 48 | { |
49 | 49 | return; |
50 | 50 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | public function toggleAuctionPayment(Session $session, int $auctionId) |
114 | 114 | { |
115 | 115 | $auction = $this->getQuery($session)->find($auctionId); |
116 | - if(($auction)) |
|
116 | + if (($auction)) |
|
117 | 117 | { |
118 | 118 | $auction->update(['paid' => !$auction->paid]); |
119 | 119 | } |