From a021c26b7ee7302d620621721d2c1da5c60d4a6a Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 29 Dec 2014 20:28:17 +0100 Subject: [PATCH] All code for issue #38. --- app/breadcrumbs.php | 30 +-- app/controllers/BillController.php | 205 ++++++++++++++++++ app/controllers/GoogleChartController.php | 16 +- app/controllers/RecurringController.php | 205 ------------------ .../2014_12_24_191544_changes_for_v322.php | 102 ++++++++- app/database/seeds/TestContentSeeder.php | 58 ++--- app/lib/FireflyIII/Chart/Chart.php | 12 +- app/lib/FireflyIII/Chart/ChartInterface.php | 2 +- .../Bill.php} | 64 +++--- .../Database/Bill/BillInterface.php | 41 ++++ .../RecurringTransactionInterface.php | 41 ---- .../TransactionJournal/TransactionJournal.php | 4 +- .../FireflyIII/Event/TransactionJournal.php | 14 +- .../{RecurringTransaction.php => Bill.php} | 14 +- app/models/TransactionJournal.php | 6 +- app/models/User.php | 4 +- app/routes.php | 30 +-- .../{recurring => bills}/create.blade.php | 6 +- .../{recurring => bills}/delete.blade.php | 6 +- app/views/{recurring => bills}/edit.blade.php | 10 +- .../{recurring => bills}/index.blade.php | 2 +- app/views/{recurring => bills}/show.blade.php | 28 +-- app/views/index.blade.php | 4 +- .../{recurring.blade.php => bills.blade.php} | 8 +- app/views/list/journals-full.blade.php | 10 +- app/views/partials/menu.blade.php | 10 +- app/views/reports/month.blade.php | 2 +- public/assets/javascript/firefly/bills.js | 7 + public/assets/javascript/firefly/index.js | 2 +- public/assets/javascript/firefly/recurring.js | 14 -- ...trollerCest.php => BillControllerCest.php} | 96 ++++---- .../functional/GoogleChartControllerCest.php | 18 +- 32 files changed, 573 insertions(+), 498 deletions(-) create mode 100644 app/controllers/BillController.php delete mode 100644 app/controllers/RecurringController.php rename app/lib/FireflyIII/Database/{RecurringTransaction/RecurringTransaction.php => Bill/Bill.php} (78%) create mode 100644 app/lib/FireflyIII/Database/Bill/BillInterface.php delete mode 100644 app/lib/FireflyIII/Database/RecurringTransaction/RecurringTransactionInterface.php rename app/models/{RecurringTransaction.php => Bill.php} (88%) rename app/views/{recurring => bills}/create.blade.php (91%) rename app/views/{recurring => bills}/delete.blade.php (84%) rename app/views/{recurring => bills}/edit.blade.php (80%) rename app/views/{recurring => bills}/index.blade.php (92%) rename app/views/{recurring => bills}/show.blade.php (75%) rename app/views/list/{recurring.blade.php => bills.blade.php} (80%) create mode 100644 public/assets/javascript/firefly/bills.js delete mode 100644 public/assets/javascript/firefly/recurring.js rename tests/functional/{RecurringControllerCest.php => BillControllerCest.php} (66%) diff --git a/app/breadcrumbs.php b/app/breadcrumbs.php index 1753d137c59..68d1e10a5fe 100644 --- a/app/breadcrumbs.php +++ b/app/breadcrumbs.php @@ -195,37 +195,37 @@ function (Generator $breadcrumbs) { } ); -// recurring transactions +// bills Breadcrumbs::register( - 'recurring.index', function (Generator $breadcrumbs) { + 'bills.index', function (Generator $breadcrumbs) { $breadcrumbs->parent('home'); - $breadcrumbs->push('Recurring transactions', route('recurring.index')); + $breadcrumbs->push('Bills', route('bills.index')); } ); Breadcrumbs::register( - 'recurring.create', function (Generator $breadcrumbs) { - $breadcrumbs->parent('recurring.index'); - $breadcrumbs->push('Create new recurring transaction', route('recurring.create')); + 'bills.create', function (Generator $breadcrumbs) { + $breadcrumbs->parent('bills.index'); + $breadcrumbs->push('Create new bill', route('bills.create')); } ); Breadcrumbs::register( - 'recurring.edit', function (Generator $breadcrumbs, RecurringTransaction $recurring) { - $breadcrumbs->parent('recurring.show', $recurring); - $breadcrumbs->push('Edit ' . $recurring->name, route('recurring.edit', $recurring->id)); + 'bills.edit', function (Generator $breadcrumbs, Bill $bill) { + $breadcrumbs->parent('bills.show', $bill); + $breadcrumbs->push('Edit ' . $bill->name, route('bills.edit', $bill->id)); } ); Breadcrumbs::register( - 'recurring.delete', function (Generator $breadcrumbs, RecurringTransaction $recurring) { - $breadcrumbs->parent('recurring.show', $recurring); - $breadcrumbs->push('Delete ' . $recurring->name, route('recurring.delete', $recurring->id)); + 'bills.delete', function (Generator $breadcrumbs, Bill $bill) { + $breadcrumbs->parent('bills.show', $bill); + $breadcrumbs->push('Delete ' . $bill->name, route('bills.delete', $bill->id)); } ); Breadcrumbs::register( - 'recurring.show', function (Generator $breadcrumbs, RecurringTransaction $recurring) { - $breadcrumbs->parent('recurring.index'); - $breadcrumbs->push($recurring->name, route('recurring.show', $recurring->id)); + 'bills.show', function (Generator $breadcrumbs, Bill $bill) { + $breadcrumbs->parent('bills.index'); + $breadcrumbs->push($bill->name, route('bills.show', $bill->id)); } ); diff --git a/app/controllers/BillController.php b/app/controllers/BillController.php new file mode 100644 index 00000000000..3ea9810eb90 --- /dev/null +++ b/app/controllers/BillController.php @@ -0,0 +1,205 @@ +_repository = $repository; + + View::share('title', 'Bills'); + View::share('mainTitleIcon', 'fa-rotate-right'); + } + + /** + * @return $this + */ + public function create() + { + $periods = \Config::get('firefly.periods_to_text'); + + return View::make('bills.create')->with('periods', $periods)->with('subTitle', 'Create new'); + } + + /** + * @param Bill $bill + * + * @return $this + */ + public function delete(Bill $bill) + { + return View::make('bills.delete')->with('bill', $bill)->with( + 'subTitle', 'Delete "' . $bill->name . '"' + ); + } + + /** + * @param Bill $bill + * + * @return \Illuminate\Http\RedirectResponse + */ + public function destroy(Bill $bill) + { + $this->_repository->destroy($bill); + Session::flash('success', 'The bill was deleted.'); + + return Redirect::route('bills.index'); + + } + + /** + * @param Bill $bill + * + * @return $this + */ + public function edit(Bill $bill) + { + $periods = \Config::get('firefly.periods_to_text'); + + return View::make('bills.edit')->with('periods', $periods)->with('bill', $bill)->with( + 'subTitle', 'Edit "' . $bill->name . '"' + ); + } + + /** + * @return $this + */ + public function index() + { + $bills = $this->_repository->get(); + + return View::make('bills.index', compact('bills')); + } + + /** + * @param Bill $bill + * + * @return mixed + */ + public function rescan(Bill $bill) + { + if (intval($bill->active) == 0) { + Session::flash('warning', 'Inactive bills cannot be scanned.'); + + return Redirect::intended('/'); + } + + $this->_repository->scanEverything($bill); + + Session::flash('success', 'Rescanned everything.'); + + return Redirect::intended('/'); + } + + /** + * @param Bill $bill + * + * @return mixed + */ + public function show(Bill $bill) + { + $journals = $bill->transactionjournals()->withRelevantData()->orderBy('date', 'DESC')->get(); + $hideBill = true; + + + return View::make('bills.show', compact('journals', 'hideBills'))->with('bill', $bill)->with( + 'subTitle', $bill->name + ); + } + + /** + * @return $this + * @throws FireflyException + */ + public function store() + { + $data = Input::all(); + $data['user_id'] = Auth::user()->id; + + + // always validate: + $messages = $this->_repository->validate($data); + + // flash messages: + Session::flash('warnings', $messages['warnings']); + Session::flash('successes', $messages['successes']); + Session::flash('errors', $messages['errors']); + if ($messages['errors']->count() > 0) { + Session::flash('error', 'Could not store bill: ' . $messages['errors']->first()); + } + + // return to create screen: + if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + return Redirect::route('bills.create')->withInput(); + } + + // store: + $this->_repository->store($data); + Session::flash('success', 'Bill "' . e($data['name']) . '" stored.'); + if ($data['post_submit_action'] == 'store') { + return Redirect::route('bills.index'); + } + + return Redirect::route('bills.create')->withInput(); + + } + + /** + * @param Bill $bill + * + * @return $this + * @throws FireflyException + */ + public function update(Bill $bill) + { + $data = Input::except('_token'); + $data['active'] = isset($data['active']) ? 1 : 0; + $data['automatch'] = isset($data['automatch']) ? 1 : 0; + $data['user_id'] = Auth::user()->id; + + // always validate: + $messages = $this->_repository->validate($data); + + // flash messages: + Session::flash('warnings', $messages['warnings']); + Session::flash('successes', $messages['successes']); + Session::flash('errors', $messages['errors']); + if ($messages['errors']->count() > 0) { + Session::flash('error', 'Could not update bill: ' . $messages['errors']->first()); + } + + // return to update screen: + if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + return Redirect::route('bills.edit', $bill->id)->withInput(); + } + + // update + $this->_repository->update($bill, $data); + Session::flash('success', 'Bill "' . e($data['name']) . '" updated.'); + + // go back to list + if ($data['post_submit_action'] == 'update') { + return Redirect::route('bills.index'); + } + + // go back to update screen. + return Redirect::route('bills.edit', $bill->id)->withInput(['post_submit_action' => 'return_to_edit']); + + } +} \ No newline at end of file diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php index fcb2c8884bf..58c3a9dfb78 100644 --- a/app/controllers/GoogleChartController.php +++ b/app/controllers/GoogleChartController.php @@ -334,11 +334,11 @@ public function piggyBankHistory(\PiggyBank $piggyBank) } /** - * @param RecurringTransaction $recurring + * @param Bill $bill * * @return \Illuminate\Http\JsonResponse */ - public function recurringOverview(RecurringTransaction $recurring) + public function billOverview(Bill $bill) { $this->_chart->addColumn('Date', 'date'); @@ -347,7 +347,7 @@ public function recurringOverview(RecurringTransaction $recurring) $this->_chart->addColumn('Current entry', 'number'); // get first transaction or today for start: - $first = $recurring->transactionjournals()->orderBy('date', 'ASC')->first(); + $first = $bill->transactionjournals()->orderBy('date', 'ASC')->first(); if ($first) { $start = $first->date; } else { @@ -355,15 +355,15 @@ public function recurringOverview(RecurringTransaction $recurring) } $end = new Carbon; while ($start <= $end) { - $result = $recurring->transactionjournals()->before($end)->after($start)->first(); + $result = $bill->transactionjournals()->before($end)->after($start)->first(); if ($result) { $amount = $result->getAmount(); } else { $amount = 0; } unset($result); - $this->_chart->addRow(clone $start, $recurring->amount_max, $recurring->amount_min, $amount); - $start = DateKit::addPeriod($start, $recurring->repeat_freq, 0); + $this->_chart->addRow(clone $start, $bill->amount_max, $bill->amount_min, $amount); + $start = DateKit::addPeriod($start, $bill->repeat_freq, 0); } $this->_chart->generate(); @@ -378,14 +378,14 @@ public function recurringOverview(RecurringTransaction $recurring) * @return \Illuminate\Http\JsonResponse * @throws \FireflyIII\Exception\FireflyException */ - public function recurringTransactionsOverview() + public function billsOverview() { $paid = ['items' => [], 'amount' => 0]; $unpaid = ['items' => [], 'amount' => 0]; $this->_chart->addColumn('Name', 'string'); $this->_chart->addColumn('Amount', 'number'); - $set = $this->_repository->getRecurringSummary($this->_start, $this->_end); + $set = $this->_repository->getBillsSummary($this->_start, $this->_end); foreach ($set as $entry) { if (intval($entry->journalId) == 0) { diff --git a/app/controllers/RecurringController.php b/app/controllers/RecurringController.php deleted file mode 100644 index 4b7f094dd70..00000000000 --- a/app/controllers/RecurringController.php +++ /dev/null @@ -1,205 +0,0 @@ -_repository = $repository; - - View::share('title', 'Recurring transactions'); - View::share('mainTitleIcon', 'fa-rotate-right'); - } - - /** - * @return $this - */ - public function create() - { - $periods = \Config::get('firefly.periods_to_text'); - - return View::make('recurring.create')->with('periods', $periods)->with('subTitle', 'Create new'); - } - - /** - * @param RecurringTransaction $recurringTransaction - * - * @return $this - */ - public function delete(RecurringTransaction $recurringTransaction) - { - return View::make('recurring.delete')->with('recurringTransaction', $recurringTransaction)->with( - 'subTitle', 'Delete "' . $recurringTransaction->name . '"' - ); - } - - /** - * @param RecurringTransaction $recurringTransaction - * - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(RecurringTransaction $recurringTransaction) - { - $this->_repository->destroy($recurringTransaction); - Session::flash('success', 'The recurring transaction was deleted.'); - - return Redirect::route('recurring.index'); - - } - - /** - * @param RecurringTransaction $recurringTransaction - * - * @return $this - */ - public function edit(RecurringTransaction $recurringTransaction) - { - $periods = \Config::get('firefly.periods_to_text'); - - return View::make('recurring.edit')->with('periods', $periods)->with('recurringTransaction', $recurringTransaction)->with( - 'subTitle', 'Edit "' . $recurringTransaction->name . '"' - ); - } - - /** - * @return $this - */ - public function index() - { - $recurring = $this->_repository->get(); - - return View::make('recurring.index', compact('recurring')); - } - - /** - * @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::intended('/'); - } - - $this->_repository->scanEverything($recurringTransaction); - - Session::flash('success', 'Rescanned everything.'); - - return Redirect::intended('/'); - } - - /** - * @param RecurringTransaction $recurringTransaction - * - * @return mixed - */ - public function show(RecurringTransaction $recurringTransaction) - { - $journals = $recurringTransaction->transactionjournals()->withRelevantData()->orderBy('date', 'DESC')->get(); - $hideRecurring = true; - - - return View::make('recurring.show', compact('journals', 'hideRecurring'))->with('recurring', $recurringTransaction)->with( - 'subTitle', $recurringTransaction->name - ); - } - - /** - * @return $this - * @throws FireflyException - */ - public function store() - { - $data = Input::all(); - $data['user_id'] = Auth::user()->id; - - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store recurring transaction: ' . $messages['errors']->first()); - } - - // return to create screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { - return Redirect::route('recurring.create')->withInput(); - } - - // store: - $this->_repository->store($data); - Session::flash('success', 'Recurring transaction "' . e($data['name']) . '" stored.'); - if ($data['post_submit_action'] == 'store') { - return Redirect::route('recurring.index'); - } - - return Redirect::route('recurring.create')->withInput(); - - } - - /** - * @param RecurringTransaction $recurringTransaction - * - * @return $this - * @throws FireflyException - */ - public function update(RecurringTransaction $recurringTransaction) - { - $data = Input::except('_token'); - $data['active'] = isset($data['active']) ? 1 : 0; - $data['automatch'] = isset($data['automatch']) ? 1 : 0; - $data['user_id'] = Auth::user()->id; - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update recurring transaction: ' . $messages['errors']->first()); - } - - // return to update screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { - return Redirect::route('recurring.edit', $recurringTransaction->id)->withInput(); - } - - // update - $this->_repository->update($recurringTransaction, $data); - Session::flash('success', 'Recurring transaction "' . e($data['name']) . '" updated.'); - - // go back to list - if ($data['post_submit_action'] == 'update') { - return Redirect::route('recurring.index'); - } - - // go back to update screen. - return Redirect::route('recurring.edit', $recurringTransaction->id)->withInput(['post_submit_action' => 'return_to_edit']); - - } -} \ No newline at end of file diff --git a/app/database/migrations/2014_12_24_191544_changes_for_v322.php b/app/database/migrations/2014_12_24_191544_changes_for_v322.php index 5c377f7ec31..54aa3288395 100644 --- a/app/database/migrations/2014_12_24_191544_changes_for_v322.php +++ b/app/database/migrations/2014_12_24_191544_changes_for_v322.php @@ -1,7 +1,6 @@ dropSoftDeletes(); } ); + + // drop keys from bills (foreign bills_uid_for and unique uid_name_unique) + Schema::table( + 'bills', function (Blueprint $table) { + $table->dropForeign('bills_uid_for'); + $table->dropUnique('uid_name_unique'); + } + ); + // drop foreign key from transaction_journals (bill_id_foreign) + Schema::table( + 'transaction_journals', function (Blueprint $table) { + $table->dropForeign('bill_id_foreign'); + + } + ); + + // drop foreign key from budget_limits: + Schema::table( + 'budget_limits', function (Blueprint $table) { + $table->dropForeign('bid_foreign'); + $table->dropUnique('unique_bl_combi'); + } + ); + + // rename bills to recurring_transactions + Schema::rename('bills', 'recurring_transactions'); + // recreate foreign key recurring_transactions_user_id_foreign in recurring_transactions + // recreate unique recurring_transactions_user_id_name_unique in recurring_transactions + Schema::table( + 'recurring_transactions', function (Blueprint $table) { + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $table->unique(['user_id', 'name']); + } + ); + + // rename bill_id to recurring_transaction_id + // recreate foreign transaction_journals_recurring_transaction_id_foreign in transaction_journals + Schema::table( + 'transaction_journals', function (Blueprint $table) { + $table->renameColumn('bill_id', 'recurring_transaction_id'); + $table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('set null'); + } + ); + + } @@ -55,13 +99,13 @@ public function up() Schema::table( 'budget_limits', function (Blueprint $table) { -// try { - //$table->dropUnique('limits_component_id_startdate_repeat_freq_unique'); -// } catch (QueryException $e) { - //$table->dropUnique('unique_ci_combi'); -// } catch (PDOException $e) { -// $table->dropUnique('unique_ci_combi'); -// } + // try { + //$table->dropUnique('limits_component_id_startdate_repeat_freq_unique'); + // } catch (QueryException $e) { + //$table->dropUnique('unique_ci_combi'); + // } catch (PDOException $e) { + // $table->dropUnique('unique_ci_combi'); + // } } ); @@ -91,6 +135,48 @@ public function up() $table->softDeletes(); } ); + + // rename everything related to recurring transactions, aka bills: + Schema::table( + 'transaction_journals', function (Blueprint $table) { + + + // drop relation + $table->dropForeign('transaction_journals_recurring_transaction_id_foreign'); + // rename column + $table->renameColumn('recurring_transaction_id', 'bill_id'); + + } + ); + + Schema::table( + 'recurring_transactions', function (Blueprint $table) { + $table->dropForeign('recurring_transactions_user_id_foreign'); + $table->dropUnique('recurring_transactions_user_id_name_unique'); + } + ); + // rename table: + Schema::rename('recurring_transactions', 'bills'); + + // recreate foreign relation: + Schema::table( + 'transaction_journals', function (Blueprint $table) { + $table->foreign('bill_id', 'bill_id_foreign')->references('id')->on('bills')->onDelete('set null'); + } + ); + + // recreate more foreign relations. + Schema::table( + 'bills', function (Blueprint $table) { + // connect user id to users + $table->foreign('user_id', 'bills_uid_for')->references('id')->on('users')->onDelete('cascade'); + + // for a user, the name must be unique + $table->unique(['user_id', 'name'], 'uid_name_unique'); + } + ); + + } } diff --git a/app/database/seeds/TestContentSeeder.php b/app/database/seeds/TestContentSeeder.php index 93e5fee98e7..1d43dc075d9 100644 --- a/app/database/seeds/TestContentSeeder.php +++ b/app/database/seeds/TestContentSeeder.php @@ -36,19 +36,19 @@ public function run() $deleteBudget = Budget::create(['user_id' => $user->id, 'name' => 'Delete me']); // some limits: - $startDate = Carbon::now()->startOfMonth(); - $endDate = Carbon::now()->endOfMonth(); + $startDate = Carbon::now()->startOfMonth(); + $endDate = Carbon::now()->endOfMonth(); $secondStart = Carbon::now()->subMonth()->startOfMonth(); - $secondEnd = Carbon::now()->subMonth()->endOfMonth(); - $limitOne = BudgetLimit::create( + $secondEnd = Carbon::now()->subMonth()->endOfMonth(); + $limitOne = BudgetLimit::create( ['startdate' => $startDate->format('Y-m-d'), 'amount' => 201, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $groceriesBudget->id] ); - $limitTwo = BudgetLimit::create( + $limitTwo = BudgetLimit::create( ['startdate' => $secondStart->format('Y-m-d'), 'amount' => 202, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $billsBudget->id] ); - $limitThree = BudgetLimit::create( + $limitThree = BudgetLimit::create( ['startdate' => '2014-01-01', 'amount' => 203, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $deleteBudget->id] ); @@ -58,7 +58,8 @@ public function run() ['budget_limit_id' => $limitOne->id, 'startdate' => $startDate->format('Y-m-d'), 'enddate' => $endDate->format('Y-m-d'), 'amount' => 201] ); $repTwo = LimitRepetition::create( - ['budget_limit_id' => $limitTwo->id, 'startdate' => $secondStart->format('Y-m-d'), 'enddate' => $secondEnd->format('Y-m-d'), 'amount' => 202] + ['budget_limit_id' => $limitTwo->id, 'startdate' => $secondStart->format('Y-m-d'), 'enddate' => $secondEnd->format('Y-m-d'), + 'amount' => 202] ); $repThree = LimitRepetition::create( ['budget_limit_id' => $limitThree->id, 'startdate' => '2014-01-01', 'enddate' => '2014-01-31', 'amount' => 203] @@ -79,7 +80,7 @@ public function run() Component::create(['user_id' => $user->id, 'name' => 'Some Component 7', 'class' => 'Category']); // piggy bank - $piggy = PiggyBank::create( + $piggy = PiggyBank::create( [ 'account_id' => $savings->id, 'name' => 'New camera', @@ -99,7 +100,7 @@ public function run() PiggyBankEvent::create(['piggy_bank_id' => 1, 'date' => $startDate->format('Y-m-d'), 'amount' => 100]); PiggyBankRepetition::create( [ - 'piggy_bank_id' => $piggy->id, + 'piggy_bank_id' => $piggy->id, 'startdate' => Carbon::now()->format('Y-m-d'), 'targetdate' => null, 'currentamount' => 0 @@ -107,7 +108,7 @@ public function run() ); // piggy bank - $piggyTargeted = PiggyBank::create( + $piggyTargeted = PiggyBank::create( [ 'account_id' => $savings->id, 'name' => 'New clothes', @@ -128,15 +129,15 @@ public function run() PiggyBankEvent::create(['piggy_bank_id' => $piggyTargeted->id, 'date' => $startDate->format('Y-m-d'), 'amount' => 100]); PiggyBankRepetition::create( [ - 'piggy_bank_id' => $piggyTargeted->id, + 'piggy_bank_id' => $piggyTargeted->id, 'startdate' => Carbon::now()->format('Y-m-d'), 'targetdate' => Carbon::now()->addMonths(4)->format('Y-m-d'), 'currentamount' => 0 ] ); - // recurring transaction - $recurring = \RecurringTransaction::create( + // bill + $firstBill = \Bill::create( [ 'user_id' => $user->id, 'name' => 'Huur', @@ -151,8 +152,8 @@ public function run() ] ); - // recurring transaction - $secondRecurring = \RecurringTransaction::create( + // bill + $secondBill = \Bill::create( [ 'user_id' => $user->id, 'name' => 'Gas licht', @@ -198,7 +199,7 @@ public function run() while ($start <= $end) { $this->createTransaction( $checking, $portaal, 500, $withdrawal, 'Huur Portaal for ' . $start->format('F Y'), $start->format('Y-m-') . '01', $billsBudget, $house, - $recurring + $firstBill ); $this->createTransaction( $checking, $vitens, 12, $withdrawal, 'Water for ' . $start->format('F Y'), $start->format('Y-m-') . '02', $billsBudget, $house @@ -261,28 +262,27 @@ public function run() * * @param Budget $budget * @param Category $category - * @param RecurringTransaction $recurring + * @param Bill $bill * * @return TransactionJournal */ public function createTransaction( - Account $from, Account $to, $amount, TransactionType $type, $description, $date, Budget $budget = null, Category $category = null, - $recurring = null + Account $from, Account $to, $amount, TransactionType $type, $description, $date, Budget $budget = null, Category $category = null, Bill $bill = null ) { - $user = User::whereEmail('thegrumpydictator@gmail.com')->first(); - $euro = TransactionCurrency::whereCode('EUR')->first(); - $recurringID = is_null($recurring) ? null : $recurring->id; + $user = User::whereEmail('thegrumpydictator@gmail.com')->first(); + $euro = TransactionCurrency::whereCode('EUR')->first(); + $billID = is_null($bill) ? null : $bill->id; /** @var TransactionJournal $journal */ $journal = TransactionJournal::create( [ - 'user_id' => $user->id, - 'transaction_type_id' => $type->id, - 'transaction_currency_id' => $euro->id, - 'recurring_transaction_id' => $recurringID, - 'description' => $description, - 'completed' => 1, - 'date' => $date + 'user_id' => $user->id, + 'transaction_type_id' => $type->id, + 'transaction_currency_id' => $euro->id, + 'bill_id' => $billID, + 'description' => $description, + 'completed' => 1, + 'date' => $date ] ); diff --git a/app/lib/FireflyIII/Chart/Chart.php b/app/lib/FireflyIII/Chart/Chart.php index 302a014c5b4..c390105efb5 100644 --- a/app/lib/FireflyIII/Chart/Chart.php +++ b/app/lib/FireflyIII/Chart/Chart.php @@ -48,12 +48,12 @@ function (JoinClause $join) { * * @return Collection */ - public function getRecurringSummary(Carbon $start, Carbon $end) + public function getBillsSummary(Carbon $start, Carbon $end) { - return \RecurringTransaction:: + return \Bill:: leftJoin( 'transaction_journals', function (JoinClause $join) use ($start, $end) { - $join->on('recurring_transactions.id', '=', 'transaction_journals.recurring_transaction_id') + $join->on('bills.id', '=', 'transaction_journals.bill_id') ->where('transaction_journals.date', '>=', $start->format('Y-m-d')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d')); } @@ -64,11 +64,11 @@ public function getRecurringSummary(Carbon $start, Carbon $end) } ) ->where('active', 1) - ->groupBy('recurring_transactions.id') + ->groupBy('bills.id') ->get( - ['recurring_transactions.id', 'recurring_transactions.name', 'transaction_journals.description', + ['bills.id', 'bills.name', 'transaction_journals.description', 'transaction_journals.id as journalId', - \DB::Raw('SUM(`recurring_transactions`.`amount_min` + `recurring_transactions`.`amount_max`) / 2 as `averageAmount`'), + \DB::Raw('SUM(`bills`.`amount_min` + `bills`.`amount_max`) / 2 as `averageAmount`'), 'transactions.amount AS actualAmount'] ); } diff --git a/app/lib/FireflyIII/Chart/ChartInterface.php b/app/lib/FireflyIII/Chart/ChartInterface.php index 7b29e3c9e94..5617cf83376 100644 --- a/app/lib/FireflyIII/Chart/ChartInterface.php +++ b/app/lib/FireflyIII/Chart/ChartInterface.php @@ -26,6 +26,6 @@ public function getCategorySummary(Carbon $start, Carbon $end); * * @return Collection */ - public function getRecurringSummary(Carbon $start, Carbon $end); + public function getBillsSummary(Carbon $start, Carbon $end); } \ No newline at end of file diff --git a/app/lib/FireflyIII/Database/RecurringTransaction/RecurringTransaction.php b/app/lib/FireflyIII/Database/Bill/Bill.php similarity index 78% rename from app/lib/FireflyIII/Database/RecurringTransaction/RecurringTransaction.php rename to app/lib/FireflyIII/Database/Bill/Bill.php index 1a4b4240432..bee52562147 100644 --- a/app/lib/FireflyIII/Database/RecurringTransaction/RecurringTransaction.php +++ b/app/lib/FireflyIII/Database/Bill/Bill.php @@ -1,6 +1,6 @@ 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']); + $bill = new \Bill; + $bill->user()->associate($this->getUser()); + $bill->name = $data['name']; + $bill->match = $data['match']; + $bill->amount_max = floatval($data['amount_max']); + $bill->amount_min = floatval($data['amount_min']); $date = new Carbon($data['date']); - $recurring->active = intval($data['active']); - $recurring->automatch = intval($data['automatch']); - $recurring->repeat_freq = $data['repeat_freq']; + $bill->active = intval($data['active']); + $bill->automatch = intval($data['automatch']); + $bill->repeat_freq = $data['repeat_freq']; /* * Jump to the start of the period. */ $date = \DateKit::startOfPeriod($date, $data['repeat_freq']); - $recurring->date = $date; - $recurring->skip = intval($data['skip']); + $bill->date = $date; + $bill->skip = intval($data['skip']); - $recurring->save(); + $bill->save(); - return $recurring; + return $bill; } /** @@ -118,7 +118,7 @@ public function validate(array $model) $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.'); } - $object = new \RecurringTransaction($model); + $object = new \Bill($model); $object->isValid(); $errors->merge($object->getErrors()); @@ -167,7 +167,7 @@ public function findByWhat($what) */ public function get() { - return $this->getUser()->recurringtransactions()->get(); + return $this->getUser()->bills()->get(); } /** @@ -189,35 +189,35 @@ public function getByIds(array $ids) */ public function getActive() { - return $this->getUser()->recurringtransactions()->where('active', 1)->get(); + return $this->getUser()->bills()->where('active', 1)->get(); } /** - * @param \RecurringTransaction $recurring + * @param \Bill $bill * @param Carbon $start * @param Carbon $end * * @return \TransactionJournal|null */ - public function getJournalForRecurringInRange(\RecurringTransaction $recurring, Carbon $start, Carbon $end) + public function getJournalForBillInRange(\Bill $bill, Carbon $start, Carbon $end) { - return $this->getUser()->transactionjournals()->where('recurring_transaction_id', $recurring->id)->after($start)->before($end)->first(); + return $this->getUser()->transactionjournals()->where('bill_id', $bill->id)->after($start)->before($end)->first(); } /** - * @param \RecurringTransaction $recurring + * @param \Bill $bill * @param \TransactionJournal $journal * * @return bool */ - public function scan(\RecurringTransaction $recurring, \TransactionJournal $journal) + public function scan(\Bill $bill, \TransactionJournal $journal) { /* * Match words. */ $wordMatch = false; - $matches = explode(',', $recurring->match); + $matches = explode(',', $bill->match); $description = strtolower($journal->description); /* @@ -261,8 +261,8 @@ public function scan(\RecurringTransaction $recurring, \TransactionJournal $jour if (count($transactions) > 1) { $amount = max(floatval($transactions[0]->amount), floatval($transactions[1]->amount)); - $min = floatval($recurring->amount_min); - $max = floatval($recurring->amount_max); + $min = floatval($bill->amount_min); + $max = floatval($bill->amount_max); if ($amount >= $min && $amount <= $max) { $amountMatch = true; \Log::debug('Amount match is true!'); @@ -273,17 +273,17 @@ public function scan(\RecurringTransaction $recurring, \TransactionJournal $jour * If both, update! */ if ($wordMatch && $amountMatch) { - $journal->recurringTransaction()->associate($recurring); + $journal->bill()->associate($bill); $journal->save(); } } /** - * @param \RecurringTransaction $recurring + * @param \Bill $bill * * @return bool */ - public function scanEverything(\RecurringTransaction $recurring) + public function scanEverything(\Bill $bill) { // get all journals that (may) be relevant. // this is usually almost all of them. @@ -291,7 +291,7 @@ public function scanEverything(\RecurringTransaction $recurring) /** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $journalRepository */ $journalRepository = \App::make('FireflyIII\Database\TransactionJournal\TransactionJournal'); - $set = \DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $recurring->amount_min)->where('amount', '<=', $recurring->amount_max) + $set = \DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max) ->get(['transaction_journal_id']); $ids = []; @@ -303,7 +303,7 @@ public function scanEverything(\RecurringTransaction $recurring) $journals = $journalRepository->getByIds($ids); /** @var \TransactionJournal $journal */ foreach ($journals as $journal) { - $this->scan($recurring, $journal); + $this->scan($bill, $journal); } } diff --git a/app/lib/FireflyIII/Database/Bill/BillInterface.php b/app/lib/FireflyIII/Database/Bill/BillInterface.php new file mode 100644 index 00000000000..7be8a55b73f --- /dev/null +++ b/app/lib/FireflyIII/Database/Bill/BillInterface.php @@ -0,0 +1,41 @@ +add('description', 'Internal error: need to know type of transaction!'); } - if (isset($model['recurring_transaction_id']) && intval($model['recurring_transaction_id']) < 0) { - $errors->add('recurring_transaction_id', 'Recurring transaction is invalid.'); + if (isset($model['bill_id']) && intval($model['bill_id']) < 0) { + $errors->add('bill_id', 'Bill is invalid.'); } if (!isset($model['description'])) { $errors->add('description', 'This field is mandatory.'); diff --git a/app/lib/FireflyIII/Event/TransactionJournal.php b/app/lib/FireflyIII/Event/TransactionJournal.php index ed62684c96b..ebb5e344f06 100644 --- a/app/lib/FireflyIII/Event/TransactionJournal.php +++ b/app/lib/FireflyIII/Event/TransactionJournal.php @@ -17,12 +17,12 @@ class TransactionJournal */ public function store(\TransactionJournal $journal) { - /** @var \FireflyIII\Database\RecurringTransaction\RecurringTransaction $repository */ - $repository = \App::make('FireflyIII\Database\RecurringTransaction\RecurringTransaction'); + /** @var \FireflyIII\Database\Bill\Bill $repository */ + $repository = \App::make('FireflyIII\Database\Bill\Bill'); $set = $repository->get(); - /** @var \RecurringTransaction $entry */ + /** @var \Bill $entry */ foreach ($set as $entry) { $repository->scan($entry, $journal); } @@ -43,13 +43,13 @@ public function subscribe(Dispatcher $events) */ public function update(\TransactionJournal $journal) { - /** @var \FireflyIII\Database\RecurringTransaction\RecurringTransaction $repository */ - $repository = \App::make('FireflyIII\Database\RecurringTransaction\RecurringTransaction'); + /** @var \FireflyIII\Database\Bill\Bill $repository */ + $repository = \App::make('FireflyIII\Database\Bill\Bill'); $set = $repository->get(); - $journal->recurring_transaction_id = null; + $journal->bill_id = null; $journal->save(); - /** @var \RecurringTransaction $entry */ + /** @var \Bill $entry */ foreach ($set as $entry) { $repository->scan($entry, $journal); } diff --git a/app/models/RecurringTransaction.php b/app/models/Bill.php similarity index 88% rename from app/models/RecurringTransaction.php rename to app/models/Bill.php index f939cff382b..a7f0da04a23 100644 --- a/app/models/RecurringTransaction.php +++ b/app/models/Bill.php @@ -3,9 +3,9 @@ use Watson\Validating\ValidatingTrait; use \Illuminate\Database\Eloquent\Model as Eloquent; /** - * Class RecurringTransaction + * Class Bill */ -class RecurringTransaction extends Eloquent +class Bill extends Eloquent { use ValidatingTrait; @@ -57,8 +57,7 @@ public function transactionjournals() /** * TODO remove this method in favour of something in the FireflyIII libraries. * - * Find the next expected match based on the set journals and the date stuff from the recurring - * transaction. + * Find the next expected match based on the set journals and the date stuff from the bill. */ public function nextExpectedMatch() { @@ -78,18 +77,15 @@ public function nextExpectedMatch() $today = DateKit::addPeriod(new Carbon, $this->repeat_freq, 0); /* - * FF3 loops from the $start of the recurring transaction, and to make sure + * FF3 loops from the $start of the bill, and to make sure * $skip works, it adds one (for modulo). */ $skip = $this->skip + 1; $start = DateKit::startOfPeriod(new Carbon, $this->repeat_freq); /* * go back exactly one month/week/etc because FF3 does not care about 'next' - * recurring transactions if they're too far into the past. + * bills if they're too far into the past. */ - // echo 'Repeat freq is: ' . $recurringTransaction->repeat_freq . '
'; - - // echo 'Start: ' . $start . '
'; $counter = 0; while ($start <= $today) { diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php index ee9cd336c76..6bfde9564fb 100644 --- a/app/models/TransactionJournal.php +++ b/app/models/TransactionJournal.php @@ -85,9 +85,9 @@ public function piggyBankEvents() /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function recurringTransaction() + public function bill() { - return $this->belongsTo('RecurringTransaction'); + return $this->belongsTo('Bill'); } /** @@ -202,7 +202,7 @@ public function scopeWithRelevantData(Builder $query) $query->with( ['transactions' => function ($q) { $q->orderBy('amount', 'ASC'); - }, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'recurringTransaction', 'budgets', 'categories'] + }, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories'] ); } diff --git a/app/models/User.php b/app/models/User.php index 938f353bde4..f41750cda7f 100644 --- a/app/models/User.php +++ b/app/models/User.php @@ -69,9 +69,9 @@ public function preferences() /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ - public function recurringtransactions() + public function bills() { - return $this->hasMany('RecurringTransaction'); + return $this->hasMany('Bill'); } /** diff --git a/app/routes.php b/app/routes.php index a519bfa7cbe..d68c3197384 100644 --- a/app/routes.php +++ b/app/routes.php @@ -34,9 +34,9 @@ function ($value, $route) { Route::bind( - 'recurring', function ($value, $route) { + 'bill', function ($value, $route) { if (Auth::check()) { - return RecurringTransaction:: + return Bill:: where('id', $value)->where('user_id', Auth::user()->id)->first(); } @@ -192,11 +192,11 @@ function ($value, $route) { Route::get('/chart/home/account', ['uses' => 'GoogleChartController@allAccountsBalanceChart']); Route::get('/chart/home/budgets', ['uses' => 'GoogleChartController@allBudgetsHomeChart']); Route::get('/chart/home/categories', ['uses' => 'GoogleChartController@allCategoriesHomeChart']); - Route::get('/chart/home/recurring', ['uses' => 'GoogleChartController@recurringTransactionsOverview']); + Route::get('/chart/home/bills', ['uses' => 'GoogleChartController@billsOverview']); Route::get('/chart/account/{account}/{view?}', ['uses' => 'GoogleChartController@accountBalanceChart']); Route::get('/chart/reports/income-expenses/{year}', ['uses' => 'GoogleChartController@yearInExp']); Route::get('/chart/reports/income-expenses-sum/{year}', ['uses' => 'GoogleChartController@yearInExpSum']); - Route::get('/chart/recurring/{recurring}', ['uses' => 'GoogleChartController@recurringOverview']); + Route::get('/chart/bills/{bill}', ['uses' => 'GoogleChartController@billOverview']); Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'GoogleChartController@budgetLimitSpending']); Route::get('/chart/piggy_history/{piggy_bank}', ['uses' => 'GoogleChartController@piggyBankHistory']); @@ -234,13 +234,13 @@ function ($value, $route) { Route::get('/profile', ['uses' => 'ProfileController@index', 'as' => 'profile']); Route::get('/profile/change-password', ['uses' => 'ProfileController@changePassword', 'as' => 'change-password']); - // recurring transactions controller - Route::get('/recurring', ['uses' => 'RecurringController@index', 'as' => 'recurring.index']); - Route::get('/recurring/rescan/{recurring}', ['uses' => 'RecurringController@rescan', 'as' => 'recurring.rescan']); # rescan for matching. - 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']); - Route::get('/recurring/show/{recurring}', ['uses' => 'RecurringController@show', 'as' => 'recurring.show']); + // bills controller + Route::get('/bills', ['uses' => 'BillController@index', 'as' => 'bills.index']); + Route::get('/bills/rescan/{bill}', ['uses' => 'BillController@rescan', 'as' => 'bills.rescan']); # rescan for matching. + Route::get('/bills/create', ['uses' => 'BillController@create', 'as' => 'bills.create']); + Route::get('/bills/edit/{bill}', ['uses' => 'BillController@edit', 'as' => 'bills.edit']); + Route::get('/bills/delete/{bill}', ['uses' => 'BillController@delete', 'as' => 'bills.delete']); + Route::get('/bills/show/{bill}', ['uses' => 'BillController@show', 'as' => 'bills.show']); // repeated expenses controller: Route::get('/repeatedexpenses', ['uses' => 'RepeatedExpenseController@index', 'as' => 'repeated.index']); @@ -328,10 +328,10 @@ function ($value, $route) { // profile controller Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword']); - // recurring controller - Route::post('/recurring/store', ['uses' => 'RecurringController@store', 'as' => 'recurring.store']); - Route::post('/recurring/update/{recurring}', ['uses' => 'RecurringController@update', 'as' => 'recurring.update']); - Route::post('/recurring/destroy/{recurring}', ['uses' => 'RecurringController@destroy', 'as' => 'recurring.destroy']); + // bills controller + Route::post('/bills/store', ['uses' => 'BillController@store', 'as' => 'bills.store']); + Route::post('/bills/update/{bill}', ['uses' => 'BillController@update', 'as' => 'bills.update']); + Route::post('/bills/destroy/{bill}', ['uses' => 'BillController@destroy', 'as' => 'bills.destroy']); // transaction controller: Route::post('/transactions/store/{what}', ['uses' => 'TransactionController@store', 'as' => 'transactions.store'])->where( diff --git a/app/views/recurring/create.blade.php b/app/views/bills/create.blade.php similarity index 91% rename from app/views/recurring/create.blade.php rename to app/views/bills/create.blade.php index a14eaf114dd..823716451d8 100644 --- a/app/views/recurring/create.blade.php +++ b/app/views/bills/create.blade.php @@ -1,7 +1,7 @@ @extends('layouts.default') @section('content') {{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) }} -{{Form::open(['class' => 'form-horizontal','id' => 'store','url' => route('recurring.store')])}} +{{Form::open(['class' => 'form-horizontal','id' => 'store','url' => route('bills.store')])}}
@@ -21,7 +21,7 @@

@@ -44,7 +44,7 @@ Options
- {{Form::ffOptionsList('create','recurring transaction')}} + {{Form::ffOptionsList('create','bill')}}
diff --git a/app/views/recurring/delete.blade.php b/app/views/bills/delete.blade.php similarity index 84% rename from app/views/recurring/delete.blade.php rename to app/views/bills/delete.blade.php index 261d505d12c..ad312dd11b5 100644 --- a/app/views/recurring/delete.blade.php +++ b/app/views/bills/delete.blade.php @@ -1,12 +1,12 @@ @extends('layouts.default') @section('content') -{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $recurringTransaction) }} -{{Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('recurring.destroy',$recurringTransaction->id)])}} +{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $bill) }} +{{Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('bills.destroy',$bill->id)])}}
- Delete recurring transaction "{{{$recurringTransaction->name}}}" + Delete bill "{{{$bill->name}}}"

diff --git a/app/views/recurring/edit.blade.php b/app/views/bills/edit.blade.php similarity index 80% rename from app/views/recurring/edit.blade.php rename to app/views/bills/edit.blade.php index 5824b10655f..9e55131576d 100644 --- a/app/views/recurring/edit.blade.php +++ b/app/views/bills/edit.blade.php @@ -1,7 +1,7 @@ @extends('layouts.default') @section('content') -{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $recurringTransaction) }} -{{Form::model($recurringTransaction, ['class' => 'form-horizontal','id' => 'update','url' => route('recurring.update', $recurringTransaction->id)])}} +{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $bill) }} +{{Form::model($bill, ['class' => 'form-horizontal','id' => 'update','url' => route('bills.update', $bill->id)])}}

@@ -15,14 +15,14 @@ {{Form::ffTags('match')}} {{Form::ffAmount('amount_min')}} {{Form::ffAmount('amount_max')}} - {{Form::ffDate('date',$recurringTransaction->date->format('Y-m-d'))}} + {{Form::ffDate('date',$bill->date->format('Y-m-d'))}} {{Form::ffSelect('repeat_freq',$periods)}}

@@ -44,7 +44,7 @@ Options
- {{Form::ffOptionsList('update','recurring transaction')}} + {{Form::ffOptionsList('update','bill')}}
diff --git a/app/views/recurring/index.blade.php b/app/views/bills/index.blade.php similarity index 92% rename from app/views/recurring/index.blade.php rename to app/views/bills/index.blade.php index ac615b33b83..a408c293443 100644 --- a/app/views/recurring/index.blade.php +++ b/app/views/bills/index.blade.php @@ -9,7 +9,7 @@
- @include('list.recurring') + @include('list.bills')
diff --git a/app/views/recurring/show.blade.php b/app/views/bills/show.blade.php similarity index 75% rename from app/views/recurring/show.blade.php rename to app/views/bills/show.blade.php index b877599d476..366c0ca6674 100644 --- a/app/views/recurring/show.blade.php +++ b/app/views/bills/show.blade.php @@ -1,19 +1,19 @@ @extends('layouts.default') @section('content') -{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $recurring) }} +{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $bill) }}
- {{{$recurring->name}}} + {{{$bill->name}}} - @if($recurring->active) + @if($bill->active) @else @endif - @if($recurring->automatch) + @if($bill->automatch) @else @@ -27,8 +27,8 @@
@@ -39,17 +39,17 @@ Matching on - @foreach(explode(',',$recurring->match) as $word) + @foreach(explode(',',$bill->match) as $word) {{{$word}}} @endforeach - between {{mf($recurring->amount_min)}} and {{mf($recurring->amount_max)}}. - Repeats {{$recurring->repeat_freq}}. + between {{mf($bill->amount_min)}} and {{mf($bill->amount_max)}}. + Repeats {{$bill->repeat_freq}}. Next expected match - nextExpectedMatch();?> + nextExpectedMatch();?> @if($nextExpectedMatch) {{$nextExpectedMatch->format('j F Y')}} @else @@ -68,7 +68,7 @@
@@ -82,7 +82,7 @@ Chart
-
+
@@ -105,7 +105,7 @@ @section('scripts') @@ -113,5 +113,5 @@ {{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/bills.js')}} @stop \ No newline at end of file diff --git a/app/views/index.blade.php b/app/views/index.blade.php index 5a90e8ce31d..fa9b896315b 100644 --- a/app/views/index.blade.php +++ b/app/views/index.blade.php @@ -67,10 +67,10 @@
- Recurring transactions + Bills
-
+
diff --git a/app/views/list/recurring.blade.php b/app/views/list/bills.blade.php similarity index 80% rename from app/views/list/recurring.blade.php rename to app/views/list/bills.blade.php index cab075f3b00..1e4839a20a3 100644 --- a/app/views/list/recurring.blade.php +++ b/app/views/list/bills.blade.php @@ -10,16 +10,16 @@ Will be automatched Repeats every - @foreach($recurring as $entry) + @foreach($bills as $entry)
- - + +
- {{{$entry->name}}} + {{{$entry->name}}} @foreach(explode(',',$entry->match) as $match) diff --git a/app/views/list/journals-full.blade.php b/app/views/list/journals-full.blade.php index 61929f43d9f..ffbaa2427f7 100644 --- a/app/views/list/journals-full.blade.php +++ b/app/views/list/journals-full.blade.php @@ -15,8 +15,8 @@ @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) @endif - @if(!isset($hideRecurring) || (isset($hideRecurring) && $hideRecurring=== false)) - + @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) + @endif @foreach($journals as $journal) @@ -100,10 +100,10 @@ @endif @endif - @if(!isset($hideRecurring) || (isset($hideRecurring) && $hideRecurring=== false)) + @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) - @if($journal->recurringTransaction) - {{{$journal->recurringTransaction->name}}} + @if($journal->bill) + {{{$journal->bill->name}}} @endif @endif diff --git a/app/views/partials/menu.blade.php b/app/views/partials/menu.blade.php index c4f7da2aefd..f3172797bb6 100644 --- a/app/views/partials/menu.blade.php +++ b/app/views/partials/menu.blade.php @@ -137,9 +137,9 @@
  • @@ -149,7 +149,7 @@ Piggy banks
  • - Recurring transactions + Bills
  • Repeated expenses @@ -162,7 +162,7 @@ $isWithdrawal = $r == 'transactions.create' && isset($what) && $what == 'withdrawal'; $isDeposit = $r == 'transactions.create' && isset($what) && $what == 'deposit'; $isTransfer = $r == 'transactions.create' && isset($what) && $what == 'transfer'; - $isRecurring = $r == 'recurring.create'; + $isBill = $r == 'bills.create'; ?>
  • Create new @@ -177,7 +177,7 @@ Transfer
  • - Recurring transaction + Bills
  • diff --git a/app/views/reports/month.blade.php b/app/views/reports/month.blade.php index ec0e3a22ca3..30366bcee58 100644 --- a/app/views/reports/month.blade.php +++ b/app/views/reports/month.blade.php @@ -181,7 +181,7 @@
    -
    Recurring transactions
    +
    Bills
    Body
    diff --git a/public/assets/javascript/firefly/bills.js b/public/assets/javascript/firefly/bills.js new file mode 100644 index 00000000000..01c26984cea --- /dev/null +++ b/public/assets/javascript/firefly/bills.js @@ -0,0 +1,7 @@ +$(document).ready(function () { + + if (typeof(googleComboChart) == 'function' && typeof(billID) != 'undefined') { + googleComboChart('chart/bills/' + billID, 'bill-overview'); + } + } +); \ No newline at end of file diff --git a/public/assets/javascript/firefly/index.js b/public/assets/javascript/firefly/index.js index d776da45b1a..3328f23d6fc 100644 --- a/public/assets/javascript/firefly/index.js +++ b/public/assets/javascript/firefly/index.js @@ -5,5 +5,5 @@ function drawChart() { googleLineChart('chart/home/account', 'accounts-chart'); googleBarChart('chart/home/budgets','budgets-chart'); googleColumnChart('chart/home/categories','categories-chart'); - googlePieChart('chart/home/recurring','recurring-chart') + googlePieChart('chart/home/bills','bills-chart') } diff --git a/public/assets/javascript/firefly/recurring.js b/public/assets/javascript/firefly/recurring.js deleted file mode 100644 index b0857f66294..00000000000 --- a/public/assets/javascript/firefly/recurring.js +++ /dev/null @@ -1,14 +0,0 @@ -$(document).ready(function () { - - if (typeof(googleTable) == 'function') { - googleTable('table/recurring', 'recurring-table'); - - if (typeof(recurringID) != 'undefined') { - googleTable('table/recurring/' + recurringID + '/transactions', 'transaction-table'); - } - } - if (typeof(googleComboChart) == 'function' && typeof(recurringID) != 'undefined') { - googleComboChart('chart/recurring/' + recurringID, 'recurring-overview'); - } - } -); \ No newline at end of file diff --git a/tests/functional/RecurringControllerCest.php b/tests/functional/BillControllerCest.php similarity index 66% rename from tests/functional/RecurringControllerCest.php rename to tests/functional/BillControllerCest.php index 54a5524dc89..3dcea51f9b9 100644 --- a/tests/functional/RecurringControllerCest.php +++ b/tests/functional/BillControllerCest.php @@ -1,9 +1,9 @@ wantTo('create a recurring transaction'); - $I->amOnPage('/recurring/create'); + $I->wantTo('create a bill'); + $I->amOnPage('/bills/create'); } /** @@ -35,8 +35,8 @@ public function create(FunctionalTester $I) */ public function delete(FunctionalTester $I) { - $I->wantTo('delete a recurring transaction'); - $I->amOnPage('/recurring/delete/1'); + $I->wantTo('delete a bill'); + $I->amOnPage('/bills/delete/1'); $I->see('Delete "Huur"'); } @@ -45,11 +45,11 @@ public function delete(FunctionalTester $I) */ public function destroy(FunctionalTester $I) { - $I->wantTo('destroy a recurring transaction'); - $I->amOnPage('/recurring/delete/1'); + $I->wantTo('destroy a bill'); + $I->amOnPage('/bills/delete/1'); $I->see('Delete "Huur"'); $I->submitForm('#destroy', []); - $I->see('The recurring transaction was deleted.'); + $I->see('The bill was deleted.'); } @@ -58,8 +58,8 @@ public function destroy(FunctionalTester $I) */ public function edit(FunctionalTester $I) { - $I->wantTo('edit a recurring transaction'); - $I->amOnPage('/recurring/edit/1'); + $I->wantTo('edit a bill'); + $I->amOnPage('/bills/edit/1'); } @@ -69,8 +69,8 @@ public function edit(FunctionalTester $I) */ public function index(FunctionalTester $I) { - $I->wantTo('see all recurring transactions'); - $I->amOnPage('/recurring'); + $I->wantTo('see all bills'); + $I->amOnPage('/bills'); } /** @@ -78,8 +78,8 @@ public function index(FunctionalTester $I) */ public function rescan(FunctionalTester $I) { - $I->wantTo('rescan a recurring transaction'); - $I->amOnPage('/recurring/rescan/1'); + $I->wantTo('rescan a bill'); + $I->amOnPage('/bills/rescan/1'); $I->see('Rescanned everything.'); } @@ -88,9 +88,9 @@ public function rescan(FunctionalTester $I) */ public function rescanInactive(FunctionalTester $I) { - $I->wantTo('rescan an inactive recurring transaction'); - $I->amOnPage('/recurring/rescan/2'); - $I->see('Inactive recurring transactions cannot be scanned.'); + $I->wantTo('rescan an inactive bill'); + $I->amOnPage('/bills/rescan/2'); + $I->see('Inactive bills cannot be scanned.'); } /** @@ -98,8 +98,8 @@ public function rescanInactive(FunctionalTester $I) */ public function show(FunctionalTester $I) { - $I->wantTo('show a recurring transaction'); - $I->amOnPage('/recurring/show/1'); + $I->wantTo('show a bill'); + $I->amOnPage('/bills/show/1'); $I->see('Huur'); } @@ -108,11 +108,11 @@ public function show(FunctionalTester $I) */ public function store(FunctionalTester $I) { - $I->wantTo('store a recurring transaction'); - $I->amOnPage('/recurring/create'); + $I->wantTo('store a bill'); + $I->amOnPage('/bills/create'); $I->submitForm( '#store', [ - 'name' => 'Some recurring', + 'name' => 'Some bill', 'match' => 'one,two', 'amount_min' => 10, 'amount_max' => 20, @@ -122,7 +122,7 @@ public function store(FunctionalTester $I) 'skip' => 0 ] ); - $I->see('Recurring transaction "Some recurring" stored.'); + $I->see('Bill "Some bill" stored.'); } /** @@ -130,11 +130,11 @@ public function store(FunctionalTester $I) */ public function storeFail(FunctionalTester $I) { - $I->wantTo('store a recurring transaction and fail'); - $I->amOnPage('/recurring/create'); + $I->wantTo('store a bill and fail'); + $I->amOnPage('/bills/create'); $I->submitForm( '#store', [ - 'name' => 'Some recurring', + 'name' => 'Some bill', 'match' => '', 'amount_min' => 10, 'amount_max' => 20, @@ -143,17 +143,17 @@ public function storeFail(FunctionalTester $I) 'skip' => 0 ] ); - $I->dontSeeInDatabase('recurring_transactions', ['name' => 'Some recurring']); - $I->see('Could not store recurring transaction'); + $I->dontSeeInDatabase('bills', ['name' => 'Some bill']); + $I->see('Could not store bill'); } public function storeRecreate(FunctionalTester $I) { - $I->wantTo('validate a recurring transaction and create another one'); - $I->amOnPage('/recurring/create'); + $I->wantTo('validate a bill and create another one'); + $I->amOnPage('/bills/create'); $I->submitForm( '#store', [ - 'name' => 'Some recurring', + 'name' => 'Some bill', 'match' => 'one,two', 'amount_min' => 10, 'amount_max' => 20, @@ -164,7 +164,7 @@ public function storeRecreate(FunctionalTester $I) ] ); - $I->see('Recurring transaction "Some recurring" stored.'); + $I->see('Bill "Some bill" stored.'); } /** @@ -172,11 +172,11 @@ public function storeRecreate(FunctionalTester $I) */ public function storeValidate(FunctionalTester $I) { - $I->wantTo('validate a recurring transaction'); - $I->amOnPage('/recurring/create'); + $I->wantTo('validate a bill'); + $I->amOnPage('/bills/create'); $I->submitForm( '#store', [ - 'name' => 'Some recurring', + 'name' => 'Some bill', 'match' => 'one,two', 'amount_min' => 10, 'amount_max' => 20, @@ -195,11 +195,11 @@ public function storeValidate(FunctionalTester $I) */ public function update(FunctionalTester $I) { - $I->wantTo('update a recurring transaction'); - $I->amOnPage('/recurring/edit/1'); + $I->wantTo('update a bill'); + $I->amOnPage('/bills/edit/1'); $I->submitForm( '#update', [ - 'name' => 'Some recurring', + 'name' => 'Some bill', 'match' => 'bla,bla', 'amount_min' => 10, 'amount_max' => 20, @@ -208,7 +208,7 @@ public function update(FunctionalTester $I) 'skip' => 0 ] ); - $I->see('Recurring transaction "Some recurring" updated.'); + $I->see('Bill "Some bill" updated.'); } /** @@ -216,11 +216,11 @@ public function update(FunctionalTester $I) */ public function updateReturn(FunctionalTester $I) { - $I->wantTo('update a recurring transaction and return to edit it'); - $I->amOnPage('/recurring/edit/1'); + $I->wantTo('update a bill and return to edit it'); + $I->amOnPage('/bills/edit/1'); $I->submitForm( '#update', [ - 'name' => 'Some recurring', + 'name' => 'Some bill', 'match' => 'bla,bla', 'amount_min' => 10, 'amount_max' => 20, @@ -230,7 +230,7 @@ public function updateReturn(FunctionalTester $I) 'skip' => 0 ] ); - $I->see('Recurring transaction "Some recurring" updated.'); + $I->see('Bill "Some bill" updated.'); } /** @@ -238,11 +238,11 @@ public function updateReturn(FunctionalTester $I) */ public function updateFail(FunctionalTester $I) { - $I->wantTo('update a recurring transaction and fail'); - $I->amOnPage('/recurring/edit/1'); + $I->wantTo('update a bill and fail'); + $I->amOnPage('/bills/edit/1'); $I->submitForm( '#update', [ - 'name' => 'Some recurring', + 'name' => 'Some bill', 'match' => '', 'amount_min' => 10, 'amount_max' => 20, @@ -251,7 +251,7 @@ public function updateFail(FunctionalTester $I) 'skip' => 0 ] ); - $I->see('Could not update recurring transaction'); + $I->see('Could not update bill'); } } \ No newline at end of file diff --git a/tests/functional/GoogleChartControllerCest.php b/tests/functional/GoogleChartControllerCest.php index dbc8e091e12..3cab18f1979 100644 --- a/tests/functional/GoogleChartControllerCest.php +++ b/tests/functional/GoogleChartControllerCest.php @@ -138,30 +138,30 @@ public function piggyBankHistory(FunctionalTester $I) /** * @param FunctionalTester $I */ - public function recurringOverview(FunctionalTester $I) + public function billOverview(FunctionalTester $I) { - $I->wantTo('see the chart for the history of a recurring transaction'); - $I->amOnPage('/chart/recurring/1'); + $I->wantTo('see the chart for the history of a bill'); + $I->amOnPage('/chart/bills/1'); $I->seeResponseCodeIs(200); } /** * @param FunctionalTester $I */ - public function emptyRecurringOverview(FunctionalTester $I) + public function emptyBillOverview(FunctionalTester $I) { - $I->wantTo('see the chart for the history of an empty recurring transaction'); - $I->amOnPage('/chart/recurring/2'); + $I->wantTo('see the chart for the history of an empty bill'); + $I->amOnPage('/chart/bills/2'); $I->seeResponseCodeIs(200); } /** * @param FunctionalTester $I */ - public function recurringTransactionsOverview(FunctionalTester $I) + public function billsOverview(FunctionalTester $I) { - $I->wantTo('see the chart for which recurring transactions I have yet to pay'); - $I->amOnPage('/chart/home/recurring'); + $I->wantTo('see the chart for which bills I have yet to pay'); + $I->amOnPage('/chart/home/bills'); $I->seeResponseCodeIs(200); }