mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expanded recurring transactions.
This commit is contained in:
parent
4a20c008ff
commit
840dfa6696
@ -100,11 +100,11 @@ class GoogleTableController extends BaseController
|
|||||||
$chart->addColumn('Name_URL', 'string');
|
$chart->addColumn('Name_URL', 'string');
|
||||||
$chart->addColumn('Name', 'string');
|
$chart->addColumn('Name', 'string');
|
||||||
$chart->addColumn('Matches','string');
|
$chart->addColumn('Matches','string');
|
||||||
$chart->addColumn('Min amount','number');
|
$chart->addColumn('Minimum amount','number');
|
||||||
$chart->addColumn('Max amount','number');
|
$chart->addColumn('Maximum amount','number');
|
||||||
|
|
||||||
/** @var \FireflyIII\Database\RecurringTransaction $repository */
|
/** @var \FireflyIII\Database\Recurring $repository */
|
||||||
$repository = App::make('FireflyIII\Database\RecurringTransaction');
|
$repository = App::make('FireflyIII\Database\Recurring');
|
||||||
|
|
||||||
$set = $repository->get();
|
$set = $repository->get();
|
||||||
|
|
||||||
@ -136,6 +136,75 @@ class GoogleTableController extends BaseController
|
|||||||
return Response::json($chart->getData());
|
return Response::json($chart->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function transactionsByRecurring(RecurringTransaction $recurring) {
|
||||||
|
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||||
|
$chart = App::make('gchart');
|
||||||
|
$chart->addColumn('ID', 'number');
|
||||||
|
$chart->addColumn('ID_Edit', 'string');
|
||||||
|
$chart->addColumn('ID_Delete', 'string');
|
||||||
|
$chart->addColumn('Date', 'date');
|
||||||
|
$chart->addColumn('Description_URL', 'string');
|
||||||
|
$chart->addColumn('Description', 'string');
|
||||||
|
$chart->addColumn('Amount', 'number');
|
||||||
|
$chart->addColumn('From_URL', 'string');
|
||||||
|
$chart->addColumn('From', 'string');
|
||||||
|
$chart->addColumn('To_URL', 'string');
|
||||||
|
$chart->addColumn('To', 'string');
|
||||||
|
$chart->addColumn('Budget_URL', 'string');
|
||||||
|
$chart->addColumn('Budget', 'string');
|
||||||
|
$chart->addColumn('Category_URL', 'string');
|
||||||
|
$chart->addColumn('Category', 'string');
|
||||||
|
|
||||||
|
$journals = $recurring->transactionjournals()->get();
|
||||||
|
|
||||||
|
/** @var TransactionJournal $transaction */
|
||||||
|
foreach ($journals as $journal) {
|
||||||
|
$date = $journal->date;
|
||||||
|
$descriptionURL = route('transactions.show', $journal->id);
|
||||||
|
$description = $journal->description;
|
||||||
|
/** @var Transaction $transaction */
|
||||||
|
foreach ($journal->transactions as $transaction) {
|
||||||
|
if (floatval($transaction->amount) > 0) {
|
||||||
|
$amount = floatval($transaction->amount);
|
||||||
|
$to = $transaction->account->name;
|
||||||
|
$toURL = route('accounts.show', $transaction->account->id);
|
||||||
|
} else {
|
||||||
|
$from = $transaction->account->name;
|
||||||
|
$fromURL = route('accounts.show', $transaction->account->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (isset($journal->budgets[0])) {
|
||||||
|
$budgetURL = route('budgets.show', $journal->budgets[0]->id);
|
||||||
|
$component = $journal->budgets[0]->name;
|
||||||
|
} else {
|
||||||
|
$budgetURL = '';
|
||||||
|
$component = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($journal->categories[0])) {
|
||||||
|
$categoryURL = route('categories.show', $journal->categories[0]->id);
|
||||||
|
$category = $journal->categories[0]->name;
|
||||||
|
} else {
|
||||||
|
$categoryURL = '';
|
||||||
|
$category = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$id = $journal->id;
|
||||||
|
$edit = route('transactions.edit', $journal->id);
|
||||||
|
$delete = route('transactions.delete', $journal->id);
|
||||||
|
$chart->addRow(
|
||||||
|
$id, $edit, $delete, $date, $descriptionURL, $description, $amount, $fromURL, $from, $toURL, $to, $budgetURL, $component, $categoryURL,
|
||||||
|
$category
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$chart->generate();
|
||||||
|
|
||||||
|
return Response::json($chart->getData());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ class PiggybankController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws NotImplementedException
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,8 +34,8 @@ class RecurringController extends BaseController
|
|||||||
public function delete(RecurringTransaction $recurringTransaction)
|
public function delete(RecurringTransaction $recurringTransaction)
|
||||||
{
|
{
|
||||||
return View::make('recurring.delete')->with('recurringTransaction', $recurringTransaction)->with(
|
return View::make('recurring.delete')->with('recurringTransaction', $recurringTransaction)->with(
|
||||||
'subTitle', 'Delete "' . $recurringTransaction->name . '"'
|
'subTitle', 'Delete "' . $recurringTransaction->name . '"'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,8 +47,8 @@ class RecurringController extends BaseController
|
|||||||
{
|
{
|
||||||
//Event::fire('recurring.destroy', [$recurringTransaction]);
|
//Event::fire('recurring.destroy', [$recurringTransaction]);
|
||||||
|
|
||||||
/** @var \FireflyIII\Database\RecurringTransaction $repository */
|
/** @var \FireflyIII\Database\Recurring $repository */
|
||||||
$repository = App::make('FireflyIII\Database\RecurringTransaction');
|
$repository = App::make('FireflyIII\Database\Recurring');
|
||||||
|
|
||||||
$result = $repository->destroy($recurringTransaction);
|
$result = $repository->destroy($recurringTransaction);
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
@ -72,8 +71,8 @@ class RecurringController extends BaseController
|
|||||||
$periods = \Config::get('firefly.periods_to_text');
|
$periods = \Config::get('firefly.periods_to_text');
|
||||||
|
|
||||||
return View::make('recurring.edit')->with('periods', $periods)->with('recurringTransaction', $recurringTransaction)->with(
|
return View::make('recurring.edit')->with('periods', $periods)->with('recurringTransaction', $recurringTransaction)->with(
|
||||||
'subTitle', 'Edit "' . $recurringTransaction->name . '"'
|
'subTitle', 'Edit "' . $recurringTransaction->name . '"'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,7 +95,11 @@ class RecurringController extends BaseController
|
|||||||
|
|
||||||
return Redirect::back();
|
return Redirect::back();
|
||||||
}
|
}
|
||||||
throw new NotImplementedException;
|
|
||||||
|
/** @var \FireflyIII\Database\Recurring $repos */
|
||||||
|
$repos = App::make('FireflyIII\Database\Recurring');
|
||||||
|
$repos->scanEverything($recurringTransaction);
|
||||||
|
|
||||||
Session::flash('success', 'Rescanned everything.');
|
Session::flash('success', 'Rescanned everything.');
|
||||||
|
|
||||||
return Redirect::back();
|
return Redirect::back();
|
||||||
@ -112,7 +115,7 @@ class RecurringController extends BaseController
|
|||||||
|
|
||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
$data = Input::except('_token');
|
$data = Input::except('_token');
|
||||||
/** @var \FireflyIII\Database\Recurring $repos */
|
/** @var \FireflyIII\Database\Recurring $repos */
|
||||||
$repos = App::make('FireflyIII\Database\Recurring');
|
$repos = App::make('FireflyIII\Database\Recurring');
|
||||||
|
|
||||||
@ -155,6 +158,43 @@ class RecurringController extends BaseController
|
|||||||
|
|
||||||
public function update(RecurringTransaction $recurringTransaction)
|
public function update(RecurringTransaction $recurringTransaction)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
/** @var \FireflyIII\Database\Recurring $repos */
|
||||||
|
$repos = App::make('FireflyIII\Database\Recurring');
|
||||||
|
$data = Input::except('_token');
|
||||||
|
|
||||||
|
switch (Input::get('post_submit_action')) {
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot handle post_submit_action "' . e(Input::get('post_submit_action')) . '"');
|
||||||
|
break;
|
||||||
|
case 'create_another':
|
||||||
|
case 'update':
|
||||||
|
$messages = $repos->validate($data);
|
||||||
|
/** @var MessageBag $messages ['errors'] */
|
||||||
|
if ($messages['errors']->count() > 0) {
|
||||||
|
Session::flash('warnings', $messages['warnings']);
|
||||||
|
Session::flash('successes', $messages['successes']);
|
||||||
|
Session::flash('error', 'Could not save recurring transaction: ' . $messages['errors']->first());
|
||||||
|
|
||||||
|
return Redirect::route('recurring.edit', $recurringTransaction->id)->withInput()->withErrors($messages['errors']);
|
||||||
|
}
|
||||||
|
// store!
|
||||||
|
$repos->update($recurringTransaction, $data);
|
||||||
|
Session::flash('success', 'Recurring transaction updated!');
|
||||||
|
|
||||||
|
if ($data['post_submit_action'] == 'create_another') {
|
||||||
|
return Redirect::route('recurring.edit', $recurringTransaction->id);
|
||||||
|
} else {
|
||||||
|
return Redirect::route('recurring.index');
|
||||||
|
}
|
||||||
|
case 'validate_only':
|
||||||
|
$messageBags = $repos->validate($data);
|
||||||
|
Session::flash('warnings', $messageBags['warnings']);
|
||||||
|
Session::flash('successes', $messageBags['successes']);
|
||||||
|
Session::flash('errors', $messageBags['errors']);
|
||||||
|
|
||||||
|
return Redirect::route('recurring.edit', $recurringTransaction->id)->withInput();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -309,60 +309,6 @@ class TransactionController extends BaseController
|
|||||||
return Redirect::route('transactions.create', $what)->withInput();
|
return Redirect::route('transactions.create', $what)->withInput();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
throw new NotImplementedException;
|
|
||||||
/*
|
|
||||||
* Collect data to process:
|
|
||||||
*/
|
|
||||||
$data = Input::except(['_token']);
|
|
||||||
$data['what'] = $what;
|
|
||||||
|
|
||||||
switch (Input::get('post_submit_action')) {
|
|
||||||
case 'store':
|
|
||||||
case 'create_another':
|
|
||||||
/*
|
|
||||||
* Try to store:
|
|
||||||
*/
|
|
||||||
$messageBag = $this->_helper->store($data);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Failure!
|
|
||||||
*/
|
|
||||||
if ($messageBag->count() > 0) {
|
|
||||||
Session::flash('error', 'Could not save transaction: ' . $messageBag->first());
|
|
||||||
|
|
||||||
return Redirect::route('transactions.create', [$what])->withInput()->withErrors($messageBag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Success!
|
|
||||||
*/
|
|
||||||
Session::flash('success', 'Transaction "' . e(Input::get('description')) . '" saved!');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Redirect to original location or back to the form.
|
|
||||||
*/
|
|
||||||
if (Input::get('post_submit_action') == 'create_another') {
|
|
||||||
return Redirect::route('transactions.create', $what)->withInput();
|
|
||||||
} else {
|
|
||||||
return Redirect::route('transactions.index.' . $what);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'validate_only':
|
|
||||||
$messageBags = $this->_helper->validate($data);
|
|
||||||
|
|
||||||
Session::flash('warnings', $messageBags['warnings']);
|
|
||||||
Session::flash('successes', $messageBags['successes']);
|
|
||||||
Session::flash('errors', $messageBags['errors']);
|
|
||||||
|
|
||||||
return Redirect::route('transactions.create', [$what])->withInput();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -374,46 +320,46 @@ class TransactionController extends BaseController
|
|||||||
public function update(TransactionJournal $journal)
|
public function update(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
switch (Input::get('post_submit_action')) {
|
// switch (Input::get('post_submit_action')) {
|
||||||
case 'update':
|
// case 'update':
|
||||||
case 'return_to_edit':
|
// case 'return_to_edit':
|
||||||
$what = strtolower($journal->transactionType->type);
|
// $what = strtolower($journal->transactionType->type);
|
||||||
$messageBag = $this->_helper->update($journal, Input::all());
|
// $messageBag = $this->_helper->update($journal, Input::all());
|
||||||
if ($messageBag->count() == 0) {
|
// if ($messageBag->count() == 0) {
|
||||||
// has been saved, return to index:
|
// // has been saved, return to index:
|
||||||
Session::flash('success', 'Transaction updated!');
|
// Session::flash('success', 'Transaction updated!');
|
||||||
Event::fire('journals.update', [$journal]);
|
// Event::fire('journals.update', [$journal]);
|
||||||
|
//
|
||||||
if (Input::get('post_submit_action') == 'return_to_edit') {
|
// if (Input::get('post_submit_action') == 'return_to_edit') {
|
||||||
return Redirect::route('transactions.edit', $journal->id)->withInput();
|
// return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||||
} else {
|
// } else {
|
||||||
return Redirect::route('transactions.index.' . $what);
|
// return Redirect::route('transactions.index.' . $what);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
Session::flash('error', 'Could not update transaction: ' . $journal->errors()->first());
|
// Session::flash('error', 'Could not update transaction: ' . $journal->errors()->first());
|
||||||
|
//
|
||||||
return Redirect::route('transactions.edit', $journal->id)->withInput()->withErrors(
|
// return Redirect::route('transactions.edit', $journal->id)->withInput()->withErrors(
|
||||||
$journal->errors()
|
// $journal->errors()
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
case 'validate_only':
|
// case 'validate_only':
|
||||||
$data = Input::all();
|
// $data = Input::all();
|
||||||
$data['what'] = strtolower($journal->transactionType->type);
|
// $data['what'] = strtolower($journal->transactionType->type);
|
||||||
$messageBags = $this->_helper->validate($data);
|
// $messageBags = $this->_helper->validate($data);
|
||||||
|
//
|
||||||
Session::flash('warnings', $messageBags['warnings']);
|
// Session::flash('warnings', $messageBags['warnings']);
|
||||||
Session::flash('successes', $messageBags['successes']);
|
// Session::flash('successes', $messageBags['successes']);
|
||||||
Session::flash('errors', $messageBags['errors']);
|
// Session::flash('errors', $messageBags['errors']);
|
||||||
|
//
|
||||||
return Redirect::route('transactions.edit', $journal->id)->withInput();
|
// return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');
|
// throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,4 +20,19 @@ interface RecurringInterface
|
|||||||
*/
|
*/
|
||||||
public function getJournalForRecurringInRange(\RecurringTransaction $recurring, Carbon $start, Carbon $end);
|
public function getJournalForRecurringInRange(\RecurringTransaction $recurring, Carbon $start, Carbon $end);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \RecurringTransaction $recurring
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function scanEverything(\RecurringTransaction $recurring);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \RecurringTransaction $recurring
|
||||||
|
* @param \TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function scan(\RecurringTransaction $recurring,\TransactionJournal $journal);
|
||||||
|
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ use FireflyIII\Exception\NotImplementedException;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use LaravelBook\Ardent\Ardent;
|
use LaravelBook\Ardent\Ardent;
|
||||||
|
use stdObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Recurring
|
* Class Recurring
|
||||||
@ -36,8 +37,9 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
*/
|
*/
|
||||||
public function destroy(Ardent $model)
|
public function destroy(Ardent $model)
|
||||||
{
|
{
|
||||||
// TODO: Implement destroy() method.
|
$model->delete();
|
||||||
throw new NotImplementedException;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,8 +49,38 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
*/
|
*/
|
||||||
public function store(array $data)
|
public function store(array $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement store() method.
|
var_dump($data);
|
||||||
throw new NotImplementedException;
|
$recurring = new \RecurringTransaction;
|
||||||
|
$recurring->user()->associate($this->getUser());
|
||||||
|
$recurring->name = $data['name'];
|
||||||
|
$recurring->match = $data['match'];
|
||||||
|
$recurring->amount_max = floatval($data['amount_max']);
|
||||||
|
$recurring->amount_min = floatval($data['amount_min']);
|
||||||
|
|
||||||
|
$date = new Carbon($data['date']);
|
||||||
|
|
||||||
|
|
||||||
|
$recurring->active = isset($data['active']) && intval($data['active']) == 1 ? 1 : 0;
|
||||||
|
$recurring->automatch = isset($data['automatch']) && intval($data['automatch']) == 1 ? 1 : 0;
|
||||||
|
$recurring->repeat_freq = $data['repeat_freq'];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Jump to the start of the period.
|
||||||
|
*/
|
||||||
|
/** @var \FireflyIII\Shared\Toolkit\Date $toolkit */
|
||||||
|
$toolkit = \App::make('FireflyIII\Shared\Toolkit\Date');
|
||||||
|
$date = $toolkit->startOfPeriod($date, $data['repeat_freq']);
|
||||||
|
$recurring->date = $date;
|
||||||
|
$recurring->skip = intval($data['skip']);
|
||||||
|
|
||||||
|
if (!$recurring->validate()) {
|
||||||
|
var_dump($recurring->errors());
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$recurring->save();
|
||||||
|
|
||||||
|
return $recurring;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,8 +91,29 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
*/
|
*/
|
||||||
public function update(Ardent $model, array $data)
|
public function update(Ardent $model, array $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement update() method.
|
var_dump($data);
|
||||||
throw new NotImplementedException;
|
|
||||||
|
$model->name = $data['name'];
|
||||||
|
$model->match = $data['match'];
|
||||||
|
$model->amount_max = floatval($data['amount_max']);
|
||||||
|
$model->amount_min = floatval($data['amount_min']);
|
||||||
|
|
||||||
|
$date = new Carbon($data['date']);
|
||||||
|
|
||||||
|
$model->date = $date;
|
||||||
|
$model->active = isset($data['active']) && intval($data['active']) == 1 ? 1 : 0;
|
||||||
|
$model->automatch = isset($data['automatch']) && intval($data['automatch']) == 1 ? 1 : 0;
|
||||||
|
$model->repeat_freq = $data['repeat_freq'];
|
||||||
|
$model->skip = intval($data['skip']);
|
||||||
|
|
||||||
|
if (!$model->validate()) {
|
||||||
|
var_dump($model->errors());
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->save();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +147,7 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
if (isset($model['amount_max']) && floatval($model['amount_max']) < 0.02) {
|
if (isset($model['amount_max']) && floatval($model['amount_max']) < 0.02) {
|
||||||
$errors->add('amount_max', 'Maximum amount must be higher.');
|
$errors->add('amount_max', 'Maximum amount must be higher.');
|
||||||
}
|
}
|
||||||
if(isset($model['amount_min']) && isset($model['amount_max']) && floatval($model['amount_min']) > floatval($model['amount_max'])) {
|
if (isset($model['amount_min']) && isset($model['amount_max']) && floatval($model['amount_min']) > floatval($model['amount_max'])) {
|
||||||
$errors->add('amount_max', 'Maximum amount can not be less than minimum amount.');
|
$errors->add('amount_max', 'Maximum amount can not be less than minimum amount.');
|
||||||
$errors->add('amount_min', 'Minimum amount can not be more than maximum amount.');
|
$errors->add('amount_min', 'Minimum amount can not be more than maximum amount.');
|
||||||
}
|
}
|
||||||
@ -116,10 +169,10 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
$errors->add('skip', 'Invalid skip.');
|
$errors->add('skip', 'Invalid skip.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$set = ['name','match','amount_min','amount_max','date','repeat_freq','skip','automatch','active'];
|
$set = ['name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active'];
|
||||||
foreach($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
if(!$errors->has($entry)) {
|
if (!$errors->has($entry)) {
|
||||||
$successes->add($entry,'OK');
|
$successes->add($entry, 'OK');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,4 +252,111 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
return $this->getUser()->transactionjournals()->where('recurring_transaction_id', $recurring->id)->after($start)->before($end)->first();
|
return $this->getUser()->transactionjournals()->where('recurring_transaction_id', $recurring->id)->after($start)->before($end)->first();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \RecurringTransaction $recurring
|
||||||
|
* @param \TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function scan(\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.
|
||||||
|
*/
|
||||||
|
if (count($journal->transactions) < 2) {
|
||||||
|
$transactions = $journal->transactions()->get();
|
||||||
|
} else {
|
||||||
|
$transactions = $journal->transactions;
|
||||||
|
}
|
||||||
|
/** @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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\Log::debug('Final description: ' . $description);
|
||||||
|
\Log::debug('Matches searched: ' . join(':', $matches));
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
foreach ($matches as $word) {
|
||||||
|
if (!(strpos($description, strtolower($word)) === false)) {
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($count >= count($matches)) {
|
||||||
|
$wordMatch = true;
|
||||||
|
\Log::debug('word match is 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;
|
||||||
|
\Log::debug('Amount match is true!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If both, update!
|
||||||
|
*/
|
||||||
|
if ($wordMatch && $amountMatch) {
|
||||||
|
$journal->recurringTransaction()->associate($recurring);
|
||||||
|
$journal->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \RecurringTransaction $recurring
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* @throws NotImplementedException
|
||||||
|
*/
|
||||||
|
public function scanEverything(\RecurringTransaction $recurring)
|
||||||
|
{
|
||||||
|
// get all journals that (may) be relevant.
|
||||||
|
// this is usually almost all of them.
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Database\TransactionJournal $journalRepository */
|
||||||
|
$journalRepository = \App::make('FireflyIII\Database\TransactionJournal');
|
||||||
|
|
||||||
|
$set = \DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $recurring->amount_min)->where(
|
||||||
|
'amount', '<=', $recurring->amount_max
|
||||||
|
)->get(['transaction_journal_id']);
|
||||||
|
$ids = [];
|
||||||
|
|
||||||
|
/** @var \Transaction $entry */
|
||||||
|
foreach ($set as $entry) {
|
||||||
|
$ids[] = intval($entry->transaction_journal_id);
|
||||||
|
}
|
||||||
|
if (count($ids) > 0) {
|
||||||
|
$journals = $journalRepository->getByIds($ids);
|
||||||
|
/** @var \TransactionJournal $journal */
|
||||||
|
foreach ($journals as $journal) {
|
||||||
|
$this->scan($recurring, $journal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
@ -355,8 +355,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
*/
|
*/
|
||||||
public function getByIds(array $ids)
|
public function getByIds(array $ids)
|
||||||
{
|
{
|
||||||
// TODO: Implement getByIds() method.
|
return $this->getUser()->transactionjournals()->with('transactions')->whereIn('id', $ids)->orderBy('date', 'ASC')->get();
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -390,9 +389,10 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
$end->endOfMonth();
|
$end->endOfMonth();
|
||||||
|
|
||||||
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
||||||
'transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id'
|
'transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id'
|
||||||
)->where('amount', '>', 0)->where('transaction_types.type', '=', 'Withdrawal')->where('transaction_journals.date', '>=', $date->format('Y-m-d'))
|
)->where('amount', '>', 0)->where('transaction_types.type', '=', 'Withdrawal')->where('transaction_journals.date', '>=', $date->format('Y-m-d'))->where(
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))->sum('transactions.amount');
|
'transaction_journals.date', '<=', $end->format('Y-m-d')
|
||||||
|
)->sum('transactions.amount');
|
||||||
$sum = floatval($sum);
|
$sum = floatval($sum);
|
||||||
|
|
||||||
return $sum;
|
return $sum;
|
||||||
@ -410,9 +410,10 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
$end->endOfMonth();
|
$end->endOfMonth();
|
||||||
|
|
||||||
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
||||||
'transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id'
|
'transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id'
|
||||||
)->where('amount', '>', 0)->where('transaction_types.type', '=', 'Deposit')->where('transaction_journals.date', '>=', $date->format('Y-m-d'))
|
)->where('amount', '>', 0)->where('transaction_types.type', '=', 'Deposit')->where('transaction_journals.date', '>=', $date->format('Y-m-d'))->where(
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))->sum('transactions.amount');
|
'transaction_journals.date', '<=', $end->format('Y-m-d')
|
||||||
|
)->sum('transactions.amount');
|
||||||
$sum = floatval($sum);
|
$sum = floatval($sum);
|
||||||
|
|
||||||
return $sum;
|
return $sum;
|
||||||
@ -441,12 +442,12 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
|
|
||||||
$accountID = $account->id;
|
$accountID = $account->id;
|
||||||
$query = $this->_user->transactionjournals()->with(['transactions', 'transactioncurrency', 'transactiontype'])->leftJoin(
|
$query = $this->_user->transactionjournals()->with(['transactions', 'transactioncurrency', 'transactiontype'])->leftJoin(
|
||||||
'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
||||||
)->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')->where('accounts.id', $accountID)->where(
|
)->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')->where('accounts.id', $accountID)->where(
|
||||||
'date', '>=', $start->format('Y-m-d')
|
'date', '>=', $start->format('Y-m-d')
|
||||||
)->where('date', '<=', $end->format('Y-m-d'))->orderBy('transaction_journals.date', 'DESC')->orderBy('transaction_journals.id', 'DESC')->take(
|
)->where('date', '<=', $end->format('Y-m-d'))->orderBy('transaction_journals.date', 'DESC')->orderBy('transaction_journals.id', 'DESC')->take(
|
||||||
$count
|
$count
|
||||||
)->get(['transaction_journals.*']);
|
)->get(['transaction_journals.*']);
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace FireflyIII\Shared\Toolkit;
|
namespace FireflyIII\Shared\Toolkit;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Firefly\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Date
|
* Class Date
|
||||||
@ -84,4 +84,44 @@ class Date
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
* @param $repeatFreq
|
||||||
|
*
|
||||||
|
* @return Carbon
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function startOfPeriod(Carbon $date, $repeatFreq)
|
||||||
|
{
|
||||||
|
switch ($repeatFreq) {
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot do startOfPeriod for $repeat_freq ' . $repeatFreq);
|
||||||
|
break;
|
||||||
|
case 'daily':
|
||||||
|
$date->startOfDay();
|
||||||
|
break;
|
||||||
|
case 'weekly':
|
||||||
|
$date->startOfWeek();
|
||||||
|
break;
|
||||||
|
case 'monthly':
|
||||||
|
$date->startOfMonth();
|
||||||
|
break;
|
||||||
|
case 'quarterly':
|
||||||
|
$date->firstOfQuarter();
|
||||||
|
break;
|
||||||
|
case 'half-year':
|
||||||
|
$month = intval($date->format('m'));
|
||||||
|
$date->startOfYear();
|
||||||
|
if ($month >= 7) {
|
||||||
|
$date->addMonths(6);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'yearly':
|
||||||
|
$date->startOfYear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
}
|
}
|
@ -91,6 +91,14 @@ class RecurringTransaction extends Ardent
|
|||||||
return $start;
|
return $start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function transactionjournals()
|
||||||
|
{
|
||||||
|
return $this->hasMany('TransactionJournal');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
|
@ -1,29 +1,31 @@
|
|||||||
@extends('layouts.default')
|
@extends('layouts.default')
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
|
||||||
<p class="lead">
|
|
||||||
Remember that deleting something is permanent.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{Form::open(['class' => 'form-horizontal','url' => route('recurring.destroy',$recurringTransaction->id)])}}
|
{{Form::open(['class' => 'form-horizontal','url' => route('recurring.destroy',$recurringTransaction->id)])}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-6 col-md-12 col-sm-12">
|
||||||
<p class="text-danger">
|
<div class="panel panel-red">
|
||||||
Press "Delete permanently" If you are sure you want to delete "{{{$recurringTransaction->name}}}".
|
<div class="panel-heading">
|
||||||
</p>
|
Delete recurring transaction "{{{$recurringTransaction->name}}}"
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<p>
|
||||||
|
Are you sure?
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<button type="submit" class="btn btn-default btn-danger">Delete permanently</button>
|
||||||
|
<a href="{{URL::previous()}}" class="btn-default btn">Cancel</a >
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<button type="submit" class="btn btn-default btn-danger">Delete permanently</button>
|
|
||||||
<a href="{{route('recurring.index')}}" class="btn-default btn">Cancel</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
@extends('layouts.default')
|
@extends('layouts.default')
|
||||||
@section('content')
|
@section('content')
|
||||||
{{Form::open(['class' => 'form-horizontal','url' => route('recurring.update', $recurringTransaction->id)])}}
|
{{Form::model($recurringTransaction, ['class' => 'form-horizontal','url' => route('recurring.update', $recurringTransaction->id)])}}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||||
@ -10,12 +10,12 @@
|
|||||||
<i class="fa fa-exclamation-circle"></i> Mandatory fields
|
<i class="fa fa-exclamation-circle"></i> Mandatory fields
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{{Form::ffText('name',$recurringTransaction->name)}}
|
{{Form::ffText('name')}}
|
||||||
{{Form::ffTags('match',join(',',explode(' ',$recurringTransaction->match)))}}
|
{{Form::ffTags('match')}}
|
||||||
{{Form::ffAmount('amount_min',$recurringTransaction->amount_min)}}
|
{{Form::ffAmount('amount_min')}}
|
||||||
{{Form::ffAmount('amount_max',$recurringTransaction->amount_max)}}
|
{{Form::ffAmount('amount_max')}}
|
||||||
{{Form::ffDate('date',$recurringTransaction->date->format('Y-m-d'))}}
|
{{Form::ffDate('date',$recurringTransaction->date->format('Y-m-d'))}}
|
||||||
{{Form::ffSelect('repeat_freq',$periods,$recurringTransaction->repeat_freq)}}
|
{{Form::ffSelect('repeat_freq',$periods)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -32,9 +32,9 @@
|
|||||||
<i class="fa fa-smile-o"></i> Optional fields
|
<i class="fa fa-smile-o"></i> Optional fields
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{{Form::ffInteger('skip',$recurringTransaction->skip)}}
|
{{Form::ffInteger('skip')}}
|
||||||
{{Form::ffCheckbox('automatch',1,$recurringTransaction->automatch)}}
|
{{Form::ffCheckbox('automatch',1)}}
|
||||||
{{Form::ffCheckbox('active',1,$recurringTransaction->active)}}
|
{{Form::ffCheckbox('active',1)}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
Matching on
|
Matching on
|
||||||
@foreach(explode(' ',$recurring->match) as $word)
|
@foreach(explode(',',$recurring->match) as $word)
|
||||||
<span class="label label-info">{{{$word}}}</span>
|
<span class="label label-info">{{{$word}}}</span>
|
||||||
@endforeach
|
@endforeach
|
||||||
between {{mf($recurring->amount_min)}} and {{mf($recurring->amount_max)}}.
|
between {{mf($recurring->amount_min)}} and {{mf($recurring->amount_max)}}.
|
||||||
@ -47,7 +47,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Next reminder</td>
|
<td>Next reminder</td>
|
||||||
<td>TODO TODO</td>
|
<td>some date <!-- TODO --></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -74,19 +74,8 @@
|
|||||||
Connected transaction journals
|
Connected transaction journals
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<table id="transactionTable" class="table table-striped table-bordered" >
|
<div id="transaction-table"></div>
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Description</th>
|
|
||||||
<th>Amount (€)</th>
|
|
||||||
<th>From</th>
|
|
||||||
<th>To</th>
|
|
||||||
<th>Budget / category</th>
|
|
||||||
<th>ID</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -95,14 +84,14 @@
|
|||||||
@stop
|
@stop
|
||||||
|
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var URL = '{{route('json.recurringjournals',$recurring->id)}}';
|
var recurringID = {{{$recurring->id}}};
|
||||||
</script>
|
</script>
|
||||||
{{HTML::script('assets/javascript/typeahead/bootstrap3-typeahead.min.js')}}
|
|
||||||
{{HTML::script('assets/javascript/datatables/jquery.dataTables.min.js')}}
|
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||||
{{HTML::script('assets/javascript/datatables/dataTables.bootstrap.js')}}
|
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||||
|
{{HTML::script('assets/javascript/firefly/gcharts.options.js')}}
|
||||||
|
{{HTML::script('assets/javascript/firefly/gcharts.js')}}
|
||||||
|
|
||||||
{{HTML::script('assets/javascript/firefly/recurring.js')}}
|
{{HTML::script('assets/javascript/firefly/recurring.js')}}
|
||||||
@stop
|
@stop
|
||||||
@section('styles')
|
|
||||||
{{HTML::style('assets/stylesheets/datatables/dataTables.bootstrap.css')}}
|
|
||||||
@stop
|
|
@ -8,14 +8,11 @@ $(function () {
|
|||||||
|
|
||||||
|
|
||||||
if (typeof(googleTable) == 'function') {
|
if (typeof(googleTable) == 'function') {
|
||||||
console.log('A');
|
|
||||||
if (typeof componentID != 'undefined' && typeof repetitionID == 'undefined') {
|
if (typeof componentID != 'undefined' && typeof repetitionID == 'undefined') {
|
||||||
console.log('B');
|
|
||||||
googleTable('table/component/' + componentID + '/0/transactions', 'transactions');
|
googleTable('table/component/' + componentID + '/0/transactions', 'transactions');
|
||||||
googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview');
|
googleColumnChart('chart/component/' + componentID + '/spending/' + year, 'componentOverview');
|
||||||
|
|
||||||
} else if (typeof componentID != 'undefined' && typeof repetitionID != 'undefined') {
|
} else if (typeof componentID != 'undefined' && typeof repetitionID != 'undefined') {
|
||||||
console.log('C');
|
|
||||||
googleTable('table/component/' + componentID + '/' + repetitionID + '/transactions', 'transactions');
|
googleTable('table/component/' + componentID + '/' + repetitionID + '/transactions', 'transactions');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,9 +200,7 @@ function googleSankeyChart(URL, container) {
|
|||||||
Format as money
|
Format as money
|
||||||
*/
|
*/
|
||||||
|
|
||||||
console.log(gdata.getNumberOfRows())
|
|
||||||
if (gdata.getNumberOfRows() < 1) {
|
if (gdata.getNumberOfRows() < 1) {
|
||||||
console.log('remove');
|
|
||||||
$('#' + container).parent().parent().remove();
|
$('#' + container).parent().parent().remove();
|
||||||
return;
|
return;
|
||||||
} else if (gdata.getNumberOfRows() < 6) {
|
} else if (gdata.getNumberOfRows() < 6) {
|
||||||
@ -261,7 +259,6 @@ function googleTable(URL, container) {
|
|||||||
|
|
||||||
for (var i = 0; i < x; i++) {
|
for (var i = 0; i < x; i++) {
|
||||||
var label = gdata.getColumnLabel(i);
|
var label = gdata.getColumnLabel(i);
|
||||||
console.log('Column ' + i + ':' + label);
|
|
||||||
/*
|
/*
|
||||||
Format a string using the previous column as URL.
|
Format a string using the previous column as URL.
|
||||||
*/
|
*/
|
||||||
@ -282,7 +279,7 @@ function googleTable(URL, container) {
|
|||||||
/*
|
/*
|
||||||
Format as money
|
Format as money
|
||||||
*/
|
*/
|
||||||
if (label == 'Amount' || label == 'Balance') {
|
if (label == 'Amount' || label == 'Balance' || label == 'Minimum amount' || label == 'Maximum amount') {
|
||||||
money.format(gdata, i);
|
money.format(gdata, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
if (typeof(googleTable) == 'function') {
|
if (typeof(googleTable) == 'function') {
|
||||||
googleTable('table/recurring','recurring-table');
|
googleTable('table/recurring', 'recurring-table');
|
||||||
}
|
}
|
||||||
|
if (typeof(googleTable) == 'function') {
|
||||||
|
googleTable('table/recurring/' + recurringID + '/transactions', 'transaction-table');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
Loading…
Reference in New Issue
Block a user