Skip to content

Firefly III: a personal finances manager

Removed unused methods.

James Coled9c2df5b0d44
diff --git a/app/lib/FireflyIII/Database/Bill/Bill.php b/app/lib/FireflyIII/Database/Bill/Bill.php
index 6e17ffe827..9c9683b7cf 100644
--- a/app/lib/FireflyIII/Database/Bill/Bill.php
+++ b/app/lib/FireflyIII/Database/Bill/Bill.php
@@ -189,19 +189,6 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
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
*
diff --git a/app/lib/FireflyIII/Database/Bill/BillInterface.php b/app/lib/FireflyIII/Database/Bill/BillInterface.php
index f6dca6325f..ec75dd1167 100644
--- a/app/lib/FireflyIII/Database/Bill/BillInterface.php
+++ b/app/lib/FireflyIII/Database/Bill/BillInterface.php
@@ -11,18 +11,6 @@ use Carbon\Carbon;
*/
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
*
diff --git a/app/lib/FireflyIII/Database/Budget/Budget.php b/app/lib/FireflyIII/Database/Budget/Budget.php
index 05f712a259..aaf6eabe3c 100644
--- a/app/lib/FireflyIII/Database/Budget/Budget.php
+++ b/app/lib/FireflyIII/Database/Budget/Budget.php
@@ -8,9 +8,9 @@ use FireflyIII\Database\SwitchUser;
use FireflyIII\Exception\FireflyException;
use FireflyIII\Exception\NotImplementedException;
use Illuminate\Database\Eloquent\Model as Eloquent;
+use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
-use Illuminate\Database\Query\Builder as QueryBuilder;
/**
* Class Budget
@@ -97,6 +97,71 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
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.
*
@@ -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 Carbon $date
@@ -316,20 +291,6 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
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)
* 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)
{
- /** @var \Limit $limit */
+ /** @var \BudgetLimit $limit */
$limit = $this->limitOnStartingOnDate($budget, $date);
if (!$limit) {
// create one!
@@ -381,7 +342,7 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
* @param \Budget $budget
* @param Carbon $date
*
- * @return \Limit
+ * @return \BudgetLimit
*/
public function limitOnStartingOnDate(\Budget $budget, Carbon $date)
{
diff --git a/app/lib/FireflyIII/Database/Category/Category.php b/app/lib/FireflyIII/Database/Category/Category.php
index 873ac9c312..14d8b64da3 100644
--- a/app/lib/FireflyIII/Database/Category/Category.php
+++ b/app/lib/FireflyIII/Database/Category/Category.php
@@ -195,19 +195,6 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
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 Carbon $date