From 6d0f7d7c81a7489f3865ebc6d84ad42a3cace3f2 Mon Sep 17 00:00:00 2001 From: Mohamed ABDELLANI Date: Mon, 30 Oct 2023 22:27:57 +0100 Subject: [PATCH] render null shipment when shipment adjustment doesn't exist --- app/models/invoice/data_presenter.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/invoice/data_presenter.rb b/app/models/invoice/data_presenter.rb index d318d62fdf1..692c99486bb 100644 --- a/app/models/invoice/data_presenter.rb +++ b/app/models/invoice/data_presenter.rb @@ -72,7 +72,15 @@ def shipment_adjustment # contains limited information about the shipment def shipment - shipment_adjustment.adjustable + shipment_adjustment&.adjustable || null_shipment + end + + def null_shipment + Struct.new( + :amount, + :included_tax_total, + :additional_tax_total, + ).new(0, 0, 0) end def display_shipment_amount_without_taxes