mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #11798 from cillian/conditional-supplier-column-in-order-cycle-report
Only display Supplier column in Order Cycle Report email if there is more than one supplier
This commit is contained in:
@@ -20,8 +20,9 @@
|
||||
%tr
|
||||
%th
|
||||
= t :sku
|
||||
%th
|
||||
= t :supplier
|
||||
- if @distributors_pickup_times.many?
|
||||
%th
|
||||
= t :supplier
|
||||
%th
|
||||
= t :product
|
||||
%th.text-right
|
||||
@@ -37,8 +38,9 @@
|
||||
%tr
|
||||
%td
|
||||
#{line_items.first.variant.sku}
|
||||
%td
|
||||
#{raw(line_items.first.product.supplier.name)}
|
||||
- if @distributors_pickup_times.many?
|
||||
%td
|
||||
#{raw(line_items.first.product.supplier.name)}
|
||||
%td
|
||||
#{raw(product_and_full_name)}
|
||||
%td.text-right
|
||||
@@ -51,7 +53,8 @@
|
||||
#{Spree::Money.new(line_items.sum(&:included_tax), currency: line_items.first.currency) }
|
||||
%tr.total-row
|
||||
%td
|
||||
%td
|
||||
- if @distributors_pickup_times.many?
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
@@ -67,8 +70,9 @@
|
||||
%tr
|
||||
%th
|
||||
= t :sku
|
||||
%th
|
||||
= t :supplier
|
||||
- if @distributors_pickup_times.many?
|
||||
%th
|
||||
= t :supplier
|
||||
%th
|
||||
= t :product
|
||||
%th.text-right
|
||||
@@ -82,8 +86,9 @@
|
||||
%tr
|
||||
%td
|
||||
#{line_item[:sku]}
|
||||
%td
|
||||
#{raw(line_item[:supplier_name])}
|
||||
- if @distributors_pickup_times.many?
|
||||
%td
|
||||
#{raw(line_item[:supplier_name])}
|
||||
%td
|
||||
#{raw(line_item[:product_and_full_name])}
|
||||
%td.text-right
|
||||
|
||||
@@ -185,6 +185,49 @@ describe ProducerMailer, type: :mailer do
|
||||
end
|
||||
end
|
||||
|
||||
context "products from multiple suppliers" do
|
||||
before do
|
||||
order_cycle.exchanges.create! sender: s1, receiver: d2, incoming: true,
|
||||
receival_instructions: 'Community hall'
|
||||
order_cycle.exchanges.create! sender: d2, receiver: d2, incoming: false,
|
||||
pickup_time: 'Mon, 22nd Dec'
|
||||
order = create(:order, distributor: d2, order_cycle:, state: 'complete')
|
||||
order.line_items << create(:line_item, quantity: 3, variant: p1.variants.first)
|
||||
order.finalize!
|
||||
order.save
|
||||
end
|
||||
|
||||
it "displays a supplier column" do
|
||||
expect(body_as_html(mail).find(".order-summary"))
|
||||
.to have_selector("th", text: "Supplier")
|
||||
end
|
||||
|
||||
context "when the show customer names to suppliers setting is enabled" do
|
||||
before { order_cycle.coordinator.update!(show_customer_names_to_suppliers: true) }
|
||||
|
||||
it "displays a supplier column in the summary of orders grouped by customer" do
|
||||
expect(body_as_html(mail).find(".customer-order"))
|
||||
.to have_selector("th", text: "Supplier")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "products from only one supplier" do
|
||||
it "doesn't display a supplier column" do
|
||||
expect(body_as_html(mail).find(".order-summary"))
|
||||
.to have_no_selector("th", text: "Supplier")
|
||||
end
|
||||
|
||||
context "when the show customer names to suppliers setting is enabled" do
|
||||
before { order_cycle.coordinator.update!(show_customer_names_to_suppliers: true) }
|
||||
|
||||
it "doesn't display a supplier column in the summary of orders grouped by customer" do
|
||||
expect(body_as_html(mail).find(".customer-order"))
|
||||
.to have_no_selector("th", text: "Supplier")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def body_lines_including(mail, str)
|
||||
|
||||
Reference in New Issue
Block a user