diff --git a/app/helpers/admin/products_helper.rb b/app/helpers/admin/products_helper.rb index ea18887e04d..b2f7beada98 100644 --- a/app/helpers/admin/products_helper.rb +++ b/app/helpers/admin/products_helper.rb @@ -14,6 +14,7 @@ def prepare_new_variant(product, producer_options) # e.g producer_options = [['producer name', id]] product.variants.build do |new_variant| new_variant.supplier_id = producer_options.first.second if producer_options.one? + new_variant.tax_category_id = product.variants.first.tax_category_id end end diff --git a/spec/helpers/admin/products_helper_spec.rb b/spec/helpers/admin/products_helper_spec.rb index cfd04180d99..d0583488af2 100644 --- a/spec/helpers/admin/products_helper_spec.rb +++ b/spec/helpers/admin/products_helper_spec.rb @@ -46,4 +46,19 @@ end end end + + describe '#prepare_new_variant' do + let(:zone) { create(:zone_with_member) } + let(:product) { + create(:taxed_product, zone:, price: 12.54, tax_rate_amount: 0, + included_in_price: true) + } + + context 'when tax category is present for first varient' do + it 'sets tax category for new variant' do + first_variant_tax_id = product.variants.first.tax_category_id + expect(helper.prepare_new_variant(product, []).tax_category_id).to eq(first_variant_tax_id) + end + end + end end