Skip to content

Firefly III: a personal finances manager

Remove encrypted amounts because it stinks.

James Cole5c55fa5fbbe9
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 5406c0616d..23ee5500da 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -117,6 +117,7 @@ class Account extends Model
/**
*
* @param $fieldName
+ *
* @codeCoverageIgnore
*
* @return string|null
@@ -153,16 +154,17 @@ class Account extends Model
/**
* @param $value
+ *
* @codeCoverageIgnore
* @return float|int
*/
public function getVirtualBalanceAttribute($value)
{
- if (is_null($this->virtual_balance_encrypted)) {
- return $value;
- }
- $value = intval(Crypt::decrypt($this->virtual_balance_encrypted));
- $value = $value / 100;
+ // if (is_null($this->virtual_balance_encrypted)) {
+ // return $value;
+ // }
+ // $value = intval(Crypt::decrypt($this->virtual_balance_encrypted));
+ // $value = $value / 100;
return $value;
}
@@ -222,14 +224,15 @@ class Account extends Model
/**
* @param $value
+ *
* @codeCoverageIgnore
*/
public function setVirtualBalanceAttribute($value)
{
- // save in cents:
- $value = intval($value * 100);
- $this->attributes['virtual_balance_encrypted'] = Crypt::encrypt($value);
- $this->attributes['virtual_balance'] = ($value / 100);
+ // $value = intval($value * 100);
+ // $this->attributes['virtual_balance_encrypted'] = Crypt::encrypt($value);
+ // $this->attributes['virtual_balance'] = ($value / 100);
+ $this->attributes['virtual_balance'] = round($value, 2);
}
/**
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index 6fdac81b3d..934249da37 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -24,11 +24,11 @@ class Bill extends Model
*/
public function getAmountMaxAttribute($value)
{
- if (is_null($this->amount_max_encrypted)) {
- return $value;
- }
- $value = intval(Crypt::decrypt($this->amount_max_encrypted));
- $value = $value / 100;
+ // if (is_null($this->amount_max_encrypted)) {
+ // return $value;
+ // }
+ // $value = intval(Crypt::decrypt($this->amount_max_encrypted));
+ // $value = $value / 100;
return $value;
}
@@ -41,11 +41,11 @@ class Bill extends Model
*/
public function getAmountMinAttribute($value)
{
- if (is_null($this->amount_min_encrypted)) {
- return $value;
- }
- $value = intval(Crypt::decrypt($this->amount_min_encrypted));
- $value = $value / 100;
+ // if (is_null($this->amount_min_encrypted)) {
+ // return $value;
+ // }
+ // $value = intval(Crypt::decrypt($this->amount_min_encrypted));
+ // $value = $value / 100;
return $value;
}
@@ -94,9 +94,10 @@ class Bill extends Model
public function setAmountMaxAttribute($value)
{
// save in cents:
- $value = intval($value * 100);
- $this->attributes['amount_max_encrypted'] = Crypt::encrypt($value);
- $this->attributes['amount_max'] = ($value / 100);
+ // $value = intval($value * 100);
+ // $this->attributes['amount_max_encrypted'] = Crypt::encrypt($value);
+ // $this->attributes['amount_max'] = ($value / 100);
+ $this->attributes['amount_max'] = round($value, 2);
}
/**
@@ -105,9 +106,10 @@ class Bill extends Model
public function setAmountMinAttribute($value)
{
// save in cents:
- $value = intval($value * 100);
- $this->attributes['amount_min_encrypted'] = Crypt::encrypt($value);
- $this->attributes['amount_min'] = ($value / 100);
+ // $value = intval($value * 100);
+ // $this->attributes['amount_min_encrypted'] = Crypt::encrypt($value);
+ // $this->attributes['amount_min'] = ($value / 100);
+ $this->attributes['amount_min'] = round($value, 2);
}
/**
diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php
index 80cc4bcc71..5a5bbe77d5 100644
--- a/app/Models/BudgetLimit.php
+++ b/app/Models/BudgetLimit.php
@@ -1,6 +1,5 @@
<?php namespace FireflyIII\Models;
-use Crypt;
use Illuminate\Database\Eloquent\Model;
/**
@@ -29,11 +28,11 @@ class BudgetLimit extends Model
*/
public function getAmountAttribute($value)
{
- if (is_null($this->amount_encrypted)) {
- return $value;
- }
- $value = intval(Crypt::decrypt($this->amount_encrypted));
- $value = $value / 100;
+ // if (is_null($this->amount_encrypted)) {
+ // return $value;
+ // }
+ // $value = intval(Crypt::decrypt($this->amount_encrypted));
+ // $value = $value / 100;
return $value;
}
@@ -60,9 +59,10 @@ class BudgetLimit extends Model
public function setAmountAttribute($value)
{
// save in cents:
- $value = intval($value * 100);
- $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
- $this->attributes['amount'] = ($value / 100);
+ // $value = intval($value * 100);
+ // $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
+ // $this->attributes['amount'] = ($value / 100);
+ $this->attributes['amount'] = round($value, 2);
}
}
diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php
index 666c14d603..e4a7a6ea7b 100644
--- a/app/Models/LimitRepetition.php
+++ b/app/Models/LimitRepetition.php
@@ -1,6 +1,5 @@
<?php namespace FireflyIII\Models;
-use Crypt;
use Illuminate\Database\Eloquent\Model;
/**
@@ -30,11 +29,11 @@ class LimitRepetition extends Model
*/
public function getAmountAttribute($value)
{
- if (is_null($this->amount_encrypted)) {
- return $value;
- }
- $value = intval(Crypt::decrypt($this->amount_encrypted));
- $value = $value / 100;
+ // if (is_null($this->amount_encrypted)) {
+ // return $value;
+ // }
+ // $value = intval(Crypt::decrypt($this->amount_encrypted));
+ // $value = $value / 100;
return $value;
}
@@ -53,9 +52,10 @@ class LimitRepetition extends Model
public function setAmountAttribute($value)
{
// save in cents:
- $value = intval($value * 100);
- $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
- $this->attributes['amount'] = ($value / 100);
+ // $value = intval($value * 100);
+ // $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
+ // $this->attributes['amount'] = ($value / 100);
+ $this->attributes['amount'] = round($value, 2);
}
}
diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php
index e3ce7e2b1b..ee15a8c294 100644
--- a/app/Models/PiggyBank.php
+++ b/app/Models/PiggyBank.php
@@ -96,11 +96,11 @@ class PiggyBank extends Model
*/
public function getTargetamountAttribute($value)
{
- if (is_null($this->targetamount_encrypted)) {
- return $value;
- }
- $value = intval(Crypt::decrypt($this->targetamount_encrypted));
- $value = $value / 100;
+ // if (is_null($this->targetamount_encrypted)) {
+ // return $value;
+ // }
+ // $value = intval(Crypt::decrypt($this->targetamount_encrypted));
+ // $value = $value / 100;
return $value;
}
@@ -137,8 +137,9 @@ class PiggyBank extends Model
public function setTargetamountAttribute($value)
{
// save in cents:
- $value = intval($value * 100);
- $this->attributes['targetamount_encrypted'] = Crypt::encrypt($value);
- $this->attributes['targetamount'] = ($value / 100);
+ // $value = intval($value * 100);
+ // $this->attributes['targetamount_encrypted'] = Crypt::encrypt($value);
+ // $this->attributes['targetamount'] = ($value / 100);
+ $this->attributes['targetamount'] = round($value, 2);
}
}
diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php
index 6e5ba604e5..089022e00f 100644
--- a/app/Models/PiggyBankEvent.php
+++ b/app/Models/PiggyBankEvent.php
@@ -1,6 +1,5 @@
<?php namespace FireflyIII\Models;
-use Crypt;
use Illuminate\Database\Eloquent\Model;
/**
@@ -23,11 +22,11 @@ class PiggyBankEvent extends Model
*/
public function getAmountAttribute($value)
{
- if (is_null($this->amount_encrypted)) {
- return $value;
- }
- $value = intval(Crypt::decrypt($this->amount_encrypted));
- $value = $value / 100;
+ // if (is_null($this->amount_encrypted)) {
+ // return $value;
+ // }
+ // $value = intval(Crypt::decrypt($this->amount_encrypted));
+ // $value = $value / 100;
return $value;
}
@@ -54,9 +53,10 @@ class PiggyBankEvent extends Model
public function setAmountAttribute($value)
{
// save in cents:
- $value = intval($value * 100);
- $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
- $this->attributes['amount'] = ($value / 100);
+ // $value = intval($value * 100);
+ // $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
+ // $this->attributes['amount'] = ($value / 100);
+ $this->attributes['amount'] = round($value, 2);
}
/**
diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php
index 7d5893fb63..636a3a1675 100644
--- a/app/Models/PiggyBankRepetition.php
+++ b/app/Models/PiggyBankRepetition.php
@@ -1,7 +1,6 @@
<?php namespace FireflyIII\Models;
use Carbon\Carbon;
-use Crypt;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
@@ -17,6 +16,22 @@ class PiggyBankRepetition extends Model
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
protected $hidden = ['currentamount_encrypted'];
+ /**
+ * @param $value
+ *
+ * @return float|int
+ */
+ public function getCurrentamountAttribute($value)
+ {
+ // if (is_null($this->currentamount_encrypted)) {
+ // return $value;
+ // }
+ // $value = intval(Crypt::decrypt($this->currentamount_encrypted));
+ // $value = $value / 100;
+
+ return $value;
+ }
+
/**
* @return array
*/
@@ -68,31 +83,16 @@ class PiggyBankRepetition extends Model
);
}
- /**
- * @param $value
- *
- * @return float|int
- */
- public function getCurrentamountAttribute($value)
- {
- if (is_null($this->currentamount_encrypted)) {
- return $value;
- }
- $value = intval(Crypt::decrypt($this->currentamount_encrypted));
- $value = $value / 100;
-
- return $value;
- }
-
/**
* @param $value
*/
public function setCurrentamountAttribute($value)
{
// save in cents:
- $value = intval($value * 100);
- $this->attributes['currentamount_encrypted'] = Crypt::encrypt($value);
- $this->attributes['currentamount'] = ($value / 100);
+ // $value = intval($value * 100);
+ // $this->attributes['currentamount_encrypted'] = Crypt::encrypt($value);
+ // $this->attributes['currentamount'] = ($value / 100);
+ $this->attributes['currentamount'] = round($value, 2);
}
}
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index b4d6d33c9d..ead89c4b36 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -1,7 +1,6 @@
<?php namespace FireflyIII\Models;
use Carbon\Carbon;
-use Crypt;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -43,12 +42,12 @@ class Transaction extends Model
public function getAmountAttribute($value)
{
return $value;
-// if (is_null($this->amount_encrypted)) {
-// return $value;
-// }
-// $value = floatval(Crypt::decrypt($this->amount_encrypted));
-//
-// return $value;
+ // if (is_null($this->amount_encrypted)) {
+ // return $value;
+ // }
+ // $value = floatval(Crypt::decrypt($this->amount_encrypted));
+ //
+ // return $value;
}
/**
@@ -87,8 +86,8 @@ class Transaction extends Model
public function setAmountAttribute($value)
{
// save in cents:
- $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
- $this->attributes['amount'] = $value;
+ // $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
+ $this->attributes['amount'] = round($value, 2);
}
/**