/**
  * Update the specified savingaccount in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $savingaccount = Savingaccount::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Savingaccount::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $savingaccount->update($data);
     return Redirect::route('savingaccounts.index');
 }
Beispiel #2
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'));
     }
 }
 public function statement($id)
 {
     $account = Savingaccount::findOrFail($id);
     $transactions = $account->transactions;
     $credit = DB::table('savingtransactions')->where('savingaccount_id', '=', $account->id)->where('type', '=', 'credit')->sum('amount');
     $debit = DB::table('savingtransactions')->where('savingaccount_id', '=', $account->id)->where('type', '=', 'debit')->sum('amount');
     $balance = $credit - $debit;
     $organization = Organization::findOrFail(1);
     $pdf = PDF::loadView('pdf.statement', compact('transactions', 'organization', 'account', 'balance'))->setPaper('a4')->setOrientation('potrait');
     return $pdf->stream('statement.pdf');
 }