Skip to content

Commit

Permalink
New varaints should inherit tax category in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
vishaldeepak committed Jan 10, 2025
1 parent 5fdd0e5 commit d381ceb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/helpers/admin/products_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions spec/helpers/admin/products_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d381ceb

Please sign in to comment.