Readonly receive input if GroupOrderArticle result has manually been changed
Conflicts: app/helpers/orders_helper.rb app/views/orders/_edit_amount.html.haml
This commit is contained in:
parent
7aae7f4d55
commit
98f59a3de3
7 changed files with 43 additions and 9 deletions
|
|
@ -165,9 +165,11 @@ class GroupOrderArticle < ActiveRecord::Base
|
|||
self[:result] || calculate_result[type]
|
||||
end
|
||||
|
||||
# This is used during order.finish!.
|
||||
# This is used for automatic distribution, e.g., in order.finish! or when receiving orders
|
||||
def save_results!(article_total = nil)
|
||||
self.update_attribute(:result, calculate_result(article_total)[:total])
|
||||
new_result = calculate_result(article_total)[:total]
|
||||
self.update_attribute(:result_computed, new_result)
|
||||
self.update_attribute(:result, new_result)
|
||||
end
|
||||
|
||||
# Returns total price for this individual article
|
||||
|
|
@ -186,6 +188,10 @@ class GroupOrderArticle < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# Check if the result deviates from the result_computed
|
||||
def result_manually_changed?
|
||||
result != result_computed
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -195,6 +195,11 @@ class OrderArticle < ActiveRecord::Base
|
|||
units = 0 if units < 0
|
||||
units
|
||||
end
|
||||
|
||||
# Check if the result of any associated GroupOrderArticle was overridden manually
|
||||
def result_manually_changed?
|
||||
group_order_articles.any? {|goa| goa.result_manually_changed?}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue