Skip to content

Firefly III: a personal finances manager

Clean up models, fixed a bug.

James Cole4720519aef1a
diff --git a/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php b/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php
index e4f2be8348..c45cddac73 100644
--- a/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php
+++ b/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php
@@ -38,10 +38,10 @@ class CreatePiggybanksTable extends Migration
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->boolean('repeats');
- $table->enum('rep_length', ['day', 'week', 'month', 'year'])->nullable();
+ $table->enum('rep_length', ['day', 'week','quarter', 'month', 'year'])->nullable();
$table->smallInteger('rep_every')->unsigned();
$table->smallInteger('rep_times')->unsigned()->nullable();
- $table->enum('reminder', ['day', 'week', 'month', 'year'])->nullable();
+ $table->enum('reminder', ['day', 'week','quarter', 'month', 'year'])->nullable();
$table->smallInteger('reminder_skip')->unsigned();
$table->boolean('remind_me');
$table->integer('order')->unsigned();
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php
index 52998712f5..f18851e342 100644
--- a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php
+++ b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php
@@ -104,7 +104,7 @@ class Reminders
}
$end = \DateKit::endOfPeriod(clone $start, $piggybank->reminder);
// should have a reminder for this period:
- /** @var \Collection $reminders */
+ /** @var Collection $reminders */
$reminders = $piggybank->reminders()->dateIs($start, $end)->get();
if ($reminders->count() == 0) {
// create new!
@@ -113,7 +113,8 @@ class Reminders
$reminder->enddate = $end;
$reminder->active = 1;
$reminder->user()->associate($repository->getUser());
- $reminder->remindersable()->associate($piggybank);
+ $reminder->remindersable_id= $piggybank->id;
+ $reminder->remindersable_type = 'Piggybank';
$reminder->save();
}
}
diff --git a/app/models/Account.php b/app/models/Account.php
index 3f2d087fee..bffa32415f 100644
--- a/app/models/Account.php
+++ b/app/models/Account.php
@@ -17,14 +17,14 @@ use LaravelBook\Ardent\Builder;
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
* @property-read \Illuminate\Database\Eloquent\Collection|\Piggybank[] $piggybanks
* @property-read \User $user
- * @method static \Illuminate\Database\Query\Builder|\Account whereId($value)
- * @method static \Illuminate\Database\Query\Builder|\Account whereCreatedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\Account whereUpdatedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\Account whereUserId($value)
- * @method static \Illuminate\Database\Query\Builder|\Account whereAccountTypeId($value)
- * @method static \Illuminate\Database\Query\Builder|\Account whereName($value)
- * @method static \Illuminate\Database\Query\Builder|\Account whereActive($value)
- * @method static \Account accountTypeIn($types)
+ * @method static \Illuminate\Database\Query\Builder|\Account whereId($value)
+ * @method static \Illuminate\Database\Query\Builder|\Account whereCreatedAt($value)
+ * @method static \Illuminate\Database\Query\Builder|\Account whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Query\Builder|\Account whereUserId($value)
+ * @method static \Illuminate\Database\Query\Builder|\Account whereAccountTypeId($value)
+ * @method static \Illuminate\Database\Query\Builder|\Account whereName($value)
+ * @method static \Illuminate\Database\Query\Builder|\Account whereActive($value)
+ * @method static \Account accountTypeIn($types)
*/
class Account extends Ardent
{
diff --git a/app/models/PiggybankRepetition.php b/app/models/PiggybankRepetition.php
index ef9557bfa1..eac5577386 100644
--- a/app/models/PiggybankRepetition.php
+++ b/app/models/PiggybankRepetition.php
@@ -21,6 +21,8 @@ use LaravelBook\Ardent\Builder;
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereStartdate($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereTargetdate($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCurrentamount($value)
+ * @method static \PiggybankRepetition starts($date)
+ * @method static \PiggybankRepetition targets($date)
*/
class PiggybankRepetition extends Ardent
{
diff --git a/app/models/Reminder.php b/app/models/Reminder.php
index 7a772d1111..01b6053f16 100644
--- a/app/models/Reminder.php
+++ b/app/models/Reminder.php
@@ -3,6 +3,7 @@
use Carbon\Carbon;
use LaravelBook\Ardent\Ardent;
+
/**
* Reminder
*
@@ -14,25 +15,22 @@ use LaravelBook\Ardent\Ardent;
* @property \Carbon\Carbon $enddate
* @property boolean $active
* @property boolean $notnow
- * @property integer $remembersable_id
- * @property string $remembersable_type
- * @property-read \Piggybank $remindersable
- * @property-read \User $user
- * @property mixed $data
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemembersableId($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemembersableType($value)
- * @method static \Reminder dateIs($start, $end)
* @property integer $remindersable_id
* @property string $remindersable_type
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableId($value)
- * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableType($value)
+ * @property-read \ $remindersable
+ * @property-read \User $user
+ * @property mixed $data
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereNotnow($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableId($value)
+ * @method static \Illuminate\Database\Query\Builder|\Reminder whereRemindersableType($value)
+ * @method static \Reminder dateIs($start, $end)
*/
class Reminder extends Ardent
{
diff --git a/app/models/TransactionGroup.php b/app/models/TransactionGroup.php
index bb29b3f3b4..10d363eb72 100644
--- a/app/models/TransactionGroup.php
+++ b/app/models/TransactionGroup.php
@@ -1,6 +1,22 @@
<?php
use LaravelBook\Ardent\Ardent;
+/**
+ * TransactionGroup
+ *
+ * @property integer $id
+ * @property \Carbon\Carbon $created_at
+ * @property \Carbon\Carbon $updated_at
+ * @property integer $user_id
+ * @property string $relation
+ * @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
+ * @property-read \User $user
+ * @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereId($value)
+ * @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereCreatedAt($value)
+ * @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereUserId($value)
+ * @method static \Illuminate\Database\Query\Builder|\TransactionGroup whereRelation($value)
+ */
class TransactionGroup extends Ardent
{
diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php
index 84cdb06353..03402735fe 100644
--- a/app/models/TransactionJournal.php
+++ b/app/models/TransactionJournal.php
@@ -60,6 +60,11 @@ use LaravelBook\Ardent\Builder;
* 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories
+ * @property-read \Illuminate\Database\Eloquent\Collection|\
+ * 'Budget[] $budgets
+ * @property-read \Illuminate\Database\Eloquent\Collection|\
+ * 'Category[] $categories
+ * @property-read \Illuminate\Database\Eloquent\Collection|\TransactionGroup[] $transactiongroups
*/
class TransactionJournal extends Ardent
{
diff --git a/app/models/TransactionRelation.php b/app/models/TransactionRelation.php
index ee49e2dcab..ed4fb6550c 100644
--- a/app/models/TransactionRelation.php
+++ b/app/models/TransactionRelation.php
@@ -2,6 +2,10 @@
use Carbon\Carbon;
use LaravelBook\Ardent\Ardent;
+/**
+ * TransactionRelation
+ *
+ */
class TransactionRelation extends Ardent {
}
\ No newline at end of file
diff --git a/app/models/User.php b/app/models/User.php
index 01d7372773..2b46dead0c 100644
--- a/app/models/User.php
+++ b/app/models/User.php
@@ -32,7 +32,7 @@ use LaravelBook\Ardent\Ardent;
* @method static \Illuminate\Database\Query\Builder|\User whereReset($value)
* @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value)
* @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value)
- * @property-read \Illuminate\Database\Eloquent\Collection|\Reminder[] $reminders
+ * @property-read \Illuminate\Database\Eloquent\Collection|\Reminder[] $reminders
*/
class User extends Ardent implements UserInterface, RemindableInterface
{
@@ -97,10 +97,6 @@ class User extends Ardent implements UserInterface, RemindableInterface
{
return $this->hasManyThrough('Piggybank', 'Account');
}
- public function transactions()
- {
- return $this->hasManyThrough('TransactionJournal', 'Transaction');
- }
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
@@ -126,7 +122,6 @@ class User extends Ardent implements UserInterface, RemindableInterface
return $this->hasMany('Reminder');
}
-
/**
* @param $value
*/
@@ -143,4 +138,9 @@ class User extends Ardent implements UserInterface, RemindableInterface
return $this->hasMany('TransactionJournal');
}
+ public function transactions()
+ {
+ return $this->hasManyThrough('TransactionJournal', 'Transaction');
+ }
+
}
\ No newline at end of file