mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some small bug fixes in the account views.
This commit is contained in:
parent
b261b0b447
commit
d98d366eea
@ -116,7 +116,14 @@ class AccountController extends Controller
|
|||||||
$subTitle = Config::get('firefly.subTitlesByIdentifier.' . $what);
|
$subTitle = Config::get('firefly.subTitlesByIdentifier.' . $what);
|
||||||
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
||||||
$types = Config::get('firefly.accountTypesByIdentifier.' . $what);
|
$types = Config::get('firefly.accountTypesByIdentifier.' . $what);
|
||||||
$accounts = Auth::user()->accounts()->accountTypeIn($types)->get(['accounts.*']);
|
|
||||||
|
// move to repository:
|
||||||
|
$accounts = Auth::user()->accounts()->with(
|
||||||
|
['accountmeta' => function ($query) {
|
||||||
|
$query->where('name', 'accountRole');
|
||||||
|
}]
|
||||||
|
)->accountTypeIn($types)->get(['accounts.*']);
|
||||||
|
|
||||||
|
|
||||||
return view('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
return view('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getJournals(Account $account, $page, $range = 'session')
|
public function getJournals(Account $account, $page, $range = 'session')
|
||||||
{
|
{
|
||||||
$offset = ($page-1) * 50;
|
$offset = ($page - 1) * 50;
|
||||||
$query = Auth::user()
|
$query = Auth::user()
|
||||||
->transactionJournals()
|
->transactionJournals()
|
||||||
->withRelevantData()
|
->withRelevantData()
|
||||||
@ -69,6 +69,23 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function leftOnAccount(Account $account)
|
||||||
|
{
|
||||||
|
$balance = \Steam::balance($account);
|
||||||
|
/** @var PiggyBank $p */
|
||||||
|
foreach ($account->piggybanks()->get() as $p) {
|
||||||
|
$balance -= $p->currentRelevantRep()->currentamount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $balance;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
@ -123,13 +140,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
// update meta data:
|
// update meta data:
|
||||||
/** @var AccountMeta $meta */
|
$this->_updateMetadata($account, $data);
|
||||||
foreach ($account->accountMeta()->get() as $meta) {
|
|
||||||
if ($meta->name == 'accountRole') {
|
|
||||||
$meta->data = $data['accountRole'];
|
|
||||||
$meta->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$openingBalance = $this->openingBalanceTransaction($account);
|
$openingBalance = $this->openingBalanceTransaction($account);
|
||||||
|
|
||||||
@ -313,18 +324,35 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
* @param array $data
|
||||||
* @return float
|
|
||||||
*/
|
*/
|
||||||
public function leftOnAccount(Account $account)
|
protected function _updateMetadata(Account $account, array $data)
|
||||||
{
|
{
|
||||||
$balance = \Steam::balance($account);
|
$metaEntries = $account->accountMeta()->get();
|
||||||
/** @var PiggyBank $p */
|
$updated = false;
|
||||||
foreach ($account->piggybanks()->get() as $p) {
|
|
||||||
$balance -= $p->currentRelevantRep()->currentamount;
|
/** @var AccountMeta $entry */
|
||||||
|
foreach ($metaEntries as $entry) {
|
||||||
|
if ($entry->name == 'accountRole') {
|
||||||
|
$entry->data = $data['accountRole'];
|
||||||
|
$updated = true;
|
||||||
|
$entry->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $balance;
|
if ($updated === false) {
|
||||||
|
$metaData = new AccountMeta(
|
||||||
|
[
|
||||||
|
'account_id' => $account->id,
|
||||||
|
'name' => 'accountRole',
|
||||||
|
'data' => $data['accountRole']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if (!$metaData->isValid()) {
|
||||||
|
App::abort(500);
|
||||||
|
}
|
||||||
|
$metaData->save();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,13 @@
|
|||||||
</td>
|
</td>
|
||||||
<td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
|
<td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
|
||||||
@if(isset($what) && $what == 'asset')
|
@if(isset($what) && $what == 'asset')
|
||||||
<td>{{{$account->accountRole}}}</td>
|
<td>
|
||||||
|
@foreach($account->accountmeta as $entry)
|
||||||
|
@if($entry->name == 'accountRole')
|
||||||
|
{{Config::get('firefly.accountRoles.'.$entry->data)}}
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</td>
|
||||||
@endif
|
@endif
|
||||||
<td>{!! Amount::format(Steam::balance($account)) !!}</td>
|
<td>{!! Amount::format(Steam::balance($account)) !!}</td>
|
||||||
<td>
|
<td>
|
||||||
|
Loading…
Reference in New Issue
Block a user