@@ -48,7 +48,7 @@ |
||
48 | 48 | 'title' => trans('common.actions.cancel'), |
49 | 49 | 'class' => 'btn btn-tertiary', |
50 | 50 | 'click' => 'close', |
51 | - ],[ |
|
51 | + ], [ |
|
52 | 52 | 'title' => trans('common.actions.save'), |
53 | 53 | 'class' => 'btn btn-primary', |
54 | 54 | 'click' => $this->rq()->saveOptions(pm()->form('options-form')), |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | public function selectCurrencies(string $countryCode) |
17 | 17 | { |
18 | - $html= $this->render('pages.tontine.currency', [ |
|
18 | + $html = $this->render('pages.tontine.currency', [ |
|
19 | 19 | 'currencies' => $this->localeService->getCountryCurrencies($countryCode) |
20 | 20 | ]); |
21 | 21 | $this->response->html('select_currency_container', $html); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function chargeCreated(Tontine $tontine, Charge $charge) |
100 | 100 | { |
101 | - if(!$charge->period_once) |
|
101 | + if (!$charge->period_once) |
|
102 | 102 | { |
103 | 103 | return; |
104 | 104 | } |
105 | 105 | $today = now(); |
106 | 106 | // Create a tontine bill for each member |
107 | - foreach($tontine->members()->get() as $member) |
|
107 | + foreach ($tontine->members()->get() as $member) |
|
108 | 108 | { |
109 | 109 | $this->createTontineBill($charge, $member, $today); |
110 | 110 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $today = now(); |
122 | 122 | // Create a tontine bill for each charge |
123 | - foreach($tontine->charges()->active()->once()->get() as $charge) |
|
123 | + foreach ($tontine->charges()->active()->once()->get() as $charge) |
|
124 | 124 | { |
125 | 125 | $this->createTontineBill($charge, $member, $today); |
126 | 126 | } |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | ])->get(); |
144 | 144 | $roundCharges = $tontine->charges()->active()->round()->get(); |
145 | 145 | // Create a round bill for each member |
146 | - foreach($members as $member) |
|
146 | + foreach ($members as $member) |
|
147 | 147 | { |
148 | - foreach($roundCharges as $charge) |
|
148 | + foreach ($roundCharges as $charge) |
|
149 | 149 | { |
150 | 150 | $count = $member->round_bills->filter(function($bill) use($charge) { |
151 | 151 | return $bill->charge_id = $charge->id; |
152 | 152 | })->count(); |
153 | - if($count === 0) |
|
153 | + if ($count === 0) |
|
154 | 154 | { |
155 | 155 | $this->createRoundBill($charge, $member, $round, $today); |
156 | 156 | } |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | } |
159 | 159 | $tontineCharges = $tontine->charges()->active()->once()->get(); |
160 | 160 | // Create a tontine bill for each member |
161 | - foreach($members as $member) |
|
161 | + foreach ($members as $member) |
|
162 | 162 | { |
163 | - foreach($tontineCharges as $charge) |
|
163 | + foreach ($tontineCharges as $charge) |
|
164 | 164 | { |
165 | 165 | $count = $member->tontine_bills->filter(function($bill) use($charge) { |
166 | 166 | return $bill->charge_id = $charge->id; |
167 | 167 | })->count(); |
168 | - if($count === 0) |
|
168 | + if ($count === 0) |
|
169 | 169 | { |
170 | 170 | $this->createTontineBill($charge, $member, $today); |
171 | 171 | } |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | $sessionCharges = $tontine->charges()->active()->session()->get(); |
194 | 194 | |
195 | 195 | // Sync the session bills for each member and each session charge |
196 | - foreach($sessionCharges as $charge) |
|
196 | + foreach ($sessionCharges as $charge) |
|
197 | 197 | { |
198 | - foreach($members as $member) |
|
198 | + foreach ($members as $member) |
|
199 | 199 | { |
200 | 200 | $count = $member->session_bills->filter(function($bill) use($charge) { |
201 | 201 | return $bill->charge_id = $charge->id; |
202 | 202 | })->count(); |
203 | - if($count === 0) |
|
203 | + if ($count === 0) |
|
204 | 204 | { |
205 | 205 | $this->createSessionBill($charge, $member, $session, $today); |
206 | 206 | } |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | |
210 | 210 | // Sync the receivables for each subscription on each pool |
211 | 211 | $pools = Pool::ofSession($session)->get(); |
212 | - foreach($pools as $pool) |
|
212 | + foreach ($pools as $pool) |
|
213 | 213 | { |
214 | - if($session->enabled($pool)) |
|
214 | + if ($session->enabled($pool)) |
|
215 | 215 | { |
216 | 216 | $subscriptions = $pool->subscriptions() |
217 | 217 | ->whereDoesntHave('receivables', function(Builder $query) use($session) { |
218 | 218 | return $query->where('session_id', $session->id); |
219 | 219 | }); |
220 | - foreach($subscriptions->get() as $subscription) |
|
220 | + foreach ($subscriptions->get() as $subscription) |
|
221 | 221 | { |
222 | 222 | $subscription->receivables()->create(['session_id' => $session->id]); |
223 | 223 | } |
@@ -53,25 +53,25 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getRemitmentCount(int $sessionCount, int $subscriptionCount, int $sessionPosition): int |
55 | 55 | { |
56 | - if($sessionCount === 0 || $subscriptionCount === 0) |
|
56 | + if ($sessionCount === 0 || $subscriptionCount === 0) |
|
57 | 57 | { |
58 | 58 | return 0; |
59 | 59 | } |
60 | 60 | |
61 | 61 | // Greatest common divisor |
62 | - $gcd = (int)gmp_gcd($sessionCount, $subscriptionCount); |
|
63 | - $sessionsInLoop = (int)($sessionCount / $gcd); |
|
62 | + $gcd = (int) gmp_gcd($sessionCount, $subscriptionCount); |
|
63 | + $sessionsInLoop = (int) ($sessionCount / $gcd); |
|
64 | 64 | $positionInLoop = $sessionPosition % $sessionsInLoop; |
65 | - $subscriptionsInLoop = (int)($subscriptionCount / $gcd); |
|
65 | + $subscriptionsInLoop = (int) ($subscriptionCount / $gcd); |
|
66 | 66 | $extraSubscriptionsInLoop = $subscriptionsInLoop % $sessionsInLoop; |
67 | 67 | |
68 | 68 | // There's is an extra remitment when the modulo decreases compared to the previous session. |
69 | 69 | $prevModulo = ($positionInLoop * $extraSubscriptionsInLoop) % $sessionsInLoop; |
70 | - if($prevModulo > ($prevModulo + $extraSubscriptionsInLoop) % $sessionsInLoop) |
|
70 | + if ($prevModulo > ($prevModulo + $extraSubscriptionsInLoop) % $sessionsInLoop) |
|
71 | 71 | { |
72 | - return (int)floor($subscriptionCount / $sessionCount) + 1; |
|
72 | + return (int) floor($subscriptionCount / $sessionCount) + 1; |
|
73 | 73 | } |
74 | - return (int)floor($subscriptionCount / $sessionCount); |
|
74 | + return (int) floor($subscriptionCount / $sessionCount); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -109,15 +109,14 @@ discard block |
||
109 | 109 | $position = 0; |
110 | 110 | $cashier = 0; |
111 | 111 | $expectedFigures = []; |
112 | - foreach($sessions as $session) |
|
112 | + foreach ($sessions as $session) |
|
113 | 113 | { |
114 | 114 | $figures = $this->makeFigures(0); |
115 | 115 | $figures->cashier->start = $cashier; |
116 | 116 | $figures->cashier->recv = $cashier + $depositAmount; |
117 | 117 | $figures->deposit->count = $depositCount; |
118 | 118 | $figures->deposit->amount = $depositAmount; |
119 | - $figures->remitment->count = !$pool->deposit_fixed ? 1 : |
|
120 | - $this->getRemitmentCount($sessionCount, $subscriptionCount, $position++); |
|
119 | + $figures->remitment->count = !$pool->deposit_fixed ? 1 : $this->getRemitmentCount($sessionCount, $subscriptionCount, $position++); |
|
121 | 120 | $figures->remitment->amount = $remitmentAmount * $figures->remitment->count; |
122 | 121 | $figures->cashier->end = $cashier + $depositAmount - $figures->remitment->amount; |
123 | 122 | $cashier = $figures->cashier->end; |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function createSessions(array $values): bool |
65 | 65 | { |
66 | - foreach($values as &$value) |
|
66 | + foreach ($values as &$value) |
|
67 | 67 | { |
68 | 68 | $value['start_at'] = $value['date'] . ' ' . $value['start'] . ':00'; |
69 | 69 | $value['end_at'] = $value['date'] . ' ' . $value['end'] . ':00'; |
70 | 70 | } |
71 | 71 | DB::transaction(function() use($values) { |
72 | 72 | $sessions = $this->tenantService->round()->sessions()->createMany($values); |
73 | - foreach($sessions as $session) |
|
73 | + foreach ($sessions as $session) |
|
74 | 74 | { |
75 | 75 | $this->disableSessionOnPools($session); |
76 | 76 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | // Make sure the host belongs to the same tontine |
95 | 95 | $hostId = intval($values['host_id']); |
96 | 96 | $values['host_id'] = null; |
97 | - if($hostId > 0) |
|
97 | + if ($hostId > 0) |
|
98 | 98 | { |
99 | 99 | $values['host_id'] = $this->tenantService->tontine()->members()->find($hostId)->id; |
100 | 100 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $session->delete(); |
136 | 136 | }); |
137 | 137 | } |
138 | - catch(Exception $e) |
|
138 | + catch (Exception $e) |
|
139 | 139 | { |
140 | 140 | throw new MessageException(trans('tontine.session.errors.delete')); |
141 | 141 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $year = now()->format('Y'); |
150 | 150 | $date = Carbon::createFromDate($year, 1, 5, 'Africa/Douala')->locale('fr'); |
151 | 151 | $sessions = []; |
152 | - for($i = 0; $i < 12; $i++) |
|
152 | + for ($i = 0; $i < 12; $i++) |
|
153 | 153 | { |
154 | 154 | $session = new \stdClass(); |
155 | 155 | $session->title = 'Séance de ' . $date->isoFormat('MMMM YYYY'); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function checkPoolsSubscriptions() |
33 | 33 | { |
34 | - if($this->tenantService->round()->pools()->whereDoesntHave('subscriptions')->count() > 0) |
|
34 | + if ($this->tenantService->round()->pools()->whereDoesntHave('subscriptions')->count() > 0) |
|
35 | 35 | { |
36 | 36 | throw new MessageException(trans('tontine.errors.action') . |
37 | 37 | '<br/>' . trans('tontine.pool.errors.no_subscription')); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function openSession(Session $session) |
79 | 79 | { |
80 | - if($session->opened) |
|
80 | + if ($session->opened) |
|
81 | 81 | { |
82 | 82 | return; |
83 | 83 | } |
@@ -159,6 +159,6 @@ discard block |
||
159 | 159 | Session::STATUS_PENDING => trans('tontine.session.status.pending'), |
160 | 160 | Session::STATUS_OPENED => trans('tontine.session.status.opened'), |
161 | 161 | Session::STATUS_CLOSED => trans('tontine.session.status.closed'), |
162 | - ];; |
|
162 | + ]; ; |
|
163 | 163 | } |
164 | 164 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $loan->interest_rate = $values['interest_rate']; |
139 | 139 | $loan->member()->associate($member); |
140 | 140 | $loan->session()->associate($session); |
141 | - if($fund !== null) |
|
141 | + if ($fund !== null) |
|
142 | 142 | { |
143 | 143 | $loan->fund()->associate($fund); |
144 | 144 | } |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | $principal = $values['principal']; |
149 | 149 | $interest = $values['interest']; |
150 | 150 | // Create an entry for each type of debt |
151 | - if($principal > 0) |
|
151 | + if ($principal > 0) |
|
152 | 152 | { |
153 | 153 | $loan->debts()->create(['type' => Debt::TYPE_PRINCIPAL, 'amount' => $principal]); |
154 | 154 | } |
155 | - if($interest > 0) |
|
155 | + if ($interest > 0) |
|
156 | 156 | { |
157 | 157 | $loan->debts()->create(['type' => Debt::TYPE_INTEREST, 'amount' => $interest]); |
158 | 158 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $loan->interest_type = $values['interest_type']; |
176 | 176 | $loan->interest_rate = $values['interest_rate']; |
177 | 177 | $loan->member()->associate($member); |
178 | - if($fund !== null) |
|
178 | + if ($fund !== null) |
|
179 | 179 | { |
180 | 180 | $loan->fund()->associate($fund); |
181 | 181 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $interest = $values['interest']; |
191 | 191 | $loan->debts()->principal()->update(['amount' => $principal]); |
192 | 192 | // The interest debt may need to be created or deleted. |
193 | - if($interest <= 0) |
|
193 | + if ($interest <= 0) |
|
194 | 194 | { |
195 | 195 | $loan->debts()->where('type', Debt::TYPE_INTEREST)->delete(); |
196 | 196 | return; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function deleteLoan(Session $session, int $loanId): void |
211 | 211 | { |
212 | - if(($loan = $session->loans()->find($loanId)) !== null) |
|
212 | + if (($loan = $session->loans()->find($loanId)) !== null) |
|
213 | 213 | { |
214 | 214 | DB::transaction(function() use($loan) { |
215 | 215 | $loan->refunds()->delete(); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->localeService->setCurrency($tontine->currency_code); |
57 | 57 | // Save as latest tontine id if it has changed. |
58 | 58 | $tontineId = $this->user->properties['latest']['tontine'] ?? 0; |
59 | - if($tontineId === $tontine->id) |
|
59 | + if ($tontineId === $tontine->id) |
|
60 | 60 | { |
61 | 61 | return; |
62 | 62 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->round = $round; |
76 | 76 | // Save as latest round id if it has changed. |
77 | 77 | $roundId = $this->user->properties['latest']['round'] ?? 0; |
78 | - if($roundId === $round->id) |
|
78 | + if ($roundId === $round->id) |
|
79 | 79 | { |
80 | 80 | return; |
81 | 81 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected static function booted() |
92 | 92 | { |
93 | - static::addGlobalScope('dates', function (Builder $query) { |
|
93 | + static::addGlobalScope('dates', function(Builder $query) { |
|
94 | 94 | $query->addSelect(['pools.*', 'v.end_at', 'v.start_at', 'v.tontine_id']) |
95 | 95 | ->join(DB::raw('v_pools as v'), 'v.id', '=', 'pools.id'); |
96 | 96 | }); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | public function sessions() |
212 | 212 | { |
213 | - if(!$this->pool_round) |
|
213 | + if (!$this->pool_round) |
|
214 | 214 | { |
215 | 215 | return $this->round->sessions(); |
216 | 216 | } |