Skip to content

Commit

Permalink
13007: only show business name when all customers have one
Browse files Browse the repository at this point in the history
  • Loading branch information
chahmedejaz committed Dec 2, 2024
1 parent addd107 commit 9482579
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/mailers/producer_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,19 @@ 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,
product_and_full_name: line_item.product_and_full_name,
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
Expand Down
10 changes: 6 additions & 4 deletions app/views/producer_mailer/order_cycle_report.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9482579

Please sign in to comment.