mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-03 20:56:21 +00:00
Code rearrangement.
This commit is contained in:
@@ -61,6 +61,18 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* @param $accountId
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function find($accountId)
|
||||
{
|
||||
return Auth::user()->accounts()->findOrNew($accountId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
@@ -84,7 +96,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method returns the users credit cards, along with some basic information about the
|
||||
* balance they have on their CC. To be used in the JSON boxes on the front page that say
|
||||
@@ -465,29 +476,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return $newAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*/
|
||||
protected function storeMetadata(Account $account, array $data)
|
||||
{
|
||||
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
||||
foreach ($validFields as $field) {
|
||||
if (isset($data[$field])) {
|
||||
$metaData = new AccountMeta(
|
||||
[
|
||||
'account_id' => $account->id,
|
||||
'name' => $field,
|
||||
'data' => $data[$field],
|
||||
]
|
||||
);
|
||||
$metaData->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $opposing
|
||||
@@ -536,33 +524,24 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*
|
||||
*/
|
||||
protected function updateMetadata(Account $account, array $data)
|
||||
protected function storeMetadata(Account $account, array $data)
|
||||
{
|
||||
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
||||
|
||||
foreach ($validFields as $field) {
|
||||
$entry = $account->accountMeta()->where('name', $field)->first();
|
||||
|
||||
if (isset($data[$field])) {
|
||||
// update if new data is present:
|
||||
if (!is_null($entry)) {
|
||||
$entry->data = $data[$field];
|
||||
$entry->save();
|
||||
} else {
|
||||
$metaData = new AccountMeta(
|
||||
[
|
||||
'account_id' => $account->id,
|
||||
'name' => $field,
|
||||
'data' => $data[$field],
|
||||
]
|
||||
);
|
||||
$metaData->save();
|
||||
}
|
||||
$metaData = new AccountMeta(
|
||||
[
|
||||
'account_id' => $account->id,
|
||||
'name' => $field,
|
||||
'data' => $data[$field],
|
||||
]
|
||||
);
|
||||
$metaData->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,14 +571,34 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*
|
||||
* @param $accountId
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function find($accountId)
|
||||
protected function updateMetadata(Account $account, array $data)
|
||||
{
|
||||
return Auth::user()->accounts()->findOrNew($accountId);
|
||||
$validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType'];
|
||||
|
||||
foreach ($validFields as $field) {
|
||||
$entry = $account->accountMeta()->where('name', $field)->first();
|
||||
|
||||
if (isset($data[$field])) {
|
||||
// update if new data is present:
|
||||
if (!is_null($entry)) {
|
||||
$entry->data = $data[$field];
|
||||
$entry->save();
|
||||
} else {
|
||||
$metaData = new AccountMeta(
|
||||
[
|
||||
'account_id' => $account->id,
|
||||
'name' => $field,
|
||||
'data' => $data[$field],
|
||||
]
|
||||
);
|
||||
$metaData->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,14 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function countAccounts(array $types);
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $moveTo
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function destroy(Account $account, Account $moveTo = null);
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
*
|
||||
@@ -33,14 +41,6 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function find($accountId);
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $moveTo
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function destroy(Account $account, Account $moveTo = null);
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
@@ -48,14 +48,6 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function getAccounts(array $types);
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param Account $account
|
||||
*
|
||||
* @return Transaction
|
||||
*/
|
||||
public function getFirstTransaction(TransactionJournal $journal, Account $account);
|
||||
|
||||
/**
|
||||
* This method returns the users credit cards, along with some basic information about the
|
||||
* balance they have on their CC. To be used in the JSON boxes on the front page that say
|
||||
@@ -70,11 +62,12 @@ interface AccountRepositoryInterface
|
||||
public function getCreditCards(Carbon $date);
|
||||
|
||||
/**
|
||||
* Get the accounts of a user that have piggy banks connected to them.
|
||||
* @param TransactionJournal $journal
|
||||
* @param Account $account
|
||||
*
|
||||
* @return Collection
|
||||
* @return Transaction
|
||||
*/
|
||||
public function getPiggyBankAccounts();
|
||||
public function getFirstTransaction(TransactionJournal $journal, Account $account);
|
||||
|
||||
/**
|
||||
* @param Preference $preference
|
||||
@@ -101,9 +94,11 @@ interface AccountRepositoryInterface
|
||||
public function getJournals(Account $account, $page);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* Get the accounts of a user that have piggy banks connected to them.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function sumOfEverything();
|
||||
public function getPiggyBankAccounts();
|
||||
|
||||
/**
|
||||
* Get savings accounts and the balance difference in the period.
|
||||
@@ -134,6 +129,11 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function store(array $data);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function sumOfEverything();
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
|
||||
@@ -46,6 +46,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return Auth::user()->ruleGroups()->orderBy('order', 'ASC')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@@ -57,36 +64,6 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
return intval($entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return Auth::user()->ruleGroups()->orderBy('order', 'ASC')->get();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveUp(RuleGroup $ruleGroup)
|
||||
{
|
||||
$order = $ruleGroup->order;
|
||||
|
||||
// find the rule with order-1 and give it order+1
|
||||
$other = Auth::user()->ruleGroups()->where('order', ($order - 1))->first();
|
||||
if ($other) {
|
||||
$other->order = ($other->order + 1);
|
||||
$other->save();
|
||||
}
|
||||
|
||||
$ruleGroup->order = ($ruleGroup->order - 1);
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
@@ -108,6 +85,26 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
$this->resetRuleGroupOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveUp(RuleGroup $ruleGroup)
|
||||
{
|
||||
$order = $ruleGroup->order;
|
||||
|
||||
// find the rule with order-1 and give it order+1
|
||||
$other = Auth::user()->ruleGroups()->where('order', ($order - 1))->first();
|
||||
if ($other) {
|
||||
$other->order = ($other->order + 1);
|
||||
$other->save();
|
||||
}
|
||||
|
||||
$ruleGroup->order = ($ruleGroup->order - 1);
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
||||
@@ -21,6 +21,10 @@ interface RuleGroupRepositoryInterface
|
||||
*/
|
||||
public function destroy(RuleGroup $ruleGroup, RuleGroup $moveTo = null);
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function get();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@@ -28,9 +32,11 @@ interface RuleGroupRepositoryInterface
|
||||
public function getHighestOrderRuleGroup();
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get();
|
||||
public function moveDown(RuleGroup $ruleGroup);
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
@@ -39,13 +45,6 @@ interface RuleGroupRepositoryInterface
|
||||
*/
|
||||
public function moveUp(RuleGroup $ruleGroup);
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveDown(RuleGroup $ruleGroup);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user