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

@@ -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));
}
}