mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
parent
026c36d066
commit
7d72d9cb34
8 changed files with 121 additions and 94 deletions
|
@ -1,19 +1,11 @@
|
|||
module Type
|
||||
class VATRate < ActiveRecord::Type::Value
|
||||
def type_cast_from_user(value)
|
||||
if value.blank?
|
||||
nil
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
class VATRate < ActiveRecord::Type::Decimal
|
||||
def type_cast_from_database(value)
|
||||
BigDecimal(value) * 100 if value
|
||||
super * 100 if value
|
||||
end
|
||||
|
||||
def type_cast_for_database(value)
|
||||
BigDecimal(value) / 100.0 if value
|
||||
super / 100.0 if value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue