From 56b254dffc2050a3e38eed34d96bbea0431e7130 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 26 Jul 2022 17:38:33 +0200 Subject: [PATCH] print an error if the current invoice does not have a main_item --- app/models/invoice.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 34b738837..450a6b823 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -129,6 +129,11 @@ class Invoice < PaymentDocument def prevent_refund? return true if user.nil? + if main_item.nil? + Rails.logger.error "Invoice (id: #{id}) does not have a main_item and is probably in error" + return true + end + if main_item.object_type == 'Reservation' && main_item.object&.reservable_type == 'Training' user.trainings.include?(main_item.object.reservable_id) else