コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
ファイル: Loanaccount.php プロジェクト: kenkode/xaraerp
 public static function submitApplication($data)
 {
     $member_id = array_get($data, 'member_id');
     $loanproduct_id = array_get($data, 'loanproduct_id');
     $member = Member::findorfail($member_id);
     $loanproduct = Loanproduct::findorfail($loanproduct_id);
     $application = new Loanaccount();
     $application->member()->associate($member);
     $application->loanproduct()->associate($loanproduct);
     $application->application_date = array_get($data, 'application_date');
     $application->amount_applied = array_get($data, 'amount_applied');
     $application->interest_rate = $loanproduct->interest_rate;
     $application->period = $loanproduct->period;
     $application->repayment_duration = array_get($data, 'repayment_duration');
     $application->save();
     Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'loan application', 'Loans', array_get($data, 'amount_applied'));
 }
コード例 #3
0
ファイル: Loanproduct.php プロジェクト: kenkode/xaraerp
 public static function submit($data)
 {
     //$charges = Input::get('charge');
     $loanproduct = new Loanproduct();
     $loanproduct->name = array_get($data, 'name');
     $loanproduct->short_name = array_get($data, 'short_name');
     $loanproduct->interest_rate = array_get($data, 'interest_rate');
     $loanproduct->formula = array_get($data, 'formula');
     $loanproduct->amortization = array_get($data, 'amortization');
     $loanproduct->currency = array_get($data, 'currency');
     $loanproduct->save();
     Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'loan product creation', 'Loans', '0');
     $loan_id = $loanproduct->id;
     Loanposting::submit($loan_id, $data);
     /*
     		foreach($charges as $charge){
     	$loanproduct->charges()->attach($charge);
     		}
     */
 }
コード例 #4
0
ファイル: Savingtransaction.php プロジェクト: kenkode/xaraerp
 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'));
     }
 }
コード例 #5
0
ファイル: Loantransaction.php プロジェクト: kenkode/xaraerp
 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);
 }
コード例 #6
0
ファイル: MembersController.php プロジェクト: kenkode/xaraerp
 /**
  * Store a newly created member in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Member::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $member = new Member();
     if (Input::get('branch_id') != null) {
         $branch = Branch::findOrFail(Input::get('branch_id'));
         $member->branch()->associate($branch);
     }
     if (Input::get('group_id') != null) {
         $group = Group::findOrFail(Input::get('group_id'));
         $member->group()->associate($group);
     }
     if (Input::hasFile('photo')) {
         $destination = public_path() . '/uploads/photos';
         $filename = str_random(12);
         $ext = Input::file('photo')->getClientOriginalExtension();
         $photo = $filename . '.' . $ext;
         Input::file('photo')->move($destination, $photo);
         $member->photo = $photo;
     }
     if (Input::hasFile('signature')) {
         $destination = public_path() . '/uploads/photos';
         $filename = str_random(12);
         $ext = Input::file('signature')->getClientOriginalExtension();
         $photo = $filename . '.' . $ext;
         Input::file('signature')->move($destination, $photo);
         $member->signature = $photo;
     }
     $member->name = Input::get('name');
     $member->id_number = Input::get('id_number');
     $member->membership_no = Input::get('membership_no');
     $member->phone = Input::get('phone');
     $member->email = Input::get('email');
     $member->address = Input::get('address');
     $member->monthly_remittance_amount = Input::get('monthly_remittance_amount');
     $member->gender = Input::get('gender');
     if (Input::get('active') == '1') {
         $member->is_active = TRUE;
     } else {
         $member->is_active = FALSE;
     }
     $member->save();
     $member_id = $member->id;
     if (Input::get('share_account') == '1') {
         Shareaccount::createAccount($member_id);
     }
     Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'member creation', 'Member', '0');
     return Redirect::route('members.index');
 }