Included new localize_input gem.
This commit is contained in:
parent
3f133bb8c3
commit
5bf6503a8f
3 changed files with 11 additions and 15 deletions
1
Gemfile
1
Gemfile
|
@ -15,6 +15,7 @@ gem 'rails3_acts_as_paranoid'
|
|||
gem 'meta_where'
|
||||
gem 'meta_search'
|
||||
gem 'inherited_resources'
|
||||
gem 'localize_input', :git => "git://github.com/bennibu/localize_input.git"
|
||||
|
||||
group :development do
|
||||
gem 'annotate'
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
GIT
|
||||
remote: git://github.com/bennibu/localize_input.git
|
||||
revision: 1de033997a66b3c22344799cd354e45f0dab4d32
|
||||
specs:
|
||||
localize_input (0.0.1)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
|
@ -115,6 +121,7 @@ DEPENDENCIES
|
|||
hirb
|
||||
inherited_resources
|
||||
jquery-rails
|
||||
localize_input!
|
||||
meta_search
|
||||
meta_where
|
||||
mysql
|
||||
|
|
|
@ -28,6 +28,9 @@ class Article < ActiveRecord::Base
|
|||
acts_as_paranoid # Avoid deleting the article for consistency of order-results
|
||||
extend ActiveSupport::Memoizable # Ability to cache method results. Use memoize :expensive_method
|
||||
|
||||
# Replace numeric seperator with database format
|
||||
localize_input_of :price, :tax, :deposit
|
||||
|
||||
# Associations
|
||||
belongs_to :supplier
|
||||
belongs_to :article_category
|
||||
|
@ -48,21 +51,6 @@ class Article < ActiveRecord::Base
|
|||
before_save :update_price_history
|
||||
before_destroy :check_article_in_use
|
||||
|
||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||
def price=(price)
|
||||
self[:price] = String.delocalized_decimal(price)
|
||||
end
|
||||
|
||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||
def tax=(tax)
|
||||
self[:tax] = String.delocalized_decimal(tax)
|
||||
end
|
||||
|
||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||
def deposit=(deposit)
|
||||
self[:deposit] = String.delocalized_decimal(deposit)
|
||||
end
|
||||
|
||||
# The financial gross, net plus tax and deposti
|
||||
def gross_price
|
||||
((price + deposit) * (tax / 100 + 1)).round(2)
|
||||
|
|
Loading…
Reference in a new issue