mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-10 03:30:22 +00:00
Merge pull request #7177 from coopdevs/fix-balances-order-cycle-report-regression
Fix balances order cycle report regression
This commit is contained in:
@@ -30,8 +30,8 @@ class OutstandingBalance
|
||||
# a little longer. See https://github.com/rails/arel/pull/400 for details.
|
||||
def statement
|
||||
<<-SQL.strip_heredoc
|
||||
CASE WHEN state IN #{non_fulfilled_states_group.to_sql} THEN payment_total
|
||||
WHEN state IS NOT NULL THEN payment_total - total
|
||||
CASE WHEN "spree_orders"."state" IN #{non_fulfilled_states_group.to_sql} THEN "spree_orders"."payment_total"
|
||||
WHEN "spree_orders"."state" IS NOT NULL THEN "spree_orders"."payment_total" - "spree_orders"."total"
|
||||
ELSE 0 END
|
||||
SQL
|
||||
end
|
||||
|
||||
@@ -291,6 +291,30 @@ describe Spree::Admin::ReportsController, type: :controller do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'Order Cycle Management' do
|
||||
let!(:present_objects) { [orderA1, orderA2, orderB1, orderB2] }
|
||||
|
||||
context 'when the customer_balance feature is enabled' do
|
||||
before do
|
||||
allow(OpenFoodNetwork::FeatureToggle)
|
||||
.to receive(:enabled?).with(:customer_balance, kind_of(Spree::User)) { true }
|
||||
|
||||
controller_login_as_enterprise_user [coordinator1]
|
||||
end
|
||||
|
||||
it 'renders the delivery report' do
|
||||
spree_post :order_cycle_management, {
|
||||
q: { completed_at_lt: 1.day.ago },
|
||||
shipping_method_in: [ "123" ], # We just need to search for shipping methods
|
||||
report_type: "delivery",
|
||||
}
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Admin" do
|
||||
before { controller_login_as_admin }
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ describe OutstandingBalance do
|
||||
normalized_sql_statement = normalize(outstanding_balance.statement)
|
||||
|
||||
expect(normalized_sql_statement).to eq(normalize(<<-SQL))
|
||||
CASE WHEN state IN ('canceled', 'returned') THEN payment_total
|
||||
WHEN state IS NOT NULL THEN payment_total - total
|
||||
CASE WHEN "spree_orders"."state" IN ('canceled', 'returned') THEN "spree_orders"."payment_total"
|
||||
WHEN "spree_orders"."state" IS NOT NULL THEN "spree_orders"."payment_total" - "spree_orders"."total"
|
||||
ELSE 0 END
|
||||
SQL
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user