13007: only show business name when all customers have one

This commit is contained in:
Ahmed Ejaz
2024-12-02 12:36:25 +05:00
parent 302336ab02
commit 626a269cf8
2 changed files with 11 additions and 5 deletions

View File

@@ -79,7 +79,11 @@ class ProducerMailer < ApplicationMailer
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 @@ class ProducerMailer < ApplicationMailer
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

View File

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