Remove code-duplication of artice price calculation
This commit is contained in:
parent
b35357d4b3
commit
2d4891bf1d
3 changed files with 16 additions and 23 deletions
|
|
@ -1,5 +1,6 @@
|
|||
# encoding: utf-8
|
||||
class Article < ActiveRecord::Base
|
||||
include PriceCalculation
|
||||
|
||||
# @!attribute name
|
||||
# @return [String] Article name
|
||||
|
|
@ -67,16 +68,6 @@ class Article < ActiveRecord::Base
|
|||
before_save :update_price_history
|
||||
before_destroy :check_article_in_use
|
||||
|
||||
# The financial gross, net plus tax and deposti
|
||||
def gross_price
|
||||
((price + deposit) * (tax / 100 + 1)).round(2)
|
||||
end
|
||||
|
||||
# The price for the foodcoop-member.
|
||||
def fc_price
|
||||
(gross_price * (FoodsoftConfig[:price_markup] / 100 + 1)).round(2)
|
||||
end
|
||||
|
||||
# Returns true if article has been updated at least 2 days ago
|
||||
def recently_updated
|
||||
updated_at > 2.days.ago
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue