@@ -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 | } |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | protected function chargeCreated(Tontine $tontine, Charge $charge) |
| 99 | 99 | { |
| 100 | - if(!$charge->period_once) |
|
| 100 | + if (!$charge->period_once) |
|
| 101 | 101 | { |
| 102 | 102 | return; |
| 103 | 103 | } |
| 104 | 104 | $today = now(); |
| 105 | 105 | // Create a tontine bill for each member |
| 106 | - foreach($tontine->members()->get() as $member) |
|
| 106 | + foreach ($tontine->members()->get() as $member) |
|
| 107 | 107 | { |
| 108 | 108 | $this->createTontineBill($charge, $member, $today); |
| 109 | 109 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $today = now(); |
| 121 | 121 | // Create a tontine bill for each charge |
| 122 | - foreach($tontine->charges()->active()->once()->get() as $charge) |
|
| 122 | + foreach ($tontine->charges()->active()->once()->get() as $charge) |
|
| 123 | 123 | { |
| 124 | 124 | $this->createTontineBill($charge, $member, $today); |
| 125 | 125 | } |
@@ -142,14 +142,14 @@ discard block |
||
| 142 | 142 | ])->get(); |
| 143 | 143 | $roundCharges = $tontine->charges()->active()->round()->get(); |
| 144 | 144 | // Create a round bill for each member |
| 145 | - foreach($members as $member) |
|
| 145 | + foreach ($members as $member) |
|
| 146 | 146 | { |
| 147 | - foreach($roundCharges as $charge) |
|
| 147 | + foreach ($roundCharges as $charge) |
|
| 148 | 148 | { |
| 149 | 149 | $count = $member->round_bills->filter(function($bill) use($charge) { |
| 150 | 150 | return $bill->charge_id = $charge->id; |
| 151 | 151 | })->count(); |
| 152 | - if($count === 0) |
|
| 152 | + if ($count === 0) |
|
| 153 | 153 | { |
| 154 | 154 | $this->createRoundBill($charge, $member, $round, $today); |
| 155 | 155 | } |
@@ -157,14 +157,14 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | $tontineCharges = $tontine->charges()->active()->once()->get(); |
| 159 | 159 | // Create a tontine bill for each member |
| 160 | - foreach($members as $member) |
|
| 160 | + foreach ($members as $member) |
|
| 161 | 161 | { |
| 162 | - foreach($tontineCharges as $charge) |
|
| 162 | + foreach ($tontineCharges as $charge) |
|
| 163 | 163 | { |
| 164 | 164 | $count = $member->tontine_bills->filter(function($bill) use($charge) { |
| 165 | 165 | return $bill->charge_id = $charge->id; |
| 166 | 166 | })->count(); |
| 167 | - if($count === 0) |
|
| 167 | + if ($count === 0) |
|
| 168 | 168 | { |
| 169 | 169 | $this->createTontineBill($charge, $member, $today); |
| 170 | 170 | } |
@@ -192,14 +192,14 @@ discard block |
||
| 192 | 192 | $sessionCharges = $tontine->charges()->active()->session()->get(); |
| 193 | 193 | |
| 194 | 194 | // Sync the session bills for each member and each session charge |
| 195 | - foreach($sessionCharges as $charge) |
|
| 195 | + foreach ($sessionCharges as $charge) |
|
| 196 | 196 | { |
| 197 | - foreach($members as $member) |
|
| 197 | + foreach ($members as $member) |
|
| 198 | 198 | { |
| 199 | 199 | $count = $member->session_bills->filter(function($bill) use($charge) { |
| 200 | 200 | return $bill->charge_id = $charge->id; |
| 201 | 201 | })->count(); |
| 202 | - if($count === 0) |
|
| 202 | + if ($count === 0) |
|
| 203 | 203 | { |
| 204 | 204 | $this->createSessionBill($charge, $member, $session, $today); |
| 205 | 205 | } |
@@ -207,15 +207,15 @@ discard block |
||
| 207 | 207 | }; |
| 208 | 208 | |
| 209 | 209 | // Sync the receivables for each subscription on each pool |
| 210 | - foreach($session->round->pools as $pool) |
|
| 210 | + foreach ($session->round->pools as $pool) |
|
| 211 | 211 | { |
| 212 | - if($session->enabled($pool)) |
|
| 212 | + if ($session->enabled($pool)) |
|
| 213 | 213 | { |
| 214 | 214 | $subscriptions = $pool->subscriptions() |
| 215 | 215 | ->whereDoesntHave('receivables', function(Builder $query) use($session) { |
| 216 | 216 | return $query->where('session_id', $session->id); |
| 217 | 217 | }); |
| 218 | - foreach($subscriptions->get() as $subscription) |
|
| 218 | + foreach ($subscriptions->get() as $subscription) |
|
| 219 | 219 | { |
| 220 | 220 | $subscription->receivables()->create(['session_id' => $session->id]); |
| 221 | 221 | } |
@@ -93,9 +93,7 @@ discard block |
||
| 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 |
||
| 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) |
@@ -83,7 +83,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 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 |
||
| 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; |
@@ -122,7 +122,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -55,12 +55,12 @@ |
||
| 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 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |