/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(AccountRequest $request)
 {
     $account = new Account(['glosa' => $request['glosa'], 'montoDebe' => $request['sumDebe'], 'montoHaber' => $request['sumHaber'], 'transaction_id' => $request['nume']]);
     $account->save();
     Session::flash('message', 'Comprobante creado');
     return redirect()->route('newAccount');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // validate request
     $this->validate($request, ['name' => 'required|max:32']);
     // limit user to max 5 accounts
     if (User::find(Auth::user()->id)->accounts->count() >= 5) {
         // stuff to pass into view
         $title = "Error";
         $errmsg = "You have reached your maximum account limit.";
         return view('errors.error', compact('errmsg', 'title', 'heading'));
     }
     // prevent duplicate categories
     $accounts = User::find(Auth::user()->id)->accounts;
     foreach ($accounts as $account) {
         if (strcasecmp($account->name, $request->name) == 0) {
             // stuff to pass into view
             $title = "Error";
             $errmsg = "You already have a account with the name.";
             return view('errors.error', compact('errmsg', 'title', 'heading'));
         }
     }
     // create a new account
     $account = new Account();
     // assign data
     $account->user_id = Auth::user()->id;
     $account->name = $request->name;
     // save the new record
     $account->save();
     // flash message
     session()->flash('flash_message', 'Account created successfully.');
     // redirect to accounts index
     return redirect()->route('accounts.index');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['account' => 'required|unique:accounts|max:100']);
     $account = new Account();
     $account->account = $request->account;
     $account->save();
     Session::flash('flash_message', 'Account successfully added!');
     return redirect()->route("account.index");
 }
 public function postStore()
 {
     $validator = Validator::make(Input::all(), $this->rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $game = Game::findOrFail(Input::get('game_id'));
         $account = new Account(['username' => Input::get('username'), 'password' => Input::get('password'), 'user_id' => Auth::user()->id, 'game_id' => $game->id]);
         $account->save();
         return Redirect::to(route('account.show', $account->id));
     }
 }
