1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

print an error if the current invoice does not have a main_item

This commit is contained in:
Sylvain 2022-07-26 17:38:33 +02:00
parent bb7eec924c
commit 56b254dffc

View File

@ -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