From 06d34e30a86e37e167e98d08625612be5fd65145 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Mon, 27 Feb 2023 09:48:45 +0200 Subject: [PATCH] update state machine --- app/models/invoice_state_machine.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/invoice_state_machine.rb b/app/models/invoice_state_machine.rb index cd1886665..047477800 100644 --- a/app/models/invoice_state_machine.rb +++ b/app/models/invoice_state_machine.rb @@ -38,7 +38,7 @@ class InvoiceStateMachine end def mark_as_unpaid - return push_error if invoice.paid? && invoice.payment_orders.last.payment_reference? || invoice.cancelled? + return push_error if invoice.paid? && invoice.payment_orders&.last&.payment_reference? || invoice.cancelled? return true unless invoice.paid? invoice.cancel_manualy