mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
parent
4f51f6c736
commit
d6d20a81a9
5 changed files with 108 additions and 23 deletions
19
app/models/type/vat_rate.rb
Normal file
19
app/models/type/vat_rate.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
module Type
|
||||
class VATRate < ActiveRecord::Type::Value
|
||||
def type_cast_from_user(value)
|
||||
if value.blank?
|
||||
nil
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def type_cast_from_database(value)
|
||||
BigDecimal(value) * 100 if value
|
||||
end
|
||||
|
||||
def type_cast_for_database(value)
|
||||
BigDecimal(value) / 100.0 if value
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue