mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-26 16:26:35 -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);
|
||||
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $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'));
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function getJournals(Account $account, $page, $range = 'session')
|
||||
{
|
||||
$offset = ($page-1) * 50;
|
||||
$offset = ($page - 1) * 50;
|
||||
$query = Auth::user()
|
||||
->transactionJournals()
|
||||
->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
|
||||
*
|
||||
@ -123,13 +140,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$account->save();
|
||||
|
||||
// update meta data:
|
||||
/** @var AccountMeta $meta */
|
||||
foreach ($account->accountMeta()->get() as $meta) {
|
||||
if ($meta->name == 'accountRole') {
|
||||
$meta->data = $data['accountRole'];
|
||||
$meta->save();
|
||||
}
|
||||
}
|
||||
$this->_updateMetadata($account, $data);
|
||||
|
||||
$openingBalance = $this->openingBalanceTransaction($account);
|
||||
|
||||
@ -313,18 +324,35 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return float
|
||||
* @param array $data
|
||||
*/
|
||||
public function leftOnAccount(Account $account)
|
||||
protected function _updateMetadata(Account $account, array $data)
|
||||
{
|
||||
$balance = \Steam::balance($account);
|
||||
/** @var PiggyBank $p */
|
||||
foreach ($account->piggybanks()->get() as $p) {
|
||||
$balance -= $p->currentRelevantRep()->currentamount;
|
||||
$metaEntries = $account->accountMeta()->get();
|
||||
$updated = false;
|
||||
|
||||
/** @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><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
|
||||
@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
|
||||
<td>{!! Amount::format(Steam::balance($account)) !!}</td>
|
||||
<td>
|
||||
|
Loading…
Reference in New Issue
Block a user