/** * Show the form for creating a new loanrepayment * * @return Response */ public function create($id) { $loanaccount = Loanaccount::findOrFail($id); $loanbalance = Loantransaction::getLoanBalance($loanaccount); $principal_due = Loantransaction::getPrincipalDue($loanaccount); $interest = Loanaccount::getInterestAmount($loanaccount); $interest_due = Loantransaction::getInterestDue($loanaccount); return View::make('loanrepayments.create', compact('loanaccount', 'principal_due', 'interest_due', 'loanbalance', 'interest')); }
public static function getInterestDue($loanaccount) { $remaining_period = Loantransaction::getRemainingPeriod($loanaccount); $principal_paid = Loanrepayment::getPrincipalPaid($loanaccount); $principal_balance = $loanaccount->amount_disbursed - $principal_paid; if ($loanaccount->loanproduct->formula == 'RB') { $interest_due = $principal_balance * ($loanaccount->interest_rate / 100); } // get principal due on Straight Line if ($loanaccount->loanproduct->formula == 'SL') { $interest_amount = Loanaccount::getInterestAmount($loanaccount); $interest_paid = Loanrepayment::getInterestPaid($loanaccount); $interest_balance = $interest_amount - $interest_paid; $interest_due = 0; if ($interest_balance > 0 && $remaining_period > 0) { $interest_due = $interest_balance / $remaining_period; } //if($loanaccount->loanproduct->amortization == 'EI'){ //$interest_due = $interest_amount / $loanaccount->repayment_duration; //} } return $interest_due; }
<th>#</th> <th>Date</th> <th>Description</th> <th>Cr</th> <th>Dr</th> <!-- <th>Balance</th> --> <th></th> </thead> <tbody> <?php $i = 2; $balance = $loanaccount->amount_disbursed + Loanaccount::getInterestAmount($loanaccount); ?> <tr> <td> 1</td> <td>{{ $loanaccount->date_disbursed }}</td> <td>Loan disbursement</td> <td> 0.00</td> <td >{{ asMoney($loanaccount->amount_disbursed)}}</td> <td> <!-- <a href="{{ URL::to('loantransactions/receipt/')}}" target="_blank"> <span class="glyphicon glyphicon-file" aria-hidden="true"></span> Receipt</a> -->
public static function getInterestBal($loanaccount) { $interest_amount = Loanaccount::getInterestAmount($loanaccount); $interest_paid = Loanrepayment::getInterestPaid($loanaccount); $interest_bal = $interest_amount - $interest_paid; return $interest_bal; }
?> {{$date}}</td> <td>Loan disbursed </td> <td>{{asMoney($account->amount_disbursed)}}</td> <td>{{asMoney(0)}}</td> <td>{{asMoney($account->amount_disbursed)}}</td> <!-- <td>{{asMoney(Loanaccount::getInterestAmount($account))}}</td> --> </tr> <?php $repayments = DB::table('loanrepayments')->where('loanaccount_id', '=', $account->id)->get(); $principal_balance = $account->amount_disbursed; $interest_balance = Loanaccount::getInterestAmount($account); $prinpaid = 0; $intpaid = 0; ?> @foreach($repayments as $repayment) <tr> <td> <?php $date = date("d-M-Y", strtotime($repayment->date)); ?>
/** * Update the specified loanaccount in storage. * * @param int $id * @return Response */ public function dodisburse($id) { //$loanaccount = new Loanaccount; $validator = Validator::make($data = Input::all(), Loanaccount::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } //$loanaccount->approve($data); $loanaccount_id = array_get($data, 'loanaccount_id'); $loanaccount = Loanaccount::findorfail($loanaccount_id); $amount = array_get($data, 'amount_disbursed'); $date = array_get($data, 'date_disbursed'); $loanaccount->date_disbursed = $date; $loanaccount->amount_disbursed = $amount; $loanaccount->repayment_start_date = array_get($data, 'repayment_start_date'); $loanaccount->account_number = Loanaccount::loanAccountNumber($loanaccount); $loanaccount->is_disbursed = TRUE; $loanaccount->update(); $loanamount = $amount + Loanaccount::getInterestAmount($loanaccount); Loantransaction::disburseLoan($loanaccount, $loanamount, $date); return Redirect::route('loans.index'); }