mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 05:06:37 +00:00
All kinds of new stuff. Started with perfecting the account controller. [skip ci]
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
|
||||
namespace Firefly\Storage\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Interface AccountRepositoryInterface
|
||||
*
|
||||
@@ -19,14 +17,26 @@ interface AccountRepositoryInterface
|
||||
public function count();
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param \AccountType $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get();
|
||||
public function createOrFind($name, \AccountType $type);
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getBeneficiaries();
|
||||
public function createOrFindBeneficiary($name);
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy($accountId);
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
@@ -45,26 +55,7 @@ interface AccountRepositoryInterface
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCashAccount();
|
||||
|
||||
/**
|
||||
* @param $ids
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getByIds($ids);
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefault();
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findOpeningBalanceTransaction(\Account $account);
|
||||
public function get();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
@@ -76,6 +67,28 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function getActiveDefaultAsSelectList();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getBeneficiaries();
|
||||
|
||||
/**
|
||||
* @param $ids
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getByIds($ids);
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCashAccount();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefault();
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
@@ -83,14 +96,6 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function store($data);
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy($accountId);
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
@@ -98,20 +103,4 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function update($data);
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function createOrFindBeneficiary($name);
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param \AccountType $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function createOrFind($name, \AccountType $type);
|
||||
|
||||
}
|
||||
@@ -264,25 +264,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
||||
return \Auth::user()->accounts()->where('id', $accountId)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function findOpeningBalanceTransaction(\Account $account)
|
||||
{
|
||||
$transactionType = \TransactionType::where('type', 'Opening balance')->first();
|
||||
$journal = \TransactionJournal::
|
||||
with(
|
||||
['transactions' => function ($q) {
|
||||
$q->orderBy('amount', 'ASC');
|
||||
}]
|
||||
)->where('transaction_type_id', $transactionType->id)
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transactions.account_id', $account->id)->first(['transaction_journals.*']);
|
||||
return $journal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user