diff --git a/app/controllers/JsonController.php b/app/controllers/JsonController.php index d1e9f4898b..d74a923a8a 100644 --- a/app/controllers/JsonController.php +++ b/app/controllers/JsonController.php @@ -3,7 +3,6 @@ use Firefly\Storage\Account\AccountRepositoryInterface as ARI; use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud; use Firefly\Storage\Category\CategoryRepositoryInterface as Cat; -use Firefly\Storage\Component\ComponentRepositoryInterface as CRI; use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI; use Illuminate\Support\Collection; use LaravelBook\Ardent\Builder; @@ -16,7 +15,6 @@ use LaravelBook\Ardent\Builder; class JsonController extends BaseController { protected $_accounts; - protected $_components; protected $_categories; protected $_budgets; /** @var TJRI $_journals */ @@ -24,14 +22,12 @@ class JsonController extends BaseController /** * @param ARI $accounts - * @param CRI $components * @param Cat $categories * @param Bud $budgets * @param TJRI $journals */ - public function __construct(ARI $accounts, CRI $components, Cat $categories, Bud $budgets, TJRI $journals) + public function __construct(ARI $accounts, Cat $categories, Bud $budgets, TJRI $journals) { - $this->_components = $components; $this->_accounts = $accounts; $this->_categories = $categories; $this->_budgets = $budgets; diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php index e1754ab2b1..15cc3c3f30 100644 --- a/app/controllers/TransactionController.php +++ b/app/controllers/TransactionController.php @@ -310,7 +310,7 @@ class TransactionController extends BaseController /** * @param TransactionJournal $journal * - * @return $this|\Illuminate\Http\RedirectResponse + * @throws FireflyException */ public function update(TransactionJournal $journal) { diff --git a/app/lib/Firefly/Database/SingleTableInheritanceEntity.php b/app/lib/Firefly/Database/SingleTableInheritanceEntity.php index 8f274f2461..762ee14ad6 100644 --- a/app/lib/Firefly/Database/SingleTableInheritanceEntity.php +++ b/app/lib/Firefly/Database/SingleTableInheritanceEntity.php @@ -1,7 +1,4 @@ 'spent-norep-' . $budget->id]; } } - - } return $data; diff --git a/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php b/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php index 355e04313e..5268fe6c40 100644 --- a/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php @@ -57,14 +57,6 @@ interface AccountRepositoryInterface */ public function find($accountId); - /** - * @param $name - * @param \AccountType $type - * - * @return \Account - */ - public function findByNameAndAccountType($name, \AccountType $type); - /** * @param $type * @@ -103,19 +95,6 @@ interface AccountRepositoryInterface */ public function findRevenueAccountByName($name); - /** - * @param \Account $from - * @param \Account $to - * - * @return \TransactionType|null - */ - public function transactionTypeByAccounts(\Account $from, \Account $to); - - /** - * @return mixed - */ - public function get(); - /** * @return mixed */ @@ -128,11 +107,6 @@ interface AccountRepositoryInterface */ public function getByIds(array $ids); - /** - * @return mixed - */ - public function getCashAccount(); - /** * @return mixed */ diff --git a/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php b/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php index d5ee214c55..9c1c86f822 100644 --- a/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php +++ b/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php @@ -36,55 +36,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface return $this->_user->accounts()->find($id); } - /** - * @param \Account $from - * @param \Account $to - * @param int $amount - * - * @throws FireflyException - * - * @return \TransactionType|null - */ - public function transactionTypeByAccounts(\Account $from, \Account $to, $amount = 0) - { - // account types for both: - $toAT = $to->accountType->type; - $fromAT = $from->accountType->type; - - $journalType = null; - - switch (true) { - case ($from->transactions()->count() == 0 && $to->transactions()->count() == 0): - $journalType = \TransactionType::where('type', 'Opening balance')->first(); - break; - - case (in_array($fromAT, ['Default account', 'Asset account']) - && in_array( - $toAT, ['Default account', 'Asset account'] - )): // both are yours: - // determin transaction type. If both accounts are new, it's an initial balance transfer. - $journalType = \TransactionType::where('type', 'Transfer')->first(); - break; - case ($amount < 0): - $journalType = \TransactionType::where('type', 'Deposit')->first(); - break; - // is deposit into one of your own accounts: - case ($toAT == 'Default account' || $toAT == 'Asset account'): - $journalType = \TransactionType::where('type', 'Deposit')->first(); - break; - // is withdrawal from one of your own accounts: - case ($fromAT == 'Default account' || $fromAT == 'Asset account'): - $journalType = \TransactionType::where('type', 'Withdrawal')->first(); - break; - } - - if (is_null($journalType)) { - throw new FireflyException('Could not figure out transaction type.'); - } - return $journalType; - } - - /** * This method finds the expense account mentioned by name. This method is a sneaky little hobbits, * because when you feed it "Import account" it will always return an import account of that type. @@ -630,17 +581,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface return $accounts; } - /** - * @param $name - * @param \AccountType $type - * - * @return \Account - */ - public function findByNameAndAccountType($name, \AccountType $type) - { - return $this->_user->accounts()->where('name', $name)->where('account_type_id', $type->id)->first(); - } - /** * @return mixed */ @@ -705,42 +645,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface return true; } -// /** -// * @return array|mixed -// */ -// public function getActiveDefaultAsSelectList() -// { -// $list = $this->getActiveDefault(); -// $return = []; -// foreach ($list as $entry) { -// $return[intval($entry->id)] = $entry->name; -// } -// -// return $return; -// } - - /** - * @return mixed - */ - public function get() - { - return $this->_user->accounts()->with('accounttype')->orderBy('name', 'ASC')->get(); - } - -// /** -// * @return mixed -// */ -// public function getBeneficiaries() -// { -// $list = $this->_user->accounts()->accountTypeIn(['Beneficiary account', 'Expense account'])->where( -// 'accounts.active', 1 -// )->orderBy( -// 'accounts.name', 'ASC' -// )->get(['accounts.*']); -// -// return $list; -// } - public function getByAccountType(\AccountType $type) { return $this->_user->accounts()->with('accounttype')->orderBy('name', 'ASC') @@ -771,27 +675,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface ) ->get(['accounts.*']); } - - /** - * @return mixed - */ - public function getCashAccount() - { - $type = \AccountType::where('type', 'Cash account')->first(); - $cash = $this->_user->accounts()->where('account_type_id', $type->id)->first(); - if (is_null($cash)) { - $cash = new \Account; - $cash->accountType()->associate($type); - $cash->user()->associate($this->_user); - $cash->name = 'Cash account'; - $cash->active = 1; - $cash->save(); - } - - return $cash; - - } - /** * @return mixed */ diff --git a/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php b/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php index 8886e737e8..87de3a6ed9 100644 --- a/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php @@ -70,11 +70,6 @@ interface BudgetRepositoryInterface */ public function get(); - /** - * @return mixed - */ - public function getAsSelectList(); - /** * @param $data * diff --git a/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php b/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php index 0f177f12ab..4bbecb7c6b 100644 --- a/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php +++ b/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php @@ -381,22 +381,6 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface return $set; } - /** - * @return array - */ - public function getAsSelectList() - { - $list = $this->_user->budgets()->with( - ['limits', 'limits.limitrepetitions'] - )->orderBy('name', 'ASC')->get(); - $return = []; - foreach ($list as $entry) { - $return[intval($entry->id)] = $entry->name; - } - - return $return; - } - /** * @param \Budget $budget * @param $data diff --git a/app/lib/Firefly/Storage/Component/ComponentRepositoryInterface.php b/app/lib/Firefly/Storage/Component/ComponentRepositoryInterface.php deleted file mode 100644 index fc352c92d4..0000000000 --- a/app/lib/Firefly/Storage/Component/ComponentRepositoryInterface.php +++ /dev/null @@ -1,37 +0,0 @@ -_user = \Auth::user(); - } - - /** - * @return mixed - */ - public function count() - { - return $this->_user->components()->count(); - - } - - /** - * @return mixed|void - * @throws \Firefly\Exception\FireflyException - */ - public function get() - { - throw new FireflyException('No implementation.'); - } - - /** - * @param \User $user - * @return mixed|void - */ - public function overruleUser(\User $user) - { - $this->_user = $user; - return true; - } - - /** - * @param $data - * - * @return \Budget|\Category|mixed - * @throws \Firefly\Exception\FireflyException - */ - public function store($data) - { - if (!isset($data['class'])) { - throw new FireflyException('No class type present.'); - } - switch ($data['class']) { - default: - case 'Budget': - $component = new \Budget; - break; - case 'Category': - $component = new \Category; - break; - - } - $component->name = $data['name']; - $component->user()->associate($this->_user); - try { - $component->save(); - } catch (QueryException $e) { - \Log::error('DB ERROR: ' . $e->getMessage()); - throw new FireflyException('Could not save component ' . $data['name'] . ' of type' - . $data['class']); - } - - return $component; - } - -} \ No newline at end of file diff --git a/app/lib/Firefly/Storage/Import/ImportRepositoryInterface.php b/app/lib/Firefly/Storage/Import/ImportRepositoryInterface.php index d72f21cb97..e5a12eeb48 100644 --- a/app/lib/Firefly/Storage/Import/ImportRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Import/ImportRepositoryInterface.php @@ -19,10 +19,28 @@ interface ImportRepositoryInterface */ public function store(\Importmap $map, $class, $oldID, $newID); + /** + * @param $id + * + * @return mixed + */ public function findImportMap($id); + /** + * @param \Importmap $map + * @param $class + * @param $oldID + * + * @return mixed + */ public function findImportEntry(\Importmap $map, $class, $oldID); + /** + * @param \Importmap $map + * @param $oldComponentId + * + * @return mixed + */ public function findImportComponentMap(\Importmap $map, $oldComponentId); /** diff --git a/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php b/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php index f2df5701ac..3f24dd60f0 100644 --- a/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php +++ b/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php @@ -129,19 +129,6 @@ class EloquentLimitRepository implements LimitRepositoryInterface return true; } - /** - * @param $limitId - * - * @return mixed - */ - public function find($limitId) - { - return \Limit::with('limitrepetitions')->where('limits.id', $limitId)->leftJoin( - 'components', 'components.id', '=', 'limits.component_id' - ) - ->where('components.user_id', $this->_user->id)->first(['limits.*']); - } - public function findByBudgetAndDate(\Budget $budget, Carbon $date) { return \Limit::whereComponentId($budget->id)->where('startdate', $date->format('Y-m-d'))->first(); diff --git a/app/lib/Firefly/Storage/Limit/LimitRepositoryInterface.php b/app/lib/Firefly/Storage/Limit/LimitRepositoryInterface.php index b52c4acc4e..92a88a3279 100644 --- a/app/lib/Firefly/Storage/Limit/LimitRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Limit/LimitRepositoryInterface.php @@ -28,12 +28,6 @@ interface LimitRepositoryInterface */ public function destroy(\Limit $limit); - /** - * @param $limitId - * - * @return mixed - */ - public function find($limitId); /** * @param \Budget $budget diff --git a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php index 1965f70d49..2d631222f7 100644 --- a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php +++ b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php @@ -157,16 +157,6 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface )->where('piggybanks.name', $piggyBankName)->first(['piggybanks.*']); } - /** - * @return mixed - */ - public function count() - { - return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where( - 'accounts.user_id', $this->_user->id - )->count(); - } - public function countNonrepeating() { return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where( diff --git a/app/lib/Firefly/Storage/Piggybank/PiggybankRepositoryInterface.php b/app/lib/Firefly/Storage/Piggybank/PiggybankRepositoryInterface.php index cd5b1a3cd7..5e9af3409c 100644 --- a/app/lib/Firefly/Storage/Piggybank/PiggybankRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Piggybank/PiggybankRepositoryInterface.php @@ -21,11 +21,6 @@ interface PiggybankRepositoryInterface */ public function importPiggybank(Job $job, array $payload); - /** - * @return mixed - */ - public function count(); - /** * @return mixed */ diff --git a/app/lib/Firefly/Storage/Reminder/EloquentReminderRepository.php b/app/lib/Firefly/Storage/Reminder/EloquentReminderRepository.php index 651ca91147..9d312ca00a 100644 --- a/app/lib/Firefly/Storage/Reminder/EloquentReminderRepository.php +++ b/app/lib/Firefly/Storage/Reminder/EloquentReminderRepository.php @@ -44,48 +44,4 @@ class EloquentReminderRepository implements ReminderRepositoryInterface return $reminder; } - - /** - * @param $id - * - * @return mixed|void - */ - public function find($id) - { - return \Reminder::find($id); - } - - /** - * @return mixed - */ - public function get() - { - $today = new Carbon; - - return $this->_user->reminders()->validOn($today)->get(); - } - - /** - * @return mixed - */ - public function getPiggybankReminders() - { - $today = new Carbon; - - return $this->_user->reminders()->where('class','PiggybankReminder')->validOn($today)->get(); - } - - /** - * - */ - public function getCurrentRecurringReminders() - { - $today = new Carbon; - - return $this->_user->reminders()->with('recurringtransaction')->validOn($today)->where( - 'class', 'RecurringTransactionReminder' - )->get(); - - } - -} \ No newline at end of file +} \ No newline at end of file diff --git a/app/lib/Firefly/Storage/Reminder/ReminderRepositoryInterface.php b/app/lib/Firefly/Storage/Reminder/ReminderRepositoryInterface.php index 819ddcdb6c..eb648ebe8d 100644 --- a/app/lib/Firefly/Storage/Reminder/ReminderRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Reminder/ReminderRepositoryInterface.php @@ -24,20 +24,6 @@ interface ReminderRepositoryInterface */ public function deactivate(\Reminder $reminder); - /** - * @return mixed - */ - public function get(); - - /** - * @param $id - * - * @return mixed - */ - public function find($id); - - - public function getCurrentRecurringReminders(); /** * @param \User $user diff --git a/app/lib/Firefly/Storage/StorageServiceProvider.php b/app/lib/Firefly/Storage/StorageServiceProvider.php index b44f5f6cfb..3047539535 100644 --- a/app/lib/Firefly/Storage/StorageServiceProvider.php +++ b/app/lib/Firefly/Storage/StorageServiceProvider.php @@ -55,11 +55,6 @@ class StorageServiceProvider extends ServiceProvider 'Firefly\Storage\TransactionJournal\EloquentTransactionJournalRepository' ); - $this->app->bind( - 'Firefly\Storage\Component\ComponentRepositoryInterface', - 'Firefly\Storage\Component\EloquentComponentRepository' - ); - $this->app->bind( 'Firefly\Storage\Limit\LimitRepositoryInterface', 'Firefly\Storage\Limit\EloquentLimitRepository' diff --git a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php index cd975290f1..57eb80aed7 100644 --- a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php +++ b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php @@ -395,48 +395,6 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito ->where('id', $journalId)->first(); } - /** - * @param $type - * - * @return \TransactionType - */ - public function getTransactionType($type) - { - return \TransactionType::whereType($type)->first(); - } - - /** - * @param \Account $account - * @param Carbon $date - * - * @return mixed - */ - public function getByAccountAndDate(\Account $account, Carbon $date) - { - $accountID = $account->id; - $query = $this->_user->transactionjournals()->with( - [ - 'transactions', - 'transactions.account', - 'transactioncurrency', - 'transactiontype' - ] - ) - ->distinct() - ->leftJoin( - 'transactions', 'transactions.transaction_journal_id', '=', - 'transaction_journals.id' - ) - ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') - ->where('transactions.account_id', $accountID) - ->where('transaction_journals.date', $date->format('Y-m-d')) - ->orderBy('transaction_journals.date', 'DESC') - ->orderBy('transaction_journals.id', 'DESC') - ->get(['transaction_journals.*']); - - return $query; - } - /** * @param \Account $account * @param int $count @@ -470,33 +428,6 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito return $query; } - - /** - * @param \TransactionType $type - * @param int $count - * @param Carbon $start - * @param Carbon $end - * - * @return mixed - */ - public function paginate(\TransactionType $type, $count = 25, Carbon $start = null, Carbon $end = null) - { - $query = $this->_user->transactionjournals()->WithRelevantData() - ->transactionTypes([$type->type]) - ->orderBy('transaction_journals.date', 'DESC') - ->orderBy('transaction_journals.id', 'DESC'); - if (!is_null($start)) { - $query->where('transaction_journals.date', '>=', $start->format('Y-m-d')); - } - if (!is_null($end)) { - $query->where('transaction_journals.date', '<=', $end->format('Y-m-d')); - } - - $result = $query->select(['transaction_journals.*'])->paginate($count); - - return $result; - } - /** * @param \TransactionJournal $journal * @param $data diff --git a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php index a5c703bfa9..8726de1f3e 100644 --- a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php +++ b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php @@ -28,23 +28,6 @@ interface TransactionJournalRepositoryInterface */ public function importTransfer(Job $job, array $payload); -// /** -// * @param \Account $from -// * @param \Account $toAccount -// * @param $description -// * @param $amount -// * @param Carbon $date -// * -// * @return mixed -// */ -// public function createSimpleJournal(\Account $from, \Account $toAccount, $description, $amount, Carbon $date); - -// /** -// * @return mixed -// */ -// public function get(); - - /** * @param \User $user * @@ -78,13 +61,6 @@ interface TransactionJournalRepositoryInterface */ public function update(\TransactionJournal $journal, $data); - /** - * @param $type - * - * @return \TransactionType - */ - public function getTransactionType($type); - /** * @param $journalId * @@ -101,23 +77,4 @@ interface TransactionJournalRepositoryInterface * @return mixed */ public function getByAccountInDateRange(\Account $account, $count = 25, Carbon $start, Carbon $end); - - /** - * @param \Account $account - * @param Carbon $date - * - * @return mixed - */ - public function getByAccountAndDate(\Account $account, Carbon $date); - - /** - * @param \TransactionType $type - * @param int $count - * @param Carbon $start - * @param Carbon $end - * - * @return mixed - */ - public function paginate(\TransactionType $type, $count = 25, Carbon $start = null, Carbon $end = null); - } \ No newline at end of file diff --git a/app/lib/Firefly/Storage/User/EloquentUserRepository.php b/app/lib/Firefly/Storage/User/EloquentUserRepository.php index e0ea955b32..476e8ad532 100644 --- a/app/lib/Firefly/Storage/User/EloquentUserRepository.php +++ b/app/lib/Firefly/Storage/User/EloquentUserRepository.php @@ -17,22 +17,6 @@ class EloquentUserRepository implements UserRepositoryInterface { } - /** - * @param $array - * - * @return bool - */ - public function auth($array) - { - $user = \User::where('email', $array['email'])->first(); - if (!is_null($user)) { - if (\Hash::check($array['password'], $user->password)) { - } - } - - return false; - } - /** * @param $email * diff --git a/app/lib/Firefly/Storage/User/UserRepositoryInterface.php b/app/lib/Firefly/Storage/User/UserRepositoryInterface.php index d1192466e3..d74b9cbae9 100644 --- a/app/lib/Firefly/Storage/User/UserRepositoryInterface.php +++ b/app/lib/Firefly/Storage/User/UserRepositoryInterface.php @@ -17,13 +17,6 @@ interface UserRepositoryInterface */ public function register($array); - /** - * @param $array - * - * @return mixed - */ - public function auth($array); - /** * @param $reset *