From c2b82651ee6d5d0a4484fbaf5a9146a0f07101c6 Mon Sep 17 00:00:00 2001 From: drummer83 Date: Fri, 13 Oct 2023 20:51:12 +0200 Subject: [PATCH 1/2] Don't show credit owed when = 0 --- app/views/spree/orders/_totals_footer.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/orders/_totals_footer.html.haml b/app/views/spree/orders/_totals_footer.html.haml index 8cdb778fec..fc9fd2c9e4 100644 --- a/app/views/spree/orders/_totals_footer.html.haml +++ b/app/views/spree/orders/_totals_footer.html.haml @@ -40,7 +40,7 @@ %td.text-right.total.not-paid %h5.not-paid = order.display_outstanding_balance.to_html - - else + - if order.outstanding_balance? && order.outstanding_balance < 0 %tr.total %td.text-right{colspan: "3"} %h5 From c0938d16075ffc956358365175ee7207746bac6d Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Mon, 16 Oct 2023 10:49:42 +1100 Subject: [PATCH 2/2] Simplify view with number helpers --- app/models/order_balance.rb | 2 +- app/views/spree/orders/_totals_footer.html.haml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/order_balance.rb b/app/models/order_balance.rb index 1e09940808..4940bf18c9 100644 --- a/app/models/order_balance.rb +++ b/app/models/order_balance.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class OrderBalance - delegate :zero?, :abs, :to_s, :to_f, :to_d, :<, :>, to: :amount + delegate :negative?, :positive?, :zero?, :abs, :to_s, :to_f, :to_d, :<, :>, to: :amount def initialize(order) @order = order diff --git a/app/views/spree/orders/_totals_footer.html.haml b/app/views/spree/orders/_totals_footer.html.haml index fc9fd2c9e4..7319869eb9 100644 --- a/app/views/spree/orders/_totals_footer.html.haml +++ b/app/views/spree/orders/_totals_footer.html.haml @@ -32,7 +32,7 @@ %td.text-right.total %strong = order.display_payment_total.to_html - - if order.outstanding_balance? && order.outstanding_balance > 0 + - if order.outstanding_balance.positive? %tr.total %td.text-right{colspan: "3"} %h5.not-paid @@ -40,7 +40,7 @@ %td.text-right.total.not-paid %h5.not-paid = order.display_outstanding_balance.to_html - - if order.outstanding_balance? && order.outstanding_balance < 0 + - if order.outstanding_balance.negative? %tr.total %td.text-right{colspan: "3"} %h5 @@ -49,7 +49,7 @@ %h5 = order.display_outstanding_balance.to_html - - if order.total_tax > 0 + - if order.total_tax.positive? #tax %tr#tax-row.total %td.text-right{colspan: "3"}