mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #2079 from mjal/424cart-page-shouldnt-show-admin-handling-if-it-is-zero
Cart page shouldnt show admin handling if it is zero
This commit is contained in:
@@ -35,13 +35,13 @@
|
||||
%td.text-right
|
||||
%span.order-total.item-total= display_checkout_subtotal(@order)
|
||||
%td
|
||||
|
||||
%tr
|
||||
%td.text-right{colspan:"3"}
|
||||
= t :orders_form_admin
|
||||
%td.text-right
|
||||
%span.order-total.distribution-total= display_checkout_admin_and_handling_adjustments_total_for(@order)
|
||||
%td
|
||||
-if display_checkout_admin_and_handling_adjustments_total_for(@order) != Spree::Money.new(0 , currency: @order.currency)
|
||||
%tr
|
||||
%td.text-right{colspan:"3"}
|
||||
= t :orders_form_admin
|
||||
%td.text-right
|
||||
%span.order-total.distribution-total= display_checkout_admin_and_handling_adjustments_total_for(@order)
|
||||
%td
|
||||
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item, :admin_and_handling]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
|
||||
%tr.order-adjustment
|
||||
|
||||
@@ -28,7 +28,7 @@ feature "full-page cart", js: true do
|
||||
end
|
||||
end
|
||||
|
||||
describe "fees" do
|
||||
describe "percentage fees" do
|
||||
let(:percentage_fee) { create(:enterprise_fee, calculator: Calculator::FlatPercentPerItem.new(preferred_flat_percent: 20)) }
|
||||
|
||||
before do
|
||||
@@ -47,6 +47,42 @@ feature "full-page cart", js: true do
|
||||
end
|
||||
end
|
||||
|
||||
describe "admin and handling flat fees" do
|
||||
context 'when there are fees' do
|
||||
let(:handling_fee) { create(:enterprise_fee, calculator: Spree::Calculator::FlatRate.new(preferred_amount: 1),
|
||||
enterprise: order_cycle.coordinator, fee_type: 'admin') }
|
||||
|
||||
before do
|
||||
add_enterprise_fee handling_fee
|
||||
add_product_to_cart order, product_fee, quantity: 3
|
||||
visit spree.cart_path
|
||||
end
|
||||
|
||||
it 'shows admin and handlings row' do
|
||||
expect(page).to have_selector('#cart-detail')
|
||||
expect(page).to have_content('Admin & Handling')
|
||||
expect(page).to have_selector '.cart-item-price', text: with_currency(0.86)
|
||||
expect(page).to have_selector '.order-total.item-total', text: with_currency(2.58)
|
||||
expect(page).to have_selector '.order-total.distribution-total', text: with_currency(1.00)
|
||||
expect(page).to have_selector '.order-total.grand-total', text: with_currency(3.58) # price * 3 + 1
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are no admin and handling fees' do
|
||||
before do
|
||||
add_product_to_cart order, product_fee, quantity: 2
|
||||
visit spree.cart_path
|
||||
end
|
||||
|
||||
it 'hides admin and handlings row' do
|
||||
expect(page).to have_selector('#cart-detail')
|
||||
expect(page).to_not have_content('Admin & Handling')
|
||||
expect(page).to have_selector '.cart-item-price', text: with_currency(0.86)
|
||||
expect(page).to have_selector '.order-total.grand-total', text: with_currency(1.72) # price * 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "tax" do
|
||||
before do
|
||||
add_enterprise_fee enterprise_fee
|
||||
|
||||
Reference in New Issue
Block a user