Merge pull request #13068 from vishaldeepak/variant-with-tax

New variants should inherit tax category in UI
This commit is contained in:
Filipe
2025-01-17 10:57:22 -06:00
committed by GitHub
2 changed files with 16 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ module Admin
# 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

View File

@@ -46,4 +46,19 @@ RSpec.describe Admin::ProductsHelper do
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