mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -06:00
Added PHP7 return type statements.
This commit is contained in:
parent
b8c7876454
commit
4424e48926
@ -122,7 +122,7 @@ class Entry
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getTypes()
|
public static function getTypes(): array
|
||||||
{
|
{
|
||||||
// key = field name (see top of class)
|
// key = field name (see top of class)
|
||||||
// value = field type (see csv.php under 'roles')
|
// value = field type (see csv.php under 'roles')
|
||||||
@ -139,7 +139,7 @@ class Entry
|
|||||||
'fromAccountId' => 'account-id',
|
'fromAccountId' => 'account-id',
|
||||||
'fromAccountName' => 'account-name',
|
'fromAccountName' => 'account-name',
|
||||||
'fromAccountIban' => 'account-iban',
|
'fromAccountIban' => 'account-iban',
|
||||||
'fromAccountType' => '_ignore',
|
'fromAccountType' => '_ignore', // no, Firefly cannot import what it exports. I know :D
|
||||||
'toAccountId' => 'opposing-id',
|
'toAccountId' => 'opposing-id',
|
||||||
'toAccountName' => 'opposing-name',
|
'toAccountName' => 'opposing-name',
|
||||||
'toAccountIban' => 'opposing-iban',
|
'toAccountIban' => 'opposing-iban',
|
||||||
@ -150,7 +150,7 @@ class Entry
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAmount()
|
public function getAmount(): string
|
||||||
{
|
{
|
||||||
return $this->amount;
|
return $this->amount;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ class AccountController extends Controller
|
|||||||
// the opening balance is tricky:
|
// the opening balance is tricky:
|
||||||
$openingBalanceAmount = null;
|
$openingBalanceAmount = null;
|
||||||
|
|
||||||
if ($openingBalance) {
|
if ($openingBalance->id) {
|
||||||
$transaction = $repository->getFirstTransaction($openingBalance, $account);
|
$transaction = $repository->getFirstTransaction($openingBalance, $account);
|
||||||
$openingBalanceAmount = $transaction->amount;
|
$openingBalanceAmount = $transaction->amount;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function countAccounts(array $types)
|
public function countAccounts(array $types): int
|
||||||
{
|
{
|
||||||
$count = Auth::user()->accounts()->accountTypeIn($types)->count();
|
$count = Auth::user()->accounts()->accountTypeIn($types)->count();
|
||||||
|
|
||||||
@ -47,9 +47,9 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param Account $moveTo
|
* @param Account $moveTo
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function destroy(Account $account, Account $moveTo = null)
|
public function destroy(Account $account, Account $moveTo = null): bool
|
||||||
{
|
{
|
||||||
if (!is_null($moveTo)) {
|
if (!is_null($moveTo)) {
|
||||||
// update all transactions:
|
// update all transactions:
|
||||||
@ -68,7 +68,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
public function find(int $accountId)
|
public function find(int $accountId): Account
|
||||||
{
|
{
|
||||||
return Auth::user()->accounts()->findOrNew($accountId);
|
return Auth::user()->accounts()->findOrNew($accountId);
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function get(array $ids)
|
public function get(array $ids): Collection
|
||||||
{
|
{
|
||||||
return Auth::user()->accounts()->whereIn('id', $ids)->get(['accounts.*']);
|
return Auth::user()->accounts()->whereIn('id', $ids)->get(['accounts.*']);
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getAccounts(array $types)
|
public function getAccounts(array $types): Collection
|
||||||
{
|
{
|
||||||
/** @var Collection $result */
|
/** @var Collection $result */
|
||||||
$result = Auth::user()->accounts()->with(
|
$result = Auth::user()->accounts()->with(
|
||||||
@ -119,7 +119,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getCreditCards(Carbon $date)
|
public function getCreditCards(Carbon $date): Collection
|
||||||
{
|
{
|
||||||
$set = Auth::user()->accounts()
|
$set = Auth::user()->accounts()
|
||||||
->hasMetaValue('accountRole', 'ccAsset')
|
->hasMetaValue('accountRole', 'ccAsset')
|
||||||
@ -147,7 +147,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Transaction
|
* @return Transaction
|
||||||
*/
|
*/
|
||||||
public function getFirstTransaction(TransactionJournal $journal, Account $account)
|
public function getFirstTransaction(TransactionJournal $journal, Account $account): Transaction
|
||||||
{
|
{
|
||||||
$transaction = $journal->transactions()->where('account_id', $account->id)->first();
|
$transaction = $journal->transactions()->where('account_id', $account->id)->first();
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getFrontpageAccounts(Preference $preference)
|
public function getFrontpageAccounts(Preference $preference): Collection
|
||||||
{
|
{
|
||||||
$query = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account']);
|
$query = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account']);
|
||||||
|
|
||||||
@ -181,9 +181,9 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end)
|
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end): Collection
|
||||||
{
|
{
|
||||||
$set = Auth::user()
|
$set = Auth::user()
|
||||||
->transactionjournals()
|
->transactionjournals()
|
||||||
@ -209,7 +209,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return LengthAwarePaginator
|
* @return LengthAwarePaginator
|
||||||
*/
|
*/
|
||||||
public function getJournals(Account $account, $page)
|
public function getJournals(Account $account, $page): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
$offset = ($page - 1) * 50;
|
$offset = ($page - 1) * 50;
|
||||||
$query = Auth::user()
|
$query = Auth::user()
|
||||||
@ -235,7 +235,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getPiggyBankAccounts()
|
public function getPiggyBankAccounts(): Collection
|
||||||
{
|
{
|
||||||
$start = clone session('start', new Carbon);
|
$start = clone session('start', new Carbon);
|
||||||
$end = clone session('end', new Carbon);
|
$end = clone session('end', new Carbon);
|
||||||
@ -277,7 +277,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getSavingsAccounts()
|
public function getSavingsAccounts(): Collection
|
||||||
{
|
{
|
||||||
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')
|
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')
|
||||||
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
|
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
|
||||||
@ -322,9 +322,9 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return float
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function leftOnAccount(Account $account, Carbon $date)
|
public function leftOnAccount(Account $account, Carbon $date): string
|
||||||
{
|
{
|
||||||
|
|
||||||
$balance = Steam::balance($account, $date, true);
|
$balance = Steam::balance($account, $date, true);
|
||||||
@ -342,7 +342,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return TransactionJournal|null
|
* @return TransactionJournal|null
|
||||||
*/
|
*/
|
||||||
public function openingBalanceTransaction(Account $account)
|
public function openingBalanceTransaction(Account $account): TransactionJournal
|
||||||
{
|
{
|
||||||
$journal = TransactionJournal
|
$journal = TransactionJournal
|
||||||
::orderBy('transaction_journals.date', 'ASC')
|
::orderBy('transaction_journals.date', 'ASC')
|
||||||
@ -351,6 +351,9 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
->transactionTypes([TransactionType::OPENING_BALANCE])
|
->transactionTypes([TransactionType::OPENING_BALANCE])
|
||||||
->orderBy('created_at', 'ASC')
|
->orderBy('created_at', 'ASC')
|
||||||
->first(['transaction_journals.*']);
|
->first(['transaction_journals.*']);
|
||||||
|
if(is_null($journal)) {
|
||||||
|
return new TransactionJournal;
|
||||||
|
}
|
||||||
|
|
||||||
return $journal;
|
return $journal;
|
||||||
}
|
}
|
||||||
@ -360,7 +363,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
public function store(array $data)
|
public function store(array $data): Account
|
||||||
{
|
{
|
||||||
$newAccount = $this->storeAccount($data);
|
$newAccount = $this->storeAccount($data);
|
||||||
if (!is_null($newAccount)) {
|
if (!is_null($newAccount)) {
|
||||||
@ -392,7 +395,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function sumOfEverything()
|
public function sumOfEverything(): string
|
||||||
{
|
{
|
||||||
return Auth::user()->transactions()->sum('amount');
|
return Auth::user()->transactions()->sum('amount');
|
||||||
}
|
}
|
||||||
@ -405,7 +408,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
public function update(Account $account, array $data)
|
public function update(Account $account, array $data): Account
|
||||||
{
|
{
|
||||||
// update the account:
|
// update the account:
|
||||||
$account->name = $data['name'];
|
$account->name = $data['name'];
|
||||||
@ -449,7 +452,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
protected function storeAccount(array $data)
|
private function storeAccount(array $data): Account
|
||||||
{
|
{
|
||||||
$type = Config::get('firefly.accountTypeByIdentifier.' . $data['accountType']);
|
$type = Config::get('firefly.accountTypeByIdentifier.' . $data['accountType']);
|
||||||
$accountType = AccountType::whereType($type)->first();
|
$accountType = AccountType::whereType($type)->first();
|
||||||
@ -493,7 +496,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return TransactionJournal
|
* @return TransactionJournal
|
||||||
*/
|
*/
|
||||||
protected function storeInitialBalance(Account $account, Account $opposing, array $data)
|
private function storeInitialBalance(Account $account, Account $opposing, array $data): TransactionJournal
|
||||||
{
|
{
|
||||||
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
|
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
|
||||||
$journal = TransactionJournal::create(
|
$journal = TransactionJournal::create(
|
||||||
@ -534,8 +537,10 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function storeMetadata(Account $account, array $data)
|
private function storeMetadata(Account $account, array $data): bool
|
||||||
{
|
{
|
||||||
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
||||||
foreach ($validFields as $field) {
|
foreach ($validFields as $field) {
|
||||||
@ -549,9 +554,9 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
);
|
);
|
||||||
$metaData->save();
|
$metaData->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -561,7 +566,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return TransactionJournal
|
* @return TransactionJournal
|
||||||
*/
|
*/
|
||||||
protected function updateInitialBalance(Account $account, TransactionJournal $journal, array $data)
|
private function updateInitialBalance(Account $account, TransactionJournal $journal, array $data): TransactionJournal
|
||||||
{
|
{
|
||||||
$journal->date = $data['openingBalanceDate'];
|
$journal->date = $data['openingBalanceDate'];
|
||||||
$journal->save();
|
$journal->save();
|
||||||
@ -585,8 +590,9 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function updateMetadata(Account $account, array $data)
|
private function updateMetadata(Account $account, array $data): bool
|
||||||
{
|
{
|
||||||
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
||||||
|
|
||||||
@ -611,5 +617,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ interface AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function countAccounts(array $types);
|
public function countAccounts(array $types): int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
@ -32,7 +32,7 @@ interface AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function destroy(Account $account, Account $moveTo = null);
|
public function destroy(Account $account, Account $moveTo = null): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $accountId
|
* @param int $accountId
|
||||||
@ -41,7 +41,7 @@ interface AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
public function find(int $accountId);
|
public function find(int $accountId): Account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the accounts by ID, for a given set.
|
* Gets all the accounts by ID, for a given set.
|
||||||
@ -50,14 +50,14 @@ interface AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function get(array $ids);
|
public function get(array $ids): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getAccounts(array $types);
|
public function getAccounts(array $types): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the users credit cards, along with some basic information about the
|
* This method returns the users credit cards, along with some basic information about the
|
||||||
@ -70,7 +70,7 @@ interface AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getCreditCards(Carbon $date);
|
public function getCreditCards(Carbon $date): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
@ -78,23 +78,23 @@ interface AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Transaction
|
* @return Transaction
|
||||||
*/
|
*/
|
||||||
public function getFirstTransaction(TransactionJournal $journal, Account $account);
|
public function getFirstTransaction(TransactionJournal $journal, Account $account): Transaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Preference $preference
|
* @param Preference $preference
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getFrontpageAccounts(Preference $preference);
|
public function getFrontpageAccounts(Preference $preference): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end);
|
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
@ -102,48 +102,48 @@ interface AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return LengthAwarePaginator
|
* @return LengthAwarePaginator
|
||||||
*/
|
*/
|
||||||
public function getJournals(Account $account, $page);
|
public function getJournals(Account $account, $page): LengthAwarePaginator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the accounts of a user that have piggy banks connected to them.
|
* Get the accounts of a user that have piggy banks connected to them.
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getPiggyBankAccounts();
|
public function getPiggyBankAccounts(): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get savings accounts and the balance difference in the period.
|
* Get savings accounts and the balance difference in the period.
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getSavingsAccounts();
|
public function getSavingsAccounts() : Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return float
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function leftOnAccount(Account $account, Carbon $date);
|
public function leftOnAccount(Account $account, Carbon $date): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return TransactionJournal|null
|
* @return TransactionJournal
|
||||||
*/
|
*/
|
||||||
public function openingBalanceTransaction(Account $account);
|
public function openingBalanceTransaction(Account $account) : TransactionJournal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
public function store(array $data);
|
public function store(array $data) : Account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function sumOfEverything();
|
public function sumOfEverything() : string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
@ -151,5 +151,5 @@ interface AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
*/
|
*/
|
||||||
public function update(Account $account, array $data);
|
public function update(Account $account, array $data): Account;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user