mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup.
This commit is contained in:
parent
c77b43458e
commit
3cfa3f3b27
@ -90,7 +90,7 @@ Breadcrumbs::register(
|
||||
$breadcrumbs->push($budget->name, route('budgets.show', $budget->id));
|
||||
if (!is_null($repetition)) {
|
||||
$breadcrumbs->push(
|
||||
DateKit::periodShow($repetition->startdate, $repetition->limit->repeat_freq), route('budgets.show', $budget->id, $repetition->id)
|
||||
DateKit::periodShow($repetition->startdate, $repetition->budgetlimit->repeat_freq), route('budgets.show', $budget->id, $repetition->id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use FireflyIII\Shared\Preferences\PreferencesInterface as Pref;
|
||||
/**
|
||||
* Class BudgetController
|
||||
*
|
||||
* TODO move AJAX methods to their own BudgetAjaxControlle
|
||||
* TODO move AJAX methods to their own BudgetAjaxController
|
||||
* TODO Find out what constitutes proper camelCase
|
||||
* TODO How is object coupling counted?
|
||||
*
|
||||
@ -44,7 +44,7 @@ class BudgetController extends BaseController
|
||||
public function amount(Budget $budget)
|
||||
{
|
||||
$amount = intval(Input::get('amount'));
|
||||
$date = Session::get('start',Carbon::now()->startOfMonth());
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$limitRepetition = $this->_repository->updateLimitAmount($budget, $date, $amount);
|
||||
|
||||
return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition->id]);
|
||||
@ -112,16 +112,18 @@ class BudgetController extends BaseController
|
||||
$budgets->each(
|
||||
function (Budget $budget) {
|
||||
/** @noinspection PhpUndefinedFieldInspection */
|
||||
$budget->spent = $this->_repository->spentInMonth($budget, \Session::get('start',Carbon::now()->startOfMonth()));
|
||||
$budget->spent = $this->_repository->spentInMonth($budget, \Session::get('start', Carbon::now()->startOfMonth()));
|
||||
/** @noinspection PhpUndefinedFieldInspection */
|
||||
$budget->currentRep = $budget->limitrepetitions()->where('limit_repetitions.startdate', \Session::get('start',Carbon::now()->startOfMonth())->format('Y-m-d'))->first(
|
||||
$budget->currentRep = $budget->limitrepetitions()->where(
|
||||
'limit_repetitions.startdate', \Session::get('start', Carbon::now()->startOfMonth())->format('Y-m-d')
|
||||
)->first(
|
||||
['limit_repetitions.*']
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$spent = $budgets->sum('spent');
|
||||
$amount = $this->_preferences->get('budgetIncomeTotal' . \Session::get('start',Carbon::now()->startOfMonth())->format('FY'), 1000)->data;
|
||||
$amount = $this->_preferences->get('budgetIncomeTotal' . \Session::get('start', Carbon::now()->startOfMonth())->format('FY'), 1000)->data;
|
||||
$overspent = $spent > $amount;
|
||||
$spentPCT = $overspent ? ceil($amount / $spent * 100) : ceil($spent / $amount * 100);
|
||||
|
||||
@ -133,7 +135,7 @@ class BudgetController extends BaseController
|
||||
*/
|
||||
public function postUpdateIncome()
|
||||
{
|
||||
$this->_preferences->set('budgetIncomeTotal' . Session::get('start',Carbon::now()->startOfMonth())->format('FY'), intval(Input::get('amount')));
|
||||
$this->_preferences->set('budgetIncomeTotal' . Session::get('start', Carbon::now()->startOfMonth())->format('FY'), intval(Input::get('amount')));
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
@ -146,13 +148,13 @@ class BudgetController extends BaseController
|
||||
*/
|
||||
public function show(Budget $budget, LimitRepetition $repetition = null)
|
||||
{
|
||||
if (!is_null($repetition) && $repetition->limit->budget->id != $budget->id) {
|
||||
if (!is_null($repetition) && $repetition->budgetlimit->budget->id != $budget->id) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
$hideBudget = true; // used in transaction list.
|
||||
$journals = $this->_repository->getJournals($budget, $repetition);
|
||||
$limits = $repetition ? [$repetition->limit] : $budget->limits()->orderBy('startdate', 'DESC')->get();
|
||||
$limits = $repetition ? [$repetition->limit] : $budget->budgetlimits()->orderBy('startdate', 'DESC')->get();
|
||||
$subTitle = $repetition ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name);
|
||||
|
||||
return View::make('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle', 'hideBudget'));
|
||||
@ -244,7 +246,7 @@ class BudgetController extends BaseController
|
||||
*/
|
||||
public function updateIncome()
|
||||
{
|
||||
$budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start',Carbon::now()->startOfMonth())->format('FY'), 1000);
|
||||
$budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start', Carbon::now()->startOfMonth())->format('FY'), 1000);
|
||||
|
||||
return View::make('budgets.income')->with('amount', $budgetAmount);
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use Grumpydictator\Gchart\GChart as GChart;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CamelCase")
|
||||
*
|
||||
* Class GoogleChartController
|
||||
*/
|
||||
class GoogleChartController extends BaseController
|
||||
@ -119,11 +120,9 @@ class GoogleChartController extends BaseController
|
||||
*/
|
||||
public function allBudgetsHomeChart()
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Budget', 'string');
|
||||
$chart->addColumn('Budgeted', 'number');
|
||||
$chart->addColumn('Spent', 'number');
|
||||
$this->_chart->addColumn('Budget', 'string');
|
||||
$this->_chart->addColumn('Budgeted', 'number');
|
||||
$this->_chart->addColumn('Spent', 'number');
|
||||
|
||||
/** @var \FireflyIII\Database\Budget $bdt */
|
||||
$bdt = App::make('FireflyIII\Database\Budget');
|
||||
@ -165,7 +164,7 @@ class GoogleChartController extends BaseController
|
||||
*/
|
||||
$expenses = floatval($budget->transactionjournals()->before($searchEnd)->after($searchStart)->lessThan(0)->sum('amount')) * -1;
|
||||
if ($expenses > 0) {
|
||||
$chart->addRow($budget->name, $limit, $expenses);
|
||||
$this->_chart->addRow($budget->name, $limit, $expenses);
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,12 +174,12 @@ class GoogleChartController extends BaseController
|
||||
*/
|
||||
$noBudgetSet = $bdt->transactionsWithoutBudgetInDateRange(Session::get('start', Carbon::now()->startOfMonth()), Session::get('end'));
|
||||
$sum = $noBudgetSet->sum('amount') * -1;
|
||||
$chart->addRow('No budget', 0, $sum);
|
||||
$this->_chart->addRow('No budget', 0, $sum);
|
||||
|
||||
|
||||
$chart->generate();
|
||||
$this->_chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
return Response::json($this->_chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,9 +29,9 @@ class HelpController extends BaseController
|
||||
}
|
||||
|
||||
// get the help-content from Github:
|
||||
$URL = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';
|
||||
$uri = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';
|
||||
try {
|
||||
$content = file_get_contents($URL);
|
||||
$content = file_get_contents($uri);
|
||||
} catch (ErrorException $e) {
|
||||
$content = '<p>There is no help for this route.</p>';
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ use FireflyIII\Database\TransactionJournal as TransactionJournalRepository;
|
||||
use FireflyIII\Report\ReportInterface as ReportHelper;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CamelCase")
|
||||
*
|
||||
* Class ReportController
|
||||
*/
|
||||
class ReportController extends BaseController
|
||||
@ -163,7 +165,7 @@ class ReportController extends BaseController
|
||||
public function unbalanced($year, $month)
|
||||
{
|
||||
try {
|
||||
$date = new Carbon($year . '-' . $month . '-01');
|
||||
new Carbon($year . '-' . $month . '-01');
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ class TransactionController extends BaseController
|
||||
}
|
||||
}
|
||||
$unique = array_unique($ids);
|
||||
if (count($ids) > 0) {
|
||||
if (count($unique) > 0) {
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $repository */
|
||||
$repository = App::make('FireflyIII\Database\TransactionJournal');
|
||||
$set = $repository->getByIds($ids);
|
||||
$set = $repository->getByIds($unique);
|
||||
$set->each(
|
||||
function (TransactionJournal $journal) {
|
||||
$journal->amount = mf($journal->getAmount());
|
||||
@ -544,6 +544,7 @@ class TransactionController extends BaseController
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return $this
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(TransactionJournal $journal)
|
||||
|
@ -30,19 +30,19 @@ class CreateComponentTransactionJournalTable extends Migration
|
||||
{
|
||||
Schema::create(
|
||||
'component_transaction_journal', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('component_id')->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
$table->increments('id');
|
||||
$table->integer('component_id')->unsigned();
|
||||
$table->integer('transaction_journal_id')->unsigned();
|
||||
|
||||
// link components with component_id
|
||||
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
|
||||
// link components with component_id
|
||||
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
|
||||
|
||||
// link transaction journals with transaction_journal_id
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
// link transaction journals with transaction_journal_id
|
||||
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
|
||||
|
||||
// combo must be unique:
|
||||
$table->unique(['component_id', 'transaction_journal_id'],'cid_tjid_unique');
|
||||
}
|
||||
// combo must be unique:
|
||||
$table->unique(['component_id', 'transaction_journal_id'], 'cid_tjid_unique');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -30,21 +30,21 @@ class CreateComponentRecurringTransactionTable extends Migration
|
||||
{
|
||||
Schema::create(
|
||||
'component_recurring_transaction', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('component_id')->unsigned();
|
||||
$table->integer('recurring_transaction_id')->unsigned();
|
||||
$table->boolean('optional');
|
||||
$table->increments('id');
|
||||
$table->integer('component_id')->unsigned();
|
||||
$table->integer('recurring_transaction_id')->unsigned();
|
||||
$table->boolean('optional');
|
||||
|
||||
// link components with component_id
|
||||
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
|
||||
// link components with component_id
|
||||
$table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
|
||||
|
||||
// link transaction journals with transaction_journal_id
|
||||
$table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('cascade');
|
||||
// link transaction journals with transaction_journal_id
|
||||
$table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('cascade');
|
||||
|
||||
// component and recurring transaction must be unique.
|
||||
$table->unique(['component_id','recurring_transaction_id'],'cid_rtid_unique');
|
||||
// component and recurring transaction must be unique.
|
||||
$table->unique(['component_id', 'recurring_transaction_id'], 'cid_rtid_unique');
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class ChangesForV321
|
||||
*/
|
||||
class ChangesForV321 extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
DB::update(DB::raw('RENAME TABLE `budget_limits` TO `limits`;'));
|
||||
DB::update(DB::raw('ALTER TABLE `limit_repetitions` ALGORITHM=INPLACE, CHANGE `budget_limit_id` `limit_id` INT UNSIGNED NOT NULL'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::update(DB::raw('RENAME TABLE `limits` TO `budget_limits`;'));
|
||||
DB::update(DB::raw('ALTER TABLE `limit_repetitions` ALGORITHM=INPLACE, CHANGE `limit_id` `budget_limit_id` INT UNSIGNED NOT NULL'));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -17,8 +17,6 @@ class TestContentSeeder extends Seeder
|
||||
$revenueType = AccountType::whereType('Revenue account')->first();
|
||||
$ibType = AccountType::whereType('Initial balance account')->first();
|
||||
|
||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||
|
||||
$obType = TransactionType::whereType('Opening balance')->first();
|
||||
$withdrawal = TransactionType::whereType('Withdrawal')->first();
|
||||
$transfer = TransactionType::whereType('Transfer')->first();
|
||||
@ -132,11 +130,15 @@ class TestContentSeeder extends Seeder
|
||||
* @param $description
|
||||
* @param $date
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Category $category
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function createTransaction(
|
||||
Account $from, Account $to, $amount, TransactionType $type, $description, $date, Budget $budget = null, Category $category = null
|
||||
) {
|
||||
)
|
||||
{
|
||||
$user = User::whereEmail('thegrumpydictator@gmail.com')->first();
|
||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||
|
||||
|
@ -5,6 +5,11 @@ namespace FireflyIII\Collection;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class PiggybankPart
|
||||
*
|
||||
* @package FireflyIII\Collection
|
||||
*/
|
||||
class PiggybankPart
|
||||
{
|
||||
/** @var float */
|
||||
@ -92,11 +97,17 @@ class PiggybankPart
|
||||
$this->targetdate = $targetdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasReminder()
|
||||
{
|
||||
return !is_null($this->reminder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float|int
|
||||
*/
|
||||
public function percentage()
|
||||
{
|
||||
if ($this->getCurrentamount() < $this->getCumulativeAmount()) {
|
||||
|
@ -221,7 +221,7 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
{
|
||||
|
||||
// delete journals:
|
||||
$journals = \TransactionJournal::whereIn(
|
||||
\TransactionJournal::whereIn(
|
||||
'id', function ($query) use ($model) {
|
||||
$query->select('transaction_journal_id')
|
||||
->from('transactions')->whereIn(
|
||||
@ -454,10 +454,9 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
|
||||
*
|
||||
* @param $what
|
||||
*
|
||||
* @throws NotImplementedException
|
||||
* @return \AccountType|null
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
@ -470,6 +469,7 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
* Returns all objects.
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
@ -487,6 +487,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
return $this->getUser()->accounts()->whereIn('id', $ids)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return static
|
||||
* @throws \FireflyIII\Exception\FireflyException
|
||||
*/
|
||||
public function firstExpenseAccountOrCreate($name)
|
||||
{
|
||||
/** @var \FireflyIII\Database\AccountType $accountTypeRepos */
|
||||
@ -510,6 +516,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return static
|
||||
* @throws \FireflyIII\Exception\FireflyException
|
||||
*/
|
||||
public function firstRevenueAccountOrCreate($name)
|
||||
{
|
||||
/** @var \FireflyIII\Database\AccountType $accountTypeRepos */
|
||||
@ -523,6 +535,12 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
* @param int $limit
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getAllTransactionJournals(\Account $account, $limit = 50)
|
||||
{
|
||||
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
|
||||
@ -568,6 +586,13 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
* @param int $limit
|
||||
* @param string $range
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getTransactionJournals(\Account $account, $limit = 50, $range = 'session')
|
||||
{
|
||||
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
|
||||
@ -580,8 +605,8 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
->orderBy('date', 'DESC');
|
||||
|
||||
if ($range == 'session') {
|
||||
$query->before(\Session::get('end', \Carbon\Carbon::now()->startOfMonth()));
|
||||
$query->after(\Session::get('start', \Carbon\Carbon::now()->startOfMonth()));
|
||||
$query->before(\Session::get('end', Carbon::now()->startOfMonth()));
|
||||
$query->after(\Session::get('start', Carbon::now()->startOfMonth()));
|
||||
}
|
||||
$count = $query->count();
|
||||
$set = $query->take($limit)->offset($offset)->get(['transaction_journals.*']);
|
||||
|
@ -21,6 +21,7 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
@ -32,6 +33,7 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -41,9 +43,10 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
@ -58,6 +61,7 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
* @param array $model
|
||||
*
|
||||
* @return array
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function validate(array $model)
|
||||
{
|
||||
@ -71,6 +75,7 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
@ -115,6 +120,7 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
* Returns all objects.
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
@ -126,6 +132,7 @@ class AccountType implements CUD, CommonDatabaseCalls
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
|
@ -136,6 +136,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
@ -159,6 +160,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
@ -200,6 +202,12 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
return \Paginator::make($items, $count, $take);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Budget $budget
|
||||
* @param int $limit
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getTransactionJournals(\Budget $budget, $limit = 50)
|
||||
{
|
||||
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
|
||||
@ -214,6 +222,13 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
@ -241,8 +256,8 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
public function repetitionOnStartingOnDate(\Budget $budget, Carbon $date)
|
||||
{
|
||||
return \LimitRepetition::
|
||||
leftJoin('limits', 'limit_repetitions.limit_id', '=', 'limits.id')->leftJoin(
|
||||
'components', 'limits.component_id', '=', 'components.id'
|
||||
leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')->leftJoin(
|
||||
'components', 'budget_limits.component_id', '=', 'components.id'
|
||||
)->where('limit_repetitions.startdate', $date->format('Y-m-d'))->where(
|
||||
'components.id', $budget->id
|
||||
)->first(['limit_repetitions.*']);
|
||||
|
@ -124,6 +124,7 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
@ -137,6 +138,7 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
@ -158,6 +160,7 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
@ -165,11 +168,22 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function firstOrCreate($name)
|
||||
{
|
||||
return \Category::firstOrCreate(['user_id' => $this->getUser()->id, 'name' => $name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Category $category
|
||||
* @param int $limit
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getTransactionJournals(\Category $category, $limit = 50)
|
||||
{
|
||||
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
|
||||
@ -185,10 +199,11 @@ class Category implements CUD, CommonDatabaseCalls
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Category $budget
|
||||
* @param \Category $category
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return null
|
||||
* @internal param \Category $budget
|
||||
*/
|
||||
public function repetitionOnStartingOnDate(\Category $category, Carbon $date)
|
||||
{
|
||||
|
@ -13,10 +13,13 @@ interface RecurringInterface
|
||||
{
|
||||
/**
|
||||
* @param \RecurringTransaction $recurring
|
||||
* @param Carbon $current
|
||||
* @param Carbon $currentEnd
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return null|\TransactionJournal
|
||||
* @internal param Carbon $current
|
||||
* @internal param Carbon $currentEnd
|
||||
*
|
||||
* @return \TransactionJournal|null
|
||||
*/
|
||||
public function getJournalForRecurringInRange(\RecurringTransaction $recurring, Carbon $start, Carbon $end);
|
||||
|
||||
|
@ -5,6 +5,11 @@ namespace FireflyIII\Database\Ifaces;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Interface ReportInterface
|
||||
*
|
||||
* @package FireflyIII\Database\Ifaces
|
||||
*/
|
||||
interface ReportInterface
|
||||
{
|
||||
|
||||
|
@ -203,6 +203,7 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
@ -224,6 +225,7 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
@ -231,7 +233,16 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
public function findRepetitionByDate(\Piggybank $piggybank, Carbon $date)
|
||||
/**
|
||||
* @param \Piggybank $piggybank
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FireflyException
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findRepetitionByDate(\Piggybank $piggybank, /** @noinspection PhpUnusedParameterInspection */
|
||||
Carbon $date)
|
||||
{
|
||||
$reps = $piggybank->piggybankrepetitions()->get();
|
||||
if ($reps->count() == 1) {
|
||||
|
@ -183,6 +183,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
@ -196,6 +197,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
@ -217,6 +219,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
|
@ -13,6 +13,11 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
|
||||
/**
|
||||
* Class RepeatedExpense
|
||||
*
|
||||
* @package FireflyIII\Database
|
||||
*/
|
||||
class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
{
|
||||
use SwitchUser;
|
||||
@ -30,6 +35,8 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
* other variables this method tries to divide the piggy bank into equal parts. Each is
|
||||
* accommodated by a reminder (if everything goes to plan).
|
||||
*
|
||||
* @param \PiggybankRepetition $repetition
|
||||
*
|
||||
* @return \PiggybankRepetition
|
||||
*/
|
||||
public function calculateParts(\PiggybankRepetition $repetition)
|
||||
@ -98,7 +105,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
foreach ($bars as $index => $bar) {
|
||||
$bar->setAmountPerBar($amountPerBar);
|
||||
$bar->setCumulativeAmount($cumulative);
|
||||
if($parts -1 == $index) {
|
||||
if ($parts - 1 == $index) {
|
||||
$bar->setCumulativeAmount($piggyBank->targetamount);
|
||||
}
|
||||
|
||||
@ -275,6 +282,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
@ -316,9 +324,10 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
@ -426,6 +435,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
@ -439,6 +449,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
@ -460,6 +471,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
@ -471,6 +483,7 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||
* @param \Account $account
|
||||
*
|
||||
* @return float
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function leftOnAccount(\Account $account)
|
||||
{
|
||||
|
@ -12,6 +12,11 @@ namespace FireflyIII\Database;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Database\Ifaces\ReportInterface;
|
||||
|
||||
/**
|
||||
* Class Report
|
||||
*
|
||||
* @package FireflyIII\Database
|
||||
*/
|
||||
class Report implements ReportInterface
|
||||
{
|
||||
use SwitchUser;
|
||||
|
@ -24,6 +24,7 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
@ -35,6 +36,7 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -59,9 +61,10 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
@ -141,6 +144,7 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
@ -154,6 +158,7 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
@ -165,6 +170,7 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
* Returns all objects.
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
@ -176,6 +182,7 @@ class Transaction implements CUD, CommonDatabaseCalls
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
|
@ -58,6 +58,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -174,6 +175,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
@ -186,9 +188,6 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
/** @var \FireflyIII\Database\TransactionCurrency $currencyRepository */
|
||||
$currencyRepository = \App::make('FireflyIII\Database\TransactionCurrency');
|
||||
|
||||
/** @var \FireflyIII\Database\Transaction $transactionRepository */
|
||||
$transactionRepository = \App::make('FireflyIII\Database\Transaction');
|
||||
|
||||
$journalType = $typeRepository->findByWhat($data['what']);
|
||||
$currency = $currencyRepository->findByCode($data['currency']);
|
||||
|
||||
@ -284,6 +283,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
* @param array $model
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function validate(array $model)
|
||||
{
|
||||
@ -350,7 +350,6 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
/*
|
||||
* Many checks to catch invalid or not-existing accounts.
|
||||
*/
|
||||
$accountError = false;
|
||||
switch (true) {
|
||||
// this combination is often seen in withdrawals.
|
||||
case (isset($model['account_id']) && isset($model['expense_account'])):
|
||||
@ -458,6 +457,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
@ -560,6 +560,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
return $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getDepositsPaginated($limit = 50)
|
||||
{
|
||||
$offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
|
||||
@ -599,6 +604,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getTransfersPaginated($limit = 50)
|
||||
{
|
||||
$offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
|
||||
@ -615,6 +625,11 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
return \Paginator::make($items, $count, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return \Illuminate\Pagination\Paginator
|
||||
*/
|
||||
public function getWithdrawalsPaginated($limit = 50)
|
||||
{
|
||||
$offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
|
||||
|
@ -23,6 +23,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
* @param \Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function destroy(\Eloquent $model)
|
||||
{
|
||||
@ -34,6 +35,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
@ -43,9 +45,10 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
|
||||
/**
|
||||
* @param \Eloquent $model
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function update(\Eloquent $model, array $data)
|
||||
{
|
||||
@ -60,6 +63,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
* @param array $model
|
||||
*
|
||||
* @return array
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function validate(array $model)
|
||||
{
|
||||
@ -73,6 +77,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Eloquent
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
@ -86,6 +91,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
@ -114,6 +120,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
* Returns all objects.
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
@ -125,6 +132,7 @@ class TransactionType implements CUD, CommonDatabaseCalls
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
|
@ -5,14 +5,25 @@ namespace FireflyIII\Event;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
/**
|
||||
* Class Account
|
||||
*
|
||||
* @package FireflyIII\Event
|
||||
*/
|
||||
class Account
|
||||
{
|
||||
/**
|
||||
* @param \Account $account
|
||||
*/
|
||||
public function destroy(\Account $account)
|
||||
{
|
||||
\Cache::forget('account.' . $account->id . '.latestBalance');
|
||||
\Cache::forget('account.' . $account->id . '.lastActivityDate');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
*/
|
||||
public function store(\Account $account)
|
||||
{
|
||||
|
||||
@ -31,6 +42,9 @@ class Account
|
||||
$events->listen('account.destroy', 'FireflyIII\Event\Account@destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
*/
|
||||
public function update(\Account $account)
|
||||
{
|
||||
\Cache::forget('account.' . $account->id . '.latestBalance');
|
||||
|
@ -5,35 +5,40 @@ namespace FireflyIII\Event;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
/**
|
||||
* Class Budget
|
||||
*
|
||||
* @package FireflyIII\Event
|
||||
*/
|
||||
class Budget
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \Limit $limit
|
||||
* @param \BudgetLimit $budgetLimit
|
||||
*/
|
||||
public function storeOrUpdateLimit(\Limit $limit)
|
||||
public function storeOrUpdateLimit(\BudgetLimit $budgetLimit)
|
||||
{
|
||||
|
||||
|
||||
$end = \DateKit::addPeriod(clone $limit->startdate, $limit->repeat_freq, 0);
|
||||
$end = \DateKit::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
|
||||
$end->subDay();
|
||||
|
||||
$set = $limit->limitrepetitions()->where('startdate', $limit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->get();
|
||||
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->get();
|
||||
/*
|
||||
* Create new LimitRepetition:
|
||||
*/
|
||||
if ($set->count() == 0) {
|
||||
|
||||
$repetition = new \LimitRepetition();
|
||||
$repetition->startdate = $limit->startdate;
|
||||
$repetition->startdate = $budgetLimit->startdate;
|
||||
$repetition->enddate = $end;
|
||||
$repetition->amount = $limit->amount;
|
||||
$repetition->limit()->associate($limit);
|
||||
$repetition->amount = $budgetLimit->amount;
|
||||
$repetition->budgetLimit()->associate($budgetLimit);
|
||||
|
||||
try {
|
||||
$repetition->save();
|
||||
} catch (QueryException $e) {
|
||||
\Log::error('Trying to save new Limitrepetition failed!');
|
||||
\Log::error('Trying to save new LimitRepetition failed!');
|
||||
\Log::error($e->getMessage());
|
||||
}
|
||||
} else {
|
||||
@ -42,7 +47,7 @@ class Budget
|
||||
* Update existing one.
|
||||
*/
|
||||
$repetition = $set->first();
|
||||
$repetition->amount = $limit->amount;
|
||||
$repetition->amount = $budgetLimit->amount;
|
||||
$repetition->save();
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,19 @@ namespace FireflyIII\Event;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
|
||||
/**
|
||||
* Class Event
|
||||
*
|
||||
* @package FireflyIII\Event
|
||||
*/
|
||||
class Event
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function deleteAccount(\Account $account)
|
||||
{
|
||||
// get piggy banks
|
||||
|
@ -6,6 +6,11 @@ namespace FireflyIII\Event;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
/**
|
||||
* Class Piggybank
|
||||
*
|
||||
* @package FireflyIII\Event
|
||||
*/
|
||||
class Piggybank
|
||||
{
|
||||
|
||||
@ -21,13 +26,19 @@ class Piggybank
|
||||
$event->amount = floatval($amount);
|
||||
$event->date = new Carbon;
|
||||
if (!$event->isValid()) {
|
||||
var_dump($event->getErrors());
|
||||
exit();
|
||||
\Log::error($event->getErrors());
|
||||
\App::abort(500);
|
||||
}
|
||||
$event->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \TransactionJournal $journal
|
||||
*
|
||||
* @throws \FireflyIII\Exception\FireflyException
|
||||
* @throws \FireflyIII\Exception\NotImplementedException
|
||||
*/
|
||||
public function destroyTransfer(\TransactionJournal $journal)
|
||||
{
|
||||
if ($journal->piggybankevents()->count() > 0) {
|
||||
@ -88,6 +99,9 @@ class Piggybank
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Piggybank $piggybank
|
||||
*/
|
||||
public function storePiggybank(\Piggybank $piggybank)
|
||||
{
|
||||
if (intval($piggybank->repeats) == 0) {
|
||||
@ -250,6 +264,9 @@ class Piggybank
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Piggybank $piggyBank
|
||||
*/
|
||||
public function updatePiggybank(\Piggybank $piggyBank)
|
||||
{
|
||||
// get the repetition:
|
||||
@ -259,6 +276,12 @@ class Piggybank
|
||||
$repetition->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \TransactionJournal $journal
|
||||
*
|
||||
* @throws \FireflyIII\Exception\FireflyException
|
||||
* @throws \FireflyIII\Exception\NotImplementedException
|
||||
*/
|
||||
public function updateTransfer(\TransactionJournal $journal)
|
||||
{
|
||||
|
||||
|
@ -5,14 +5,25 @@ namespace FireflyIII\Event;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
/**
|
||||
* Class Transaction
|
||||
*
|
||||
* @package FireflyIII\Event
|
||||
*/
|
||||
class Transaction
|
||||
{
|
||||
/**
|
||||
* @param \Transaction $transaction
|
||||
*/
|
||||
public function destroy(\Transaction $transaction)
|
||||
{
|
||||
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
|
||||
\Cache::forget('account.' . $transaction->account_id . '.lastActivityDate');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Transaction $transaction
|
||||
*/
|
||||
public function store(\Transaction $transaction)
|
||||
{
|
||||
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
|
||||
@ -30,6 +41,9 @@ class Transaction
|
||||
$events->listen('transaction.destroy', 'FireflyIII\Event\Transaction@destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Transaction $transaction
|
||||
*/
|
||||
public function update(\Transaction $transaction)
|
||||
{
|
||||
\Cache::forget('account.' . $transaction->account_id . '.latestBalance');
|
||||
|
@ -4,10 +4,19 @@ namespace FireflyIII\Event;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
/**
|
||||
* Class TransactionJournal
|
||||
*
|
||||
* @package FireflyIII\Event
|
||||
*/
|
||||
class TransactionJournal
|
||||
{
|
||||
|
||||
public function store(\TransactionJournal $journal, $id = 0)
|
||||
/**
|
||||
* @param \TransactionJournal $journal
|
||||
* @param int $id
|
||||
*/
|
||||
public function store(\TransactionJournal $journal)
|
||||
{
|
||||
/** @var \FireflyIII\Database\Recurring $repository */
|
||||
$repository = \App::make('FireflyIII\Database\Recurring');
|
||||
@ -30,6 +39,9 @@ class TransactionJournal
|
||||
$events->listen('transactionJournal.update', 'FireflyIII\Event\TransactionJournal@update');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \TransactionJournal $journal
|
||||
*/
|
||||
public function update(\TransactionJournal $journal)
|
||||
{
|
||||
/** @var \FireflyIII\Database\Recurring $repository */
|
||||
|
@ -287,18 +287,17 @@ class Form
|
||||
/*
|
||||
* Store.
|
||||
*/
|
||||
$store = '';
|
||||
switch ($type) {
|
||||
case 'create':
|
||||
$store = '<div class="form-group"><label for="default" class="col-sm-4 control-label">Store</label>';
|
||||
$store = '<div class="form-group"><label for="' . $name . '_store" class="col-sm-4 control-label">Store</label>';
|
||||
$store .= '<div class="col-sm-8"><div class="radio"><label>';
|
||||
$store .= \Form::radio('post_submit_action', 'store', $previousValue == 'store');
|
||||
$store .= \Form::radio('post_submit_action', 'store', $previousValue == 'store', ['id' => $name . '_store']);
|
||||
$store .= 'Store ' . $name . '</label></div></div></div>';
|
||||
break;
|
||||
case 'update':
|
||||
$store = '<div class="form-group"><label for="default" class="col-sm-4 control-label">Store</label>';
|
||||
$store = '<div class="form-group"><label for="' . $name . 'update" class="col-sm-4 control-label">Store</label>';
|
||||
$store .= '<div class="col-sm-8"><div class="radio"><label>';
|
||||
$store .= \Form::radio('post_submit_action', 'update', $previousValue == 'store');
|
||||
$store .= \Form::radio('post_submit_action', 'update', $previousValue == 'update', ['id' => $name . '_update']);
|
||||
$store .= 'Update ' . $name . '</label></div></div></div>';
|
||||
break;
|
||||
default:
|
||||
@ -309,9 +308,9 @@ class Form
|
||||
/*
|
||||
* validate is always the same:
|
||||
*/
|
||||
$validate = '<div class="form-group"><label for="validate_only" class="col-sm-4 control-label">Validate only';
|
||||
$validate = '<div class="form-group"><label for="' . $name . 'validate_only" class="col-sm-4 control-label">Validate only';
|
||||
$validate .= '</label><div class="col-sm-8"><div class="radio"><label>';
|
||||
$validate .= \Form::radio('post_submit_action', 'validate_only', $previousValue == 'validate_only');
|
||||
$validate .= \Form::radio('post_submit_action', 'validate_only', $previousValue == 'validate_only', ['id' => $name . '_validate_only']);
|
||||
$validate .= 'Only validate, do not save</label></div></div></div>';
|
||||
|
||||
/*
|
||||
@ -319,15 +318,15 @@ class Form
|
||||
*/
|
||||
switch ($type) {
|
||||
case 'create':
|
||||
$return = '<div class="form-group"><label for="return_to_form" class="col-sm-4 control-label">';
|
||||
$return = '<div class="form-group"><label for="' . $name . 'return_to_form" class="col-sm-4 control-label">';
|
||||
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
|
||||
$return .= \Form::radio('post_submit_action', 'create_another', $previousValue == 'create_another');
|
||||
$return .= \Form::radio('post_submit_action', 'create_another', $previousValue == 'create_another', ['id' => $name . '_create_another']);
|
||||
$return .= 'After storing, return here to create another one.</label></div></div></div>';
|
||||
break;
|
||||
case 'update':
|
||||
$return = '<div class="form-group"><label for="return_to_edit" class="col-sm-4 control-label">';
|
||||
$return = '<div class="form-group"><label for="' . $name . 'return_to_edit" class="col-sm-4 control-label">';
|
||||
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
|
||||
$return .= \Form::radio('post_submit_action', 'return_to_edit', $previousValue == 'return_to_edit');
|
||||
$return .= \Form::radio('post_submit_action', 'return_to_edit', $previousValue == 'return_to_edit', ['id' => $name . '_return_to_edit']);
|
||||
$return .= 'After updating, return here.</label></div></div></div>';
|
||||
break;
|
||||
default:
|
||||
|
@ -9,6 +9,8 @@ use Illuminate\Support\Collection;
|
||||
/**
|
||||
* Class Report
|
||||
*
|
||||
* @SuppressWarnings("CamelCase")
|
||||
*
|
||||
* @package FireflyIII\Report
|
||||
*/
|
||||
class Report implements ReportInterface
|
||||
|
@ -5,6 +5,11 @@ namespace FireflyIII\Search;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class Search
|
||||
*
|
||||
* @package FireflyIII\Search
|
||||
*/
|
||||
class Search
|
||||
{
|
||||
/**
|
||||
|
@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class DateKit
|
||||
*
|
||||
* @package FireflyIII\Shared\Facade
|
||||
*/
|
||||
class DateKit extends Facade
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'datekit';
|
||||
|
@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class FFForm
|
||||
*
|
||||
* @package FireflyIII\Shared\Facade
|
||||
*/
|
||||
class FFForm extends Facade
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'ffform';
|
||||
|
@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Filter
|
||||
*
|
||||
* @package FireflyIII\Shared\Facade
|
||||
*/
|
||||
class Filter extends Facade
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'filter';
|
||||
|
@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Navigation
|
||||
*
|
||||
* @package FireflyIII\Shared\Facade
|
||||
*/
|
||||
class Navigation extends Facade
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'navigation';
|
||||
|
@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Reminders
|
||||
*
|
||||
* @package FireflyIII\Shared\Facade
|
||||
*/
|
||||
class Reminders extends Facade
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'reminders';
|
||||
|
@ -4,10 +4,18 @@ namespace FireflyIII\Shared\Facade;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Steam
|
||||
*
|
||||
* @package FireflyIII\Shared\Facade
|
||||
*/
|
||||
class Steam extends Facade
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'steam';
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace FireflyIII\Shared\Mail;
|
||||
|
||||
use Swift_RfcComplianceException;
|
||||
|
||||
/**
|
||||
@ -28,10 +29,11 @@ class Registration implements RegistrationInterface
|
||||
try {
|
||||
\Mail::send(
|
||||
['emails.user.register-html', 'emails.user.register-text'], $data, function ($message) use ($email) {
|
||||
$message->to($email, $email)->subject('Welcome to Firefly!');
|
||||
}
|
||||
$message->to($email, $email)->subject('Welcome to Firefly!');
|
||||
}
|
||||
);
|
||||
} catch(Swift_RfcComplianceException $e) {}
|
||||
} catch (Swift_RfcComplianceException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,8 +51,8 @@ class Registration implements RegistrationInterface
|
||||
$data = ['reset' => $reset];
|
||||
\Mail::send(
|
||||
['emails.user.remindme-html', 'emails.user.remindme-text'], $data, function ($message) use ($email) {
|
||||
$message->to($email, $email)->subject('Forgot your password?');
|
||||
}
|
||||
$message->to($email, $email)->subject('Forgot your password?');
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -72,8 +74,8 @@ class Registration implements RegistrationInterface
|
||||
|
||||
\Mail::send(
|
||||
['emails.user.verify-html', 'emails.user.verify-text'], $data, function ($message) use ($email) {
|
||||
$message->to($email, $email)->subject('Verify your e-mail address.');
|
||||
}
|
||||
$message->to($email, $email)->subject('Verify your e-mail address.');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -13,13 +13,10 @@ abstract class SingleTableInheritanceEntity extends \Eloquent
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isSubclass = false;
|
||||
/**
|
||||
* The field that stores the subclass
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $isSubclass = false;
|
||||
protected $subclassField = null;
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* @param array $attributes
|
||||
@ -77,9 +74,8 @@ abstract class SingleTableInheritanceEntity extends \Eloquent
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(
|
||||
array $rules = [], array $customMessages = [], array $options = [], \Closure $beforeSave = null, \Closure $afterSave = null
|
||||
) {
|
||||
public function save(array $rules = [], array $customMessages = [], array $options = [], \Closure $beforeSave = null, \Closure $afterSave = null)
|
||||
{
|
||||
if ($this->subclassField) {
|
||||
$this->attributes[$this->subclassField] = get_class($this);
|
||||
}
|
||||
|
@ -143,6 +143,13 @@ class Date
|
||||
return $currentEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param $repeatFrequency
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function periodShow(Carbon $date, $repeatFrequency)
|
||||
{
|
||||
switch ($repeatFrequency) {
|
||||
@ -216,12 +223,13 @@ class Date
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param int $subtract
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
* @internal param Carbon $date
|
||||
*/
|
||||
public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)
|
||||
{
|
||||
|
@ -10,6 +10,13 @@ use Illuminate\Validation\Validator;
|
||||
*/
|
||||
class FireflyValidator extends Validator
|
||||
{
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateAlphabasic($attribute, $value, $parameters)
|
||||
{
|
||||
$pattern = '/[^[:alnum:]_\-\.\& \(\)\'"]/iu';
|
||||
|
@ -3,6 +3,9 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class Account
|
||||
*/
|
||||
class Account extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
@ -12,20 +15,17 @@ class Account extends Eloquent
|
||||
* @var array
|
||||
*/
|
||||
public static $rules
|
||||
= [
|
||||
= [
|
||||
'name' => ['required', 'between:1,100'],
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'account_type_id' => 'required|exists:account_types,id',
|
||||
'active' => 'required|boolean'
|
||||
|
||||
];
|
||||
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
||||
/**
|
||||
* Fillable fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
||||
protected $fillable = ['name', 'user_id', 'account_type_id', 'active'];
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* Account type.
|
||||
@ -96,6 +96,12 @@ class Account extends Eloquent
|
||||
return $this->hasMany('Transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fieldName
|
||||
* @param $fieldValue
|
||||
*
|
||||
* @return AccountMeta
|
||||
*/
|
||||
public function updateMeta($fieldName, $fieldValue)
|
||||
{
|
||||
$meta = $this->accountMeta()->get();
|
||||
@ -117,6 +123,9 @@ class Account extends Eloquent
|
||||
return $meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function accountMeta()
|
||||
{
|
||||
return $this->hasMany('AccountMeta');
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class AccountMeta
|
||||
*/
|
||||
class AccountMeta extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
@ -16,8 +19,10 @@ class AccountMeta extends Eloquent
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $fillable = ['account_id', 'name', 'date'];
|
||||
protected $table = 'account_meta';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@ -3,6 +3,9 @@
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class AccountType
|
||||
*/
|
||||
class AccountType extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
@ -1,20 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class Budget
|
||||
*/
|
||||
class Budget extends Component
|
||||
{
|
||||
protected $isSubclass = true;
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
public function limitrepetitions()
|
||||
{
|
||||
return $this->hasManyThrough('LimitRepetition', 'Limit', 'component_id');
|
||||
return $this->hasManyThrough('LimitRepetition', 'BudgetLimit', 'component_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function limits()
|
||||
public function budgetlimits()
|
||||
{
|
||||
return $this->hasMany('Limit', 'component_id');
|
||||
return $this->hasMany('BudgetLimit', 'component_id');
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,7 +4,10 @@ use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Limit extends Eloquent
|
||||
/**
|
||||
* Class Limit
|
||||
*/
|
||||
class BudgetLimit extends Eloquent
|
||||
{
|
||||
|
||||
use ValidatingTrait;
|
||||
@ -61,8 +64,6 @@ class Limit extends Eloquent
|
||||
}
|
||||
$end->subDay();
|
||||
$count = $this->limitrepetitions()->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->count();
|
||||
\Log::debug('All: ' . $this->limitrepetitions()->count() . ' (#' . $this->id . ')');
|
||||
\Log::debug('Found ' . $count . ' limit-reps for limit #' . $this->id . ' with start ' . $start->format('Y-m-d') . ' and end ' . $end->format('Y-m-d'));
|
||||
|
||||
if ($count == 0) {
|
||||
|
||||
@ -70,7 +71,7 @@ class Limit extends Eloquent
|
||||
$repetition->startdate = $start;
|
||||
$repetition->enddate = $end;
|
||||
$repetition->amount = $this->amount;
|
||||
$repetition->limit()->associate($this);
|
||||
$repetition->budgetLimit()->associate($this);
|
||||
|
||||
try {
|
||||
$repetition->save();
|
@ -1,8 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
*/
|
||||
class Category extends Component
|
||||
{
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $isSubclass = true;
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
|
||||
}
|
@ -4,6 +4,9 @@ use FireflyIII\Shared\SingleTableInheritanceEntity;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class Component
|
||||
*/
|
||||
class Component extends SingleTableInheritanceEntity
|
||||
{
|
||||
|
||||
@ -13,10 +16,12 @@ class Component extends SingleTableInheritanceEntity
|
||||
'name' => 'required|between:1,100|alphabasic',
|
||||
'class' => 'required',
|
||||
];
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
||||
protected $fillable = ['name', 'user_id'];
|
||||
protected $subclassField = 'class';
|
||||
protected $table = 'components';
|
||||
// @codingStandardsIgnoreEnd
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
/**
|
||||
|
@ -3,17 +3,28 @@
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class LimitRepetition
|
||||
*/
|
||||
class LimitRepetition extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
public static $rules
|
||||
= [
|
||||
'limit_id' => 'required|exists:limits,id',
|
||||
'startdate' => 'required|date',
|
||||
'enddate' => 'required|date',
|
||||
'amount' => 'numeric|required|min:0.01',
|
||||
'budgetlimit_id' => 'required|exists:budgetlimits,id',
|
||||
'startdate' => 'required|date',
|
||||
'enddate' => 'required|date',
|
||||
'amount' => 'numeric|required|min:0.01',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function budgetLimit()
|
||||
{
|
||||
return $this->belongsTo('BudgetLimit');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -22,14 +33,6 @@ class LimitRepetition extends Eloquent
|
||||
return ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function limit()
|
||||
{
|
||||
return $this->belongsTo('Limit');
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO see if this scope is still used.
|
||||
*
|
||||
@ -51,8 +54,8 @@ class LimitRepetition extends Eloquent
|
||||
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
||||
'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
|
||||
)->leftJoin('components', 'components.id', '=', 'component_transaction_journal.component_id')->leftJoin(
|
||||
'limits', 'limits.component_id', '=', 'components.id'
|
||||
)->leftJoin('limit_repetitions', 'limit_repetitions.limit_id', '=', 'limits.id')->where(
|
||||
'budgetlimits', 'budgetlimits.component_id', '=', 'components.id'
|
||||
)->leftJoin('limit_repetitions', 'limit_repetitions.limit_id', '=', 'budgetlimits.id')->where(
|
||||
'transaction_journals.date', '>=', $this->startdate->format('Y-m-d')
|
||||
)->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))->where('transactions.amount', '>', 0)->where(
|
||||
'limit_repetitions.id', '=', $this->id
|
||||
|
@ -2,6 +2,9 @@
|
||||
use Carbon\Carbon;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class Piggybank
|
||||
*/
|
||||
class Piggybank extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
@ -155,6 +158,9 @@ class Piggybank extends Eloquent
|
||||
return $this->hasMany('PiggybankEvent');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
*/
|
||||
public function reminders()
|
||||
{
|
||||
return $this->morphMany('Reminder', 'remindersable');
|
||||
@ -197,6 +203,9 @@ class Piggybank extends Eloquent
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('Transaction');
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class PiggybankEvent
|
||||
*/
|
||||
class PiggybankEvent extends Eloquent
|
||||
{
|
||||
|
||||
|
@ -3,6 +3,9 @@ use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class PiggybankRepetition
|
||||
*/
|
||||
class PiggybankRepetition extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
@ -46,11 +49,19 @@ class PiggybankRepetition extends Eloquent
|
||||
return $this->belongsTo('Piggybank');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeStarts(Builder $query, Carbon $date)
|
||||
{
|
||||
$query->where('startdate', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeTargets(Builder $query, Carbon $date)
|
||||
{
|
||||
$query->where('targetdate', $date->format('Y-m-d'));
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class Preference
|
||||
*/
|
||||
class Preference extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
@ -2,6 +2,9 @@
|
||||
use Carbon\Carbon;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class RecurringTransaction
|
||||
*/
|
||||
class RecurringTransaction extends Eloquent
|
||||
{
|
||||
|
||||
@ -18,8 +21,9 @@ class RecurringTransaction extends Eloquent
|
||||
'automatch' => 'required|between:0,1',
|
||||
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
|
||||
'skip' => 'required|between:0,31',];
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch'];
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
@ -3,12 +3,22 @@
|
||||
use Carbon\Carbon;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class Reminder
|
||||
*/
|
||||
class Reminder extends Eloquent
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $table = 'reminders';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDataAttribute($value)
|
||||
{
|
||||
return json_decode($value);
|
||||
@ -32,6 +42,13 @@ class Reminder extends Eloquent
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDateIs($query, Carbon $start, Carbon $end)
|
||||
{
|
||||
return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'));
|
||||
|
@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class Transaction
|
||||
*/
|
||||
class Transaction extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
@ -56,11 +59,19 @@ class Transaction extends Eloquent
|
||||
return $this->belongsTo('Piggybank');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param Account $account
|
||||
*/
|
||||
public function scopeAccountIs(Builder $query, Account $account)
|
||||
{
|
||||
$query->where('transactions.account_id', $account->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeAfter(Builder $query, Carbon $date)
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
@ -72,6 +83,10 @@ class Transaction extends Eloquent
|
||||
$query->where('transaction_journals.date', '>=', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param Carbon $date
|
||||
*/
|
||||
public function scopeBefore(Builder $query, Carbon $date)
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
@ -83,16 +98,28 @@ class Transaction extends Eloquent
|
||||
$query->where('transaction_journals.date', '<=', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param $amount
|
||||
*/
|
||||
public function scopeLessThan(Builder $query, $amount)
|
||||
{
|
||||
$query->where('amount', '<', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param $amount
|
||||
*/
|
||||
public function scopeMoreThan(Builder $query, $amount)
|
||||
{
|
||||
$query->where('amount', '>', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes(Builder $query, array $types)
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
|
@ -3,6 +3,9 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class TransactionCurrency
|
||||
*/
|
||||
class TransactionCurrency extends Eloquent
|
||||
{
|
||||
|
||||
|
@ -2,6 +2,9 @@
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class TransactionGroup
|
||||
*/
|
||||
class TransactionGroup extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class TransactionJournal
|
||||
*/
|
||||
class TransactionJournal extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
@ -47,6 +50,8 @@ class TransactionJournal extends Eloquent
|
||||
/**
|
||||
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getAmount(\Account $account = null)
|
||||
@ -123,11 +128,18 @@ class TransactionJournal extends Eloquent
|
||||
return $query->where('date', '<=', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
*/
|
||||
public function scopeDefaultSorting(Builder $query)
|
||||
{
|
||||
$query->orderBy('date', 'DESC')->orderBy('transaction_journals.id', 'DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param $amount
|
||||
*/
|
||||
public function scopeLessThan(Builder $query, $amount)
|
||||
{
|
||||
if (is_null($this->joinedTransactions)) {
|
||||
@ -140,6 +152,10 @@ class TransactionJournal extends Eloquent
|
||||
$query->where('transactions.amount', '<=', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param $amount
|
||||
*/
|
||||
public function scopeMoreThan(Builder $query, $amount)
|
||||
{
|
||||
if (is_null($this->joinedTransactions)) {
|
||||
@ -163,6 +179,10 @@ class TransactionJournal extends Eloquent
|
||||
return $query->where('date', '=', $date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeTransactionTypes(Builder $query, array $types)
|
||||
{
|
||||
if (is_null($this->joinedTransactionTypes)) {
|
||||
@ -207,6 +227,9 @@ class TransactionJournal extends Eloquent
|
||||
return $this->belongsTo('TransactionType');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function transactiongroups()
|
||||
{
|
||||
return $this->belongsToMany('TransactionGroup');
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class TransactionRelation
|
||||
*/
|
||||
class TransactionRelation extends Eloquent
|
||||
{
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class TransactionType
|
||||
*/
|
||||
class TransactionType extends Eloquent
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
@ -6,6 +6,9 @@ use Illuminate\Auth\UserInterface;
|
||||
use Illuminate\Auth\UserTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*/
|
||||
class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
{
|
||||
|
||||
@ -13,24 +16,16 @@ class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
|
||||
|
||||
public static $rules
|
||||
= [
|
||||
= [
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'password' => 'required|between:60,60',
|
||||
'reset' => 'between:32,32',
|
||||
];
|
||||
protected $fillable = ['email'];
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['remember_token'];
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
// @codingStandardsIgnoreStart
|
||||
protected $fillable = ['email'];
|
||||
protected $hidden = ['remember_token'];
|
||||
protected $table = 'users';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
@ -64,6 +59,9 @@ class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
return $this->hasMany('Component');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
public function piggybanks()
|
||||
{
|
||||
return $this->hasManyThrough('Piggybank', 'Account');
|
||||
@ -109,6 +107,9 @@ class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
return $this->hasMany('TransactionJournal');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasManyThrough('TransactionJournal', 'Transaction');
|
||||
|
@ -99,8 +99,8 @@ Route::bind(
|
||||
'limitrepetition', function ($value, $route) {
|
||||
if (Auth::check()) {
|
||||
return LimitRepetition::
|
||||
where('limit_repetitions.id', $value)->leftjoin('limits', 'limits.id', '=', 'limit_repetitions.limit_id')->leftJoin(
|
||||
'components', 'components.id', '=', 'limits.component_id'
|
||||
where('limit_repetitions.id', $value)->leftjoin('budgetlimits', 'budgetlimits.id', '=', 'limit_repetitions.limit_id')->leftJoin(
|
||||
'components', 'components.id', '=', 'budgetlimits.component_id'
|
||||
)->where('components.class', 'Budget')->where('components.user_id', Auth::user()->id)->first(['limit_repetitions.*']);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ Log::useDailyFiles(storage_path('logs') . DIRECTORY_SEPARATOR . 'laravel.log', 3
|
||||
|
||||
App::error(
|
||||
function (Exception $exception, $code) {
|
||||
Log::error($exception);
|
||||
Log::error($code . ': ' . $exception);
|
||||
}
|
||||
);
|
||||
|
||||
@ -71,48 +71,48 @@ App::down(
|
||||
// forms:
|
||||
\Form::macro(
|
||||
'ffText', function ($name, $value = null, array $options = []) {
|
||||
return \FireflyIII\Form\Form::ffText($name, $value, $options);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffText($name, $value, $options);
|
||||
}
|
||||
);
|
||||
\Form::macro(
|
||||
'ffSelect', function ($name, array $list = [], $selected = null, array $options = []) {
|
||||
return \FireflyIII\Form\Form::ffSelect($name, $list, $selected, $options);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffSelect($name, $list, $selected, $options);
|
||||
}
|
||||
);
|
||||
\Form::macro(
|
||||
'ffInteger', function ($name, $value = null, array $options = []) {
|
||||
return \FireflyIII\Form\Form::ffInteger($name, $value, $options);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffInteger($name, $value, $options);
|
||||
}
|
||||
);
|
||||
\Form::macro(
|
||||
'ffAmount', function ($name, $value = null, array $options = []) {
|
||||
return \FireflyIII\Form\Form::ffAmount($name, $value, $options);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffAmount($name, $value, $options);
|
||||
}
|
||||
);
|
||||
\Form::macro(
|
||||
'ffBalance', function ($name, $value = null, array $options = []) {
|
||||
return \FireflyIII\Form\Form::ffBalance($name, $value, $options);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffBalance($name, $value, $options);
|
||||
}
|
||||
);
|
||||
\Form::macro(
|
||||
'ffDate', function ($name, $value = null, array $options = []) {
|
||||
return \FireflyIII\Form\Form::ffDate($name, $value, $options);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffDate($name, $value, $options);
|
||||
}
|
||||
);
|
||||
\Form::macro(
|
||||
'ffTags', function ($name, $value = null, array $options = []) {
|
||||
return \FireflyIII\Form\Form::ffTags($name, $value, $options);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffTags($name, $value, $options);
|
||||
}
|
||||
);
|
||||
\Form::macro(
|
||||
'ffCheckbox', function ($name, $value = 1, $checked = null, $options = []) {
|
||||
return \FireflyIII\Form\Form::ffCheckbox($name, $value, $checked, $options);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffCheckbox($name, $value, $checked, $options);
|
||||
}
|
||||
);
|
||||
\Form::macro(
|
||||
'ffOptionsList', function ($type, $name) {
|
||||
return \FireflyIII\Form\Form::ffOptionsList($type, $name);
|
||||
}
|
||||
return \FireflyIII\Form\Form::ffOptionsList($type, $name);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
@ -38,7 +38,6 @@ class CategoryControllerCest
|
||||
public function delete(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('delete a category');
|
||||
$I->amOnPage('/categories/delete/1');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +55,6 @@ class CategoryControllerCest
|
||||
public function edit(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('edit a category');
|
||||
$I->amOnPage('/categories/edit/1');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,7 +72,6 @@ class CategoryControllerCest
|
||||
public function show(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('show a category');
|
||||
$I->amOnPage('/categories/delete/1');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user