Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More like a workaround for the flawed db structure though...
  • Loading branch information
lentschi committed Mar 9, 2024
1 parent f017053 commit 7a2e475
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/order_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ def update_article_and_price!(order_article_attributes, article_attributes, pric
self.article_price = article.article_prices.first and save # Assign new created article price to order article
else
# Creates a new article_price if neccessary
# Set created_at timestamp to order ends, to make sure the current article price isn't changed
create_article_price!(price_attributes.merge(article_id: article_id, created_at: order.ends)) and save
# Ugly workaround for faulty db structure:
# Set created_at timestamp to just before the latest article price, to make sure the current article price isn't changed
create_article_price!(price_attributes.merge(article_id: article_id, created_at: article.article_prices.last.created_at - 1.second)) and save
end

# Updates ordergroup values
Expand Down

0 comments on commit 7a2e475

Please sign in to comment.