mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Use facades.
This commit is contained in:
parent
ec776bb6eb
commit
3dce194930
@ -499,9 +499,6 @@ class GoogleChartController extends BaseController
|
|||||||
public function recurringOverview(RecurringTransaction $recurring)
|
public function recurringOverview(RecurringTransaction $recurring)
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
|
||||||
$dateKit = App::make('FireflyIII\Shared\Toolkit\Date');
|
|
||||||
|
|
||||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||||
$chart = App::make('gchart');
|
$chart = App::make('gchart');
|
||||||
$chart->addColumn('Date', 'date');
|
$chart->addColumn('Date', 'date');
|
||||||
@ -526,7 +523,7 @@ class GoogleChartController extends BaseController
|
|||||||
}
|
}
|
||||||
unset($result);
|
unset($result);
|
||||||
$chart->addRow(clone $start, $recurring->amount_max, $recurring->amount_min, $amount);
|
$chart->addRow(clone $start, $recurring->amount_max, $recurring->amount_min, $amount);
|
||||||
$start = $dateKit->addPeriod($start, $recurring->repeat_freq, 0);
|
$start = DateKit::addPeriod($start, $recurring->repeat_freq, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$chart->generate();
|
$chart->generate();
|
||||||
@ -557,9 +554,6 @@ class GoogleChartController extends BaseController
|
|||||||
/** @var \FireflyIII\Database\Recurring $rcr */
|
/** @var \FireflyIII\Database\Recurring $rcr */
|
||||||
$rcr = App::make('FireflyIII\Database\Recurring');
|
$rcr = App::make('FireflyIII\Database\Recurring');
|
||||||
|
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
|
||||||
$dateKit = App::make('FireflyIII\Shared\Toolkit\Date');
|
|
||||||
|
|
||||||
$recurring = $rcr->get();
|
$recurring = $rcr->get();
|
||||||
|
|
||||||
/** @var \RecurringTransaction $entry */
|
/** @var \RecurringTransaction $entry */
|
||||||
@ -580,7 +574,7 @@ class GoogleChartController extends BaseController
|
|||||||
* Get end of period for $current:
|
* Get end of period for $current:
|
||||||
*/
|
*/
|
||||||
$currentEnd = clone $current;
|
$currentEnd = clone $current;
|
||||||
$dateKit->endOfPeriod($currentEnd, $entry->repeat_freq);
|
DateKit::endOfPeriod($currentEnd, $entry->repeat_freq);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In the current session range?
|
* In the current session range?
|
||||||
@ -605,7 +599,7 @@ class GoogleChartController extends BaseController
|
|||||||
/*
|
/*
|
||||||
* Add some time for the next loop!
|
* Add some time for the next loop!
|
||||||
*/
|
*/
|
||||||
$dateKit->addPeriod($current, $entry->repeat_freq, intval($entry->skip));
|
DateKit::addPeriod($current, $entry->repeat_freq, intval($entry->skip));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,12 +84,9 @@ class HomeController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function sessionNext()
|
public function sessionNext()
|
||||||
{
|
{
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Navigation $navigation */
|
Navigation::next();
|
||||||
$navigation = App::make('FireflyIII\Shared\Toolkit\Navigation');
|
|
||||||
$navigation->next();
|
|
||||||
|
|
||||||
return Redirect::back();
|
return Redirect::back();
|
||||||
//return Redirect::route('index');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,11 +94,8 @@ class HomeController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function sessionPrev()
|
public function sessionPrev()
|
||||||
{
|
{
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Navigation $navigation */
|
Navigation::prev();
|
||||||
$navigation = App::make('FireflyIII\Shared\Toolkit\Navigation');
|
|
||||||
$navigation->prev();
|
|
||||||
|
|
||||||
return Redirect::back();
|
return Redirect::back();
|
||||||
//return Redirect::route('index');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,13 +48,10 @@ class PiggybankController extends BaseController
|
|||||||
/** @var \FireflyIII\Database\Account $acct */
|
/** @var \FireflyIII\Database\Account $acct */
|
||||||
$acct = App::make('FireflyIII\Database\Account');
|
$acct = App::make('FireflyIII\Database\Account');
|
||||||
|
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Form $toolkit */
|
|
||||||
$toolkit = App::make('FireflyIII\Shared\Toolkit\Form');
|
|
||||||
|
|
||||||
$periods = Config::get('firefly.piggybank_periods');
|
$periods = Config::get('firefly.piggybank_periods');
|
||||||
|
|
||||||
|
|
||||||
$accounts = $toolkit->makeSelectList($acct->getAssetAccounts());
|
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
|
||||||
|
|
||||||
return View::make('piggybanks.create', compact('accounts', 'periods'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc')->with(
|
return View::make('piggybanks.create', compact('accounts', 'periods'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc')->with(
|
||||||
'subTitle', 'Create new piggy bank'
|
'subTitle', 'Create new piggy bank'
|
||||||
@ -99,12 +96,9 @@ class PiggybankController extends BaseController
|
|||||||
/** @var \FireflyIII\Database\Account $acct */
|
/** @var \FireflyIII\Database\Account $acct */
|
||||||
$acct = App::make('FireflyIII\Database\Account');
|
$acct = App::make('FireflyIII\Database\Account');
|
||||||
|
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Form $toolkit */
|
|
||||||
$toolkit = App::make('FireflyIII\Shared\Toolkit\Form');
|
|
||||||
|
|
||||||
$periods = Config::get('firefly.piggybank_periods');
|
$periods = Config::get('firefly.piggybank_periods');
|
||||||
|
|
||||||
$accounts = $toolkit->makeSelectList($acct->getAssetAccounts());
|
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flash some data to fill the form.
|
* Flash some data to fill the form.
|
||||||
|
@ -21,20 +21,15 @@ class ReminderController extends BaseController
|
|||||||
{
|
{
|
||||||
|
|
||||||
$amount = null;
|
$amount = null;
|
||||||
$actionURL = '#';
|
|
||||||
if (get_class($reminder->remindersable) == 'Piggybank') {
|
if (get_class($reminder->remindersable) == 'Piggybank') {
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Reminders $toolkit */
|
|
||||||
$reminderKit = App::make('FireflyIII\Shared\Toolkit\Reminders');
|
|
||||||
|
|
||||||
$amount = $reminderKit->amountForReminder($reminder);
|
$amount = Reminders::amountForReminder($reminder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('reminders.show', compact('reminder', 'amount'));
|
return View::make('reminders.show', compact('reminder', 'amount'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function act(Reminder $reminder) {
|
public function act(Reminder $reminder) {
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Reminders $toolkit */
|
|
||||||
$reminderKit = App::make('FireflyIII\Shared\Toolkit\Reminders');
|
|
||||||
|
|
||||||
switch(get_class($reminder->remindersable)) {
|
switch(get_class($reminder->remindersable)) {
|
||||||
default:
|
default:
|
||||||
@ -42,7 +37,7 @@ class ReminderController extends BaseController
|
|||||||
break;
|
break;
|
||||||
break;
|
break;
|
||||||
case 'Piggybank':
|
case 'Piggybank':
|
||||||
$amount = $reminderKit->amountForReminder($reminder);
|
$amount = Reminders::amountForReminder($reminder);
|
||||||
$prefilled = [
|
$prefilled = [
|
||||||
'amount' => round($amount,2),
|
'amount' => round($amount,2),
|
||||||
'description' => 'Money for ' . $reminder->remindersable->name,
|
'description' => 'Money for ' . $reminder->remindersable->name,
|
||||||
|
@ -34,8 +34,6 @@ class TransactionController extends BaseController
|
|||||||
/*
|
/*
|
||||||
* The repositories we need:
|
* The repositories we need:
|
||||||
*/
|
*/
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Form $form */
|
|
||||||
$form = App::make('FireflyIII\Shared\Toolkit\Form');
|
|
||||||
|
|
||||||
/** @var \FireflyIII\Database\Account $accountRepository */
|
/** @var \FireflyIII\Database\Account $accountRepository */
|
||||||
$accountRepository = App::make('FireflyIII\Database\Account');
|
$accountRepository = App::make('FireflyIII\Database\Account');
|
||||||
@ -47,14 +45,14 @@ class TransactionController extends BaseController
|
|||||||
$piggyRepository = App::make('FireflyIII\Database\Piggybank');
|
$piggyRepository = App::make('FireflyIII\Database\Piggybank');
|
||||||
|
|
||||||
// get asset accounts with names and id's .
|
// get asset accounts with names and id's .
|
||||||
$assetAccounts = $form->makeSelectList($accountRepository->getAssetAccounts());
|
$assetAccounts = FFForm::makeSelectList($accountRepository->getAssetAccounts());
|
||||||
|
|
||||||
// get budgets as a select list.
|
// get budgets as a select list.
|
||||||
$budgets = $form->makeSelectList($budgetRepository->get());
|
$budgets = FFForm::makeSelectList($budgetRepository->get());
|
||||||
$budgets[0] = '(no budget)';
|
$budgets[0] = '(no budget)';
|
||||||
|
|
||||||
// get the piggy banks.
|
// get the piggy banks.
|
||||||
$piggies = $form->makeSelectList($piggyRepository->get());
|
$piggies = FFForm::makeSelectList($piggyRepository->get());
|
||||||
$piggies[0] = '(no piggy bank)';
|
$piggies[0] = '(no piggy bank)';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -135,8 +133,6 @@ class TransactionController extends BaseController
|
|||||||
/*
|
/*
|
||||||
* All the repositories we need:
|
* All the repositories we need:
|
||||||
*/
|
*/
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Form $form */
|
|
||||||
$form = App::make('FireflyIII\Shared\Toolkit\Form');
|
|
||||||
|
|
||||||
/** @var \FireflyIII\Database\Account $accountRepository */
|
/** @var \FireflyIII\Database\Account $accountRepository */
|
||||||
$accountRepository = App::make('FireflyIII\Database\Account');
|
$accountRepository = App::make('FireflyIII\Database\Account');
|
||||||
@ -152,10 +148,10 @@ class TransactionController extends BaseController
|
|||||||
$what = strtolower($journal->transactiontype->type);
|
$what = strtolower($journal->transactiontype->type);
|
||||||
|
|
||||||
// get asset accounts with names and id's.
|
// get asset accounts with names and id's.
|
||||||
$accounts = $form->makeSelectList($accountRepository->getAssetAccounts());
|
$accounts = FFForm::makeSelectList($accountRepository->getAssetAccounts());
|
||||||
|
|
||||||
// get budgets as a select list.
|
// get budgets as a select list.
|
||||||
$budgets = $form->makeSelectList($budgetRepository->get());
|
$budgets = FFForm::makeSelectList($budgetRepository->get());
|
||||||
$budgets[0] = '(no budget)';
|
$budgets[0] = '(no budget)';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -163,7 +159,7 @@ class TransactionController extends BaseController
|
|||||||
* of the transactions in the journal has this field, it should all fill in nicely.
|
* of the transactions in the journal has this field, it should all fill in nicely.
|
||||||
*/
|
*/
|
||||||
// get the piggy banks.
|
// get the piggy banks.
|
||||||
$piggies = $form->makeSelectList($piggyRepository->get());
|
$piggies = FFForm::makeSelectList($piggyRepository->get());
|
||||||
$piggies[0] = '(no piggy bank)';
|
$piggies[0] = '(no piggy bank)';
|
||||||
$piggyBankId = 0;
|
$piggyBankId = 0;
|
||||||
foreach ($journal->transactions as $t) {
|
foreach ($journal->transactions as $t) {
|
||||||
|
@ -7,16 +7,9 @@ App::before(
|
|||||||
$reminders = [];
|
$reminders = [];
|
||||||
|
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Filter $toolkit */
|
Filter::setSessionDateRange();
|
||||||
$filter = App::make('FireflyIII\Shared\Toolkit\Filter');
|
Reminders::updateReminders();
|
||||||
$filter->setSessionDateRange();
|
$reminders = Reminders::getReminders();
|
||||||
|
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Reminders $toolkit */
|
|
||||||
$reminderKit = App::make('FireflyIII\Shared\Toolkit\Reminders');
|
|
||||||
|
|
||||||
$reminderKit->updateReminders();
|
|
||||||
$reminders = $reminderKit->getReminders();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
View::share('reminders', $reminders);
|
View::share('reminders', $reminders);
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
public function transactionsWithoutBudgetInDateRange(Carbon $start, Carbon $end)
|
public function transactionsWithoutBudgetInDateRange(Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
// Add expenses that have no budget:
|
// Add expenses that have no budget:
|
||||||
return \Auth::user()->transactionjournals()->whereNotIn(
|
return $this->getUser()->transactionjournals()->whereNotIn(
|
||||||
'transaction_journals.id', function ($query) use ($start, $end) {
|
'transaction_journals.id', function ($query) use ($start, $end) {
|
||||||
$query->select('transaction_journals.id')->from('transaction_journals')->leftJoin(
|
$query->select('transaction_journals.id')->from('transaction_journals')->leftJoin(
|
||||||
'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
|
'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
|
||||||
|
@ -67,9 +67,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
/*
|
/*
|
||||||
* Jump to the start of the period.
|
* Jump to the start of the period.
|
||||||
*/
|
*/
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Date $toolkit */
|
$date = DateKit::startOfPeriod($date, $data['repeat_freq']);
|
||||||
$toolkit = \App::make('FireflyIII\Shared\Toolkit\Date');
|
|
||||||
$date = $toolkit->startOfPeriod($date, $data['repeat_freq']);
|
|
||||||
$recurring->date = $date;
|
$recurring->date = $date;
|
||||||
$recurring->skip = intval($data['skip']);
|
$recurring->skip = intval($data['skip']);
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
$validator = \Validator::make([$model], \Transaction::$rules);
|
$validator = \Validator::make([$model], \TransactionJournal::$rules);
|
||||||
if ($validator->invalid()) {
|
if ($validator->invalid()) {
|
||||||
$errors->merge($errors);
|
$errors->merge($errors);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,9 @@ class Budget
|
|||||||
*/
|
*/
|
||||||
public function storeOrUpdateLimit(\Limit $limit)
|
public function storeOrUpdateLimit(\Limit $limit)
|
||||||
{
|
{
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
|
||||||
$dateKit = \App::make('FireflyIII\Shared\Toolkit\Date');
|
|
||||||
|
|
||||||
|
|
||||||
$end = $dateKit->addPeriod(clone $limit->startdate, $limit->repeat_freq, 0);
|
$end = DateKit::addPeriod(clone $limit->startdate, $limit->repeat_freq, 0);
|
||||||
$end->subDay();
|
$end->subDay();
|
||||||
|
|
||||||
$set = $limit->limitrepetitions()->where('startdate', $limit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->get();
|
$set = $limit->limitrepetitions()->where('startdate', $limit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->get();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
namespace FireflyIII;
|
namespace FireflyIII;
|
||||||
|
|
||||||
use FireflyIII\Shared\Validation\FireflyValidator;
|
use FireflyIII\Shared\Validation\FireflyValidator;
|
||||||
|
use Illuminate\Foundation\AliasLoader;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,6 +22,16 @@ class FF3ServiceProvider extends ServiceProvider
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the services bla bla.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provides()
|
||||||
|
{
|
||||||
|
return ['reminders', 'filters', 'datekit', 'navigation'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered automatically by Laravel
|
* Triggered automatically by Laravel
|
||||||
*/
|
*/
|
||||||
@ -29,12 +40,50 @@ class FF3ServiceProvider extends ServiceProvider
|
|||||||
// FORMAT:
|
// FORMAT:
|
||||||
#$this->app->bind('Interface', 'Class');
|
#$this->app->bind('Interface', 'Class');
|
||||||
|
|
||||||
|
$this->app->bind(
|
||||||
|
'reminders', function () {
|
||||||
|
return new \FireflyIII\Shared\Toolkit\Reminders;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$this->app->bind(
|
||||||
|
'filter', function () {
|
||||||
|
return new \FireflyIII\Shared\Toolkit\Filter;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$this->app->bind(
|
||||||
|
'datekit', function () {
|
||||||
|
return new \FireflyIII\Shared\Toolkit\Date;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$this->app->bind(
|
||||||
|
'navigation', function () {
|
||||||
|
return new \FireflyIII\Shared\Toolkit\Navigation;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$this->app->bind(
|
||||||
|
'ffform', function () {
|
||||||
|
return new \FireflyIII\Shared\Toolkit\Form;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// preferences:
|
// preferences:
|
||||||
$this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');
|
$this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');
|
||||||
|
|
||||||
// registration and user mail:
|
// registration and user mail:
|
||||||
$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
|
$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
|
||||||
|
|
||||||
|
// Shortcut so developers don't need to add an Alias in app/config/app.php
|
||||||
|
$this->app->booting(
|
||||||
|
function () {
|
||||||
|
$loader = AliasLoader::getInstance();
|
||||||
|
$loader->alias('Reminders', 'FireflyIII\Shared\Facade\Reminders');
|
||||||
|
$loader->alias('Filter', 'FireflyIII\Shared\Facade\Filter');
|
||||||
|
$loader->alias('DateKit', 'FireflyIII\Shared\Facade\DateKit');
|
||||||
|
$loader->alias('Navigation', 'FireflyIII\Shared\Facade\Navigation');
|
||||||
|
$loader->alias('FFForm', 'FireflyIII\Shared\Facade\FFForm');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
16
app/lib/FireflyIII/Shared/Facade/DateKit.php
Normal file
16
app/lib/FireflyIII/Shared/Facade/DateKit.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Shared\Facade;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class DateKit extends Facade
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'datekit';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
app/lib/FireflyIII/Shared/Facade/FFForm.php
Normal file
16
app/lib/FireflyIII/Shared/Facade/FFForm.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Shared\Facade;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class FFForm extends Facade
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'ffform';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
app/lib/FireflyIII/Shared/Facade/Filter.php
Normal file
16
app/lib/FireflyIII/Shared/Facade/Filter.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Shared\Facade;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class Filter extends Facade
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'filter';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
app/lib/FireflyIII/Shared/Facade/Navigation.php
Normal file
16
app/lib/FireflyIII/Shared/Facade/Navigation.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Shared\Facade;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class Navigation extends Facade
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'navigation';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
app/lib/FireflyIII/Shared/Facade/Reminders.php
Normal file
16
app/lib/FireflyIII/Shared/Facade/Reminders.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Shared\Facade;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class Reminders extends Facade
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'reminders';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,6 +22,7 @@ class Date
|
|||||||
*/
|
*/
|
||||||
public function addPeriod(Carbon $date, $repeatFreq, $skip)
|
public function addPeriod(Carbon $date, $repeatFreq, $skip)
|
||||||
{
|
{
|
||||||
|
// TODO clone the dates so referred date won't be altered.
|
||||||
$add = ($skip + 1);
|
$add = ($skip + 1);
|
||||||
switch ($repeatFreq) {
|
switch ($repeatFreq) {
|
||||||
default:
|
default:
|
||||||
|
@ -23,9 +23,6 @@ class Reminders
|
|||||||
public function amountForReminder(\Reminder $reminder)
|
public function amountForReminder(\Reminder $reminder)
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
|
||||||
$dateKit = \App::make('FireflyIII\Shared\Toolkit\Date');
|
|
||||||
|
|
||||||
switch (get_class($reminder->remindersable)) {
|
switch (get_class($reminder->remindersable)) {
|
||||||
|
|
||||||
case 'Piggybank':
|
case 'Piggybank':
|
||||||
@ -34,7 +31,7 @@ class Reminders
|
|||||||
$reminders = 0;
|
$reminders = 0;
|
||||||
while ($start <= $end) {
|
while ($start <= $end) {
|
||||||
$reminders++;
|
$reminders++;
|
||||||
$start = $dateKit->addPeriod($start, $reminder->remindersable->reminder, $reminder->remindersable->reminder_skip);
|
$start = DateKit::addPeriod($start, $reminder->remindersable->reminder, $reminder->remindersable->reminder_skip);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Now find amount yet to save.
|
* Now find amount yet to save.
|
||||||
@ -49,9 +46,6 @@ class Reminders
|
|||||||
throw new FireflyException('Cannot handle class ' . get_class($reminder->remindersable) . ' in amountForReminder.');
|
throw new FireflyException('Cannot handle class ' . get_class($reminder->remindersable) . ' in amountForReminder.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 50;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,10 +71,6 @@ class Reminders
|
|||||||
/** @var \FireflyIII\Database\Piggybank $repository */
|
/** @var \FireflyIII\Database\Piggybank $repository */
|
||||||
$repository = \App::make('FireflyIII\Database\Piggybank');
|
$repository = \App::make('FireflyIII\Database\Piggybank');
|
||||||
|
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
|
||||||
$dateKit = \App::make('FireflyIII\Shared\Toolkit\Date');
|
|
||||||
|
|
||||||
|
|
||||||
/** @var Collection $piggybanks */
|
/** @var Collection $piggybanks */
|
||||||
$piggybanks = $repository->get();
|
$piggybanks = $repository->get();
|
||||||
$set = $piggybanks->filter(
|
$set = $piggybanks->filter(
|
||||||
@ -100,12 +90,12 @@ class Reminders
|
|||||||
*/
|
*/
|
||||||
/** @var \PiggybankRepetition $repetition */
|
/** @var \PiggybankRepetition $repetition */
|
||||||
$repetition = $piggybank->currentRelevantRep();
|
$repetition = $piggybank->currentRelevantRep();
|
||||||
$start = $dateKit->startOfPeriod(Carbon::now(), $piggybank->reminder);
|
$start = DateKit::startOfPeriod(Carbon::now(), $piggybank->reminder);
|
||||||
if ($repetition->targetdate && $repetition->targetdate <= Carbon::now()) {
|
if ($repetition->targetdate && $repetition->targetdate <= Carbon::now()) {
|
||||||
// break when no longer relevant:
|
// break when no longer relevant:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$end = $dateKit->endOfPeriod(clone $start, $piggybank->reminder);
|
$end = DateKit::endOfPeriod(clone $start, $piggybank->reminder);
|
||||||
// should have a reminder for this period:
|
// should have a reminder for this period:
|
||||||
/** @var \Collection $reminders */
|
/** @var \Collection $reminders */
|
||||||
$reminders = $piggybank->reminders()->dateIs($start, $end)->get();
|
$reminders = $piggybank->reminders()->dateIs($start, $end)->get();
|
||||||
|
@ -83,6 +83,7 @@ class RecurringTransaction extends Ardent
|
|||||||
return $this->hasMany('TransactionJournal');
|
return $this->hasMany('TransactionJournal');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO remove this method in favour of something in the FireflyIII libraries.
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
*
|
*
|
||||||
@ -92,9 +93,6 @@ class RecurringTransaction extends Ardent
|
|||||||
public function nextExpectedMatch()
|
public function nextExpectedMatch()
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
|
||||||
$dateKit = App::make('FireflyIII\Shared\Toolkit\Date');
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The date Firefly tries to find. If this stays null, it's "unknown".
|
* The date Firefly tries to find. If this stays null, it's "unknown".
|
||||||
*/
|
*/
|
||||||
@ -104,14 +102,14 @@ class RecurringTransaction extends Ardent
|
|||||||
* $today is the start of the next period, to make sure FF3 won't miss anything
|
* $today is the start of the next period, to make sure FF3 won't miss anything
|
||||||
* when the current period has a transaction journal.
|
* when the current period has a transaction journal.
|
||||||
*/
|
*/
|
||||||
$today = $dateKit->addPeriod(new Carbon, $this->repeat_freq, 0);
|
$today = DateKit::addPeriod(new Carbon, $this->repeat_freq, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FF3 loops from the $start of the recurring transaction, and to make sure
|
* FF3 loops from the $start of the recurring transaction, and to make sure
|
||||||
* $skip works, it adds one (for modulo).
|
* $skip works, it adds one (for modulo).
|
||||||
*/
|
*/
|
||||||
$skip = $this->skip + 1;
|
$skip = $this->skip + 1;
|
||||||
$start = $dateKit->startOfPeriod(new Carbon, $this->repeat_freq);
|
$start = DateKit::startOfPeriod(new Carbon, $this->repeat_freq);
|
||||||
/*
|
/*
|
||||||
* go back exactly one month/week/etc because FF3 does not care about 'next'
|
* go back exactly one month/week/etc because FF3 does not care about 'next'
|
||||||
* recurring transactions if they're too far into the past.
|
* recurring transactions if they're too far into the past.
|
||||||
@ -124,7 +122,7 @@ class RecurringTransaction extends Ardent
|
|||||||
while ($start <= $today) {
|
while ($start <= $today) {
|
||||||
if (($counter % $skip) == 0) {
|
if (($counter % $skip) == 0) {
|
||||||
// do something.
|
// do something.
|
||||||
$end = $dateKit->endOfPeriod(clone $start, $this->repeat_freq);
|
$end = DateKit::endOfPeriod(clone $start, $this->repeat_freq);
|
||||||
$journalCount = $this->transactionjournals()->before($end)->after($start)->count();
|
$journalCount = $this->transactionjournals()->before($end)->after($start)->count();
|
||||||
if ($journalCount == 0) {
|
if ($journalCount == 0) {
|
||||||
$finalDate = clone $start;
|
$finalDate = clone $start;
|
||||||
@ -133,7 +131,7 @@ class RecurringTransaction extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add period for next round!
|
// add period for next round!
|
||||||
$start = $dateKit->addPeriod($start, $this->repeat_freq, 0);
|
$start = DateKit::addPeriod($start, $this->repeat_freq, 0);
|
||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use LaravelBook\Ardent\Ardent;
|
|||||||
* @property boolean $active
|
* @property boolean $active
|
||||||
* @property integer $remembersable_id
|
* @property integer $remembersable_id
|
||||||
* @property string $remembersable_type
|
* @property string $remembersable_type
|
||||||
* @property-read \ $remindersable
|
* @property-read \Piggybank $remindersable
|
||||||
* @property-read \User $user
|
* @property-read \User $user
|
||||||
* @property mixed $data
|
* @property mixed $data
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
|
||||||
@ -62,6 +62,8 @@ class Reminder extends Eloquent
|
|||||||
{
|
{
|
||||||
return $this->belongsTo('User');
|
return $this->belongsTo('User');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function scopeDateIs($query, Carbon $start, Carbon $end)
|
public function scopeDateIs($query, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'));
|
return $query->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'));
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
Somewhere between {{$reminder->startdate->format('j F Y')}} and {{$reminder->enddate->format('j F Y')}} you
|
Somewhere between {{$reminder->startdate->format('j F Y')}} and {{$reminder->enddate->format('j F Y')}} you
|
||||||
should deposit {{mf($amount)}} in piggy bank <a href="{{route('piggybanks.show',$reminder->remindersable_id)}}">{{{$reminder->remindersable->name}}}</a>
|
should deposit {{mf($amount)}} in piggy bank <a href="{{route('piggybanks.show',$reminder->remindersable_id)}}">{{{$reminder->remindersable->name}}}</a>
|
||||||
in order to make your goal of saving {{mf($reminder->remindersable->targetamount)}} on {{$reminder->remindersable->targetdate->format('j F Y')}}
|
in order to make your goal of saving {{mf($reminder->remindersable->targetamount)}} on {{$reminder->remindersable->targetdate->format('j F Y')}}
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -102,13 +102,17 @@ Event::subscribe('FireflyIII\Event\TransactionJournal');
|
|||||||
// event for when the non-repeating piggy bank is updated because the single repetition must also be changed.
|
// event for when the non-repeating piggy bank is updated because the single repetition must also be changed.
|
||||||
// (also make piggy bank events "invalid" when they start falling outside of the date-scope of the piggy bank,
|
// (also make piggy bank events "invalid" when they start falling outside of the date-scope of the piggy bank,
|
||||||
// although this not changes the amount in the piggy bank).
|
// although this not changes the amount in the piggy bank).
|
||||||
// TODO check if recurring transactions are being updated when journals are updated (aka no longer fitting, thus removed).
|
// check if recurring transactions are being updated when journals are updated (aka no longer fitting, thus removed).
|
||||||
// TODO think about reminders.
|
// think about reminders.
|
||||||
// TODO an event that triggers and creates a limit + limit repetition when a budget is created, or something?
|
// an event that triggers and creates a limit + limit repetition when a budget is created, or something?
|
||||||
// TODO has many through needs to be added wherever relevant. Account > journals, etc.
|
// has many through needs to be added wherever relevant. Account > journals, etc.
|
||||||
// TODO check all models for "external" methods once more.
|
// check all models for "external" methods once more.
|
||||||
// TODO Auth::user() should be used very sparsely.
|
// Auth::user() should be used very sparsely.
|
||||||
// TODO direct calls to models are BAD
|
// direct calls to models are BAD
|
||||||
// TODO cleanup everything related to reminders because it still feels a bit sloppy.
|
// cleanup everything related to reminders because it still feels a bit sloppy.
|
||||||
// TODO use a Database\Reminder thing instead of self-made ORM.
|
// use a Database\Reminder thing instead of self-made ORM.
|
||||||
|
// TODO create static calls instead of all the App::make() things.
|
||||||
|
// TODO see if the various has-many-throughs actually get used.
|
||||||
|
// TODO set very tight rules on all models
|
||||||
|
// TODO create custom uniquely rules.
|
||||||
return $app;
|
return $app;
|
||||||
|
Loading…
Reference in New Issue
Block a user