Ejemplo n.º 5
0
 public function accounts($num = 20)
 {
     for ($i = 0; $i < $num; $i++) {
         $account = new Account();
         $account->name = $this->faker->company;
         $account->description = $this->faker->text(200);
         $account->type = $this->faker->randomElement($array = array('personal', 'corporate'));
         $account->save();
         if ($account->type == 'corporate') {
             $this->users($this->faker->numberBetween(2, 30), $account->id, null);
         } else {
             $this->users(1, $account->id, null);
         }
     }
     User::rebuild();
     $this->rebuildLeads();
     return \Response::make(200);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(LoanApprovalRequest $request)
 {
     $appli = LoanApplication::findOrFail($request->id);
     //$appli->accepted = $request::get('accept');
     //$appli->save();
     //if($appli->accepted=='true'){
     if ($request->accept == 'true') {
         $acc = new Account();
         $acc->loan_id = $appli->loan_id;
         $acc->member_id = $appli->member_id;
         $acc->terms = $appli->terms;
         $acc->amountGranted = $appli->amountGranted;
         $acc->comaker = $appli->comaker;
         $acc->dateGranted = $request->date;
         $acc->dueDate = $acc->dateGranted;
         $acc->dueDate->addDays($acc->terms);
         $acc->balance = $acc->amountGranted;
         $acc->save();
         $ledger = new Ledger();
         $ledger->account_id = $acc->id;
         $ledger->curDate = $acc->dateGranted;
         $ledger->particulars = $request->particular;
         $ledger->reference = $request->reference;
         $ledger->avaiment = $acc->amountGranted;
         $ledger->amountPayed = 0;
         $ledger->interestDue = 0.0;
         $ledger->penaltyDue = 0.0;
         $ledger->principal = 0.0;
         $ledger->interestPayed = 0.0;
         $ledger->penaltyPayed = 0.0;
         $ledger->balance = $acc->amountGranted;
         $acc->balance = $acc->amountGranted;
         //toodo
         $ledger->save();
     }
     $appli->delete();
     flash()->success("Success!");
     return redirect('/admin');
 }
 public function run()
 {
     $start_date = '';
     $end_date = '';
     $folderpath = 'database/seeds/seed_files';
     $folders = File::directories($folderpath);
     $latest = '11232015';
     foreach ($folders as $value) {
         $_dir = explode("/", $value);
         $cnt = count($_dir);
         $name = $_dir[$cnt - 1];
         $latest_date = DateTime::createFromFormat('mdY', $latest);
         $now = DateTime::createFromFormat('mdY', $name);
         if ($now > $latest_date) {
             $latest = $name;
         }
     }
     $file_path = $folderpath . "/" . $latest . "/Store Mapping.xlsx";
     echo (string) $file_path, "\n";
     // dd($file_path);
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('audit_templates')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->template)) {
                 $template = AuditTemplate::where('template', $row->template)->first();
                 if (count($template) == 0) {
                     $newtemplate = new AuditTemplate();
                     $newtemplate->template_code = $row->channel_code;
                     $newtemplate->template = $row->template;
                     $newtemplate->save();
                 }
             }
         });
     });
     DB::table('grade_matrixs')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->enrollment_type)) {
                 $matrix = GradeMatrix::where('desc', $row->enrollment_type)->first();
                 if (count($matrix) == 0) {
                     $newmatrix = new GradeMatrix();
                     $newmatrix->desc = $row->enrollment_type;
                     $newmatrix->save();
                 }
             }
         });
     });
     DB::table('users')->truncate();
     DB::table('role_user')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->fullname)) {
                 $userlist = explode("/", $row->fullname);
                 $emaillist = explode("/", $row->email);
                 // dd($row);
                 for ($i = 0; $i < count($userlist); $i++) {
                     $user = User::where('username', $row->username)->first();
                     if (count($user) == 0) {
                         if (empty($emaillist[$i])) {
                             $email = strtolower($row->username . "@unilever.com");
                         } else {
                             $email = strtolower($emaillist[$i]);
                         }
                         $newuser = User::create(array('name' => strtoupper($userlist[$i]), 'email' => $email, 'username' => $row->username, 'password' => Hash::make('password')));
                         $newuser->roles()->attach(3);
                     } else {
                         // $user->name = strtoupper($row->fullname);
                         // $user->username = $row->username;
                         // $user->email = strtolower($row->email);
                         // $user->update();
                         // if(!$user->hasRole('field')){
                         // 	$user->roles()->attach(3);
                         // }
                         // echo $user->hasRole('field');
                     }
                 }
             }
         });
     });
     DB::table('accounts')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $account = Account::where('account', $row->account)->first();
                 if (count($account) == 0) {
                     $newaccount = new Account();
                     $newaccount->account = $row->account;
                     $newaccount->save();
                 }
             }
         });
     });
     DB::table('customers')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 // var_dump($row);
                 $account = Account::where('account', $row->account)->first();
                 if (!empty($account)) {
                     $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first();
                     if (count($customer) == 0) {
                         $newcustomer = new Customer();
                         $newcustomer->account_id = $account->id;
                         $newcustomer->customer_code = $row->customer_code;
                         $newcustomer->customer = $row->customer;
                         $newcustomer->save();
                     }
                 }
             }
         });
     });
     DB::table('areas')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $account = Account::where('account', $row->account)->first();
                 if (!empty($account)) {
                     $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first();
                     if (!empty($customer)) {
                         $area = Area::where('customer_id', $customer->id)->where('area', $row->area)->first();
                         if (count($area) == 0) {
                             $newarea = new Area();
                             $newarea->customer_id = $customer->id;
                             $newarea->area = $row->area;
                             $newarea->save();
                         }
                     }
                 }
             }
         });
     });
     DB::table('regions')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $region = Region::where('region_code', $row->region_code)->where('region', $row->region)->first();
                 if (count($region) == 0) {
                     $newregion = new Region();
                     $newregion->region_code = $row->region_code;
                     $newregion->region = $row->region;
                     $newregion->save();
                 }
             }
         });
     });
     DB::table('distributors')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $dis = Distributor::where('distributor_code', $row->distributor_code)->where('distributor', $row->distributor)->first();
                 if (count($dis) == 0) {
                     $newdis = new Distributor();
                     $newdis->distributor_code = $row->distributor_code;
                     $newdis->distributor = strtoupper($row->distributor);
                     $newdis->save();
                 }
             }
         });
     });
     DB::table('stores')->truncate();
     DB::table('store_user')->truncate();
     Excel::selectSheets('Sheet1')->load($file_path, function ($reader) {
         $records = $reader->get();
         $records->each(function ($row) {
             if (!is_null($row->account)) {
                 $account = Account::where('account', $row->account)->first();
                 if (!empty($account)) {
                     $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first();
                     if (!empty($customer)) {
                         $region = Region::where('region_code', $row->region_code)->first();
                         $dis = Distributor::where('distributor_code', $row->distributor_code)->first();
                         $store = Store::where('account_id', $account->id)->where('customer_id', $customer->id)->where('region_id', $region->id)->where('distributor_id', $dis->id)->where('store_code', $row->store_code)->where('store', $row->store_name)->first();
                         if (count($store) == 0) {
                             $template = AuditTemplate::where('template', $row->template)->first();
                             $matrix = GradeMatrix::where('desc', $row->enrollment_type)->first();
                             $newstore = new Store();
                             $newstore->account_id = $account->id;
                             $newstore->customer_id = $customer->id;
                             $newstore->region_id = $region->id;
                             $newstore->distributor_id = $dis->id;
                             $newstore->store_code = $row->store_code;
                             $newstore->store = $row->store_name;
                             $newstore->grade_matrix_id = $matrix->id;
                             $newstore->audit_template_id = $template->id;
                             $newstore->save();
                             $emaillist = explode("/", $row->email);
                             for ($i = 0; $i < count($emaillist); $i++) {
                                 if (empty($emaillist[$i])) {
                                     $email = strtolower($row->username . "@unilever.com");
                                 } else {
                                     $email = strtolower($emaillist[$i]);
                                 }
                                 $user = User::where('email', $email)->first();
                                 $newstore->users()->attach($user->id);
                             }
                         } else {
                             $emaillist = explode("/", $row->email);
                             for ($i = 0; $i < count($emaillist); $i++) {
                                 if (empty($emaillist[$i])) {
                                     $email = strtolower($row->username . "@unilever.com");
                                 } else {
                                     $email = strtolower($emaillist[$i]);
                                 }
                                 $user = User::where('email', $email)->first();
                                 $store->users()->attach($user->id);
                             }
                         }
                     }
                 }
             }
         });
     });
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
Ejemplo n.º 8
0
 public function account(Request $request)
 {
     $login = Login::where('remember_token', '=', $request->header('token'))->where('status', '=', '1')->where('login_from', '=', $request->ip())->first();
     $account = new Account();
     $account->addedBy = $login->member_id;
     $account->memberId = $request['memberId'];
     $account->amount = $request['amount'];
     $account->type = $request['type'];
     $account->save();
     $returnData = array('status' => 'ok', 'account' => $account, 'message' => "Account updated Successfully", 'code' => 200, 'account' => $account);
     return $returnData;
 }
