mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-23 23:13:18 -06:00
Move some code for #339
This commit is contained in:
parent
f1fa6c3108
commit
49e32abd3f
@ -297,23 +297,8 @@ class AccountController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(AccountFormRequest $request, ARI $repository)
|
public function store(AccountFormRequest $request, ARI $repository)
|
||||||
{
|
{
|
||||||
$accountData = [
|
$data = $request->getAccountData();
|
||||||
'name' => trim($request->input('name')),
|
$account = $repository->store($data);
|
||||||
'accountType' => $request->input('what'),
|
|
||||||
'virtualBalance' => round($request->input('virtualBalance'), 2),
|
|
||||||
'virtualBalanceCurrency' => intval($request->input('amount_currency_id_virtualBalance')),
|
|
||||||
'active' => true,
|
|
||||||
'user' => auth()->user()->id,
|
|
||||||
'iban' => trim($request->input('iban')),
|
|
||||||
'accountNumber' => trim($request->input('accountNumber')),
|
|
||||||
'accountRole' => $request->input('accountRole'),
|
|
||||||
'openingBalance' => round($request->input('openingBalance'), 2),
|
|
||||||
'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
|
|
||||||
'openingBalanceCurrency' => intval($request->input('amount_currency_id_openingBalance')),
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
$account = $repository->store($accountData);
|
|
||||||
|
|
||||||
Session::flash('success', strval(trans('firefly.stored_new_account', ['name' => $account->name])));
|
Session::flash('success', strval(trans('firefly.stored_new_account', ['name' => $account->name])));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
@ -345,22 +330,8 @@ class AccountController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(AccountFormRequest $request, ARI $repository, Account $account)
|
public function update(AccountFormRequest $request, ARI $repository, Account $account)
|
||||||
{
|
{
|
||||||
|
$data = $request->getAccountData();
|
||||||
$accountData = [
|
$repository->update($account, $data);
|
||||||
'name' => $request->input('name'),
|
|
||||||
'active' => $request->input('active'),
|
|
||||||
'user' => auth()->user()->id,
|
|
||||||
'iban' => $request->input('iban'),
|
|
||||||
'accountNumber' => $request->input('accountNumber'),
|
|
||||||
'accountRole' => $request->input('accountRole'),
|
|
||||||
'virtualBalance' => round($request->input('virtualBalance'), 2),
|
|
||||||
'openingBalance' => round($request->input('openingBalance'), 2),
|
|
||||||
'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
|
|
||||||
'openingBalanceCurrency' => intval($request->input('amount_currency_id_openingBalance')),
|
|
||||||
'ccType' => $request->input('ccType'),
|
|
||||||
'ccMonthlyPaymentDate' => $request->input('ccMonthlyPaymentDate'),
|
|
||||||
];
|
|
||||||
$repository->update($account, $accountData);
|
|
||||||
|
|
||||||
Session::flash('success', strval(trans('firefly.updated_account', ['name' => $account->name])));
|
Session::flash('success', strval(trans('firefly.updated_account', ['name' => $account->name])));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
@ -13,6 +13,7 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
@ -33,6 +34,29 @@ class AccountFormRequest extends Request
|
|||||||
return auth()->check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getAccountDate(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => trim($this->input('name')),
|
||||||
|
'active' => intval($this->input('active')) === 1,
|
||||||
|
'accountType' => $this->input('what'),
|
||||||
|
'virtualBalance' => round($this->input('virtualBalance'), 2),
|
||||||
|
'virtualBalanceCurrency' => intval($this->input('amount_currency_id_virtualBalance')),
|
||||||
|
'user' => auth()->user()->id,
|
||||||
|
'iban' => trim($this->input('iban')),
|
||||||
|
'accountNumber' => trim($this->input('accountNumber')),
|
||||||
|
'accountRole' => $this->input('accountRole'),
|
||||||
|
'openingBalance' => round($this->input('openingBalance'), 2),
|
||||||
|
'openingBalanceDate' => new Carbon((string)$this->input('openingBalanceDate')),
|
||||||
|
'openingBalanceCurrency' => intval($this->input('amount_currency_id_openingBalance')),
|
||||||
|
'ccType' => $this->input('ccType'),
|
||||||
|
'ccMonthlyPaymentDate' => $this->input('ccMonthlyPaymentDate'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<form action="{{ route('accounts.store') }}" method="post" id="store" class="form-horizontal">
|
<form action="{{ route('accounts.store') }}" method="post" id="store" class="form-horizontal">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
<input type="hidden" name="what" value="{{ what }}"/>
|
<input type="hidden" name="what" value="{{ what }}"/>
|
||||||
|
<input type="hidden" name="active" value="1"/>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
|
Loading…
Reference in New Issue
Block a user