mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
13007: only show business name when all customers have one
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user