mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add failing spec for payment fee calculation in customer totals report
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
require "spec_helper"
|
||||
require 'open_food_network/orders_and_fulfillments_report'
|
||||
require 'open_food_network/orders_and_fulfillments_report/customer_totals_report'
|
||||
require 'open_food_network/order_grouper'
|
||||
|
||||
RSpec.describe OpenFoodNetwork::OrdersAndFulfillmentsReport::CustomerTotalsReport do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
@@ -79,6 +81,28 @@ RSpec.describe OpenFoodNetwork::OrdersAndFulfillmentsReport::CustomerTotalsRepor
|
||||
end
|
||||
end
|
||||
|
||||
context "displaying payment fees" do
|
||||
context "with both failed and completed payments present" do
|
||||
let!(:order) {
|
||||
create(:order_ready_to_ship, user: customer.user,
|
||||
customer: customer, distributor: distributor)
|
||||
}
|
||||
let(:completed_payment) { order.payments.completed.first }
|
||||
let!(:failed_payment) { create(:payment, order: order, state: "failed") }
|
||||
|
||||
before do
|
||||
completed_payment.adjustment.update amount: 123.00
|
||||
failed_payment.adjustment.update amount: 456.00, eligible: false, state: "finalized"
|
||||
end
|
||||
|
||||
xit "shows the correct payment fee amount for the order" do
|
||||
# Fails; the sum of adjustments for both failed and complete payments is shown
|
||||
payment_fee_field = report_table.last[12]
|
||||
expect(payment_fee_field).to eq completed_payment.adjustment.amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a variant override applies' do
|
||||
let!(:order) do
|
||||
create(:completed_order_with_totals, line_items_count: 1, user: customer.user,
|
||||
|
||||
Reference in New Issue
Block a user