コード例 #1
0
 /**
  * @param NewUserFormRequest         $request
  * @param AccountRepositoryInterface $repository
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function submit(NewUserFormRequest $request, AccountRepositoryInterface $repository)
 {
     // create normal asset account:
     $assetAccount = ['name' => $request->get('bank_name'), 'iban' => null, 'accountType' => 'asset', 'virtualBalance' => 0, 'active' => true, 'user' => Auth::user()->id, 'accountRole' => 'defaultAsset', 'openingBalance' => round($request->input('bank_balance'), 2), 'openingBalanceDate' => new Carbon(), 'openingBalanceCurrency' => intval($request->input('balance_currency_id'))];
     $repository->store($assetAccount);
     // create savings account
     if (strlen($request->get('savings_balance') > 0)) {
         $savingsAccount = ['name' => $request->get('bank_name') . ' savings account', 'iban' => null, 'accountType' => 'asset', 'virtualBalance' => 0, 'active' => true, 'user' => Auth::user()->id, 'accountRole' => 'savingAsset', 'openingBalance' => round($request->input('savings_balance'), 2), 'openingBalanceDate' => new Carbon(), 'openingBalanceCurrency' => intval($request->input('balance_currency_id'))];
         $repository->store($savingsAccount);
     }
     // create credit card.
     if (strlen($request->get('credit_card_limit') > 0)) {
         $creditAccount = ['name' => 'Credit card', 'iban' => null, 'accountType' => 'asset', 'virtualBalance' => round($request->get('credit_card_limit'), 2), 'active' => true, 'user' => Auth::user()->id, 'accountRole' => 'ccAsset', 'openingBalance' => null, 'openingBalanceDate' => null, 'openingBalanceCurrency' => intval($request->input('balance_currency_id'))];
         $creditCard = $repository->store($creditAccount);
         // store meta for CC:
         AccountMeta::create(['name' => 'ccType', 'data' => 'monthlyFull', 'account_id' => $creditCard->id]);
         AccountMeta::create(['name' => 'ccMonthlyPaymentDate', 'data' => Carbon::now()->year . '-01-01', 'account_id' => $creditCard->id]);
     }
     Session::flash('success', 'New account(s) created!');
     Preferences::mark();
     return redirect(route('index'));
 }
コード例 #2
0
 /**
  * @param NewUserFormRequest   $request
  * @param AccountCrudInterface $crud
  *
  * @return bool
  */
 private function storeCreditCard(NewUserFormRequest $request, AccountCrudInterface $crud) : bool
 {
     $creditAccount = ['name' => 'Credit card', 'iban' => null, 'accountType' => 'asset', 'virtualBalance' => round($request->get('credit_card_limit'), 2), 'active' => true, 'user' => auth()->user()->id, 'accountRole' => 'ccAsset', 'openingBalance' => null, 'openingBalanceDate' => null, 'openingBalanceCurrency' => intval($request->input('amount_currency_id_credit_card_limit'))];
     $creditCard = $crud->store($creditAccount);
     // store meta for CC:
     $crud->storeMeta($creditCard, 'ccType', 'monthlyFull');
     $crud->storeMeta($creditCard, 'ccMonthlyPaymentDate', Carbon::now()->year . '-01-01');
     return true;
 }