Compare commits

..

29 Commits
3.1 ... 3.1.4

Author SHA1 Message Date
Sander Dorigo
42458ce11d Merge branch 'release/3.1.4' 2014-10-14 07:32:00 +02:00
Sander Dorigo
aceb683d07 Remove chart when nothing to show. 2014-10-14 07:27:06 +02:00
Sander Dorigo
b7517b49ed Expand match to include expense account. 2014-10-14 07:24:59 +02:00
Sander Dorigo
849b711b79 Recycle code instead of copy pasting. 2014-10-14 07:24:41 +02:00
Sander Dorigo
25585b28c7 Removed "date in the future" demand. 2014-10-14 07:24:27 +02:00
Sander Dorigo
073da8fb2a Small layout changes. 2014-10-13 20:47:36 +02:00
Sander Dorigo
a787ff3f3c Merge branch 'release/3.1.3' 2014-10-13 19:13:44 +02:00
Sander Dorigo
733b6d7eb7 Expand the chart. 2014-10-13 18:50:37 +02:00
Sander Dorigo
36d8dee853 Building a chart for the recurring transactions. 2014-10-13 17:54:20 +02:00
Sander Dorigo
65a2e07d24 Cleaned out most of the "reminders" code. 2014-10-12 09:45:57 +02:00
Sander Dorigo
7c97c558ab No reference to reminders. 2014-10-12 09:41:10 +02:00
Sander Dorigo
a6bb61050c Remove piggy bank reminders. 2014-10-12 09:41:00 +02:00
Sander Dorigo
b184aa2315 No trigger for recurring transactions. 2014-10-12 09:39:40 +02:00
Sander Dorigo
e4595333e7 Do not destroy reminders since there aren't any. 2014-10-12 09:39:29 +02:00
Sander Dorigo
41dd139bde Trigger no longer fires or creates reminders for piggy banks. 2014-10-12 09:37:31 +02:00
Sander Dorigo
c577dd302a Removed unused reminder methods. 2014-10-12 09:36:24 +02:00
Sander Dorigo
0ab87de78b Removed unused routes. 2014-10-12 09:34:47 +02:00
Sander Dorigo
8a22509b41 Removed a no longer used view. 2014-10-12 09:34:30 +02:00
Sander Dorigo
b024c18441 Cleaned out the reminder controller. 2014-10-12 09:34:10 +02:00
Sander Dorigo
d9ac681a68 Bug fixes in recurring transaction matching. 2014-10-12 09:31:25 +02:00
Sander Dorigo
637a5579ec Small cleanup. 2014-10-12 09:29:19 +02:00
Sander Dorigo
4794156e80 Merge branch 'master' into develop 2014-10-12 08:20:31 +02:00
Sander Dorigo
5f4db7874c New view and what-not for feature. 2014-10-12 08:19:18 +02:00
Sander Dorigo
b4ea1839a5 Fixed some bugs in the recurring transaction match. 2014-10-12 08:03:35 +02:00
Sander Dorigo
6a6d889983 Merge branch 'release/3.1.1' 2014-10-12 07:39:27 +02:00
Sander Dorigo
287c2e7af8 Added the ability to change the range preference on the fly. 2014-10-12 07:33:45 +02:00
Sander Dorigo
0fe6acc8cf Merge branch 'feature/recurring-expand' into develop 2014-10-11 21:24:38 +02:00
Sander Dorigo
7d2dab7ca0 First set of code. 2014-10-11 21:23:31 +02:00
Sander Dorigo
f68c1aff26 Cleaned up the show view. 2014-10-11 18:52:24 +02:00
37 changed files with 1005 additions and 962 deletions

View File

