Merge pull request #144 from foodcoop-adam/fix-closed-group_order-totals
fix closed group_order totals
This commit is contained in:
commit
2060261c89
2 changed files with 19 additions and 1 deletions
|
@ -167,7 +167,7 @@ class GroupOrderArticle < ActiveRecord::Base
|
||||||
# the minimum price depending on configuration. When the order is finished it
|
# the minimum price depending on configuration. When the order is finished it
|
||||||
# will be the value depending of the article results.
|
# will be the value depending of the article results.
|
||||||
def total_price(order_article = self.order_article)
|
def total_price(order_article = self.order_article)
|
||||||
unless order_article.order.finished?
|
if order_article.order.open?
|
||||||
if FoodsoftConfig[:tolerance_is_costly]
|
if FoodsoftConfig[:tolerance_is_costly]
|
||||||
order_article.article.fc_price * (quantity + tolerance)
|
order_article.article.fc_price * (quantity + tolerance)
|
||||||
else
|
else
|
||||||
|
|
18
db/migrate/20130702113610_update_group_order_totals.rb
Normal file
18
db/migrate/20130702113610_update_group_order_totals.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
class UpdateGroupOrderTotals < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
say "If you have ever modified an order after it was settled, the group_order's " +
|
||||||
|
"price may be calculated incorrectly. This can take a lot of time on a " +
|
||||||
|
"large database."
|
||||||
|
|
||||||
|
say "If you do want to update the ordergroup totals, open the rails console " +
|
||||||
|
"(by running `rails c`), and enter:"
|
||||||
|
|
||||||
|
say "GroupOrder.all.each { |go| go.order.closed? and go.update_price! }", subitem: true
|
||||||
|
|
||||||
|
say "You may want to check first that no undesired accounting issues are introduced. " +
|
||||||
|
"It may be wise to discuss this with those responsible for the ordering finances."
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue