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; }
$savingproduct_id = Input::get('savingproduct'); $savingproduct = Savingproduct::findOrFail($savingproduct_id); foreach ($savingproduct->savingaccounts as $savingaccount) { if ($savingaccount->member->is_active && Savingaccount::getLastAmount($savingaccount) > 0) { $data = array('account_id' => $savingaccount->id, 'amount' => Savingaccount::getLastAmount($savingaccount), 'date' => date('Y-m-d'), 'type' => 'credit'); Savingtransaction::creditAccounts($data); } } Autoprocess::record(date('Y-m-d'), 'saving', $savingproduct); } else { $loanproduct_id = Input::get('loanproduct'); $loanproduct = Loanproduct::findOrFail($loanproduct_id); foreach ($loanproduct->loanaccounts as $loanaccount) { if ($loanaccount->member->is_active && Loanaccount::getEMP($loanaccount) > 0) { $data = array('loanaccount_id' => $loanaccount->id, 'amount' => Loanaccount::getEMP($loanaccount), 'date' => date('Y-m-d')); Loanrepayment::repayLoan($data); } } Autoprocess::record(date('Y-m-d'), 'loan', $loanproduct); } return Redirect::back()->with('notice', 'successfully processed'); }); Route::get('loanrepayments/offprint/{id}', 'LoanrepaymentsController@offprint'); Route::resource('members', 'MembersController'); Route::post('members/update/{id}', 'MembersController@update'); Route::get('members/delete/{id}', 'MembersController@destroy'); Route::get('members/edit/{id}', 'MembersController@edit'); Route::get('members/show/{id}', 'MembersController@show'); Route::get('members/loanaccounts/{id}', 'MembersController@loanaccounts'); Route::get('memberloans', 'MembersController@loanaccounts2'); Route::group(['before' => 'limit'], function () {
public function offprint($id) { $loanaccount = Loanaccount::findOrFail($id); $organization = Organization::find(1); $principal_paid = Loanrepayment::getPrincipalPaid($loanaccount); $principal_due = $loanaccount->amount_disbursed - $principal_paid; $interest_due = $principal_due * ($loanaccount->interest_rate / 100); $pdf = PDF::loadView('pdf.offset', compact('loanaccount', 'organization', 'principal_paid', 'interest_due', 'principal_due'))->setPaper('a4')->setOrientation('potrait'); return $pdf->stream('Offset.pdf'); }
public static function getPrincipalBal($loanaccount) { $principal_amount = $loanaccount->amount_disbursed + $loanaccount->top_up_amount; $principal_paid = Loanrepayment::getPrincipalPaid($loanaccount); $principal_bal = $principal_amount - $principal_paid; return $principal_bal; }
public function show2($id) { $loanaccount = Loanaccount::findOrFail($id); $interest = Loanaccount::getInterestAmount($loanaccount); $loanbalance = Loantransaction::getLoanBalance($loanaccount); $principal_paid = Loanrepayment::getPrincipalPaid($loanaccount); $interest_paid = Loanrepayment::getInterestPaid($loanaccount); $loanguarantors = $loanaccount->guarantors; return View::make('css.loanshow', compact('loanaccount', 'loanguarantors', 'interest', 'principal_paid', 'interest_paid', 'loanbalance')); }
public static function payInterest($loanaccount, $date, $interest_due) { $repayment = new Loanrepayment(); $repayment->loanaccount()->associate($loanaccount); $repayment->date = $date; $repayment->interest_paid = $interest_due; $repayment->save(); $account = Loanposting::getPostingAccount($loanaccount->loanproduct, 'interest_repayment'); $data = array('credit_account' => $account['credit'], 'debit_account' => $account['debit'], 'date' => $date, 'amount' => $interest_due, 'initiated_by' => 'system', 'description' => 'interest repayment'); $journal = new Journal(); $journal->journal_entry($data); }