@@ -2,7 +2,7 @@
use Carbon\Carbon;
return [
'index_periods' => ['1D', '1W', '1M', '3M', '6M', 'custom'],
'index_periods' => ['1D', '1W', '1M', '3M', '6M','1Y', 'custom'],
'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
'piggybank_periods' => ['day', 'week', 'month', 'year'],
'periods_to_text' => [
@@ -21,6 +21,14 @@ return [
'6M' => 'half year',
'custom' => '(custom)'
],
'range_to_name' => [
'1D' => 'one day',
'1W' => 'one week',
'1M' => 'one month',
'3M' => 'three months',
'6M' => 'six months',
'1Y' => 'one year',
],
'range_to_repeat_freq' => [
'1D' => 'weekly',
'1W' => 'weekly',

View File

@@ -1,8 +1,10 @@
<?php
use Carbon\Carbon;
use Firefly\Exception\FireflyException;
use Firefly\Helper\Controllers\ChartInterface;
use Firefly\Storage\Account\AccountRepositoryInterface;
use Illuminate\Support\Collection;
/**
* Class ChartController
@@ -18,7 +20,7 @@ class ChartController extends BaseController
/**
* @param ChartInterface $chart
* @param ChartInterface $chart
* @param AccountRepositoryInterface $accounts
*/
public function __construct(ChartInterface $chart, AccountRepositoryInterface $accounts)
@@ -57,13 +59,13 @@ class ChartController extends BaseController
$return = [
'chart_title' => 'Overview for budget ' . $budget->name,
'subtitle' => 'All envelopes',
'series' => [
'subtitle' => 'All envelopes',
'series' => [
[
'type' => 'line',
'type' => 'line',
'yAxis' => 1,
'name' => 'Amount in envelope',
'data' => $envelope
'name' => 'Amount in envelope',
'data' => $envelope
],
[
'type' => 'column',
@@ -71,10 +73,10 @@ class ChartController extends BaseController
'data' => $expense
],
[
'type' => 'line',
'type' => 'line',
'yAxis' => 1,
'name' => 'Spent percentage for envelope',
'data' => $left
'name' => 'Spent percentage for envelope',
'data' => $left
]
@@ -111,14 +113,14 @@ class ChartController extends BaseController
$return = [
'chart_title' => 'Overview for budget ' . $budget->name,
'subtitle' =>
'subtitle' =>
'Between ' . $rep->startdate->format('M jS, Y') . ' and ' . $rep->enddate->format('M jS, Y'),
'series' => [
'series' => [
[
'type' => 'column',
'name' => 'Expenses per day',
'type' => 'column',
'name' => 'Expenses per day',
'yAxis' => 1,
'data' => $expense
'data' => $expense
],
[
'type' => 'line',
@@ -175,8 +177,8 @@ class ChartController extends BaseController
}
$return = [
'chart_title' => 'Overview for ' . $budget->name,
'subtitle' => 'Not organized by an envelope',
'series' => [
'subtitle' => 'Not organized by an envelope',
'series' => [
[
'type' => 'column',
'name' => 'Expenses per day',
@@ -245,11 +247,11 @@ class ChartController extends BaseController
// create a serie for the repetition.
$currentSerie = [
'type' => 'spline',
'id' => 'rep-' . $repetition->id,
'type' => 'spline',
'id' => 'rep-' . $repetition->id,
'yAxis' => 1,
'name' => 'Envelope #' . $repetition->id . ' in ' . $repetition->periodShow(),
'data' => []
'name' => 'Envelope #' . $repetition->id . ' in ' . $repetition->periodShow(),
'data' => []
];
$current = clone $repetition->startdate;
while ($current <= $repetition->enddate) {
@@ -271,11 +273,11 @@ class ChartController extends BaseController
$return = [
'chart_title' => 'Overview for budget ' . $budget->name,
'subtitle' =>
'subtitle' =>
'Between ' . Session::get('start')->format('M jS, Y') . ' and ' . Session::get('end')->format(
'M jS, Y'
),
'series' => $series
'series' => $series
];
return Response::json($return);
@@ -296,8 +298,8 @@ class ChartController extends BaseController
$serie = $this->_chart->categoryShowChart($category, $range, $start, $end);
$data = [
'chart_title' => $category->name,
'subtitle' => '<a href="' . route('categories.show', [$category->id]) . '">View more</a>',
'series' => $serie
'subtitle' => '<a href="' . route('categories.show', [$category->id]) . '">View more</a>',
'series' => $serie
];
return Response::json($data);
@@ -336,8 +338,8 @@ class ChartController extends BaseController
'<a href="' . route('accounts.index') . '">View more</a>';
$data = [
'chart_title' => count($accounts) == 1 ? $accounts[0]->name : 'All accounts',
'subtitle' => $url,
'series' => []
'subtitle' => $url,
'series' => []
];
foreach ($accounts as $account) {
@@ -431,11 +433,11 @@ class ChartController extends BaseController
if ($limit > 0 || $expenses > 0) {
$data['labels'][] = $budget->name;
$data['series'][0]['data'][] = [
'y' => $limit,
'y' => $limit,
'url' => route('budgets.show', [$budget->id, $id]) . '?' . $parameter
];
$data['series'][1]['data'][] = [
'y' => $expenses,
'y' => $expenses,
'url' => route('budgets.show', [$budget->id, $id]) . '?' . $parameter
];
}
@@ -444,26 +446,26 @@ class ChartController extends BaseController
$set = \Auth::user()->transactionjournals()->whereNotIn(
'transaction_journals.id', function ($query) use ($start, $end) {
$query->select('transaction_journals.id')->from('transaction_journals')
->leftJoin(
'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=',
'transaction_journals.id'
)
->leftJoin('components', 'components.id', '=', 'component_transaction_journal.component_id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('components.class', 'Budget');
->leftJoin(
'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=',
'transaction_journals.id'
)
->leftJoin('components', 'components.id', '=', 'component_transaction_journal.component_id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('components.class', 'Budget');
}
)->before($end)->after($start)->lessThan(0)->transactionTypes(['Withdrawal'])->sum('amount');
// This can be debugged by using get(['transaction_journals.*','transactions.amount']);
$data['labels'][] = 'No budget';
$data['series'][0]['data'][] = [
'y' => 0,
'url' => route('budgets.nobudget','session')
'y' => 0,
'url' => route('budgets.nobudget', 'session')
];
$data['series'][1]['data'][] = [
'y' => floatval($set) * -1,
'url' => route('budgets.nobudget','session')
'y' => floatval($set) * -1,
'url' => route('budgets.nobudget', 'session')
];
return Response::json($data);
@@ -482,4 +484,120 @@ class ChartController extends BaseController
}
/**
* This method checks all recurring transactions, calculates the current "moment" and returns
* a list of yet to be paid (and paid) recurring transactions. This list can be used to show a beautiful chart
* to the end user who will love it and cherish it.
*
* @throws FireflyException
*/
public function homeRecurring()
{
/** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
/*
* Set of paid transaction journals.
* Set of unpaid recurring transactions.
*/
$paid = [];
$unpaid = [];
/*
* Loop the recurring transactions.
*/
/** @var \RecurringTransaction $recurring */
foreach (\Auth::user()->recurringtransactions()->get() as $recurring) {
/*
* Start another loop starting at the $date.
*/
$start = clone $recurring->date;
$end = Carbon::now();
/*
* The jump we make depends on the $repeat_freq
*/
$current = clone $start;
while ($current <= $end) {
/*
* Get end of period for $current:
*/
$currentEnd = clone $current;
$toolkit->endOfPeriod($currentEnd, $recurring->repeat_freq);
/*
* In the current session range?
*/
if (\Session::get('end') >= $current and $currentEnd >= \Session::get('start')) {
/*
* Lets see if we've already spent money on this recurring transaction (it hath recurred).
*/
/** @var TransactionJournal $set */
$transaction = \Auth::user()->transactionjournals()->where('recurring_transaction_id', $recurring->id)->after($current)->before($currentEnd)->first();
if(is_null($transaction)) {
$unpaid[] = $recurring;
} else {
$paid[] = $transaction;
}
}
/*
* Add some time for the next loop!
*/
$toolkit->addPeriod($current, $recurring->repeat_freq, intval($recurring->skip));
}
}
/*
* Get some colors going.
*/
$unPaidColours = $toolkit->colorRange('AA4643', 'FFFFFF', count($unpaid) == 0 ? 1 : count($unpaid));
$paidColours = $toolkit->colorRange('4572A7', 'FFFFFF', count($paid) == 0 ? 1 : count($paid));
/*
* The chart serie:
*/
$serie = [
'type' => 'pie',
'name' => 'Amount',
'data' => []
];
/*
* Loop paid and unpaid to make two haves for a pie chart.
*/
/** @var TransactionJournal $entry */
foreach ($paid as $index => $entry) {
$transactions = $entry->transactions()->get();
$amount = max(floatval($transactions[0]->amount), floatval($transactions[1]->amount));
$serie['data'][] = [
'name' => 'Already paid "'.$entry->description.'"',
'y' => $amount,
'url' => route('transactions.show',$entry->id),
'objType' => 'paid',
'color' => $paidColours[$index]
];
}
/** @var RecurringTransaction $entry */
foreach ($unpaid as $index => $entry) {
$amount = (floatval($entry->amount_max) + floatval($entry->amount_min)) / 2;
$serie['data'][] = [
'name' => 'Still due: '.$entry->name,
'y' => $amount,
'url' => route('recurring.show',$entry->id),
'objType' => 'unpaid',
'color' => $unPaidColours[$index]
];
}
return Response::json([$serie]);
}
}

View File

@@ -1,7 +1,6 @@
<?php
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
use Firefly\Storage\Reminder\ReminderRepositoryInterface as RRI;
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
/**
@@ -14,24 +13,22 @@ class HomeController extends BaseController
protected $_accounts;
protected $_preferences;
protected $_journal;
protected $_reminders;
/**
* @param ARI $accounts
* @param PHI $preferences
* @param ARI $accounts
* @param PHI $preferences
* @param TJRI $journal
* @param RRI $reminders
*/
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, RRI $reminders)
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal)
{
$this->_accounts = $accounts;
$this->_preferences = $preferences;
$this->_journal = $journal;
$this->_reminders = $reminders;
}
public function jobDev() {
$fullName = storage_path().DIRECTORY_SEPARATOR.'firefly-export-2014-07-23.json';
public function jobDev()
{
$fullName = storage_path() . DIRECTORY_SEPARATOR . 'firefly-export-2014-07-23.json';
\Log::notice('Pushed start job.');
Queue::push('Firefly\Queue\Import@start', ['file' => $fullName, 'user' => 1]);
@@ -40,7 +37,8 @@ class HomeController extends BaseController
/*
*
*/
public function sessionPrev() {
public function sessionPrev()
{
/** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
$toolkit->prev();
@@ -51,7 +49,8 @@ class HomeController extends BaseController
/*
*
*/
public function sessionNext() {
public function sessionNext()
{
/** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
$toolkit->next();
@@ -59,6 +58,18 @@ class HomeController extends BaseController
//return Redirect::route('index');
}
public function rangeJump($range)
{
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y',];
if (in_array($range, $valid)) {
$this->_preferences->set('viewRange', $range);
Session::forget('range');
}
return Redirect::back();
}
/**
* @return \Illuminate\Http\RedirectResponse
*/
@@ -102,6 +113,6 @@ class HomeController extends BaseController
// build the home screen:
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with('title', 'Firefly')
->with('subTitle', 'What\'s playing?')->with('mainTitleIcon','fa-fire');
->with('subTitle', 'What\'s playing?')->with('mainTitleIcon', 'fa-fire');
}
}

View File

@@ -19,7 +19,6 @@ class JsonController extends BaseController
$this->helper = $helper;
}
/**
@@ -97,11 +96,32 @@ class JsonController extends BaseController
return Response::json($resultSet);
}
/**
*
*/
public function recurringjournals(RecurringTransaction $recurringTransaction)
{
$parameters = $this->helper->dataTableParameters();
$parameters['transactionTypes'] = ['Withdrawal'];
$parameters['amount'] = 'negative';
$query = $this->helper->journalQuery($parameters);
$query->where('recurring_transaction_id', $recurringTransaction->id);
$resultSet = $this->helper->journalDataset($parameters, $query);
/*
* Build return data:
*/
return Response::json($resultSet);
}
public function recurring()
{
$parameters = $this->helper->dataTableParameters();
$query = $this->helper->recurringTransactionsQuery($parameters);
$resultSet = $this->helper->recurringTransactionsDataset($parameters, $query);
$query = $this->helper->recurringTransactionsQuery($parameters);
$resultSet = $this->helper->recurringTransactionsDataset($parameters, $query);
return Response::json($resultSet);
}

View File

@@ -22,9 +22,9 @@ class ProfileController extends BaseController
*/
public function index()
{
View::share('title','Profile');
View::share('subTitle',Auth::user()->email);
View::share('mainTitleIcon','fa-user');
View::share('title', 'Profile');
View::share('subTitle', Auth::user()->email);
View::share('mainTitleIcon', 'fa-user');
return View::make('profile.index');
}
@@ -33,9 +33,9 @@ class ProfileController extends BaseController
*/
public function changePassword()
{
View::share('title',Auth::user()->email);
View::share('subTitle','Change your password');
View::share('mainTitleIcon','fa-user');
View::share('title', Auth::user()->email);
View::share('subTitle', 'Change your password');
View::share('mainTitleIcon', 'fa-user');
return View::make('profile.change-password');
}

View File

@@ -21,7 +21,7 @@ class RecurringController extends BaseController
public function __construct(RTR $repository, RI $helper)
{
$this->_repository = $repository;
$this->_helper = $helper;
$this->_helper = $helper;
View::share('title', 'Recurring transactions');
View::share('mainTitleIcon', 'fa-rotate-right');
@@ -102,6 +102,31 @@ class RecurringController extends BaseController
}
/**
* @param RecurringTransaction $recurringTransaction
* @return mixed
*/
public function rescan(RecurringTransaction $recurringTransaction)
{
if (intval($recurringTransaction->active) == 0) {
Session::flash('warning', 'Inactive recurring transactions cannot be scanned.');
return Redirect::back();
}
// do something!
/** @var \Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface $repo */
$repo = App::make('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
$set = $repo->get();
/** @var TransactionJournal $journal */
foreach ($set as $journal) {
Event::fire('recurring.rescan', [$recurringTransaction, $journal]);
}
Session::flash('success', 'Rescanned everything.');
return Redirect::back();
}
public function store()
{
$data = Input::except(['_token', 'post_submit_action']);
@@ -170,14 +195,14 @@ class RecurringController extends BaseController
Session::flash('error', 'Could not update recurring transaction: ' . $messageBag->first());
return Redirect::route('transactions.edit', $recurringTransaction->id)->withInput()
->withErrors($messageBag);
->withErrors($messageBag);
}
break;
case 'validate_only':
$data = Input::all();
$data['id'] = $recurringTransaction->id;
$data = Input::all();
$data['id'] = $recurringTransaction->id;
$messageBags = $this->_helper->validate($data);
Session::flash('warnings', $messageBags['warnings']);

View File

@@ -1,97 +1,10 @@
<?php
use Carbon\Carbon;
use Firefly\Storage\Reminder\ReminderRepositoryInterface as RRI;
/**
* Class ReminderController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/
class ReminderController extends BaseController
{
protected $_repository;
/**
* @param RRI $repository
*/
public function __construct(RRI $repository)
{
$this->_repository = $repository;
}
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\JsonResponse
*/
public function dismiss(\Reminder $reminder)
{
$reminder = $this->_repository->deactivate($reminder);
return Response::json($reminder->id);
}
/**
* Returns the reminders currently active for the modal dialog.
*/
public function modalDialog()
{
$today = new Carbon;
$reminders = $this->_repository->getPiggybankReminders();
/** @var \Reminder $reminder */
foreach ($reminders as $index => $reminder) {
if (\Session::has('dismissal-' . $reminder->id)) {
$time = \Session::get('dismissal-' . $reminder->id);
if ($time >= $today) {
unset($reminders[$index]);
}
}
}
return View::make('reminders.popup')->with('reminders', $reminders);
}
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\JsonResponse
*/
public function postpone(\Reminder $reminder)
{
$now = new Carbon;
$now->addDay();
Session::put('dismissal-' . $reminder->id, $now);
return Response::json($reminder->id);
}
/**
* @param Reminder $reminder
*
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function redirect(\Reminder $reminder)
{
if ($reminder instanceof PiggybankReminder) {
// fields to prefill:
$parameters = [
'account_to_id' => $reminder->piggybank->account->id,
'amount' => round($reminder->amountToSave(), 2),
'description' => 'Money for ' . $reminder->piggybank->name,
'piggybank_id' => $reminder->piggybank->id,
'reminder_id' => $reminder->id
];
return Redirect::to(
route('transactions.create', ['what' => 'transfer']) . '?' . http_build_query($parameters)
);
}
return View::make('error')->with('message', 'No such reminder.');
}
}
}

View File

@@ -27,26 +27,11 @@ class CreateRemindersTable extends Migration
'reminders', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('class', 40);
$table->integer('piggybank_id')->unsigned()->nullable();
$table->integer('recurring_transaction_id')->unsigned()->nullable();
$table->integer('user_id')->unsigned();
$table->date('startdate');
$table->date('enddate')->nullable();
$table->boolean('active');
// connect reminders to piggy banks.
$table->foreign('piggybank_id')
->references('id')->on('piggybanks')
->onDelete('set null');
// connect reminders to recurring transactions.
$table->foreign('recurring_transaction_id')
->references('id')->on('recurring_transactions')
->onDelete('set null');
// connect reminders to users
$table->foreign('user_id')
->references('id')->on('users')

View File

@@ -10,6 +10,7 @@ App::before(
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
$toolkit->getDateRange();
$toolkit->checkImportJobs();
Event::fire('recurring.verify');
}
}

View File

@@ -355,7 +355,7 @@ class Json implements JsonInterface
* Loop set and create entries to return.
*/
foreach ($set as $entry) {
$data['data'][] = [
$set = [
'name' => ['name' => $entry->name, 'url' => route('recurring.show', $entry->id)],
'match' => explode(' ', $entry->match),
@@ -370,6 +370,11 @@ class Json implements JsonInterface
'delete' => route('recurring.delete', $entry->id)
]
];
if (intval($entry->skip) > 0) {
$set['repeat_freq'] = $entry->repeat_freq . ' (skip ' . $entry->skip . ')';
}
$data['data'][] = $set;
}
return $data;

View File

@@ -84,22 +84,23 @@ class Toolkit implements ToolkitInterface
/**
*
*/
public function checkImportJobs() {
public function checkImportJobs()
{
/*
* Get all jobs.
*/
/** @var \Importmap $importJob */
$importJob = \Importmap::where('user_id',\Auth::user()->id)
->where('totaljobs','>',\DB::Raw('`jobsdone`'))
->orderBy('created_at','DESC')
->first();
if(!is_null($importJob)) {
$diff = intval($importJob->totaljobs) - intval($importJob->jobsdone);
$date = new Carbon;
$importJob = \Importmap::where('user_id', \Auth::user()->id)
->where('totaljobs', '>', \DB::Raw('`jobsdone`'))
->orderBy('created_at', 'DESC')
->first();
if (!is_null($importJob)) {
$diff = intval($importJob->totaljobs) - intval($importJob->jobsdone);
$date = new Carbon;
$today = new Carbon;
$date->addSeconds($diff);
\Session::put('job_pct',$importJob->pct());
\Session::put('job_text',$date->diffForHumans());
\Session::put('job_pct', $importJob->pct());
\Session::put('job_text', $date->diffForHumans());
} else {
\Session::forget('job_pct');
\Session::forget('job_text');
@@ -134,7 +135,6 @@ class Toolkit implements ToolkitInterface
*/
protected function _updateStartDate($range, Carbon $start)
{
$today = new Carbon;
switch ($range) {
case '1D':
$start->startOfDay();
@@ -149,12 +149,15 @@ class Toolkit implements ToolkitInterface
$start->firstOfQuarter();
break;
case '6M':
if (intval($today->format('m')) >= 7) {
if (intval($start->format('m')) >= 7) {
$start->startOfYear()->addMonths(6);
} else {
$start->startOfYear();
}
break;
case '1Y':
$start->startOfYear();
break;
}
return $start;
@@ -170,34 +173,34 @@ class Toolkit implements ToolkitInterface
*/
protected function _updateEndDate($range, Carbon $start)
{
$end = clone $start;
switch ($range) {
default:
throw new FireflyException('_updateEndDate cannot handle $range ' . $range);
break;
case '1D':
$end = clone $start;
$end->endOfDay();
break;
case '1W':
$end = clone $start;
$end->endOfWeek();
break;
case '1M':
$end = clone $start;
$end->endOfMonth();
break;
case '3M':
$end = clone $start;
$end->lastOfQuarter();
break;
case '6M':
$end = clone $start;
if (intval($start->format('m')) >= 7) {
$end->endOfYear();
} else {
$end->startOfYear()->addMonths(6);
}
break;
default:
throw new FireflyException('Nothing happened with $end!');
case '1Y':
$end->endOfYear();
break;
}
return $end;
@@ -209,15 +212,39 @@ class Toolkit implements ToolkitInterface
default:
throw new FireflyException('No _periodName() for range "' . $range . '"');
break;
case '1D':
return $date->format('jS F Y');
break;
case '1W':
return 'week ' . $date->format('W, Y');
break;
case '1M':
return $date->format('F Y');
break;
case '3M':
$month = intval($date->format('m'));
return 'Q' . ceil(($month / 12) * 4) . ' ' . $date->format('Y');
break;
case '6M':
$month = intval($date->format('m'));
$half = ceil(($month / 12) * 2);
$halfName = $half == 1 ? 'first' : 'second';
return $halfName . ' half of ' . $date->format('d-m-Y');
break;
case '1Y':
return $date->format('Y');
break;
}
}
protected function _previous($range, Carbon $date)
{
switch ($range) {
default:
throw new FireflyException('Cannot do _previous() on ' . $range);
break;
case '1D':
$date->startOfDay()->subDay();
break;
@@ -231,12 +258,17 @@ class Toolkit implements ToolkitInterface
$date->firstOfQuarter()->subMonths(3)->firstOfQuarter();
break;
case '6M':
if (intval($date->format('m')) >= 7) {
$date->startOfYear();
} else {
$month = intval($date->format('m'));
if ($month <= 6) {
$date->startOfYear()->subMonths(6);
} else {
$date->startOfYear();
}
break;
case '1Y':
$date->startOfYear()->subYear();
break;
}
return $date;
}
@@ -254,7 +286,7 @@ class Toolkit implements ToolkitInterface
$date->endOfMonth()->addDay()->startOfMonth();
break;
case '3M':
$date->lastOfQuarter();
$date->lastOfQuarter()->addDay();
break;
case '6M':
if (intval($date->format('m')) >= 7) {
@@ -263,6 +295,12 @@ class Toolkit implements ToolkitInterface
$date->startOfYear()->addMonths(6);
}
break;
case '1Y':
$date->startOfYear()->addYear();
break;
default:
throw new FireflyException('Cannot do _next() on ' . $range);
break;
}
return $date;
}
@@ -311,7 +349,7 @@ class Toolkit implements ToolkitInterface
* Takes any collection and tries to make a sensible select list compatible array of it.
*
* @param Collection $set
* @param null $titleField
* @param null $titleField
*
* @return mixed
*/
@@ -343,4 +381,127 @@ class Toolkit implements ToolkitInterface
}
return $selectList;
}
/**
* @param string $start
* @param string $end
* @param int $steps
*/
public function colorRange($start, $end, $steps = 5)
{
if (strlen($start) != 6) {
throw new FireflyException('Start, ' . e($start) . ' should be a six character HTML colour.');
}
if (strlen($end) != 6) {
throw new FireflyException('End, ' . e($end) . ' should be a six character HTML colour.');
}
if ($steps < 1) {
throw new FireflyException('Steps must be > 1');
}
$start = '#' . $start;
$end = '#' . $end;
/*
* Split html colours.
*/
list($rs, $gs, $bs) = sscanf($start, "#%02x%02x%02x");
list($re, $ge, $be) = sscanf($end, "#%02x%02x%02x");
$stepr = ($re - $rs) / $steps;
$stepg = ($ge - $gs) / $steps;
$stepb = ($be - $bs) / $steps;
$return = [];
for ($i = 0; $i <= $steps; $i++) {
$cr = $rs + ($stepr * $i);
$cg = $gs + ($stepg * $i);
$cb = $bs + ($stepb * $i);
$return[] = $this->rgb2html($cr, $cg, $cb);
}
return $return;
}
protected function rgb2html($r, $g = -1, $b = -1)
{
$r = dechex($r < 0 ? 0 : ($r > 255 ? 255 : $r));
$g = dechex($g < 0 ? 0 : ($g > 255 ? 255 : $g));
$b = dechex($b < 0 ? 0 : ($b > 255 ? 255 : $b));
$color = (strlen($r) < 2 ? '0' : '') . $r;
$color .= (strlen($g) < 2 ? '0' : '') . $g;
$color .= (strlen($b) < 2 ? '0' : '') . $b;
return '#' . $color;
}
/**
* @param Carbon $currentEnd
* @param $repeatFreq
* @throws FireflyException
*/
public function endOfPeriod(Carbon $currentEnd, $repeatFreq)
{
switch ($repeatFreq) {
default:
throw new FireflyException('Cannot do getFunctionForRepeatFreq for $repeat_freq ' . $repeatFreq);
break;
case 'daily':
$currentEnd->addDay();
break;
case 'weekly':
$currentEnd->addWeek()->subDay();
break;
case 'monthly':
$currentEnd->addMonth()->subDay();
break;
case 'quarterly':
$currentEnd->addMonths(3)->subDay();
break;
case 'half-year':
$currentEnd->addMonths(6)->subDay();
break;
case 'yearly':
$currentEnd->addYear()->subDay();
break;
}
}
/**
* @param Carbon $date
* @param $repeatFreq
* @param $skip
* @return Carbon
* @throws FireflyException
*/
public function addPeriod(Carbon $date, $repeatFreq, $skip)
{
$add = ($skip + 1);
switch ($repeatFreq) {
default:
throw new FireflyException('Cannot do getFunctionForRepeatFreq for $repeat_freq ' . $repeatFreq);
break;
case 'daily':
$date->addDays($add);
break;
case 'weekly':
$date->addWeeks($add);
break;
case 'monthly':
$date->addMonths($add);
break;
case 'quarterly':
$months = $add * 3;
$date->addMonths($months);
break;
case 'half-year':
$months = $add * 6;
$date->addMonths($months);
break;
case 'yearly':
$date->addYears($add);
break;
}
return $date;
}
}

View File

@@ -2,6 +2,7 @@
namespace Firefly\Helper\Toolkit;
use Carbon\Carbon;
use Illuminate\Support\Collection;
/**
@@ -21,7 +22,7 @@ interface ToolkitInterface
* Takes any collection and tries to make a sensible select list compatible array of it.
*
* @param Collection $set
* @param null $titleField
* @param null $titleField
*
* @return mixed
*/
@@ -33,4 +34,19 @@ interface ToolkitInterface
public function checkImportJobs();
/**
* @param string $start
* @param string $end
* @param int $steps
*/
public function colorRange($start, $end, $steps = 5);
/**
* @param Carbon $date
* @param $repeatFreq
* @param $skip
* @return Carbon
*/
public function addPeriod(Carbon $date, $repeatFreq, $skip);
}

View File

@@ -175,12 +175,6 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
return $messageBag;
}
if ($recurringTransaction->date < Carbon::now()) {
$messageBag->add('date', 'Must be in the future.');
return $messageBag;
}
if ($recurringTransaction->validate()) {
$recurringTransaction->save();
} else {

View File

@@ -31,17 +31,4 @@ class EloquentReminderRepository implements ReminderRepositoryInterface
{
$this->_user = \Auth::user();
}
/**
* @param \Reminder $reminder
*
* @return mixed|void
*/
public function deactivate(\Reminder $reminder)
{
$reminder->active = 0;
$reminder->save();
return $reminder;
}
}

View File

@@ -10,14 +10,6 @@ namespace Firefly\Storage\Reminder;
interface ReminderRepositoryInterface
{
/**
* @param \Reminder $reminder
*
* @return mixed
*/
public function deactivate(\Reminder $reminder);
/**
* @param \User $user
* @return mixed

View File

@@ -5,6 +5,7 @@ namespace Firefly\Storage\TransactionJournal;
use Carbon\Carbon;
use Illuminate\Queue\Jobs\Job;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
/**
@@ -24,6 +25,15 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
$this->_user = \Auth::user();
}
/**
* Get them ALL
*
* @return Collection
*/
public function get() {
return $this->_user->transactionjournals()->with('transactions')->get();
}
/**
* @param Job $job
* @param array $payload

View File

@@ -4,6 +4,7 @@ namespace Firefly\Storage\TransactionJournal;
use Carbon\Carbon;
use Illuminate\Queue\Jobs\Job;
use Illuminate\Support\Collection;
/**
* Interface TransactionJournalRepositoryInterface
@@ -20,6 +21,13 @@ interface TransactionJournalRepositoryInterface
*/
public function importTransaction(Job $job, array $payload);
/**
* Get them ALL
*
* @return Collection
*/
public function get();
/**
* @param Job $job
* @param array $payload

View File

@@ -23,44 +23,19 @@ class EloquentJournalTrigger
/*
* Grab all recurring events.
*/
$set = $journal->user()->first()->recurringtransactions()->get();
$set = $journal->user()->first()->recurringtransactions()->get();
$result = [];
/*
* Prep vars
*/
$description = strtolower($journal->description);
$result = [0 => 0];
/** @var \RecurringTransaction $recurring */
foreach ($set as $recurring) {
$matches = explode(' ', $recurring->match);
/*
* Count the number of matches.
*/
$count = 0;
foreach ($matches as $word) {
if (!(strpos($description, $word) === false)) {
$count++;
\Log::debug('Recurring transaction #' . $recurring->id . ': word "' . $word . '" found in "' . $description . '".');
}
}
$result[$recurring->id] = $count;
\Event::fire('recurring.rescan', [$recurring, $journal]);
}
/*
* The one with the highest value is the winrar!
*/
$index = array_search(max($result), $result);
/*
* Find the recurring transaction:
*/
if (count($result[$index]) > 0) {
$winner = $journal->user()->first()->recurringtransactions()->find($index);
if ($winner) {
$journal->recurringTransaction()->associate($winner);
$journal->save();
}
}
return true;
}

View File

@@ -107,159 +107,6 @@ class EloquentPiggybankTrigger
return true;
}
/**
* Whenever a repetition is made, the decision is there to make reminders for it. Or not.
* Some combinations are "invalid" or impossible and will never trigger reminders. Others do.
*
* The numbers below refer to a small list I made in a text-file (it no longer exists) which contained the eight
* binary combinations that can be made of three properties each piggy bank has (among others):
*
* - Whether or not it has a start date.
* - Whether or not it has an end date.
* - Whether or not the piggy bank repeats itself.
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
* @param \PiggybankRepetition $repetition
*
* @return null
*/
public function createdRepetition(\PiggybankRepetition $repetition)
{
\Log::debug('TRIGGER on createdRepetition() for repetition #' . $repetition->id);
$piggyBank = $repetition->piggybank;
// first, exclude all combinations that will not generate (valid) reminders
// no reminders needed (duh)
if (is_null(($piggyBank->reminder))) {
\Log::debug('No reminders because no reminder needed.');
return null;
}
// no start, no target, no repeat (#1):
if (is_null($piggyBank->startdate) && is_null($piggyBank->targetdate) && $piggyBank->repeats == 0) {
\Log::debug('No reminders because no start, no target, no repeat (#1)');
return null;
}
// no start, but repeats (#5):
if (is_null($piggyBank->startdate) && $piggyBank->repeats == 1) {
\Log::debug('No reminders because no start, but repeats (#5)');
return null;
}
// no start, no end, but repeats (#6)
if (is_null($piggyBank->startdate) && is_null($piggyBank->targetdate) && $piggyBank->repeats == 1) {
\Log::debug('No reminders because no start, no end, but repeats (#6)');
return null;
}
// no end, but repeats (#7)
if (is_null($piggyBank->targetdate) && $piggyBank->repeats == 1) {
\Log::debug('No reminders because no end, but repeats (#7)');
return null;
}
\Log::debug('Will continue...');
/*
* #2, #3, #4 and #8 are valid combo's.
*
* We add two years to the end when the repetition has no target date; we "pretend" there is a target date.
*
*/
if (is_null($repetition->targetdate)) {
$end = new Carbon;
$end->addYears(2);
} else {
$end = $repetition->targetdate;
}
/*
* If there is no start date, the start dat becomes right now.
*/
if (is_null($repetition->startdate)) {
$start = new Carbon;
} else {
$start = $repetition->startdate;
}
/*
* Firefly checks every period X between $start and $end and if necessary creates a reminder. Firefly
* only creates reminders if the $current date is after today. Piggy banks may have their start in the past.
*
* This loop will jump a month when the reminder is set monthly, a week when it's set weekly, etcetera.
*/
$current = $start;
$today = new Carbon;
$today->startOfDay();
while ($current <= $end) {
\Log::debug('Looping reminder dates; now at ' . $current);
/*
* Piggy bank reminders start X days before the actual date of the event.
*/
$reminderStart = clone $current;
switch ($piggyBank->reminder) {
case 'day':
$reminderStart->subDay();
break;
case 'week':
$reminderStart->subDays(4);
break;
case 'month':
$reminderStart->subDays(21);
break;
case 'year':
$reminderStart->subMonths(9);
break;
}
/*
* If the date is past today we create a reminder, otherwise we don't. The end date is the date
* the reminder is due; after that it is invalid.
*/
if ($current >= $today) {
$reminder = new \PiggybankReminder;
$reminder->piggybank()->associate($piggyBank);
$reminder->user()->associate(\Auth::user());
$reminder->startdate = $reminderStart;
$reminder->enddate = $current;
$reminder->active = 1;
\Log::debug('Will create a reminder. Is it valid?');
\Log::debug($reminder->validate());
try {
$reminder->save();
} catch (QueryException $e) {
\Log::error('Could not save reminder: ' . $e->getMessage());
}
} else {
\Log::debug('Current is before today, will not make a reminder.');
}
/*
* Here Firefly jumps ahead to the next reminder period.
*/
switch ($piggyBank->reminder) {
case 'day':
$current->addDays($piggyBank->reminder_skip);
break;
case 'week':
$current->addWeeks($piggyBank->reminder_skip);
break;
case 'month':
$current->addMonths($piggyBank->reminder_skip);
break;
case 'year':
$current->addYears($piggyBank->reminder_skip);
break;
}
}
}
/**
* @param \Piggybank $piggyBank
*
@@ -267,13 +114,6 @@ class EloquentPiggybankTrigger
*/
public function destroy(\Piggybank $piggyBank)
{
$reminders = $piggyBank->piggybankreminders()->get();
/** @var \PiggybankReminder $reminder */
foreach ($reminders as $reminder) {
$reminder->delete();
}
return true;
}
@@ -356,9 +196,6 @@ class EloquentPiggybankTrigger
'piggybanks.check', 'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@checkRepeatingPiggies'
);
$events->listen(
'piggybanks.repetition', 'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@createdRepetition'
);
}
/**

View File

@@ -3,6 +3,7 @@
namespace Firefly\Trigger\Recurring;
use Carbon\Carbon;
use Firefly\Exception\FireflyException;
use Illuminate\Events\Dispatcher;
/**
@@ -28,8 +29,67 @@ class EloquentRecurringTrigger
}
public function createReminders()
/**
* @param \RecurringTransaction $recurring
* @param \TransactionJournal $journal
*/
public function rescan(\RecurringTransaction $recurring, \TransactionJournal $journal)
{
/*
* Match words.
*/
$wordMatch = false;
$matches = explode(' ', $recurring->match);
$description = strtolower($journal->description);
/*
* Attach expense account to description for more narrow matching.
*/
$transactions = $journal->transactions()->get();
/** @var \Transaction $transaction */
foreach ($transactions as $transaction) {
/** @var \Account $account */
$account = $transaction->account()->first();
/** @var \AccountType $type */
$type = $account->accountType()->first();
if ($type->type == 'Expense account' || $type->type == 'Beneficiary account') {
$description .= ' ' . strtolower($account->name);
}
}
$count = 0;
foreach ($matches as $word) {
if (!(strpos($description, strtolower($word)) === false)) {
$count++;
}
}
if ($count >= count($matches)) {
$wordMatch = true;
}
/*
* Match amount.
*/
$amountMatch = false;
if (count($transactions) > 1) {
$amount = max(floatval($transactions[0]->amount), floatval($transactions[1]->amount));
$min = floatval($recurring->amount_min);
$max = floatval($recurring->amount_max);
if ($amount >= $min && $amount <= $max) {
$amountMatch = true;
}
}
/*
* If both, update!
*/
if ($wordMatch && $amountMatch) {
$journal->recurringTransaction()->associate($recurring);
$journal->save();
}
}
/**
@@ -39,10 +99,7 @@ class EloquentRecurringTrigger
*/
public function subscribe(Dispatcher $events)
{
// $events->listen('recurring.destroy', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@destroy');
// $events->listen('recurring.store', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@store');
// $events->listen('recurring.update', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@update');
// $events->listen('recurring.check', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@createReminders');
$events->listen('recurring.rescan', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@rescan');
}
/**

View File

@@ -104,68 +104,6 @@ class Piggybank extends Ardent
return ['created_at', 'updated_at', 'targetdate', 'startdate'];
}
/**
* Firefly shouldn't create piggybank repetions that completely
* lie in the future, so we should be able to safely grab the "latest"
* one and use that to calculate when the user will be reminded.
*/
public function nextReminderDate()
{
if (is_null($this->reminder)) {
return null;
}
/** @var \PiggybankRepetition $rep */
$rep = $this->currentRelevantRep();
$today = new Carbon;
if ($rep && is_null($rep->startdate)) {
switch ($this->reminder) {
case 'day':
return $today;
break;
case 'week':
return $today->endOfWeek();
break;
case 'month':
return $today->endOfMonth();
break;
case 'year':
return $today->endOfYear();
break;
}
return null;
}
if ($rep && !is_null($rep->startdate)) {
// start with the start date
// when its bigger than today, return it:
$start = clone $rep->startdate;
while ($start <= $today) {
switch ($this->reminder) {
default:
return null;
break;
case 'day':
$start->addDay();
break;
case 'week':
$start->addWeek();
break;
case 'month':
$start->addMonth();
break;
case 'year':
$start->addYear();
break;
}
}
return $start;
}
return new Carbon;
}
/**
* Grabs the PiggyBankRepetition that's currently relevant / active
*
@@ -222,14 +160,6 @@ class Piggybank extends Ardent
return $this->hasMany('PiggybankEvent');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggybankreminders()
{
return $this->hasMany('PiggybankReminder');
}
/**
* Same but for specific date.
*

View File

@@ -1,105 +0,0 @@
<?php
use Carbon\Carbon;
/**
* PiggybankReminder
*
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $class
* @property integer $piggybank_id
* @property integer $recurring_transaction_id
* @property integer $user_id
* @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $enddate
* @property boolean $active
* @property-read \Piggybank $piggybank
* @property-read \RecurringTransaction $recurringTransaction
* @property-read \User $user
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereId($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereClass($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder wherePiggybankId($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereRecurringTransactionId($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereStartdate($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereEnddate($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereActive($value)
* @method static \Reminder validOn($date)
* @method static \Reminder validOnOrAfter($date)
*/
class PiggybankReminder extends Reminder
{
protected $isSubclass = true;
/**
* This method will render a string telling you something about what to save or something.
* @return string
*/
public function render()
{
/** @var \Piggybank $piggyBank */
$piggyBank = $this->piggybank;
$fullText
= 'In order to save enough money for <a href="' . route('piggybanks.show', $piggyBank->id) . '">"' . e(
$piggyBank->name
) . '"</a> you';
$fullText .= ' should save at least ' . mf($this->amountToSave(), false) . ' this ' . $piggyBank->reminder
. ', before ' . $this->enddate->format('M jS, Y');
return $fullText;
}
/**
* @return float
* @throws Firefly\Exception\FireflyException
*/
public function amountToSave()
{
/** @var \Piggybank $piggyBank */
$piggyBank = $this->piggybank;
/** @var \PiggybankRepetition $repetition */
$repetition = $piggyBank->currentRelevantRep();
// if the target date of the repetition is zero, we use the created_at date of the repetition
// and add two years; it's the same routine used elsewhere.
if (is_null($repetition->targetdate)) {
$targetdate = clone $repetition->created_at;
$targetdate->addYears(2);
} else {
$targetdate = $repetition->targetdate;
}
$today = new Carbon;
$diff = $today->diff($targetdate);
$left = $piggyBank->targetamount - $repetition->currentamount;
// to prevent devide by zero:
$piggyBank->reminder_skip = $piggyBank->reminder_skip < 1 ? 1 : $piggyBank->reminder_skip;
$toSave = 0;
switch ($piggyBank->reminder) {
case 'day':
$toSave = $left;// / ($diff->days / $piggyBank->reminder_skip);
break;
case 'week':
$weeks = ceil($diff->days / 7);
$toSave = $left / ($weeks / $piggyBank->reminder_skip);
break;
case 'month':
$toSave = $left / ($diff->m / $piggyBank->reminder_skip);
break;
case 'year':
throw new \Firefly\Exception\FireflyException('No impl year reminder/ PiggyBankReminder Render');
break;
}
return floatval($toSave);
}
}

View File

@@ -62,15 +62,6 @@ class RecurringTransaction extends Ardent
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function reminders()
{
return $this->hasMany('RecurringTransactionReminder');
}
/**
* @return Carbon
*/

View File

@@ -1,42 +0,0 @@
<?php
/**
* RecurringTransactionReminder
*
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $class
* @property integer $piggybank_id
* @property integer $recurring_transaction_id
* @property integer $user_id
* @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $enddate
* @property boolean $active
* @property-read \Piggybank $piggybank
* @property-read \RecurringTransaction $recurringTransaction
* @property-read \User $user
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereId($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereClass($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder wherePiggybankId($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereRecurringTransactionId($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereStartdate($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereEnddate($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereActive($value)
* @method static \Reminder validOn($date)
* @method static \Reminder validOnOrAfter($date)
*/
class RecurringTransactionReminder extends Reminder
{
protected $isSubclass = true;
public function render()
{
return '123';
}
}

View File

@@ -2,6 +2,8 @@
use Carbon\Carbon;
use Firefly\Database\SingleTableInheritanceEntity;
use LaravelBook\Ardent\Ardent;
/**
* Reminder
@@ -10,33 +12,24 @@ use Firefly\Database\SingleTableInheritanceEntity;
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $class
* @property integer $piggybank_id
* @property integer $recurring_transaction_id
* @property integer $user_id
* @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $enddate
* @property boolean $active
* @property-read \Piggybank $piggybank
* @property-read \RecurringTransaction $recurringTransaction
* @property-read \User $user
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereClass($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder wherePiggybankId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRecurringTransactionId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
* @method static \Reminder validOn($date)
* @method static \Reminder validOnOrAfter($date)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereClass($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
* @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
*/
class Reminder extends SingleTableInheritanceEntity
class Reminder extends Ardent
{
protected $table = 'reminders';
protected $subclassField = 'class';
/**
@@ -47,49 +40,6 @@ class Reminder extends SingleTableInheritanceEntity
return ['created_at', 'updated_at', 'startdate', 'enddate'];
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function piggybank()
{
return $this->belongsTo('Piggybank');
}
public function recurringTransaction()
{
return $this->belongsTo('RecurringTransaction');
}
public function render()
{
return '';
}
public function scopeValidOn($query, Carbon $date)
{
return $query->where('startdate', '<=', $date->format('Y-m-d'))->where('enddate', '>=', $date->format('Y-m-d'))
->where('active', 1);
}
public function scopeValidOnOrAfter($query, Carbon $date)
{
return $query->where(
function ($q) use ($date) {
$q->where('startdate', '<=', $date->format('Y-m-d'))->where(
'enddate', '>=', $date->format('Y-m-d')
);
$q->orWhere(
function ($q) use ($date) {
$q->where('startdate', '>=', $date);
$q->where('enddate', '>=', $date);
}
);
}
)->where('active', 1);
}
/**
* User
*

View File

@@ -215,6 +215,30 @@ use LaravelBook\Ardent\Builder;
* 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories
*/
class TransactionJournal extends Ardent
{

View File

@@ -78,22 +78,6 @@ class User extends Ardent implements UserInterface, RemindableInterface
return $this->hasMany('Budget');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function reminders()
{
return $this->hasMany('Reminder');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggybankreminders()
{
return $this->hasMany('PiggybankReminder');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/

View File

@@ -133,6 +133,7 @@ Route::group(['before' => 'auth'], function () {
// some date routes:
Route::get('/prev',['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);
Route::get('/next',['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);
Route::get('/jump/{range}',['uses' => 'HomeController@rangeJump','as' => 'rangeJump']);
// account controller:
Route::get('/accounts', ['uses' => 'AccountController@index', 'as' => 'accounts.index']);
@@ -169,6 +170,7 @@ Route::group(['before' => 'auth'], function () {
Route::get('/chart/home/budgets', ['uses' => 'ChartController@homeBudgets', 'as' => 'chart.budgets']);
Route::get('/chart/home/info/{accountnameA}/{day}/{month}/{year}', ['uses' => 'ChartController@homeAccountInfo', 'as' => 'chart.info']);
Route::get('/chart/categories/show/{category}', ['uses' => 'ChartController@categoryShowChart','as' => 'chart.showcategory']);
Route::get('/chart/home/recurring', ['uses' => 'ChartController@homeRecurring', 'as' => 'chart.recurring']);
// (new charts for budgets)
Route::get('/chart/budget/{budget}/default', ['uses' => 'ChartController@budgetDefault', 'as' => 'chart.budget.default']);
Route::get('chart/budget/{budget}/no_envelope', ['uses' => 'ChartController@budgetNoLimits', 'as' => 'chart.budget.nolimit']);
@@ -187,6 +189,7 @@ Route::group(['before' => 'auth'], function () {
Route::get('/json/revenue', ['uses' => 'JsonController@revenue', 'as' => 'json.revenue']);
Route::get('/json/transfers', ['uses' => 'JsonController@transfers', 'as' => 'json.transfers']);
Route::get('/json/recurring', ['uses' => 'JsonController@recurring', 'as' => 'json.recurring']);
Route::get('/json/recurringjournals/{recurring}', ['uses' => 'JsonController@recurringjournals', 'as' => 'json.recurringjournals']);
// limit controller:
Route::get('/budgets/limits/create/{budget?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']);
@@ -217,16 +220,11 @@ Route::group(['before' => 'auth'], function () {
// recurring transactions controller
Route::get('/recurring',['uses' => 'RecurringController@index', 'as' => 'recurring.index']);
Route::get('/recurring/show/{recurring}',['uses' => 'RecurringController@show', 'as' => 'recurring.show']);
Route::get('/recurring/rescan/{recurring}',['uses' => 'RecurringController@rescan', 'as' => 'recurring.rescan']);
Route::get('/recurring/create',['uses' => 'RecurringController@create', 'as' => 'recurring.create']);
Route::get('/recurring/edit/{recurring}',['uses' => 'RecurringController@edit','as' => 'recurring.edit']);
Route::get('/recurring/delete/{recurring}',['uses' => 'RecurringController@delete','as' => 'recurring.delete']);
// reminder controller
Route::get('/reminders/dialog',['uses' => 'ReminderController@modalDialog']);
Route::post('/reminders/postpone/{reminder}',['uses' => 'ReminderController@postpone']);
Route::post('/reminders/dismiss/{reminder}',['uses' => 'ReminderController@dismiss']);
Route::get('/reminders/redirect/{reminder}',['uses' => 'ReminderController@redirect']);
// report controller:
Route::get('/reports',['uses' => 'ReportController@index','as' => 'reports.index']);

View File

@@ -20,7 +20,7 @@
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<h2><a href="{{route('accounts.create')}}">Start from scratch</a></h2>
<h2><a href="{{route('accounts.create','asset')}}">Start from scratch</a></h2>
<p>
Use this option if you are new to Firefly (III).
@@ -29,9 +29,10 @@
@else
<!-- ACCOUNTS -->
<div class="row">
<div class="col-lg-8 col-md-12 col-sm-12">
<!-- ACCOUNTS -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-credit-card fa-fw"></i> <a href="#">Your accounts</a>
@@ -40,6 +41,7 @@
<div id="accounts-chart" style="height:300px;"></div>
</div>
</div>
<!-- BUDGETS -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-tasks fa-fw"></i> <a href="{{route('budgets.index.date')}}">Budgets and spending</a>
@@ -48,6 +50,7 @@
<div id="budgets"></div>
</div>
</div>
<!-- CATEGORIES -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart fa-fw"></i> <a href="{{route('categories.index')}}">Categories</a>
@@ -55,8 +58,15 @@
<div class="panel-body">
<div id="categories"></div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-line-chart"></i> Savings
</div>
<div class="panel-body">
Bla bla
</div>
</div>
@@ -65,6 +75,16 @@
<!-- time based navigation -->
@include('partials.date_nav')
<!-- REMINDERS -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-line-chart"></i> Recurring transactions
</div>
<div class="panel-body">
<div id="recurring"></div>
</div>
</div>
<!-- TRANSACTIONS -->
@foreach($transactions as $data)
<div class="panel panel-default">

View File

@@ -2,6 +2,22 @@
<div class="panel-heading">
<i class="fa fa-clock-o fa-fw"></i>
{{{\Session::get('period')}}}
<!-- ACTIONS MENU -->
<div class="pull-right">
<div class="btn-group">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
Range
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right" role="menu">
@foreach(Config::get('firefly.range_to_name') as $name => $label)
<li><a href="{{route('rangeJump',$name)}}"><i class="fa fa-calendar fa-fw"></i> {{{ucfirst($label)}}}</a></li>
@endforeach
</ul>
</div>
</div>
</div>
<div class="panel-body">
<div class="btn-group btn-group-sm btn-group-justified">

View File

@@ -57,7 +57,7 @@
Target date: {{$piggyBank->targetdate->format('M jS, Y')}}<br />
@endif
@if(!is_null($piggyBank->reminder))
Next reminder: {{$piggyBank->nextReminderDate()->format('M jS, Y')}} ({{$piggyBank->reminder}})
Next reminder: TODO
@endif
</p>
@@ -119,7 +119,7 @@
@if(!is_null($repeated->reminder))
<small>
Next reminder: {{$repeated->nextReminderDate()->format('M jS, Y')}} ({{$piggyBank->reminder}})
Next reminder: TODO
</small>
@endif

View File

@@ -1,43 +1,41 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<p class="text-info">
Use this extremely obvious form to change your password.
</p>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-12">
{{Form::open(['class' => 'form-horizontal'])}}
<div class="form-group">
<label for="inputOldPassword" class="col-sm-4 control-label">Old password</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="inputOldPassword" placeholder="Old password" name="old">
</div>
<div class="panel panel-primary">
<div class="panel-heading">
Change your password
</div>
<div class="panel-body">
{{Form::open(['class' => 'form-horizontal'])}}
<div class="form-group">
<label for="inputOldPassword" class="col-sm-4 control-label">Old password</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="inputOldPassword" placeholder="Old password" name="old">
</div>
</div>
<div class="form-group">
<label for="inputNewPassword1" class="col-sm-4 control-label">New password</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="inputNewPassword1" placeholder="New password" name="new1">
</div>
</div>
<div class="form-group">
<label for="inputNewPassword1" class="col-sm-4 control-label">New password</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="inputNewPassword1" placeholder="New password" name="new1">
</div>
</div>
<div class="form-group">
<label for="inputNewPassword2" class="col-sm-4 control-label">New password (again)</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="inputNewPassword2" placeholder="New password (again)" name="new2">
</div>
<div class="form-group">
<label for="inputNewPassword2" class="col-sm-4 control-label">New password (again)</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="inputNewPassword2" placeholder="New password (again)" name="new2">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-10">
<button type="submit" class="btn btn-success">Change your password</button>
</div>
</div>
{{Form::close()}}
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-10">
<button type="submit" class="btn btn-success">Change your password</button>
</div>
</div>
{{Form::close()}}
</div>
</div>
</div>
@stop

View File

@@ -1,8 +1,15 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<p class="lead"><a href="{{route('change-password')}}">Change your password</a></p>
<div class="col-lg-6 col-md-12 col-sm-12">
<div class="panel panel-primary">
<div class="panel-heading">
Options
</div>
<div class="panel-body">
<a href="{{route('change-password')}}">Change your password</a>
</div>
</div>
</div>
</div>
@stop

View File

@@ -1,68 +1,108 @@
@extends('layouts.default')
@section('content')
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<p class="lead">Use recurring transactions to track repeated withdrawals</p>
<p>
<div class="btn-group btn-group-xs">
<a href="{{route('recurring.edit',$recurring->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> edit</a>
<a href="{{route('recurring.delete',$recurring->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> delete</a>
</div>
</p>
<div class="col-lg-6 col-sm-12 col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-rotate-right"></i> {{{$recurring->name}}}
@if($recurring->active)
<span class="glyphicon glyphicon-ok" title="Active"></span>
@else
<span class="glyphicon glyphicon-remove" title="Inactive"></span>
@endif
@if($recurring->automatch)
<span class="glyphicon glyphicon-ok" title="Automatically matched by Firefly"></span>
@else
<span class="glyphicon glyphicon-remove" title="Not automatically matched by Firefly"></span>
@endif
<!-- ACTIONS MENU -->
<div class="pull-right">
<div class="btn-group">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
Actions
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right" role="menu">
<li><a href="{{route('recurring.edit',$recurring->id)}}"><span class="glyphicon glyphicon-pencil"></span> edit</a></li>
<li><a href="{{route('recurring.delete',$recurring->id)}}"><span class="glyphicon glyphicon-trash"></span> delete</a></li>
</ul>
</div>
</div>
</div>
<div class="panel-body">
<table class="table">
<tr>
<td colspan="2">
Matching on
@foreach(explode(' ',$recurring->match) as $word)
<span class="label label-info">{{{$word}}}</span>
@endforeach
between {{mf($recurring->amount_min)}} and {{mf($recurring->amount_max)}}.
Repeats {{$recurring->repeat_freq}}.</td>
</tr>
<tr>
<td>Next reminder</td>
<td>TODO TODO</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12 col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
More
</div>
<div class="panel-body">
<p>
<a href="{{route('recurring.rescan',$recurring->id)}}" class="btn btn-default">Rescan old transactions</a>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-sm-6 col-md-12">
<table class="table">
<tr>
<td>Matches on: </td>
<td>
@foreach(explode(' ',$recurring->match) as $word)
<span class="label label-info">{{{$word}}}</span>
@endforeach
</td>
</tr>
<tr>
<td>Between</td>
<td> {{mf($recurring->amount_min)}} &ndash; {{mf($recurring->amount_max)}}</td>
</tr>
<tr>
<td>Repeats</td>
<td>{{ucfirst($recurring->repeat_freq)}}</td>
</tr>
<tr>
<td>Next reminder</td>
<td>{{$recurring->next()->format('d-m-Y')}}</td>
</tr>
<tr>
<td>Will be auto-matched</td>
<td>
@if($recurring->automatch)
<span class="glyphicon glyphicon-ok"></span>
@else
<span class="glyphicon glyphicon-remove"></span>
@endif
</td>
</tr>
<tr>
<td>Is active</td>
<td>
@if($recurring->active)
<span class="glyphicon glyphicon-ok"></span>
@else
<span class="glyphicon glyphicon-remove"></span>
@endif
</td>
</tr>
</table>
<td>
</td>
</tr>
<div class="col-lg-12 col-sm-12 col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
Connected transaction journals
</div>
<div class="panel-body">
<table id="transactionTable" class="table table-striped table-bordered" >
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th>Amount (&euro;)</th>
<th>From</th>
<th>To</th>
<th>Budget / category</th>
<th>ID</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
@stop
@section('scripts')
<script type="text/javascript">
var URL = '{{route('json.recurringjournals',$recurring->id)}}';
</script>
{{HTML::script('assets/javascript/typeahead/bootstrap3-typeahead.min.js')}}
{{HTML::script('assets/javascript/datatables/jquery.dataTables.min.js')}}
{{HTML::script('assets/javascript/datatables/dataTables.bootstrap.js')}}
{{HTML::script('assets/javascript/firefly/recurring.js')}}
@stop
@section('styles')
{{HTML::style('assets/stylesheets/datatables/dataTables.bootstrap.css')}}
@stop

View File

@@ -1,24 +0,0 @@
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal"><span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span></button>
<h4 class="modal-title">Reminders</h4>
</div>
<div class="modal-body">
<table class="table">
@foreach($reminders as $reminder)
<tr class="reminder-row-{{$reminder->id}}">
<td>{{$reminder->render()}}</td>
<td style="width:50%;">
<a href="#" data-id="{{$reminder->id}}" class="dismiss-24 btn btn-danger btn-sm">Postpone (24hrs)</a>
<a href="#" data-id="{{$reminder->id}}" class="dismiss-forever btn btn-danger btn-sm">Dismiss (forever)</a>
<a href="#" data-id="{{$reminder->id}}" class="do-it btn btn-success btn-sm">I want to do this</a>
</td>
</tr>
@endforeach
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>

View File

@@ -17,7 +17,7 @@ $(function () {
allowDecimals: false,
labels: {
formatter: function () {
if(this.value >= 1000 || this.value <= -1000) {
if (this.value >= 1000 || this.value <= -1000) {
return '\u20AC ' + (this.value / 1000) + 'k';
}
return '\u20AC ' + this.value;
@@ -36,10 +36,10 @@ $(function () {
text: null
}
},
legend: {enabled:false},
legend: {enabled: false},
tooltip: {
formatter: function () {
return this.series.name + ': \u20AC ' + Highcharts.numberFormat(this.y,2);
return this.series.name + ': \u20AC ' + Highcharts.numberFormat(this.y, 2);
}
},
plotOptions: {
@@ -101,7 +101,7 @@ $(function () {
},
labels: {
formatter: function () {
if(this.value >= 1000 || this.value <= -1000) {
if (this.value >= 1000 || this.value <= -1000) {
return '\u20AC ' + (this.value / 1000) + 'k';
}
return '\u20AC ' + this.value;
@@ -165,17 +165,17 @@ $(function () {
},
tooltip: {
formatter: function () {
return this.series.name + ': \u20AC ' + Highcharts.numberFormat(this.y,2);
return this.series.name + ': \u20AC ' + Highcharts.numberFormat(this.y, 2);
}
},
yAxis: {
min: 0,
title: {text:null},
title: {text: null},
labels: {
overflow: 'justify',
formatter: function () {
if(this.value >= 1000 || this.value <= -1000) {
if (this.value >= 1000 || this.value <= -1000) {
return '\u20AC ' + (this.value / 1000) + 'k';
}
return '\u20AC ' + this.value;
@@ -188,7 +188,7 @@ $(function () {
cursor: 'pointer',
events: {
click: function (e) {
if(e.point.url != null) {
if (e.point.url != null) {
window.location = e.point.url;
}
}
@@ -202,7 +202,7 @@ $(function () {
}
},
legend: {
enabled: false,
enabled: false
},
credits: {
enabled: false
@@ -211,5 +211,46 @@ $(function () {
});
});
$.getJSON('chart/home/recurring').success(function (data) {
if (data[0].data.length == 0) {
$('#recurring').parent().parent().remove();
} else {
$('#recurring').highcharts({
title: {
text: null
},
credits: {
enabled: false
},
tooltip: {
formatter: function () {
if (this.point.objType == 'paid') {
return this.key + ': \u20AC ' + Highcharts.numberFormat(this.y, 2);
} else {
return this.key + ': ~\u20AC ' + Highcharts.numberFormat(this.y, 2);
}
}
},
plotOptions: {
pie: {
events: {
click: function (e) {
if (e.point.url != null) {
window.location = e.point.url;
}
}
},
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
}
}
},
series: data
});
}
});
});

View File

@@ -1,112 +1,204 @@
$(document).ready(function () {
$('#recurringTable').DataTable(
{
serverSide: true,
ajax: URL,
paging: true,
processing: true,
order: [],
"lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],
columns: [
if ($('#recurringTable').length > 0) {
$('#recurringTable').DataTable(
{
name: 'name',
data: 'name',
searchable: true,
title: 'Name',
render: function (data) {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'match',
data: 'match',
searchable: true,
title: 'Matches on',
render: function (data) {
var str = '';
for (x in data) {
str += '<span class="label label-info">' + data[x] + '</span> ';
}
return str;//return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'amount_min',
data: 'amount_min',
searchable: false,
title: '&rarr;',
render: function (data) {
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
}
},
{
name: 'amount_max',
data: 'amount_max',
searchable: false,
title: '&larr;',
render: function (data) {
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
}
serverSide: true,
ajax: URL,
paging: true,
processing: true,
order: [],
"lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],
columns: [
{
name: 'name',
data: 'name',
searchable: true,
title: 'Name',
render: function (data) {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'match',
data: 'match',
searchable: true,
title: 'Matches on',
render: function (data) {
var str = '';
for (x in data) {
str += '<span class="label label-info">' + data[x] + '</span> ';
}
return str;//return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'amount_min',
data: 'amount_min',
searchable: false,
title: '&rarr;',
render: function (data) {
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
}
},
{
name: 'amount_max',
data: 'amount_max',
searchable: false,
title: '&larr;',
render: function (data) {
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
}
},
{
name: 'date',
data: 'date',
title: 'Expected on',
searchable: false
},
},
{
name: 'date',
data: 'date',
title: 'Expected on',
searchable: false
},
{
name: 'active',
data: 'active',
searchable: false,
sortable: false,
render: function(data) {
if(data == 1) {
return '<i class="fa fa-check fa-faw"></i>';
} else {
return '<i class="fa fa-remove fa-faw"></i>';
{
name: 'active',
data: 'active',
searchable: false,
sortable: false,
render: function (data) {
if (data == 1) {
return '<i class="fa fa-check fa-faw"></i>';
} else {
return '<i class="fa fa-remove fa-faw"></i>';
}
},
title: 'Is active?'
},
{
name: 'automatch',
data: 'automatch',
sortable: false,
searchable: false,
render: function (data) {
if (data == 1) {
return '<i class="fa fa-check fa-faw"></i>';
} else {
return '<i class="fa fa-remove fa-faw"></i>';
}
},
title: 'Automatch?'
},
{
name: 'repeat_freq',
data: 'repeat_freq',
searchable: false,
sortable: false,
title: 'Repeat frequency'
},
{
name: 'id',
data: 'id',
searchable: false,
sortable: false,
title: '',
render: function (data, type, full, meta) {
return '<div class="btn-group btn-group-xs">' +
'<a class="btn btn-default btn-xs" href="' + data.edit + '">' +
'<span class="glyphicon glyphicon-pencil"</a>' +
'<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +
'<span class="glyphicon glyphicon-trash"</a>' +
'</a></div>';
}
}
},
title: 'Is active?'
},
{
name: 'automatch',
data: 'automatch',
sortable: false,
searchable: false,
render: function(data) {
if(data == 1) {
return '<i class="fa fa-check fa-faw"></i>';
} else {
return '<i class="fa fa-remove fa-faw"></i>';
}
},
title: 'Automatch?'
},
{
name: 'repeat_freq',
data: 'repeat_freq',
searchable: false,
sortable: false,
title: 'Repeat frequency'
},
{
name: 'id',
data: 'id',
searchable: false,
sortable: false,
title: '',
render: function (data, type, full, meta) {
return '<div class="btn-group btn-group-xs">' +
'<a class="btn btn-default btn-xs" href="' + data.edit + '">' +
'<span class="glyphicon glyphicon-pencil"</a>' +
'<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +
'<span class="glyphicon glyphicon-trash"</a>' +
'</a></div>';
}
]
}
]
);
}
);
});
if ($('#transactionTable').length > 0) {
$('#transactionTable').DataTable(
{
serverSide: true,
ajax: URL,
paging: true,
processing: true,
order: [],
"lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],
columns: [
{
name: 'date',
data: 'date',
searchable: false
},
{
name: 'description',
data: 'description',
render: function (data, type, full, meta) {
icon = 'glyphicon-arrow-left';
return '<span class="glyphicon ' + icon + '"></span> ' +
'<a href="' + data.url + '" title="' + data.description + '">' + data.description + '</a>';
}
},
{
name: 'amount',
data: 'amount',
'title': 'Amount (\u20AC)',
searchable: false,
render: function (data, type, full, meta) {
return '<span class="text-danger">\u20AC ' + data.toFixed(2) + '</span>';
}
},
{
name: 'from',
data: 'from',
searchable: false,
render: function (data, type, full, meta) {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'to',
data: 'to',
searchable: false,
render: function (data, type, full, meta) {
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
}
},
{
name: 'components',
data: 'components',
searchable: true,
sortable: false,
title: '',
render: function (data, type, full, meta) {
var html = '';
if (data.budget_id > 0) {
html += '<a href="' + data.budget_url + '" title="' + data.budget_name + '"><i class="fa fa-tasks fa-fw"></i></a> ';
}
if (data.category_id > 0) {
html += '<a href="' + data.category_url + '" title="' + data.category_name + '"><i class="fa fa-bar-chart fa-fw"></i></a> ';
}
if (data.recurring_id > 0) {
html += '<a href="' + data.recurring_url + '" title="' + data.recurring_name + '"><i class="fa fa-rotate-right fa-fw"></i></a> ';
}
return html;
}
},
{
name: 'id',
data: 'id',
searchable: false,
sortable: false,
title: '',
render: function (data, type, full, meta) {
return '<div class="btn-group btn-group-xs">' +
'<a class="btn btn-default btn-xs" href="' + data.edit + '">' +
'<span class="glyphicon glyphicon-pencil"</a>' +
'<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +
'<span class="glyphicon glyphicon-trash"</a>' +
'</a></div>';
}
}
]
}
);
}
}
);