Ejemplo n.º 9
0
 public function transferToDelivery(Request $request)
 {
     $metaData = MetaData::where('meta_key', 'server_status')->first();
     if ($metaData['meta_value'] == 0) {
         $errorData = array('status' => 'fail', 'message' => 'Sorry! Server is closed. Please try later.', 'code' => '422');
         return Response::json($errorData, 422);
     }
     $login = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     $clientStock = ClientStock::find($request['clientStockId']);
     $account = new Account();
     if ($account->getAccount($login->member_id) < $clientStock->remaining_cost + $clientStock->delivery_charge) {
         $errorData = array('status' => 'fail', 'message' => 'Insufficient Balance!', 'code' => '422');
         return Response::json($errorData, 422);
     }
     if ($clientStock->memberId != $login->member_id) {
         $errorData = array('status' => 'fail', 'message' => 'Invalid Request!', 'code' => '422');
         return Response::json($errorData, 422);
     } else {
         $clientStock->status = 4;
         $clientStock->save();
         $account = new Account();
         $account->ticket = $clientStock->ticket;
         $account->amount = $clientStock->remaining_cost + $clientStock->delivery_charge;
         $account->type = 0;
         $account->addedBy = $login->member_id;
         $account->memberId = $clientStock->memberId;
         $account->save();
         $returnData = array('status' => 'ok', 'code' => '200', 'clientStock' => $clientStock, 'account' => $account);
         return Response::json($returnData, 200);
     }
 }
 public function postIndex()
 {
     $user = Auth::user();
     $id = Input::get('payment');
     /*
      *There is an invisible field called form that tells what form was submitted
      *
      */
     if (Input::get('form') == 'trans') {
         $monthNum = substr(Input::get('date'), 0, 2);
         $month = date('M', mktime(0, 0, 0, $monthNum, 10));
         $year = substr(Input::get('date'), -4);
         $transaction = new Transaction();
         $transaction->userID = $user->id;
         $transaction->date = Input::get('date');
         $transaction->amount = Input::get('amount');
         $transaction->typeID = Input::get('type');
         $transaction->note = Input::get('note');
         $transaction->year = $year;
         $transaction->month = $month;
         if ($id == 'cash') {
             $month = Month::where('userID', $user->id)->where('name', $month)->where('year', date("Y"))->first();
             $month->cash -= Input::get('amount');
             $month->save();
             $transaction->accountID = 0;
         } else {
             $transaction->accountID = $id;
             $account = Account::find($id);
             //add for credit subtract for bank
             if ($account->accountType == 'c') {
                 $account->balance += Input::get('amount');
             } else {
                 $account->balance -= Input::get('amount');
             }
             $account->save();
         }
         $transaction->save();
         return redirect('options')->with('message', 'Transaction added successfully.');
     } else {
         if (Input::get('form') == 'type') {
             $type = new Type();
             $type->userID = $user->id;
             $type->name = Input::get('name');
             $type->save();
             return redirect('options')->with('message', 'Category added successfully.');
         } else {
             if (Input::get('form') == 'payment') {
                 $monthNum = substr(Input::get('date'), 0, 2);
                 $month = date('M', mktime(0, 0, 0, $monthNum, 10));
                 $year = substr(Input::get('date'), -4);
                 $amount = Input::get('amount');
                 $bankID = Input::get('bank');
                 $ccID = Input::get('payment');
                 $note = Input::get('note');
                 $date = Input::get('date');
                 if ($ccID == 'cash') {
                     $month2 = Month::where('userID', $user->id)->where('name', $month)->first();
                     $month2->cash = $month2->cash + $amount;
                     $month2->save();
                     if ($bankID == 'cash') {
                         $month2 = Month::where('userID', $user->id)->where('name', $month)->first();
                         $month2->cash = $month2->cash - $amount;
                         $month2->save();
                     } else {
                         $bank = Account::find($bankID);
                         $bank->balance = $bank->balance - $amount;
                         $bank->save();
                     }
                     $transfer = new Transfer();
                     $transfer->userID = $user->id;
                     $transfer->creditAccountID = $bankID;
                     $transfer->debitAccountID = 0;
                     $transfer->amount = $amount;
                     $transfer->note = $note;
                     $transfer->date = $date;
                     $transfer->year = $year;
                     $transfer->month = $month;
                     $transfer->save();
                 } else {
                     $cc = Account::find($ccID);
                     if ($bankID == 'cash') {
                         $month2 = Month::where('userID', $user->id)->where('name', $month)->first();
                         $month2->cash = $month2->cash - $amount;
                         $month2->save();
                     } else {
                         $bank = Account::find($bankID);
                         $bank->balance = $bank->balance - $amount;
                         $bank->save();
                     }
                     if ($cc->accountType == 'b') {
                         //transfer
                         $cc->balance = $cc->balance + $amount;
                         $transfer = new Transfer();
                         $transfer->userID = $user->id;
                         $transfer->creditAccountID = $bankID;
                         $transfer->debitAccountID = $ccID;
                         $transfer->amount = $amount;
                         $transfer->note = $note;
                         $transfer->date = $date;
                         $transfer->year = $year;
                         $transfer->month = $month;
                         $transfer->save();
                     } else {
                         //payment
                         $cc->balance = $cc->balance - $amount;
                         $payment = new Payment();
                         $payment->userID = $user->id;
                         $payment->creditAccountID = $bankID;
                         $payment->debitAccountID = $ccID;
                         $payment->amount = $amount;
                         $payment->note = $note;
                         $payment->date = $date;
                         $payment->year = $year;
                         $payment->month = $month;
                         $payment->save();
                     }
                     $cc->save();
                 }
                 return redirect('options')->with('message', 'Payment saved successfully.');
             } else {
                 if (Input::get('form') == 'cc') {
                     $cc = new Account();
                     $cc->userID = $user->id;
                     $cc->name = Input::get('name');
                     $cc->balance = Input::get('balance');
                     $cc->creditLimit = Input::get('limit');
                     $cc->statementDay = Input::get('date');
                     $cc->accountType = 'c';
                     $cc->save();
                     return redirect('options')->with('message', 'Credit Card added successfully.');
                 } else {
                     if (Input::get('form') == 'bank') {
                         $bank = new Account();
                         $bank->userID = $user->id;
                         $bank->name = Input::get('name');
                         $bank->balance = Input::get('balance');
                         $bank->accountType = 'b';
                         $bank->save();
                         return redirect('options')->with('message', 'Bank Account added successfully.');
                     } else {
                         if (Input::get('form') == 'income') {
                             $date = Input::get('date');
                             $monthNum = substr($date, 0, 2);
                             $month = date('M', mktime(0, 0, 0, $monthNum, 10));
                             $amount = Input::get('amount');
                             $bankID = Input::get('bank');
                             $year = substr(Input::get('date'), -4);
                             $income = new Income();
                             $income->userID = $user->id;
                             $income->month = $month;
                             $income->amount = $amount;
                             $income->note = Input::get('note');
                             $income->date = $date;
                             $income->year = $year;
                             if ($bankID == "cash") {
                                 $income->accountID = 0;
                                 $month = Month::where('userID', $user->id)->where('name', $month)->first();
                                 $month->cash = $month->cash + $amount;
                                 $month->save();
                             } else {
                                 $income->accountID = $bankID;
                                 $bank = Account::find($bankID);
                                 $bank->balance = $bank->balance + $amount;
                                 $bank->save();
                             }
                             $income->save();
                             return redirect('options')->with('message', 'Income added successfully.');
                         }
                     }
                 }
             }
         }
     }
 }
 public function addBusStop(Request $request, $id)
 {
     $input = $request->all();
     $agent = Merchant::find($id);
     if (isset($input['type']) && $input['type'] == 'genticket') {
         $validator = Validator::make($request->all(), ["terminal_id" => "required", "ticket_type" => "required"]);
         if ($validator->fails()) {
             if ($request->ajax()) {
                 return response()->json($validator->messages());
             } else {
                 return \Redirect::back()->withErrors($validator)->withInput();
             }
         }
         //$input = $request->all();
         $stack = new Ticketstack();
         $stack->batch_code = Ticket::stackCode();
         $stack->created_at = date("Y-m-d H:i:s");
         $stack->save();
         $ticket = new Ticket();
         $terminal = Busstop::where("id", "=", trim($input['terminal_id']))->first();
         $count = $input['qty'];
         $account = Account::where("app_id", "=", $input['app_id'])->first();
         for ($k = 1; $k <= $count; $k++) {
             $time = time();
             DB::table('ticketseed')->insert(['code' => $time]);
             $mid = DB::table("ticketseed")->max("id");
             //$amount   =  ($input['ticket_type'] == 1) ? $terminal->one_way_to_fare : $terminal->one_way_from_fare ;
             $amount = 1000;
             Ticket::insert(array("code" => $ticket->ticketCode($mid), "account_id" => $account->id, "app_id" => $input['app_id'], "agent_id" => $id, "serial_no" => $ticket->uniqueID($mid), "terminal_id" => $terminal->id, "stack_id" => $stack->id, "route_id" => $input['route_id'], "amount" => $amount, "ticket_type" => $input['ticket_type']));
         }
         $account->balance += $amount * $input['qty'];
         $agent->balance += $amount * $input['qty'];
         $account->update();
         $agent->update();
     } else {
         $account = new Account();
         $mid = Account::uniqueID() + 1;
         $terminal_id = DB::table("busstops")->where("short_name", "=", $input['short_name'])->pluck("id");
         $account->merchant_id = $input['merchant_id'];
         $account->busstop_id = $terminal_id;
         $m = $account->merchant_id + $mid;
         $realid = uniqid($m);
         $realid = substr($realid, -1, 5);
         $realid = $realid . str_pad($mid, 5, 0, STR_PAD_LEFT);
         $account->account_id = uniqid($m);
         if ($account->save()) {
             return response()->json("record saved successfully");
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * save.
  *
  * @param Account $account account
  * @param Request $input   输入
  */
 public function savePost($account, $input)
 {
     $account->fill($input);
     return $account->save();
 }
Ejemplo n.º 13
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateLoanRequest $request)
 {
     //dd($request->loan_id);
     $acc = new Account();
     $acc->loan_id = $request->loan_id;
     $acc->member_id = $request->member_id;
     $acc->terms = $request->terms;
     $acc->amountGranted = $request->amount;
     $acc->comaker = $request->comaker;
     $acc->dateGranted = $request->dateGranted;
     $acc->dueDate = $acc->dateGranted;
     $acc->dueDate->addDays($acc->terms + 1);
     $acc->balance = $acc->amountGranted;
     $acc->save();
     $insurance = 0.0;
     $cbu = 0.0;
     $sfee = 0.0;
     $advint = 0.0;
     switch ($acc->loan_id - 1) {
         case 0:
             $today = \Carbon\Carbon::now();
             $mm = $today->month;
             if ($mm == 12 || $mm == 1) {
                 $insurance = 0;
                 //todo
             } else {
                 if ($mm >= 6 && $mm <= 8) {
                     $insurance = $acc->amountGranted * 0.15;
                 }
             }
             $cbu = 500 * $acc->member->landArea;
             break;
         case 1:
             $cbu = 500;
             break;
         case 2:
         case 3:
         case 4:
         case 5:
             $advint = $acc->amountGranted * $acc->loan->intRate * $acc->terms / 360 / 2;
             break;
         case 6:
             //wala
             break;
     }
     $sfee = $acc->amountGranted * $acc->loan->sFee;
     //$total = $advint+$pcic+$insurance+$sfee+$sdeposit+$mortuary+$cbu+$balance+$penalty;
     $total = $advint + $insurance + $sfee + $cbu;
     $net = $acc->amountGranted - $total;
     $ledger = new Ledger();
     $ledger->account_id = $acc->id;
     $ledger->curDate = date('Y-m-d');
     $ledger->particulars = 'LOAN';
     $ledger->reference = $acc->id;
     $ledger->avaiment = $acc->amountGranted;
     $ledger->amountPayed = 0;
     $ledger->interestDue = 0.0;
     $ledger->penaltyDue = 0.0;
     $ledger->principal = 0.0;
     $ledger->interestPayed = 0.0;
     $ledger->penaltyPayed = 0.0;
     $ledger->balance = $acc->amountGranted;
     $acc->balance = $acc->amountGranted;
     //toodo
     $ledger->save();
     $inwords = $this->convert_number_to_words($net);
     return \PDF::loadHTML(view('reports.report1', compact('insurance', 'cbu', 'sfee', 'advint', 'total', 'net', 'acc', 'inwords')))->stream('test.pdf');
     //flash()->success("Success!");
     //return redirect('/admin');
 }