Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Now with the added capability of adding money to a piggy bank from a transfer. Also various fixes (see issue #6). [skip ci]
James Coled645a38aec92
diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.phpindex 1da2a19443..3e6796724e 100644--- a/app/controllers/PiggybankController.php+++ b/app/controllers/PiggybankController.php@@ -6,6 +6,7 @@ use Firefly\Storage\Piggybank\PiggybankRepositoryInterface as PRI;/*** Class PiggybankController+ **/class PiggybankController extends BaseController{@@ -63,7 +64,6 @@ class PiggybankController extends BaseController*/public function destroy(Piggybank $piggyBank){- // TODO move to repository.$this->_repository->destroy($piggyBank);Event::fire('piggybanks.change');Session::flash('success', 'Piggy bank deleted.');@@ -96,9 +96,9 @@ class PiggybankController extends BaseController*/public function index(){+ Event::fire('piggybanks.change');$countRepeating = $this->_repository->countRepeating();$countNonRepeating = $this->_repository->countNonrepeating();- Event::fire('piggybanks.change'); // TODO remove$piggybanks = $this->_repository->get();return View::make('piggybanks.index')->with('piggybanks', $piggybanks)@@ -111,7 +111,6 @@ class PiggybankController extends BaseController*/public function show(Piggybank $piggyBank){- Event::fire('piggybanks.change'); // TODO removereturn View::make('piggybanks.show')->with('piggyBank', $piggyBank);}@@ -159,7 +158,7 @@ class PiggybankController extends BaseController$data['order'] = 0;$piggyBank = $this->_repository->store($data);- if ($piggyBank->validate()) {+ if ($piggyBank->id) {Session::flash('success', 'New piggy bank "' . $piggyBank->name . '" created!');Event::fire('piggybanks.change');diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.phpindex 82ffbd2ccd..0fb9d2bda5 100644--- a/app/controllers/TransactionController.php+++ b/app/controllers/TransactionController.php@@ -37,10 +37,15 @@ class TransactionController extends BaseController$budgets = $budgetRepository->getAsSelectList();$budgets[0] = '(no budget)';+ // get the number of piggy banks.+ /** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */+ $piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');+ $piggies = $piggyRepository->get();+return View::make('transactions.create')->with('accounts', $accounts)->with('budgets', $budgets)->with('what', $what- );+ )->with('piggies',$piggies);}/**diff --git a/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php b/app/database/migrations/2014_06_27_163818_create_piggybanks_table.phpsimilarity index 100%rename from app/database/migrations/2014_07_05_100651_create_piggybanks_table.phprename to app/database/migrations/2014_06_27_163818_create_piggybanks_table.phpdiff --git a/app/database/migrations/2014_06_27_164836_create_transactions_table.php b/app/database/migrations/2014_06_27_164836_create_transactions_table.phpindex 1b9ab96301..9bd7c6177d 100644--- a/app/database/migrations/2014_06_27_164836_create_transactions_table.php+++ b/app/database/migrations/2014_06_27_164836_create_transactions_table.php@@ -11,6 +11,16 @@ use Illuminate\Database\Schema\Blueprint;class CreateTransactionsTable extends Migration{+ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down()+ {+ Schema::drop('transactions');+ }+/*** Run the migrations.*@@ -23,6 +33,7 @@ class CreateTransactionsTable extends Migration$table->increments('id');$table->timestamps();$table->integer('account_id')->unsigned();+ $table->integer('piggybank_id')->nullable()->unsigned();$table->integer('transaction_journal_id')->unsigned();$table->string('description', 255)->nullable();$table->decimal('amount', 10, 2);@@ -32,6 +43,11 @@ class CreateTransactionsTable extends Migration->references('id')->on('transaction_journals')->onDelete('cascade');+ // connect piggy banks+ $table->foreign('piggybank_id')+ ->references('id')->on('piggybanks')+ ->onDelete('set null');+// connect account id:$table->foreign('account_id')->references('id')->on('accounts')@@ -41,14 +57,4 @@ class CreateTransactionsTable extends Migration);}- /**- * Reverse the migrations.- *- * @return void- */- public function down()- {- Schema::drop('transactions');- }-}diff --git a/app/database/migrations/2014_08_12_173919_create_piggy_instance.php b/app/database/migrations/2014_08_12_173919_create_piggy_instance.phpindex 53fce65e6d..c4a0c0ceeb 100644--- a/app/database/migrations/2014_08_12_173919_create_piggy_instance.php+++ b/app/database/migrations/2014_08_12_173919_create_piggy_instance.php@@ -1,43 +1,45 @@<?php-use Illuminate\Database\Schema\Blueprint;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;-class CreatePiggyInstance extends Migration {+class CreatePiggyInstance extends Migration+{- /**- * Run the migrations.- *- * @return void- */- public function up()- {- Schema::create('piggybank_repetitions', function(Blueprint $table)- {- $table->increments('id');- $table->timestamps();- $table->integer('piggybank_id')->unsigned();- $table->date('startdate')->nullable();- $table->date('targetdate')->nullable();- $table->decimal('currentamount',10,2);+ /**+ * Run the migrations.+ *+ * @return void+ */+ public function up()+ {+ Schema::create(+ 'piggybank_repetitions', function (Blueprint $table) {+ $table->increments('id');+ $table->timestamps();+ $table->integer('piggybank_id')->unsigned();+ $table->date('startdate')->nullable();+ $table->date('targetdate')->nullable();+ $table->decimal('currentamount', 10, 2);- $table->unique(['piggybank_id','startdate','targetdate']);+ $table->unique(['piggybank_id', 'startdate', 'targetdate']);- // connect instance to piggybank.- $table->foreign('piggybank_id')- ->references('id')->on('piggybanks')- ->onDelete('cascade');- });- }+ // connect instance to piggybank.+ $table->foreign('piggybank_id')+ ->references('id')->on('piggybanks')+ ->onDelete('cascade');+ }+ );+ }- /**- * Reverse the migrations.- *- * @return void- */- public function down()- {- Schema::drop('piggybank_repetitions');- }+ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down()+ {+ Schema::drop('piggybank_repetitions');+ }}diff --git a/app/lib/Firefly/Helper/Controllers/Chart.php b/app/lib/Firefly/Helper/Controllers/Chart.phpindex 2a163d011f..161fa23325 100644--- a/app/lib/Firefly/Helper/Controllers/Chart.php+++ b/app/lib/Firefly/Helper/Controllers/Chart.php@@ -114,6 +114,8 @@ class Chart implements ChartInterface$q->where('startdate', $start->format('Y-m-d'));}])->orderBy('name', 'ASC')->get();+ $limitInPeriod = '';+ $spentInPeriod = '';foreach ($budgets as $budget) {$budget->count = 0;diff --git a/app/lib/Firefly/Storage/Category/EloquentCategoryRepository.php b/app/lib/Firefly/Storage/Category/EloquentCategoryRepository.phpindex 0a55ff0ca8..f18369abc4 100644--- a/app/lib/Firefly/Storage/Category/EloquentCategoryRepository.php+++ b/app/lib/Firefly/Storage/Category/EloquentCategoryRepository.php@@ -16,6 +16,9 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface*/public function createOrFind($name){+ if(strlen($name) == 0) {+ return null;+ }$category = $this->findByName($name);if (!$category) {return $this->store(['name' => $name]);@@ -55,7 +58,7 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface*/public function findByName($name){- if ($name == '') {+ if ($name == '' || strlen($name) == 0) {return null;}diff --git a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.phpindex 3189d75589..dafd2b750e 100644--- a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php+++ b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php@@ -163,20 +163,15 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface$piggy->startdate= isset($data['startdate']) && strlen($data['startdate']) > 0 ? new Carbon($data['startdate']) : null;- // everything we can update for NON repeating piggy banks:- if ($piggy->repeats == 0) {- // if non-repeating there is only one PiggyBank instance and we can delete it safely.- // it will be recreated.- $piggy->piggybankrepetitions()->first()->delete();- } else {- // we can delete all of them, because reasons- foreach ($piggy->piggybankrepetitions()->get() as $rep) {- $rep->delete();- }+ foreach ($piggy->piggybankrepetitions()->get() as $rep) {+ $rep->delete();+ }+ if ($piggy->repeats == 1) {$piggy->rep_every = intval($data['rep_every']);$piggy->rep_length = $data['rep_length'];}+if ($piggy->validate()) {// check the things we check for new piggies$piggy->save();diff --git a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.phpindex 062b502483..ece635ea00 100644--- a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php+++ b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php@@ -34,8 +34,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito* A gains 200 (200). * -1* B loses 200 (-200). * 1*- * @param \Account $from- * @param \Account $toAccount+ * @param \Account $from+ * @param \Account $toAccount* @param $description* @param $amount* @param \Carbon\Carbon $date@@ -287,6 +287,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositocase 'transfer':$fromAccount = $accountRepository->find(intval($data['account_from_id']));$toAccount = $accountRepository->find(intval($data['account_to_id']));++break;}// fall back to cash if necessary:@@ -310,6 +312,39 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositoreturn $transactionJournal;}+ // here we're done and we have transactions in the journal:+ // do something with the piggy bank:+ if ($what == 'transfer') {+ /** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */+ $piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');++ if (isset($data['piggybank_id'])) {+ /** @var \Piggybank $piggyBank */+ $piggyBank = $piggyRepository->find(intval($data['piggybank_id']));++ if ($piggyBank) {+ if ($toAccount->id == $piggyBank->account_id) {++ // find the transaction connected to the $toAccount:+ /** @var \Transaction $transaction */+ $transaction+ = $transactionJournal->transactions()->where('account_id', $toAccount->id)->first();+ // connect the piggy to it:+ $transaction->piggybank()->associate($piggyBank);+ $transaction->save();+ } else {+ \Session::flash(+ 'warning',+ 'Piggy bank "' . e($piggyBank->name) . '" is not set to draw money from account "' . e(+ $toAccount->name+ ) . '", so the money isn\'t added to the piggy bank.'+ );+ }+ }+ }+ }++// attach:if (!is_null($budget)) {$transactionJournal->budgets()->save($budget);@@ -390,10 +425,13 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositobreak;case 'Transfer':// means transaction[0] is account that sent the money (from).+ /** @var \Account $fromAccount */$fromAccount = $accountRepository->find($data['account_from_id']);+ /** @var \Account $toAccount */$toAccount = $accountRepository->find($data['account_to_id']);$journal->transactions[0]->account()->associate($fromAccount);$journal->transactions[1]->account()->associate($toAccount);+break;default:throw new FireflyException('Cannot edit this!');diff --git a/app/lib/Firefly/Trigger/Piggybanks/EloquentPiggybankTrigger.php b/app/lib/Firefly/Trigger/Piggybanks/EloquentPiggybankTrigger.phpindex ba59b08440..f9f4b7f912 100644--- a/app/lib/Firefly/Trigger/Piggybanks/EloquentPiggybankTrigger.php+++ b/app/lib/Firefly/Trigger/Piggybanks/EloquentPiggybankTrigger.php@@ -45,6 +45,24 @@ class EloquentPiggybankTrigger} catch (QueryException $e) {}}++ // whatever we did here, we now have all repetitions for this+ // piggy bank, and we can find transactions that fall within+ // that repetition (to fix the "saved amount".+ $reps = $piggy->piggybankrepetitions()->get();+ /** @var \PiggybankRepetition $rep */+ foreach ($reps as $rep) {+ $sum = \Transaction::where('piggybank_id', $piggy->id)->leftJoin(+ 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'+ )->where('transaction_journals.date', '>=', $rep->startdate->format('Y-m-d'))->where(+ 'transaction_journals.date', '<=', $rep->targetdate->format('Y-m-d')+ )->sum('transactions.amount');+ $rep->currentamount = floatval($sum);+ $rep->save();+++ }+}unset($piggy, $piggybanks, $rep);@@ -59,14 +77,8 @@ class EloquentPiggybankTrigger$rep->targetdate = $repeated->targetdate;$rep->currentamount = 0;try {- \Log::debug(- 'Creating initial rep ('.$repeated->name.') (from ' . ($rep->startdate ? $rep->startdate->format('d-m-Y')- : 'NULL') . ' to '- . ($rep->targetdate ? $rep->targetdate->format('d-m-Y') : 'NULL') . ')'- );$rep->save();} catch (QueryException $e) {- \Log::error('FAILED initital repetition.');}unset($rep);@@ -109,6 +121,19 @@ class EloquentPiggybankTrigger}}}+ $reps = $repeated->piggybankrepetitions()->get();+ /** @var \PiggybankRepetition $rep */+ foreach ($reps as $rep) {+ $sum = \Transaction::where('piggybank_id', $repeated->id)->leftJoin(+ 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'+ )->where('transaction_journals.date', '>=', $rep->startdate->format('Y-m-d'))->where(+ 'transaction_journals.date', '<=', $rep->targetdate->format('Y-m-d')+ )->sum('transactions.amount');+ $rep->currentamount = floatval($sum);+ $rep->save();+++ }}}}\ No newline at end of filediff --git a/app/models/Transaction.php b/app/models/Transaction.phpindex 8cfb9bf43a..29bc4e00a4 100644--- a/app/models/Transaction.php+++ b/app/models/Transaction.php@@ -53,11 +53,19 @@ class Transaction extends Ardent}/**- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany*/- public function transactionJournal()+ public function budgets(){- return $this->belongsTo('TransactionJournal');+ return $this->belongsToMany('Budget', 'component_transaction', 'transaction_id', 'component_id');+ }++ /**+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany+ */+ public function categories()+ {+ return $this->belongsToMany('Category', 'component_transaction', 'transaction_id', 'component_id');}/**@@ -69,18 +77,18 @@ class Transaction extends Ardent}/**- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/- public function budgets()+ public function piggybank(){- return $this->belongsToMany('Budget', 'component_transaction', 'transaction_id', 'component_id');+ return $this->belongsTo('Piggybank');}/**- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/- public function categories()+ public function transactionJournal(){- return $this->belongsToMany('Category', 'component_transaction', 'transaction_id', 'component_id');+ return $this->belongsTo('TransactionJournal');}}\ No newline at end of filediff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.phpindex dfea8f830c..26a7a18235 100644--- a/app/models/TransactionJournal.php+++ b/app/models/TransactionJournal.php@@ -3,91 +3,6 @@use LaravelBook\Ardent\Ardent;-/**- * TransactionJournal- *- * @property integer $id- * @property \Carbon\Carbon $created_at- * @property \Carbon\Carbon $updated_at- * @property integer $transaction_type_id- * @property integer $transaction_currency_id- * @property string $description- * @property boolean $completed- * @property \Carbon\Carbon $date- * @property-read \TransactionType $transactionType- * @property-read \TransactionCurrency $transactionCurrency- * @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions- * @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereId($value)- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCreatedAt($value)- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUpdatedAt($value)- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionTypeId($value)- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionCurrencyId($value)- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDescription($value)- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCompleted($value)- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value)- * @method static \TransactionJournal after($date)- * @method static \TransactionJournal before($date)- * @property integer $user_id- * @property-read \User $user- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUserId($value)- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Budget[] $budgets- * @property-read \Illuminate\Database\Eloquent\Collection|\- * 'Category[] $categories- */class TransactionJournal extends Ardent{@@ -118,96 +33,95 @@ class TransactionJournal extends Ardent}/**- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany*/- public function transactionType()+ public function budgets(){- return $this->belongsTo('TransactionType');+ return $this->belongsToMany(+ 'Budget', 'component_transaction_journal', 'transaction_journal_id', 'component_id'+ );}/**- * User- *- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany*/- public function user()+ public function categories(){- return $this->belongsTo('User');+ return $this->belongsToMany(+ 'Category', 'component_transaction_journal', 'transaction_journal_id', 'component_id'+ );}-/**- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany*/- public function transactionCurrency()+ public function components(){- return $this->belongsTo('TransactionCurrency');+ return $this->belongsToMany('Component');}/**- * @return \Illuminate\Database\Eloquent\Relations\HasMany+ * @return array*/- public function transactions()+ public function getDates(){- return $this->hasMany('Transaction');+ return ['created_at', 'updated_at', 'date'];}/**- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany+ * @param $query+ * @param \Carbon\Carbon $date+ *+ * @return mixed*/- public function components()+ public function scopeAfter($query, \Carbon\Carbon $date){- return $this->belongsToMany('Component');+ return $query->where('date', '>=', $date->format('Y-m-d'));}/**- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany+ * @param $query+ * @param \Carbon\Carbon $date+ *+ * @return mixed*/- public function budgets()+ public function scopeBefore($query, \Carbon\Carbon $date){- return $this->belongsToMany(- 'Budget', 'component_transaction_journal', 'transaction_journal_id', 'component_id'- );+ return $query->where('date', '<=', $date->format('Y-m-d'));}/**- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/- public function categories()+ public function transactionCurrency(){- return $this->belongsToMany(- 'Category', 'component_transaction_journal', 'transaction_journal_id', 'component_id'- );+ return $this->belongsTo('TransactionCurrency');}/**- * @return array+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/- public function getDates()+ public function transactionType(){- return ['created_at', 'updated_at', 'date'];+ return $this->belongsTo('TransactionType');}/**- * @param $query- * @param \Carbon\Carbon $date- *- * @return mixed+ * @return \Illuminate\Database\Eloquent\Relations\HasMany*/- public function scopeAfter($query, \Carbon\Carbon $date)+ public function transactions(){- return $query->where('date', '>=', $date->format('Y-m-d'));+ return $this->hasMany('Transaction');}/**- * @param $query- * @param \Carbon\Carbon $date+ * User*- * @return mixed+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo*/- public function scopeBefore($query, \Carbon\Carbon $date)+ public function user(){- return $query->where('date', '<=', $date->format('Y-m-d'));+ return $this->belongsTo('User');}}\ No newline at end of filediff --git a/app/views/transactions/create.blade.php b/app/views/transactions/create.blade.phpindex fcc31a572e..705b843d79 100644--- a/app/views/transactions/create.blade.php+++ b/app/views/transactions/create.blade.php@@ -175,6 +175,37 @@</div></div>+ <!-- RELATE THIS TRANSFER TO A PIGGY BANK -->+ @if($what == 'transfer' && count($piggies) > 0)+ <div class="form-group">+ <label for="piggybank_id" class="col-sm-4 control-label">+ Piggy bank+ </label>+ <div class="col-sm-8">+ <select name="piggybank_id" class="form-control">+ <option value="0" label="(no piggy bank)">(no piggy bank)</option>+ @foreach($piggies as $piggy)+ @if($piggy->id == Input::old('piggybank_id'))+ <option value="{{$piggy->id}}" label="{{{$piggy->name}}}" selected="selected ">{{{$piggy->name}}}</option>+ @else+ <option value="{{$piggy->id}}" label="{{{$piggy->name}}}">{{{$piggy->name}}}</option>+ @endif+ @endforeach+ </select>+ @if($errors->has('piggybank_id'))+ <p class="text-danger">{{$errors->first('piggybank_id')}}</p>+ @else+ <span class="help-block">+ You can directly add the amount you're transferring+ to one of your piggy banks, provided they are related to the account your+ transferring <em>to</em>.+ </span>+ @endif+ </div>+ </div>+ @endif++</div></div>