Fixed some math.

This commit is contained in:
James Cole
2015-05-24 08:00:40 +02:00
parent 724db6c34c
commit 288546c2b9
12 changed files with 64 additions and 218 deletions

View File

@@ -151,24 +151,6 @@ class Account extends Model
return $value;
}
/**
* @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;
return $value;
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
@@ -229,10 +211,7 @@ class Account extends Model
*/
public function setVirtualBalanceAttribute($value)
{
// $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);
$this->attributes['virtual_balance'] = strval(round($value, 2));
}
/**

View File

@@ -17,39 +17,6 @@ class Bill extends Model
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
/**
* @param $value
*
* @return float|int
*/
public function getAmountMaxAttribute($value)
{
// if (is_null($this->amount_max_encrypted)) {
// return $value;
// }
// $value = intval(Crypt::decrypt($this->amount_max_encrypted));
// $value = $value / 100;
return $value;
}
/**
*
* @param $value
*
* @return float|int
*/
public function getAmountMinAttribute($value)
{
// if (is_null($this->amount_min_encrypted)) {
// return $value;
// }
// $value = intval(Crypt::decrypt($this->amount_min_encrypted));
// $value = $value / 100;
return $value;
}
/**
* @return array
*/
@@ -93,11 +60,7 @@ 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);
$this->attributes['amount_max'] = round($value, 2);
$this->attributes['amount_max'] = strval(round($value, 2));
}
/**
@@ -105,11 +68,7 @@ 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);
$this->attributes['amount_min'] = round($value, 2);
$this->attributes['amount_min'] = strval(round($value, 2));
}
/**

View File

@@ -21,22 +21,6 @@ class BudgetLimit extends Model
return $this->belongsTo('FireflyIII\Models\Budget');
}
/**
* @param $value
*
* @return float|int
*/
public function getAmountAttribute($value)
{
// if (is_null($this->amount_encrypted)) {
// return $value;
// }
// $value = intval(Crypt::decrypt($this->amount_encrypted));
// $value = $value / 100;
return $value;
}
/**
* @return array
*/
@@ -58,11 +42,7 @@ 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);
$this->attributes['amount'] = round($value, 2);
$this->attributes['amount'] = strval(round($value, 2));
}
}

View File

@@ -22,22 +22,6 @@ class LimitRepetition extends Model
return $this->belongsTo('FireflyIII\Models\BudgetLimit');
}
/**
* @param $value
*
* @return float|int
*/
public function getAmountAttribute($value)
{
// if (is_null($this->amount_encrypted)) {
// return $value;
// }
// $value = intval(Crypt::decrypt($this->amount_encrypted));
// $value = $value / 100;
return $value;
}
/**
* @return array
*/
@@ -51,11 +35,7 @@ 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);
$this->attributes['amount'] = round($value, 2);
$this->attributes['amount'] = strval(round($value, 2));
}
}

View File

@@ -89,22 +89,6 @@ class PiggyBank extends Model
return intval($value) == 1;
}
/**
* @param $value
*
* @return float|int
*/
public function getTargetamountAttribute($value)
{
// if (is_null($this->targetamount_encrypted)) {
// return $value;
// }
// $value = intval(Crypt::decrypt($this->targetamount_encrypted));
// $value = $value / 100;
return $value;
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
@@ -136,10 +120,6 @@ 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);
$this->attributes['targetamount'] = round($value, 2);
$this->attributes['targetamount'] = strval(round($value, 2));
}
}

View File

@@ -15,22 +15,6 @@ class PiggyBankEvent extends Model
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
protected $hidden = ['amount_encrypted'];
/**
* @param $value
*
* @return float|int
*/
public function getAmountAttribute($value)
{
// if (is_null($this->amount_encrypted)) {
// return $value;
// }
// $value = intval(Crypt::decrypt($this->amount_encrypted));
// $value = $value / 100;
return $value;
}
/**
* @return array
*/
@@ -52,11 +36,7 @@ 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);
$this->attributes['amount'] = round($value, 2);
$this->attributes['amount'] = strval(round($value, 2));
}
/**

View File

@@ -16,22 +16,6 @@ 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
*/
@@ -88,11 +72,7 @@ class PiggyBankRepetition extends Model
*/
public function setCurrentamountAttribute($value)
{
// save in cents:
// $value = intval($value * 100);
// $this->attributes['currentamount_encrypted'] = Crypt::encrypt($value);
// $this->attributes['currentamount'] = ($value / 100);
$this->attributes['currentamount'] = round($value, 2);
$this->attributes['currentamount'] = strval(round($value, 2));
}
}

View File

@@ -42,12 +42,6 @@ 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;
}
/**
@@ -85,9 +79,7 @@ class Transaction extends Model
*/
public function setAmountAttribute($value)
{
// save in cents:
// $this->attributes['amount_encrypted'] = Crypt::encrypt($value);
$this->attributes['amount'] = round($value, 2);
$this->attributes['amount'] = strval(round($value, 2));
}
/**