Merge pull request #10040 from abdellani/add_variant_sku_to_ocst_report

add variant sku to the OCST report
This commit is contained in:
Konrad
2022-11-27 21:28:07 +01:00
committed by GitHub
3 changed files with 23 additions and 1 deletions

View File

@@ -43,6 +43,10 @@ module Reporting
proc { |line_items| line_items.first.variant.full_name }
end
def variant_sku
proc { |line_items| line_items.first.variant.sku }
end
def supplier_name
proc { |line_items| line_items.first.variant.product.supplier.name }
end

View File

@@ -12,7 +12,8 @@ module Reporting
quantity: proc { |line_items| line_items.sum(&:quantity) },
total_units: proc { |line_items| total_units(line_items) },
curr_cost_per_unit: proc { |line_items| line_items.first.price },
total_cost: proc { |line_items| line_items.sum(&:amount) }
total_cost: proc { |line_items| line_items.sum(&:amount) },
sku: variant_sku
}
end
@@ -41,6 +42,10 @@ module Reporting
[e.variant_id, e.price]
}.values
end
def default_params
super.merge({ fields_to_hide: ["sku"] })
end
end
end
end

View File

@@ -18,6 +18,10 @@ module Reporting
OrderCycleSupplierTotals.new(current_user, params)
end
let(:table_headers) do
report.table_headers
end
let(:report_table) do
report.table_rows
end
@@ -31,6 +35,15 @@ module Reporting
supplier_name_field = report_table.first[0]
expect(supplier_name_field).to eq supplier.name
end
it "includes sku column" do
variant_sku = order.line_items.first.variant.sku
last_column_title = table_headers.last
first_row_last_column_value = report_table.first.last
expect(last_column_title).to eq "SKU"
expect(first_row_last_column_value).to eq variant_sku
end
end
end
end