Exemplo n.º 1
0
 /**
  * Store a newly created journal in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Journal::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data = array('date' => Input::get('date'), 'debit_account' => Input::get('debit_account'), 'credit_account' => Input::get('credit_account'), 'description' => Input::get('description'), 'amount' => Input::get('amount'), 'initiated_by' => Input::get('user'));
     $journal = new Journal();
     $journal->journal_entry($data);
     return Redirect::route('journals.index');
 }
 /**
  * Store a newly created savingtransaction in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Savingtransaction::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $date = Input::get('date');
     $transAmount = Input::get('amount');
     $savingaccount = Savingaccount::findOrFail(Input::get('account_id'));
     $savingtransaction = new Savingtransaction();
     $savingtransaction->date = Input::get('date');
     $savingtransaction->savingaccount()->associate($savingaccount);
     $savingtransaction->amount = Input::get('amount');
     $savingtransaction->type = Input::get('type');
     $savingtransaction->description = Input::get('description');
     $savingtransaction->transacted_by = Input::get('transacted_by');
     $savingtransaction->save();
     // withdrawal
     if (Input::get('type') == 'debit') {
         foreach ($savingaccount->savingproduct->savingpostings as $posting) {
             if ($posting->transaction == 'withdrawal') {
                 $debit_account = $posting->debit_account;
                 $credit_account = $posting->credit_account;
             }
         }
         $data = array('credit_account' => $credit_account, 'debit_account' => $debit_account, 'date' => Input::get('date'), 'amount' => Input::get('amount'), 'initiated_by' => 'system', 'description' => 'cash withdrawal');
         $journal = new Journal();
         $journal->journal_entry($data);
         Savingtransaction::withdrawalCharges($savingaccount, $date, $transAmount);
         Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'savings withdrawal', 'Savings', Input::get('amount'));
     }
     // deposit
     if (Input::get('type') == 'credit') {
         foreach ($savingaccount->savingproduct->savingpostings as $posting) {
             if ($posting->transaction == 'deposit') {
                 $debit_account = $posting->debit_account;
                 $credit_account = $posting->credit_account;
             }
         }
         $data = array('credit_account' => $credit_account, 'debit_account' => $debit_account, 'date' => Input::get('date'), 'amount' => Input::get('amount'), 'initiated_by' => 'system', 'description' => 'cash deposit');
         $journal = new Journal();
         $journal->journal_entry($data);
         Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'savings deposit', 'Savings', Input::get('amount'));
     }
     return Redirect::to('savingtransactions/show/' . $savingaccount->id);
 }
Exemplo n.º 3
0
 public static function topupLoan($loanaccount, $amount, $date)
 {
     $transaction = new Loantransaction();
     $transaction->loanaccount()->associate($loanaccount);
     $transaction->date = $date;
     $transaction->description = 'loan top up';
     $transaction->amount = $amount;
     $transaction->type = 'debit';
     $transaction->save();
     $account = Loanposting::getPostingAccount($loanaccount->loanproduct, 'disbursal');
     $data = array('credit_account' => $account['credit'], 'debit_account' => $account['debit'], 'date' => $date, 'amount' => $loanaccount->top_up_amount, 'initiated_by' => 'system', 'description' => 'loan top up');
     $journal = new Journal();
     $journal->journal_entry($data);
     Audit::logAudit($date, Confide::user()->username, 'loan to up', 'Loans', $amount);
 }
Exemplo n.º 4
0
 public static function creditAccounts($data)
 {
     $savingaccount = Savingaccount::findOrFail(array_get($data, 'account_id'));
     $savingtransaction = new Savingtransaction();
     $savingtransaction->date = array_get($data, 'date');
     $savingtransaction->savingaccount()->associate($savingaccount);
     $savingtransaction->amount = array_get($data, 'amount');
     $savingtransaction->type = array_get($data, 'type');
     $savingtransaction->description = 'savings deposit';
     $savingtransaction->save();
     // deposit
     if (array_get($data, 'type') == 'credit') {
         foreach ($savingaccount->savingproduct->savingpostings as $posting) {
             if ($posting->transaction == 'deposit') {
                 $debit_account = $posting->debit_account;
                 $credit_account = $posting->credit_account;
             }
         }
         $data = array('credit_account' => $credit_account, 'debit_account' => $debit_account, 'date' => array_get($data, 'date'), 'amount' => array_get($data, 'amount'), 'initiated_by' => 'system', 'description' => 'cash deposit');
         $journal = new Journal();
         $journal->journal_entry($data);
         Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'savings deposit', 'Savings', array_get($data, 'amount'));
     }
 }
Exemplo n.º 5
0
 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);
 }