@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function getQuery(Pool $pool, bool $filter) |
54 | 54 | { |
55 | 55 | $query = $this->tenantService->tontine()->members()->active(); |
56 | - if($filter) |
|
56 | + if ($filter) |
|
57 | 57 | { |
58 | 58 | // Return only members with subscription in this pool |
59 | 59 | $query = $query->whereHas('subscriptions', function(Builder $query) use($pool) { |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | { |
108 | 108 | // When the remitments are planned, don't create a subscription |
109 | 109 | // if receivables already exist on the pool. |
110 | - if($pool->remit_planned && |
|
110 | + if ($pool->remit_planned && |
|
111 | 111 | $pool->subscriptions()->whereHas('receivables')->count() > 0) |
112 | 112 | { |
113 | 113 | throw new MessageException(trans('tontine.subscription.errors.create')); |
114 | 114 | } |
115 | 115 | // Enforce unique subscription per member in pool with libre deposit amount. |
116 | - if(!$pool->deposit_fixed && |
|
116 | + if (!$pool->deposit_fixed && |
|
117 | 117 | $pool->subscriptions()->where('member_id', $memberId)->count() > 0) |
118 | 118 | { |
119 | 119 | throw new MessageException(trans('tontine.subscription.errors.create')); |
@@ -143,18 +143,18 @@ discard block |
||
143 | 143 | { |
144 | 144 | // When the remitments are planned, don't delete a subscription |
145 | 145 | // if receivables already exist on the pool. |
146 | - if($pool->remit_planned && |
|
146 | + if ($pool->remit_planned && |
|
147 | 147 | $pool->subscriptions()->whereHas('receivables')->count() > 0) |
148 | 148 | { |
149 | 149 | throw new MessageException(trans('tontine.subscription.errors.delete')); |
150 | 150 | } |
151 | 151 | $subscription = $pool->subscriptions()->where('member_id', $memberId) |
152 | 152 | ->with(['payable', 'payable.remitment'])->first(); |
153 | - if(!$subscription) |
|
153 | + if (!$subscription) |
|
154 | 154 | { |
155 | 155 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
156 | 156 | } |
157 | - if($subscription->payable->remitment !== null) |
|
157 | + if ($subscription->payable->remitment !== null) |
|
158 | 158 | { |
159 | 159 | throw new MessageException(trans('tontine.subscription.errors.delete')); |
160 | 160 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function unsetPayableSession(Subscription $subscription) |
200 | 200 | { |
201 | - if(($subscription->payable->session_id)) |
|
201 | + if (($subscription->payable->session_id)) |
|
202 | 202 | { |
203 | 203 | $subscription->payable->session()->dissociate(); |
204 | 204 | $subscription->payable->save(); |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | { |
221 | 221 | $session = $this->tenantService->getSession($sessionId); |
222 | 222 | $currSubscription = null; |
223 | - if($currSubscriptionId > 0) |
|
223 | + if ($currSubscriptionId > 0) |
|
224 | 224 | { |
225 | 225 | $currSubscription = $pool->subscriptions()->find($currSubscriptionId); |
226 | - if(($currSubscription !== null && $currSubscription->payable !== null && |
|
226 | + if (($currSubscription !== null && $currSubscription->payable !== null && |
|
227 | 227 | $currSubscription->payable->remitment !== null) || $session->closed) |
228 | 228 | { |
229 | 229 | // Can't chage the beneficiary if the session is closed or if |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | |
237 | 237 | DB::transaction(function() use($session, $currSubscription, $nextSubscription) { |
238 | 238 | // If the beneficiary already has a session assigned, first remove it. |
239 | - if($currSubscription !== null) |
|
239 | + if ($currSubscription !== null) |
|
240 | 240 | { |
241 | 241 | $this->unsetPayableSession($currSubscription); |
242 | 242 | } |
243 | 243 | // If there is a new session assigned to the beneficiary, then save it. |
244 | - if($nextSubscription !== null) |
|
244 | + if ($nextSubscription !== null) |
|
245 | 245 | { |
246 | 246 | $this->setPayableSession($nextSubscription, $session); |
247 | 247 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | { |
58 | 58 | $cashier = 0; |
59 | 59 | $collectedFigures = []; |
60 | - foreach($sessions as $session) |
|
60 | + foreach ($sessions as $session) |
|
61 | 61 | { |
62 | - if($session->disabled($pool) || $session->pending) |
|
62 | + if ($session->disabled($pool) || $session->pending) |
|
63 | 63 | { |
64 | 64 | $collectedFigures[$session->id] = $this->makeFigures(' '); |
65 | 65 | continue; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | }); |
110 | 110 | $sessions = $this->_getSessions($pool, ['payables.remitment']); |
111 | 111 | $figures = new stdClass(); |
112 | - if($pool->remit_planned) |
|
112 | + if ($pool->remit_planned) |
|
113 | 113 | { |
114 | 114 | $figures->expected = $this->getExpectedFigures($pool, $sessions, $subscriptions); |
115 | 115 | } |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | |
134 | 134 | $figures = []; |
135 | 135 | $position = 0; |
136 | - foreach($sessions as $session) |
|
136 | + foreach ($sessions as $session) |
|
137 | 137 | { |
138 | 138 | $figures[$session->id] = new stdClass(); |
139 | 139 | $figures[$session->id]->payables = $session->payables; |
140 | 140 | $figures[$session->id]->count = 0; |
141 | 141 | $figures[$session->id]->amount = ''; |
142 | - if($session->enabled($pool)) |
|
142 | + if ($session->enabled($pool)) |
|
143 | 143 | { |
144 | 144 | $figures[$session->id]->count = |
145 | 145 | $this->getRemitmentCount($sessionCount, $subscriptionCount, $position++); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function getSessionRemitmentCount(Pool $pool, Session $session): int |
160 | 160 | { |
161 | - if(!$pool->deposit_fixed) |
|
161 | + if (!$pool->deposit_fixed) |
|
162 | 162 | { |
163 | 163 | return 1; |
164 | 164 | } |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | ->each(function($payable) use($session) { |
120 | 120 | $payable->amount = $this->balanceCalculator->getPayableAmount($payable, $session); |
121 | 121 | }); |
122 | - if(!$pool->remit_planned) |
|
122 | + if (!$pool->remit_planned) |
|
123 | 123 | { |
124 | 124 | return $payables; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // When the number of remitments is planned, the list is padded to the expected number. |
128 | 128 | $remitmentCount = $this->summaryService->getSessionRemitmentCount($pool, $session); |
129 | - $emptyPayable = (object)[ |
|
129 | + $emptyPayable = (object) [ |
|
130 | 130 | 'id' => 0, |
131 | 131 | 'amount' => $pool->amount * $this->tenantService->countEnabledSessions($pool), |
132 | 132 | 'remitment' => null, |
@@ -161,18 +161,18 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function savePlannedRemitment(Pool $pool, Session $session, int $payableId): void |
163 | 163 | { |
164 | - if(!$pool->remit_planned || $pool->remit_auction) |
|
164 | + if (!$pool->remit_planned || $pool->remit_auction) |
|
165 | 165 | { |
166 | 166 | // Only when remitments are planned and without auctions. |
167 | 167 | return; |
168 | 168 | } |
169 | 169 | // The payable is supposed to already have been associated to the session. |
170 | 170 | $payable = $this->getPayable($pool, $session, $payableId); |
171 | - if(!$payable) |
|
171 | + if (!$payable) |
|
172 | 172 | { |
173 | 173 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
174 | 174 | } |
175 | - if($payable->remitment) |
|
175 | + if ($payable->remitment) |
|
176 | 176 | { |
177 | 177 | return; |
178 | 178 | } |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | ->whereDoesntHave('remitment') |
200 | 200 | ->whereIn('subscription_id', $pool->subscriptions()->pluck('id')) |
201 | 201 | ->find($payableId); |
202 | - if(!$payable) |
|
202 | + if (!$payable) |
|
203 | 203 | { |
204 | 204 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
205 | 205 | } |
206 | - if($payable->session_id !== null && $payable->session_id !== $session->id) |
|
206 | + if ($payable->session_id !== null && $payable->session_id !== $session->id) |
|
207 | 207 | { |
208 | 208 | // The selected member is already planned on another session. |
209 | 209 | throw new MessageException(trans('tontine.remitment.errors.planning')); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | // Create the remitment. |
217 | 217 | $remitment = $payable->remitment()->create(['amount' => $amount]); |
218 | 218 | |
219 | - if($pool->remit_auction && $auction > 0) |
|
219 | + if ($pool->remit_auction && $auction > 0) |
|
220 | 220 | { |
221 | 221 | // Create the corresponding auction. |
222 | 222 | Auction::create([ |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $payable = $this->getQuery($pool, $session) |
244 | 244 | ->with(['remitment', 'remitment.auction']) |
245 | 245 | ->find($payableId); |
246 | - if(!$payable || !($remitment = $payable->remitment)) |
|
246 | + if (!$payable || !($remitment = $payable->remitment)) |
|
247 | 247 | { |
248 | 248 | return; |
249 | 249 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $remitment->auction()->delete(); |
254 | 254 | $remitment->delete(); |
255 | 255 | // Detach from the session, but only if the remitment was not planned. |
256 | - if(!$pool->remit_planned || $pool->remit_auction) |
|
256 | + if (!$pool->remit_planned || $pool->remit_auction) |
|
257 | 257 | { |
258 | 258 | $payable->session()->dissociate(); |
259 | 259 | $payable->save(); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | public function getSubscriptions(Pool $pool, Session $session): Collection |
273 | 273 | { |
274 | 274 | $subscriptions = $pool->subscriptions()->with(['payable', 'member'])->get(); |
275 | - if($pool->remit_planned && !$pool->remit_auction) |
|
275 | + if ($pool->remit_planned && !$pool->remit_auction) |
|
276 | 276 | { |
277 | 277 | // Only the beneficiaries planned for this session. |
278 | 278 | return $subscriptions |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | public function getSessions(?Session $lastSession = null, |
131 | 131 | bool $withCurrent = true, bool $orderAsc = true): Collection |
132 | 132 | { |
133 | - if($lastSession === null) |
|
133 | + if ($lastSession === null) |
|
134 | 134 | { |
135 | 135 | // Return all the sessions |
136 | 136 | return $this->round()->sessions |
@@ -141,8 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | return $this->round()->sessions |
143 | 143 | ->filter(function($session) use($lastSession, $withCurrent) { |
144 | - return $withCurrent ? $session->start_at <= $lastSession->start_at : |
|
145 | - $session->start_at < $lastSession->start_at; |
|
144 | + return $withCurrent ? $session->start_at <= $lastSession->start_at : $session->start_at < $lastSession->start_at; |
|
146 | 145 | }) |
147 | 146 | ->when(!$orderAsc, function($collection, $session) { |
148 | 147 | return $collection->sortByDesc('start_at')->values(); |
@@ -199,7 +198,7 @@ discard block |
||
199 | 198 | public function getPool(int $poolId, bool $with = false): ?Pool |
200 | 199 | { |
201 | 200 | $pools = $this->round->pools(); |
202 | - if($with) |
|
201 | + if ($with) |
|
203 | 202 | { |
204 | 203 | $pools->with(['subscriptions.receivables.deposit']); |
205 | 204 | } |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | return $session->opened; |
35 | 35 | }) |
36 | 36 | ->pluck('title', 'id'); |
37 | - if($sessions->count() === 0) |
|
37 | + if ($sessions->count() === 0) |
|
38 | 38 | { |
39 | 39 | return $this->response; |
40 | 40 | } |
41 | 41 | $members = $this->tontineService->getMembers(); |
42 | - if($members->count() === 0) |
|
42 | + if ($members->count() === 0) |
|
43 | 43 | { |
44 | 44 | return $this->response; |
45 | 45 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function showSession(int $sessionId) |
70 | 70 | { |
71 | - if(!($session = $this->tenantService->getSession($sessionId))) |
|
71 | + if (!($session = $this->tenantService->getSession($sessionId))) |
|
72 | 72 | { |
73 | 73 | return $this->response; |
74 | 74 | } |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | |
82 | 82 | public function showMember(int $sessionId, int $memberId) |
83 | 83 | { |
84 | - if(!($session = $this->tenantService->getSession($sessionId))) |
|
84 | + if (!($session = $this->tenantService->getSession($sessionId))) |
|
85 | 85 | { |
86 | 86 | return $this->response; |
87 | 87 | } |
88 | - if(!($member = $this->tontineService->getMember($memberId))) |
|
88 | + if (!($member = $this->tontineService->getMember($memberId))) |
|
89 | 89 | { |
90 | 90 | return $this->response; |
91 | 91 | } |
@@ -123,7 +123,7 @@ discard block |
||
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,12 +147,12 @@ discard block |
||
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 | 157 | $receivable->deposit->amount = $amount; |
158 | 158 | $receivable->deposit->save(); |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | public function deleteDeposit(Pool $pool, Session $session, int $receivableId): void |
179 | 179 | { |
180 | 180 | $receivable = $this->getReceivable($pool, $session, $receivableId); |
181 | - if(!$receivable || !$receivable->deposit) |
|
181 | + if (!$receivable || !$receivable->deposit) |
|
182 | 182 | { |
183 | 183 | throw new MessageException(trans('tontine.subscription.errors.not_found')); |
184 | 184 | } |
185 | - if(($receivable->deposit->online)) |
|
185 | + if (($receivable->deposit->online)) |
|
186 | 186 | { |
187 | 187 | throw new MessageException(trans('tontine.subscription.errors.online')); |
188 | 188 | } |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | public function createAllDeposits(Pool $pool, Session $session): void |
201 | 201 | { |
202 | 202 | $receivables = $this->getQuery($pool, $session)->whereDoesntHave('deposit')->get(); |
203 | - if($receivables->count() === 0) |
|
203 | + if ($receivables->count() === 0) |
|
204 | 204 | { |
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | 208 | DB::transaction(function() use($session, $receivables) { |
209 | - foreach($receivables as $receivable) |
|
209 | + foreach ($receivables as $receivable) |
|
210 | 210 | { |
211 | 211 | $deposit = new Deposit(); |
212 | 212 | $deposit->receivable()->associate($receivable); |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | public function deleteAllDeposits(Pool $pool, Session $session): void |
228 | 228 | { |
229 | 229 | $receivables = $this->getQuery($pool, $session)->whereHas('deposit')->get(); |
230 | - if($receivables->count() === 0) |
|
230 | + if ($receivables->count() === 0) |
|
231 | 231 | { |
232 | 232 | return; |
233 | 233 | } |
234 | 234 | |
235 | 235 | DB::transaction(function() use($session, $receivables) { |
236 | - foreach($receivables as $receivable) |
|
236 | + foreach ($receivables as $receivable) |
|
237 | 237 | { |
238 | 238 | $receivable->deposit()->where('session_id', $session->id)->delete(); |
239 | 239 | } |
@@ -35,12 +35,11 @@ |
||
35 | 35 | { |
36 | 36 | $icon = '<i class="fa fa-toggle-off"></i>'; |
37 | 37 | $linkClass = "btn-add-$name"; |
38 | - if(($payment)) |
|
38 | + if (($payment)) |
|
39 | 39 | { |
40 | 40 | $icon = '<i class="fa fa-toggle-on"></i>'; |
41 | 41 | $linkClass = "btn-del-$name"; |
42 | 42 | } |
43 | 43 | |
44 | - return $disableLink ? $icon : |
|
45 | - '<a href="javascript:void(0)" class="' . $linkClass . '">' . $icon . '</a>'; |
|
44 | + return $disableLink ? $icon : '<a href="javascript:void(0)" class="' . $linkClass . '">' . $icon . '</a>'; |
|
46 | 45 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->target()->args()[0] : $this->bag('meeting')->get('pool.id'); |
69 | 69 | $this->pool = $this->depositService->getPool($poolId); |
70 | 70 | |
71 | - if(!$this->session || !$this->pool || $this->session->disabled($this->pool)) |
|
71 | + if (!$this->session || !$this->pool || $this->session->disabled($this->pool)) |
|
72 | 72 | { |
73 | 73 | $this->notify->error(trans('tontine.session.errors.disabled'), trans('common.titles.error')); |
74 | 74 | $this->pool = null; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function addDeposit(int $receivableId) |
136 | 136 | { |
137 | - if($this->session->closed) |
|
137 | + if ($this->session->closed) |
|
138 | 138 | { |
139 | 139 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
140 | 140 | return $this->response; |
@@ -153,21 +153,20 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function editAmount(int $receivableId) |
155 | 155 | { |
156 | - if($this->session->closed) |
|
156 | + if ($this->session->closed) |
|
157 | 157 | { |
158 | 158 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
159 | 159 | return $this->response; |
160 | 160 | } |
161 | 161 | $receivable = $this->depositService->getReceivable($this->pool, $this->session, $receivableId); |
162 | - if(!$receivable || !$receivable->deposit) |
|
162 | + if (!$receivable || !$receivable->deposit) |
|
163 | 163 | { |
164 | 164 | return $this->page(); |
165 | 165 | } |
166 | 166 | |
167 | 167 | $html = $this->view()->render('tontine.pages.meeting.deposit.libre.edit', [ |
168 | 168 | 'id' => $receivable->id, |
169 | - 'amount' => !$receivable->deposit ? '' : |
|
170 | - $this->localeService->getMoneyValue($receivable->deposit->amount), |
|
169 | + 'amount' => !$receivable->deposit ? '' : $this->localeService->getMoneyValue($receivable->deposit->amount), |
|
171 | 170 | ]); |
172 | 171 | $fieldId = 'receivable-' . $receivable->id; |
173 | 172 | $this->response->html($fieldId, $html); |
@@ -188,22 +187,21 @@ discard block |
||
188 | 187 | */ |
189 | 188 | public function saveAmount(int $receivableId, string $amount) |
190 | 189 | { |
191 | - if($this->session->closed) |
|
190 | + if ($this->session->closed) |
|
192 | 191 | { |
193 | 192 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
194 | 193 | return $this->response; |
195 | 194 | } |
196 | 195 | $amount = str_replace(',', '.', trim($amount)); |
197 | - if($amount !== '' && filter_var($amount, FILTER_VALIDATE_FLOAT) === false) |
|
196 | + if ($amount !== '' && filter_var($amount, FILTER_VALIDATE_FLOAT) === false) |
|
198 | 197 | { |
199 | 198 | $this->notify->error(trans('meeting.errors.amount.invalid', ['amount' => $amount])); |
200 | 199 | return $this->response; |
201 | 200 | } |
202 | - $amount = $amount === '' ? 0 : $this->localeService->convertMoneyToInt((float)$amount); |
|
201 | + $amount = $amount === '' ? 0 : $this->localeService->convertMoneyToInt((float) $amount); |
|
203 | 202 | |
204 | 203 | $amount > 0 ? |
205 | - $this->depositService->saveDepositAmount($this->pool, $this->session, $receivableId, $amount): |
|
206 | - $this->depositService->deleteDeposit($this->pool, $this->session, $receivableId); |
|
204 | + $this->depositService->saveDepositAmount($this->pool, $this->session, $receivableId, $amount) : $this->depositService->deleteDeposit($this->pool, $this->session, $receivableId); |
|
207 | 205 | |
208 | 206 | return $this->page(); |
209 | 207 | } |
@@ -215,7 +213,7 @@ discard block |
||
215 | 213 | */ |
216 | 214 | public function delDeposit(int $receivableId) |
217 | 215 | { |
218 | - if($this->session->closed) |
|
216 | + if ($this->session->closed) |
|
219 | 217 | { |
220 | 218 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
221 | 219 | return $this->response; |
@@ -231,12 +229,12 @@ discard block |
||
231 | 229 | */ |
232 | 230 | public function addAllDeposits() |
233 | 231 | { |
234 | - if($this->session->closed) |
|
232 | + if ($this->session->closed) |
|
235 | 233 | { |
236 | 234 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
237 | 235 | return $this->response; |
238 | 236 | } |
239 | - if(!$this->pool->deposit_fixed) |
|
237 | + if (!$this->pool->deposit_fixed) |
|
240 | 238 | { |
241 | 239 | return $this->response; |
242 | 240 | } |
@@ -251,12 +249,12 @@ discard block |
||
251 | 249 | */ |
252 | 250 | public function delAllDeposits() |
253 | 251 | { |
254 | - if($this->session->closed) |
|
252 | + if ($this->session->closed) |
|
255 | 253 | { |
256 | 254 | $this->notify->warning(trans('meeting.warnings.session.closed')); |
257 | 255 | return $this->response; |
258 | 256 | } |
259 | - if(!$this->pool->deposit_fixed) |
|
257 | + if (!$this->pool->deposit_fixed) |
|
260 | 258 | { |
261 | 259 | return $this->response; |
262 | 260 | } |
@@ -55,26 +55,26 @@ discard block |
||
55 | 55 | private function setDistributions(Session $session, Collection $fundings): Collection |
56 | 56 | { |
57 | 57 | // Set fundings durations and distributions |
58 | - foreach($fundings as $funding) |
|
58 | + foreach ($fundings as $funding) |
|
59 | 59 | { |
60 | 60 | $funding->duration = $this->getFundingDuration($session, $funding); |
61 | 61 | $funding->distribution = $funding->amount * $funding->duration; |
62 | 62 | } |
63 | 63 | // Reduce the distributions |
64 | - $distributionGcd = (int)$fundings->reduce(function($gcd, $funding) { |
|
65 | - if($gcd === 0) |
|
64 | + $distributionGcd = (int) $fundings->reduce(function($gcd, $funding) { |
|
65 | + if ($gcd === 0) |
|
66 | 66 | { |
67 | 67 | return $funding->distribution; |
68 | 68 | } |
69 | - if($funding->duration === 0) |
|
69 | + if ($funding->duration === 0) |
|
70 | 70 | { |
71 | 71 | return $gcd; |
72 | 72 | } |
73 | 73 | return gmp_gcd($gcd, $funding->distribution); |
74 | 74 | }, $fundings->first()->distribution); |
75 | - if($distributionGcd > 0) |
|
75 | + if ($distributionGcd > 0) |
|
76 | 76 | { |
77 | - foreach($fundings as $funding) |
|
77 | + foreach ($fundings as $funding) |
|
78 | 78 | { |
79 | 79 | $funding->distribution /= $distributionGcd; |
80 | 80 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | ->orderBy('members.name', 'asc') |
102 | 102 | ->orderBy('sessions.start_at', 'asc') |
103 | 103 | ->with(['session', 'member'])->get(); |
104 | - if($fundings->count() === 0) |
|
104 | + if ($fundings->count() === 0) |
|
105 | 105 | { |
106 | 106 | return $fundings; |
107 | 107 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | 'amount' => $profitAmount, |
149 | 149 | ]; |
150 | 150 | $round = $this->tenantService->round(); |
151 | - if($round->property !== null) |
|
151 | + if ($round->property !== null) |
|
152 | 152 | { |
153 | 153 | $content = $round->property->content; |
154 | 154 | $content['profit'] = $profit; |