From 948257972e700c4bd33391b19bba03a6a8e7dc17 Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Mon, 2 Dec 2024 12:36:25 +0500 Subject: [PATCH] 13007: only show business name when all customers have one --- app/mailers/producer_mailer.rb | 6 +++++- app/views/producer_mailer/order_cycle_report.html.haml | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/mailers/producer_mailer.rb b/app/mailers/producer_mailer.rb index be341834ba3..7bb7dbccb32 100644 --- a/app/mailers/producer_mailer.rb +++ b/app/mailers/producer_mailer.rb @@ -79,7 +79,11 @@ def tax_total_from_line_items(line_items) def set_customer_data(line_items) return unless @coordinator.show_customer_names_to_suppliers? + @display_business_name = false line_items.map do |line_item| + customer_code = line_item.order.customer.code + @display_business_name = true if customer_code.present? + { sku: line_item.variant.sku, supplier_name: line_item.variant.supplier.name, @@ -87,7 +91,7 @@ def set_customer_data(line_items) quantity: line_item.quantity, first_name: line_item.order.billing_address.first_name, last_name: line_item.order.billing_address.last_name, - business_name: line_item.order.customer.code, + business_name: customer_code, } end.sort_by { |line_item| [line_item[:last_name].downcase, line_item[:first_name].downcase] } end diff --git a/app/views/producer_mailer/order_cycle_report.html.haml b/app/views/producer_mailer/order_cycle_report.html.haml index fa656ead365..645d9c7cd1e 100644 --- a/app/views/producer_mailer/order_cycle_report.html.haml +++ b/app/views/producer_mailer/order_cycle_report.html.haml @@ -81,8 +81,9 @@ = t :first_name %th.text-right = t :last_name - %th.text-right - = t :business_name + - if @display_business_name + %th.text-right + = t :business_name %tbody - @customer_line_items.each do |line_item| %tr @@ -99,8 +100,9 @@ = line_item[:first_name] %td = line_item[:last_name] - %td - = line_item[:business_name] + - if @display_business_name + %td + = line_item[:business_name] %p = t :producer_mail_text_after %p