mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Removed unused methods.
This commit is contained in:
parent
a854b2c17e
commit
d9c2df5b0d
@ -189,19 +189,6 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
|
|||||||
return $this->getUser()->bills()->where('active', 1)->get();
|
return $this->getUser()->bills()->where('active', 1)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Bill $bill
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return \TransactionJournal|null
|
|
||||||
*/
|
|
||||||
public function getJournalForBillInRange(\Bill $bill, Carbon $start, Carbon $end)
|
|
||||||
{
|
|
||||||
return $this->getUser()->transactionjournals()->where('bill_id', $bill->id)->after($start)->before($end)->first();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Bill $bill
|
* @param \Bill $bill
|
||||||
*
|
*
|
||||||
|
@ -11,18 +11,6 @@ use Carbon\Carbon;
|
|||||||
*/
|
*/
|
||||||
interface BillInterface
|
interface BillInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @param \Bill $bill
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return null|\TransactionJournal
|
|
||||||
* @internal param Carbon $current
|
|
||||||
* @internal param Carbon $currentEnd
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function getJournalForBillInRange(\Bill $bill, Carbon $start, Carbon $end);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Bill $bill
|
* @param \Bill $bill
|
||||||
*
|
*
|
||||||
|
@ -8,9 +8,9 @@ use FireflyIII\Database\SwitchUser;
|
|||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
use Illuminate\Database\Query\Builder as QueryBuilder;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use Illuminate\Database\Query\Builder as QueryBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Budget
|
* Class Budget
|
||||||
@ -97,6 +97,71 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
|||||||
return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
|
return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function expenseNoBudget(Carbon $start, Carbon $end)
|
||||||
|
{
|
||||||
|
// Add expenses that have no budget:
|
||||||
|
return $this->getUser()
|
||||||
|
->transactionjournals()
|
||||||
|
->whereNotIn(
|
||||||
|
'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) {
|
||||||
|
$query
|
||||||
|
->select('transaction_journals.id')
|
||||||
|
->from('transaction_journals')
|
||||||
|
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
|
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
||||||
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'));
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->before($end)
|
||||||
|
->after($start)
|
||||||
|
->lessThan(0)
|
||||||
|
->transactionTypes(['Withdrawal'])
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function journalsNoBudget(Carbon $start, Carbon $end)
|
||||||
|
{
|
||||||
|
$set = $this->getUser()
|
||||||
|
->transactionjournals()
|
||||||
|
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
|
->whereNull('budget_transaction_journal.id')
|
||||||
|
->before($end)
|
||||||
|
->after($start)
|
||||||
|
->orderBy('transaction_journals.date')
|
||||||
|
->get(['transaction_journals.*']);
|
||||||
|
|
||||||
|
return $set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method includes the time because otherwise, SQLite does not understand it.
|
||||||
|
*
|
||||||
|
* @param \Budget $budget
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return \LimitRepetition|null
|
||||||
|
*/
|
||||||
|
public function repetitionOnStartingOnDate(\Budget $budget, Carbon $date)
|
||||||
|
{
|
||||||
|
return \LimitRepetition::
|
||||||
|
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
|
||||||
|
->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00'))
|
||||||
|
->where('budget_limits.budget_id', $budget->id)
|
||||||
|
->first(['limit_repetitions.*']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an object with id $id.
|
* Returns an object with id $id.
|
||||||
*
|
*
|
||||||
@ -210,96 +275,6 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Budget $budget
|
|
||||||
* @param \LimitRepetition $repetition
|
|
||||||
* @param int $limit
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Pagination\Paginator
|
|
||||||
*/
|
|
||||||
public function getTransactionJournalsInRepetition(\Budget $budget, \LimitRepetition $repetition, $limit = 50)
|
|
||||||
{
|
|
||||||
$start = $repetition->startdate;
|
|
||||||
$end = $repetition->enddate;
|
|
||||||
|
|
||||||
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
|
|
||||||
$set = $budget->transactionJournals()->withRelevantData()->before($end)->after($start)->take($limit)->offset($offset)->orderBy('date', 'DESC')->get(
|
|
||||||
['transaction_journals.*']
|
|
||||||
);
|
|
||||||
$count = $budget->transactionJournals()->before($end)->after($start)->count();
|
|
||||||
$items = [];
|
|
||||||
foreach ($set as $entry) {
|
|
||||||
$items[] = $entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
return \Paginator::make($items, $count, $limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method includes the time because otherwise, SQLite does not understand it.
|
|
||||||
*
|
|
||||||
* @param \Budget $budget
|
|
||||||
* @param Carbon $date
|
|
||||||
*
|
|
||||||
* @return \LimitRepetition|null
|
|
||||||
*/
|
|
||||||
public function repetitionOnStartingOnDate(\Budget $budget, Carbon $date)
|
|
||||||
{
|
|
||||||
return \LimitRepetition::
|
|
||||||
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
|
|
||||||
->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00'))
|
|
||||||
->where('budget_limits.budget_id', $budget->id)
|
|
||||||
->first(['limit_repetitions.*']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function expenseNoBudget(Carbon $start, Carbon $end)
|
|
||||||
{
|
|
||||||
// Add expenses that have no budget:
|
|
||||||
return $this->getUser()
|
|
||||||
->transactionjournals()
|
|
||||||
->whereNotIn(
|
|
||||||
'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) {
|
|
||||||
$query
|
|
||||||
->select('transaction_journals.id')
|
|
||||||
->from('transaction_journals')
|
|
||||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
|
||||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'));
|
|
||||||
}
|
|
||||||
)
|
|
||||||
->before($end)
|
|
||||||
->after($start)
|
|
||||||
->lessThan(0)
|
|
||||||
->transactionTypes(['Withdrawal'])
|
|
||||||
->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function journalsNoBudget(Carbon $start, Carbon $end)
|
|
||||||
{
|
|
||||||
$set = $this->getUser()
|
|
||||||
->transactionjournals()
|
|
||||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
|
||||||
->whereNull('budget_transaction_journal.id')
|
|
||||||
->before($end)
|
|
||||||
->after($start)
|
|
||||||
->orderBy('transaction_journals.date')
|
|
||||||
->get(['transaction_journals.*']);
|
|
||||||
|
|
||||||
return $set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
@ -316,20 +291,6 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
|||||||
return $sum;
|
return $sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Budget $budget
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function spentInPeriod(\Budget $budget, Carbon $start, Carbon $end)
|
|
||||||
{
|
|
||||||
$sum = floatval($budget->transactionjournals()->before($end)->after($start)->lessThan(0)->sum('amount')) * -1;
|
|
||||||
|
|
||||||
return $sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method updates the amount (envelope) for the given date and budget. This results in a (new) limit (aka an envelope)
|
* This method updates the amount (envelope) for the given date and budget. This results in a (new) limit (aka an envelope)
|
||||||
* for that budget. Returned to the user is the new limit repetition.
|
* for that budget. Returned to the user is the new limit repetition.
|
||||||
@ -343,7 +304,7 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
|||||||
*/
|
*/
|
||||||
public function updateLimitAmount(\Budget $budget, Carbon $date, $amount)
|
public function updateLimitAmount(\Budget $budget, Carbon $date, $amount)
|
||||||
{
|
{
|
||||||
/** @var \Limit $limit */
|
/** @var \BudgetLimit $limit */
|
||||||
$limit = $this->limitOnStartingOnDate($budget, $date);
|
$limit = $this->limitOnStartingOnDate($budget, $date);
|
||||||
if (!$limit) {
|
if (!$limit) {
|
||||||
// create one!
|
// create one!
|
||||||
@ -381,7 +342,7 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
|
|||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return \Limit
|
* @return \BudgetLimit
|
||||||
*/
|
*/
|
||||||
public function limitOnStartingOnDate(\Budget $budget, Carbon $date)
|
public function limitOnStartingOnDate(\Budget $budget, Carbon $date)
|
||||||
{
|
{
|
||||||
|
@ -195,19 +195,6 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
|
|||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Category $category
|
|
||||||
* @param Carbon $date
|
|
||||||
*
|
|
||||||
* @return null
|
|
||||||
* @throws NotImplementedException
|
|
||||||
* @internal param \Category $budget
|
|
||||||
*/
|
|
||||||
public function repetitionOnStartingOnDate(\Category $category, Carbon $date)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Category $category
|
* @param \Category $category
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
|
Loading…
Reference in New Issue
Block a user