mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 09:22:33 +00:00
New stuff for encrypted amounts.
This commit is contained in:
@@ -14,6 +14,38 @@ class Bill extends Model
|
||||
protected $fillable
|
||||
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
@@ -56,6 +88,28 @@ class Bill extends Model
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setAmountMaxAttribute($value)
|
||||
{
|
||||
// save in cents:
|
||||
$value = intval($value * 100);
|
||||
$this->attributes['amount_max_encrypted'] = Crypt::encrypt($value);
|
||||
$this->attributes['amount_max'] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setAmountMinAttribute($value)
|
||||
{
|
||||
// save in cents:
|
||||
$value = intval($value * 100);
|
||||
$this->attributes['amount_min_encrypted'] = Crypt::encrypt($value);
|
||||
$this->attributes['amount_min'] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
|
Reference in New Issue
Block a user