From 7a2e475ce63a707acd549b3372592b3587bb1501 Mon Sep 17 00:00:00 2001 From: Florian Lentsch Date: Sat, 9 Mar 2024 13:19:23 +0100 Subject: [PATCH] Fixes #1056 More like a workaround for the flawed db structure though... --- app/models/order_article.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/order_article.rb b/app/models/order_article.rb index 14193d155..f79d8ff05 100644 --- a/app/models/order_article.rb +++ b/app/models/order_article.rb @@ -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