mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #9990 from abdellani/get_producer_and_product_taxt_status_in_OCSTR
add producer and product tax category tax status to the OCSTs report
This commit is contained in:
@@ -2832,6 +2832,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
report_header_customer_code: Customer Code
|
||||
report_header_product: Product
|
||||
report_header_product_properties: Product Properties
|
||||
report_header_product_tax_category: Product Tax Category
|
||||
report_header_quantity: Quantity
|
||||
report_header_max_quantity: Max Quantity
|
||||
report_header_variant: Variant
|
||||
@@ -2844,6 +2845,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
report_header_supplier: Supplier
|
||||
report_header_producer: Producer
|
||||
report_header_producer_suburb: Producer Suburb
|
||||
report_header_producer_charges_sales_tax?: GST/VAT Registered
|
||||
report_header_unit: Unit
|
||||
report_header_group_buy_unit_quantity: Group Buy Unit Quantity
|
||||
report_header_cost: Cost
|
||||
|
||||
@@ -74,7 +74,7 @@ module Reporting
|
||||
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
def format_cell(value, column = nil)
|
||||
return "" if value.nil?
|
||||
return "none" if value.nil?
|
||||
|
||||
# Currency
|
||||
if report.columns_format[column] == :currency
|
||||
|
||||
@@ -10,6 +10,7 @@ module Reporting
|
||||
|
||||
def default_params
|
||||
{
|
||||
fields_to_hide: [:producer_charges_sales_tax?, :product_tax_category],
|
||||
q: {
|
||||
completed_at_gt: 1.month.ago.beginning_of_day,
|
||||
completed_at_lt: 1.day.from_now.beginning_of_day
|
||||
@@ -51,10 +52,18 @@ module Reporting
|
||||
proc { |line_items| line_items.first.variant.product.supplier.name }
|
||||
end
|
||||
|
||||
def supplier_charges_sales_tax?
|
||||
proc { |line_items| line_items.first.variant.product.supplier.charges_sales_tax }
|
||||
end
|
||||
|
||||
def product_name
|
||||
proc { |line_items| line_items.first.variant.product.name }
|
||||
end
|
||||
|
||||
def product_tax_category
|
||||
proc { |line_items| line_items.first.variant.product.tax_category&.name }
|
||||
end
|
||||
|
||||
def hub_name
|
||||
proc { |line_items| line_items.first.order.distributor.name }
|
||||
end
|
||||
|
||||
@@ -13,7 +13,9 @@ module Reporting
|
||||
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) },
|
||||
sku: variant_sku
|
||||
sku: variant_sku,
|
||||
producer_charges_sales_tax?: supplier_charges_sales_tax?,
|
||||
product_tax_category: product_tax_category
|
||||
}
|
||||
end
|
||||
|
||||
@@ -44,7 +46,11 @@ module Reporting
|
||||
end
|
||||
|
||||
def default_params
|
||||
super.merge({ fields_to_hide: ["sku"] })
|
||||
super.merge({ fields_to_hide: [
|
||||
:sku,
|
||||
:producer_charges_sales_tax?,
|
||||
:product_tax_category
|
||||
] })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
Hub,Customer,Email,Phone,Producer,Product,Variant,Quantity,Item ($),Item + Fees ($),Admin & Handling ($),Ship ($),Pay fee ($),Total ($),Paid?,Shipping,Delivery?,Ship Street,Ship Street 2,Ship City,Ship Postcode,Ship State,Comments,SKU,Order Cycle,Payment Method,Customer Code,Tags,Billing Street,Billing Street 2,Billing City,Billing Postcode,Billing State,Order number,Date
|
||||
Apple Market,John Doe,john@example.net,123-456-7890,Apple Farmer,Apples,"1g, S",1,10.0,10.0,"","","","",No,UPS Ground,Yes,10 Lovely Street,Northwest,Herndon,20170,Victoria,"",APP,"","",JHN,"",10 Lovely Street,Northwest,Herndon,20170,Victoria,R644360121,2022-05-26 00:00:00
|
||||
Apple Market,John Doe,"","","","","",TOTAL,10.0,10.0,0,0.0,0,10.0,No,"","","","","","","","","","","","","","","","","","",R644360121,2022-05-26 00:00:00
|
||||
Apple Market,John Doe,john@example.net,123-456-7890,Apple Farmer,Apples,"1g, S",1,10.0,10.0,"","","","",false,UPS Ground,true,10 Lovely Street,Northwest,Herndon,20170,Victoria,"",APP,,,JHN,"",10 Lovely Street,Northwest,Herndon,20170,Victoria,R644360121,2022-05-26 00:00:00
|
||||
|
||||
|
@@ -41,10 +41,14 @@ describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotals do
|
||||
"spec/fixtures/reports/orders_and_fulfillment/order_cycle_customer_totals_report.csv"
|
||||
end
|
||||
|
||||
it "generates the report" do
|
||||
expect(report_table.length).to eq(2)
|
||||
context 'csv format' do
|
||||
let(:params) { { report_format: 'csv', display_summary_row: false, q: search_params } }
|
||||
|
||||
expect(report.render_as(:csv)).to eq comparison_report
|
||||
it "generates the report" do
|
||||
expect(report_table.length).to eq(1)
|
||||
|
||||
expect(report.render_as(:csv)).to eq comparison_report
|
||||
end
|
||||
end
|
||||
|
||||
it "has a line item row" do
|
||||
|
||||
@@ -11,7 +11,9 @@ module Reporting
|
||||
let!(:order) do
|
||||
create(:completed_order_with_totals, line_items_count: 1, distributor: distributor)
|
||||
end
|
||||
|
||||
let!(:supplier) do
|
||||
order.line_items.first.variant.product.supplier
|
||||
end
|
||||
let(:current_user) { distributor.owner }
|
||||
let(:params) { { display_summary_row: false } }
|
||||
let(:report) do
|
||||
@@ -29,17 +31,67 @@ module Reporting
|
||||
it "generates the report" do
|
||||
expect(report_table.length).to eq(1)
|
||||
end
|
||||
context "with a VAT/GST-free supplier" do
|
||||
before(:each) do
|
||||
supplier.update(charges_sales_tax: false)
|
||||
end
|
||||
|
||||
it "has a variant row" do
|
||||
supplier = order.line_items.first.variant.product.supplier
|
||||
supplier_name_field = report_table.first[0]
|
||||
expect(supplier_name_field).to eq supplier.name
|
||||
it "has a variant row when product belongs to a tax category" do
|
||||
product_tax_category_name = order.line_items.first.variant.product.tax_category.name
|
||||
|
||||
supplier_name_field = report_table.first[0]
|
||||
supplier_vat_status_field = report_table.first[-2]
|
||||
product_tax_category_field = report_table.first[-1]
|
||||
|
||||
expect(supplier_name_field).to eq supplier.name
|
||||
expect(supplier_vat_status_field).to eq "No"
|
||||
expect(product_tax_category_field).to eq product_tax_category_name
|
||||
end
|
||||
|
||||
it "has a variant row when product doesn't belong to a tax category" do
|
||||
order.line_items.first.variant.product.update(tax_category_id: nil)
|
||||
supplier_name_field = report_table.first[0]
|
||||
supplier_vat_status_field = report_table.first[-2]
|
||||
product_tax_category_field = report_table.first[-1]
|
||||
|
||||
expect(supplier_name_field).to eq supplier.name
|
||||
expect(supplier_vat_status_field).to eq "No"
|
||||
expect(product_tax_category_field).to eq "none"
|
||||
end
|
||||
end
|
||||
context "with a VAT/GST-enabled supplier" do
|
||||
before(:each) do
|
||||
supplier.update(charges_sales_tax: true)
|
||||
end
|
||||
|
||||
it "has a variant row when product belongs to a tax category" do
|
||||
product_tax_category_name = order.line_items.first.variant.product.tax_category.name
|
||||
|
||||
supplier_name_field = report_table.first[0]
|
||||
supplier_vat_status_field = report_table.first[-2]
|
||||
product_tax_category_field = report_table.first[-1]
|
||||
|
||||
expect(supplier_name_field).to eq supplier.name
|
||||
expect(supplier_vat_status_field).to eq "Yes"
|
||||
expect(product_tax_category_field).to eq product_tax_category_name
|
||||
end
|
||||
|
||||
it "has a variant row when product doesn't belong to a tax category" do
|
||||
order.line_items.first.variant.product.update(tax_category_id: nil)
|
||||
supplier_name_field = report_table.first[0]
|
||||
supplier_vat_status_field = report_table.first[-2]
|
||||
product_tax_category_field = report_table.first[-1]
|
||||
|
||||
expect(supplier_name_field).to eq supplier.name
|
||||
expect(supplier_vat_status_field).to eq "Yes"
|
||||
expect(product_tax_category_field).to eq "none"
|
||||
end
|
||||
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
|
||||
last_column_title = table_headers[-3]
|
||||
first_row_last_column_value = report_table.first[-3]
|
||||
|
||||
expect(last_column_title).to eq "SKU"
|
||||
expect(first_row_last_column_value).to eq variant_sku
|
||||
|
||||
@@ -52,12 +52,12 @@ describe "Revenues By Hub Reports" do
|
||||
expect(page.find("table.report__table tbody tr").text).to have_content([
|
||||
"Hub 1",
|
||||
order.distributor.id,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"none",
|
||||
"none",
|
||||
"none",
|
||||
"none",
|
||||
"email@email.com",
|
||||
nil,
|
||||
"none",
|
||||
"10 Lovely Street",
|
||||
nil,
|
||||
"Northwest Herndon",
|
||||
|
||||
@@ -308,17 +308,17 @@ describe '
|
||||
"Product Name",
|
||||
product1.properties.map(&:presentation).join(", "),
|
||||
product1.primary_taxon.name, "Test", "100.0",
|
||||
product1.group_buy_unit_size.to_s, "", "sku1"]
|
||||
"none", "", "sku1"]
|
||||
expect(page).to have_table_row [product1.supplier.name, product1.supplier.address.city,
|
||||
"Product Name",
|
||||
product1.properties.map(&:presentation).join(", "),
|
||||
product1.primary_taxon.name, "Something", "80.0",
|
||||
product1.group_buy_unit_size.to_s, "", "sku2"]
|
||||
"none", "", "sku2"]
|
||||
expect(page).to have_table_row [product2.supplier.name, product1.supplier.address.city,
|
||||
"Product 2",
|
||||
product1.properties.map(&:presentation).join(", "),
|
||||
product2.primary_taxon.name, "100g", "99.0",
|
||||
product1.group_buy_unit_size.to_s, "", "product_sku"]
|
||||
"none", "", "product_sku"]
|
||||
end
|
||||
|
||||
it "shows the LettuceShare report" do
|
||||
|
||||
Reference in New Issue
Block a user