mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #13068 from vishaldeepak/variant-with-tax
New variants should inherit tax category in UI
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user