From 0887f0676f97c7393c0dd6ebf8a17d4bccc22fce Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Thu, 4 Apr 2024 06:06:23 +0500 Subject: [PATCH 1/2] 12294 - Fix Wrong Tax Category Display - Only display the tax_category name if the tax_category_id is present - tax_category is overriden in the variant model - if tax category is not present, then return the default tax category --- app/views/admin/products_v3/_variant_row.html.haml | 2 +- config/locales/en.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/admin/products_v3/_variant_row.html.haml b/app/views/admin/products_v3/_variant_row.html.haml index 77af4ee424..97646ec1ba 100644 --- a/app/views/admin/products_v3/_variant_row.html.haml +++ b/app/views/admin/products_v3/_variant_row.html.haml @@ -44,7 +44,7 @@ %td.align-left .content= variant.primary_taxon&.name %td.align-left - .content= variant.tax_category&.name || "None" # TODO: convert to dropdown, else translate hardcoded string. + .content= (variant.tax_category_id ? variant.tax_category&.name : t('.none_tax_category')) # TODO: convert to dropdown %td.align-left -# empty %td.align-right diff --git a/config/locales/en.yml b/config/locales/en.yml index efb8d01f37..b19ece15c6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -897,6 +897,8 @@ en: delete_variant: success: Successfully deleted the variant error: Unable to delete the variant + variant_row: + none_tax_category: None product_import: title: Product Import file_not_found: File not found or could not be opened From 870e2b447c67ad833c1119ed75a66ee1daecbe77 Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Fri, 5 Apr 2024 23:49:52 +0500 Subject: [PATCH 2/2] 12294 - add specs - display none if no tax category is selected - add a tax_category_column css selector for future related specs --- spec/system/admin/products_v3/products_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index df24a79483..1756230ef1 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -485,6 +485,7 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do expect(new_variant.price).to eq 10.25 expect(new_variant.unit_value).to eq 1000 expect(new_variant.on_hand).to eq 3 + expect(new_variant.tax_category_id).to be_nil within row_containing_name("Large box") do expect(page).to have_field "Name", with: "Large box" @@ -492,6 +493,9 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do expect(page).to have_field "Price", with: "10.25" expect(page).to have_content "1kg" expect(page).to have_button "On Hand", text: "3" + within tax_category_column do + expect(page).to have_content "None" + end end end @@ -962,4 +966,8 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do def expect_page_to_have_image(url) expect(page).to have_selector("img[src$='#{url}']") end + + def tax_category_column + @tax_category_column ||= 'td:nth-child(10)' + end end