Merge pull request #9442 from jibees/8904-display-fees-name-instead-of-type-on-invoices

Display fees name instead of type on invoices
This commit is contained in:
Maikel
2022-10-10 13:15:01 +11:00
committed by GitHub
8 changed files with 24 additions and 45 deletions

View File

@@ -131,7 +131,7 @@ describe CheckoutHelper, type: :helper do
let(:enterprise_fee) { create(:enterprise_fee, amount: 123) }
let!(:fee_adjustment) {
create(:adjustment, originator: enterprise_fee, adjustable: order,
order: order)
order: order, label: "Enterprise Fee")
}
before do
@@ -145,11 +145,8 @@ describe CheckoutHelper, type: :helper do
adjustments = helper.checkout_adjustments_for(order)
shipping_adjustment = order.shipment_adjustments.first
expect(adjustments).to include shipping_adjustment
admin_fee_summary = adjustments.last
expect(admin_fee_summary.label).to eq I18n.t(:orders_form_admin)
expect(admin_fee_summary.amount).to eq 123
expect(adjustments).to match_array [shipping_adjustment, fee_adjustment]
end
context "tax rate adjustments" do

View File

@@ -64,7 +64,7 @@ module OpenFoodNetwork
describe "making labels" do
let(:variant) { double(:variant, product: double(:product, name: 'Bananas')) }
let(:enterprise_fee) {
double(:enterprise_fee, fee_type: 'packing',
double(:enterprise_fee, name: 'packing name',
enterprise: double(:enterprise, name: 'Ballantyne'))
}
let(:applicator) { EnterpriseFeeApplicator.new enterprise_fee, variant, 'distributor' }
@@ -72,7 +72,7 @@ module OpenFoodNetwork
describe "#line_item_adjustment_label" do
it "makes an adjustment label for a line item" do
expect(applicator.send(:line_item_adjustment_label)).
to eq("Bananas - packing fee by distributor Ballantyne")
to eq("Bananas - packing name fee by distributor Ballantyne")
end
end
@@ -81,7 +81,7 @@ module OpenFoodNetwork
it "makes an adjustment label for an order" do
expect(applicator.send(:order_adjustment_label)).
to eq("Whole order - packing fee by distributor Ballantyne")
to eq("Whole order - packing name fee by distributor Ballantyne")
end
end
end

View File

@@ -215,7 +215,8 @@ describe '
it "displays GST for enterprise fees" do
pending "ii) for legend see picture on PR #9495"
# enterprise fee of $20.00
expect(page).to have_content "Admin & Handling 1 $20.00 $120.00"
expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \
"#{user1.enterprises.first.name} 1 $20.00 (included) $120.00"
end
it "displays the taxes correctly" do
@@ -225,7 +226,8 @@ describe '
expect(page).to have_content "#{Spree::Product.second.name} 3 $250.08 $1,500.45"
expect(page).to have_content "(1g)" # display as
# Enterprise fee
expect(page).to have_content "Admin & Handling 1 $120.00"
expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \
"#{user1.enterprises.first.name} 1 $15.65 (included) $120.00"
# Shipping
expect(page).to have_content "Shipping 1 $9.14 (included) $100.55"
# Order Totals
@@ -257,7 +259,8 @@ describe '
expect(page).to have_content "(1g)" # display as
expect(page).to have_content "3 $500.15 $1,500.45 20.0%"
# Enterprise fee
expect(page).to have_content "Admin & Handling $120.00"
expect(page).to have_content "#{enterprise_fee.name} fee by coordinator " \
"#{user1.enterprises.first.name} $120.00"
# Shipping
expect(page).to have_content "Shipping $100.55 10.0%"
# Tax totals
@@ -357,14 +360,16 @@ describe '
it "displays GST for enterprise fees" do
pending "v) for legend see picture on PR #9495"
# enterprise fee of $24.00
expect(page).to have_content "Admin & Handling 1 $20.00 $120.00"
expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \
"#{user1.enterprises.first.name} 1 $20.00 $120.00"
end
it "displays the taxes correctly" do
# header
expect(page).to have_content "Item Qty GST Price"
# Enterprise fee
expect(page).to have_content "Admin & Handling 1 $120.00"
expect(page).to have_content "Whole order - #{enterprise_fee.name} fee by coordinator " \
"#{user1.enterprises.first.name} 1 $18.00 $120.00"
# Shipping
expect(page).to have_content "Shipping 1 $10.06 $100.55"
# Order Totals
@@ -395,7 +400,8 @@ describe '
expect(page).to have_content "(1g)" # display as
expect(page).to have_content "3 $500.15 $1,500.45 20.0%"
# Enterprise fee
expect(page).to have_content "Admin & Handling $120.00"
expect(page).to have_content "#{enterprise_fee.name} fee by coordinator " \
"#{user1.enterprises.first.name} $120.00"
# Shipping
expect(page).to have_content "Shipping $100.55 10.0%"
# Tax totals

View File

@@ -106,14 +106,14 @@ describe "full-page cart", js: true do
visit main_app.cart_path
end
it "shows admin and handlings row" do
it "shows enterprise fees row row" do
expect(page).to have_selector('#cart-detail')
expect(page).to have_content('Admin & Handling')
expect(page).to have_content("Whole order - #{handling_fee.name} fee by distributor #{order_cycle.coordinator.name}")
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',
expect(page).to have_selector '.order-adjustment .total',
text: with_currency(1.00)
expect(page).to have_selector '.order-total.grand-total', text: with_currency(3.58) # price * 3 + 1
end