mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 02:45:58 +00:00
Code cleanup.
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||||
use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud;
|
use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud;
|
||||||
use Firefly\Storage\Category\CategoryRepositoryInterface as Cat;
|
use Firefly\Storage\Category\CategoryRepositoryInterface as Cat;
|
||||||
use Firefly\Storage\Component\ComponentRepositoryInterface as CRI;
|
|
||||||
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
|
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use LaravelBook\Ardent\Builder;
|
use LaravelBook\Ardent\Builder;
|
||||||
@@ -16,7 +15,6 @@ use LaravelBook\Ardent\Builder;
|
|||||||
class JsonController extends BaseController
|
class JsonController extends BaseController
|
||||||
{
|
{
|
||||||
protected $_accounts;
|
protected $_accounts;
|
||||||
protected $_components;
|
|
||||||
protected $_categories;
|
protected $_categories;
|
||||||
protected $_budgets;
|
protected $_budgets;
|
||||||
/** @var TJRI $_journals */
|
/** @var TJRI $_journals */
|
||||||
@@ -24,14 +22,12 @@ class JsonController extends BaseController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ARI $accounts
|
* @param ARI $accounts
|
||||||
* @param CRI $components
|
|
||||||
* @param Cat $categories
|
* @param Cat $categories
|
||||||
* @param Bud $budgets
|
* @param Bud $budgets
|
||||||
* @param TJRI $journals
|
* @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->_accounts = $accounts;
|
||||||
$this->_categories = $categories;
|
$this->_categories = $categories;
|
||||||
$this->_budgets = $budgets;
|
$this->_budgets = $budgets;
|
||||||
|
@@ -310,7 +310,7 @@ class TransactionController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function update(TransactionJournal $journal)
|
public function update(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Firefly\Database;
|
namespace Firefly\Database;
|
||||||
|
|
||||||
use LaravelBook\Ardent\Ardent;
|
use LaravelBook\Ardent\Ardent;
|
||||||
|
@@ -208,8 +208,6 @@ class Chart implements ChartInterface
|
|||||||
'id' => 'spent-norep-' . $budget->id];
|
'id' => 'spent-norep-' . $budget->id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@@ -57,14 +57,6 @@ interface AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function find($accountId);
|
public function find($accountId);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $name
|
|
||||||
* @param \AccountType $type
|
|
||||||
*
|
|
||||||
* @return \Account
|
|
||||||
*/
|
|
||||||
public function findByNameAndAccountType($name, \AccountType $type);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $type
|
* @param $type
|
||||||
*
|
*
|
||||||
@@ -103,19 +95,6 @@ interface AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function findRevenueAccountByName($name);
|
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
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -128,11 +107,6 @@ interface AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getByIds(array $ids);
|
public function getByIds(array $ids);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getCashAccount();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@@ -36,55 +36,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
return $this->_user->accounts()->find($id);
|
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,
|
* 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.
|
* 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;
|
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
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -705,42 +645,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
return true;
|
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)
|
public function getByAccountType(\AccountType $type)
|
||||||
{
|
{
|
||||||
return $this->_user->accounts()->with('accounttype')->orderBy('name', 'ASC')
|
return $this->_user->accounts()->with('accounttype')->orderBy('name', 'ASC')
|
||||||
@@ -771,27 +675,6 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
)
|
)
|
||||||
->get(['accounts.*']);
|
->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
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@@ -70,11 +70,6 @@ interface BudgetRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function get();
|
public function get();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getAsSelectList();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
*
|
*
|
||||||
|
@@ -381,22 +381,6 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
|||||||
return $set;
|
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 \Budget $budget
|
||||||
* @param $data
|
* @param $data
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace Firefly\Storage\Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface ComponentRepositoryInterface
|
|
||||||
*
|
|
||||||
* @package Firefly\Storage\Component
|
|
||||||
*/
|
|
||||||
interface ComponentRepositoryInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function count();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function get();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $data
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function store($data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \User $user
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function overruleUser(\User $user);
|
|
||||||
|
|
||||||
}
|
|
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace Firefly\Storage\Component;
|
|
||||||
|
|
||||||
use Firefly\Exception\FireflyException;
|
|
||||||
use Illuminate\Database\QueryException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class EloquentComponentRepository
|
|
||||||
*
|
|
||||||
* @package Firefly\Storage\Component
|
|
||||||
*/
|
|
||||||
class EloquentComponentRepository implements ComponentRepositoryInterface
|
|
||||||
{
|
|
||||||
public $validator;
|
|
||||||
protected $_user = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -19,10 +19,28 @@ interface ImportRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function store(\Importmap $map, $class, $oldID, $newID);
|
public function store(\Importmap $map, $class, $oldID, $newID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function findImportMap($id);
|
public function findImportMap($id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Importmap $map
|
||||||
|
* @param $class
|
||||||
|
* @param $oldID
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function findImportEntry(\Importmap $map, $class, $oldID);
|
public function findImportEntry(\Importmap $map, $class, $oldID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Importmap $map
|
||||||
|
* @param $oldComponentId
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function findImportComponentMap(\Importmap $map, $oldComponentId);
|
public function findImportComponentMap(\Importmap $map, $oldComponentId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -129,19 +129,6 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
return true;
|
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)
|
public function findByBudgetAndDate(\Budget $budget, Carbon $date)
|
||||||
{
|
{
|
||||||
return \Limit::whereComponentId($budget->id)->where('startdate', $date->format('Y-m-d'))->first();
|
return \Limit::whereComponentId($budget->id)->where('startdate', $date->format('Y-m-d'))->first();
|
||||||
|
@@ -28,12 +28,6 @@ interface LimitRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function destroy(\Limit $limit);
|
public function destroy(\Limit $limit);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $limitId
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function find($limitId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
|
@@ -157,16 +157,6 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
)->where('piggybanks.name', $piggyBankName)->first(['piggybanks.*']);
|
)->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()
|
public function countNonrepeating()
|
||||||
{
|
{
|
||||||
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
return \Piggybank::leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where(
|
||||||
|
@@ -21,11 +21,6 @@ interface PiggybankRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function importPiggybank(Job $job, array $payload);
|
public function importPiggybank(Job $job, array $payload);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function count();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@@ -44,48 +44,4 @@ class EloquentReminderRepository implements ReminderRepositoryInterface
|
|||||||
|
|
||||||
return $reminder;
|
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();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -24,20 +24,6 @@ interface ReminderRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function deactivate(\Reminder $reminder);
|
public function deactivate(\Reminder $reminder);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function get();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $id
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function find($id);
|
|
||||||
|
|
||||||
|
|
||||||
public function getCurrentRecurringReminders();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \User $user
|
* @param \User $user
|
||||||
|
@@ -55,11 +55,6 @@ class StorageServiceProvider extends ServiceProvider
|
|||||||
'Firefly\Storage\TransactionJournal\EloquentTransactionJournalRepository'
|
'Firefly\Storage\TransactionJournal\EloquentTransactionJournalRepository'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->app->bind(
|
|
||||||
'Firefly\Storage\Component\ComponentRepositoryInterface',
|
|
||||||
'Firefly\Storage\Component\EloquentComponentRepository'
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->app->bind(
|
$this->app->bind(
|
||||||
'Firefly\Storage\Limit\LimitRepositoryInterface',
|
'Firefly\Storage\Limit\LimitRepositoryInterface',
|
||||||
'Firefly\Storage\Limit\EloquentLimitRepository'
|
'Firefly\Storage\Limit\EloquentLimitRepository'
|
||||||
|
@@ -395,48 +395,6 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
->where('id', $journalId)->first();
|
->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 \Account $account
|
||||||
* @param int $count
|
* @param int $count
|
||||||
@@ -470,33 +428,6 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
|||||||
|
|
||||||
return $query;
|
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 \TransactionJournal $journal
|
||||||
* @param $data
|
* @param $data
|
||||||
|
@@ -28,23 +28,6 @@ interface TransactionJournalRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function importTransfer(Job $job, array $payload);
|
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
|
* @param \User $user
|
||||||
*
|
*
|
||||||
@@ -78,13 +61,6 @@ interface TransactionJournalRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function update(\TransactionJournal $journal, $data);
|
public function update(\TransactionJournal $journal, $data);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $type
|
|
||||||
*
|
|
||||||
* @return \TransactionType
|
|
||||||
*/
|
|
||||||
public function getTransactionType($type);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $journalId
|
* @param $journalId
|
||||||
*
|
*
|
||||||
@@ -101,23 +77,4 @@ interface TransactionJournalRepositoryInterface
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getByAccountInDateRange(\Account $account, $count = 25, Carbon $start, Carbon $end);
|
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);
|
|
||||||
|
|
||||||
}
|
}
|
@@ -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
|
* @param $email
|
||||||
*
|
*
|
||||||
|
@@ -17,13 +17,6 @@ interface UserRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function register($array);
|
public function register($array);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $array
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function auth($array);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $reset
|
* @param $reset
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user