mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Merge pull request #4415 from lin-d-hop/delivery-report
Update end date on delivery report
This commit is contained in:
@@ -2,7 +2,7 @@ require 'open_food_network/user_balance_calculator'
|
||||
|
||||
module OpenFoodNetwork
|
||||
class OrderCycleManagementReport
|
||||
DEFAULT_DATE_INTERVAL = 1.month
|
||||
DEFAULT_DATE_INTERVAL = { from: -1.month, to: 1.day }.freeze
|
||||
attr_reader :params
|
||||
def initialize(user, params = {}, render_table = false)
|
||||
@params = sanitize_params(params)
|
||||
@@ -137,8 +137,8 @@ module OpenFoodNetwork
|
||||
|
||||
def sanitize_params(params)
|
||||
params[:q] ||= {}
|
||||
params[:q][:completed_at_gt] ||= Time.zone.today - DEFAULT_DATE_INTERVAL
|
||||
params[:q][:completed_at_lt] ||= Time.zone.today
|
||||
params[:q][:completed_at_gt] ||= Time.zone.today + DEFAULT_DATE_INTERVAL[:from]
|
||||
params[:q][:completed_at_lt] ||= Time.zone.today + DEFAULT_DATE_INTERVAL[:to]
|
||||
params
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,8 +27,8 @@ module OpenFoodNetwork
|
||||
|
||||
context "default date range" do
|
||||
it "fetches orders completed in the past month" do
|
||||
o1 = create(:order, completed_at: Time.zone.today - OrderCycleManagementReport::DEFAULT_DATE_INTERVAL - 1.day)
|
||||
o2 = create(:order, completed_at: Time.zone.today - OrderCycleManagementReport::DEFAULT_DATE_INTERVAL + 1.day)
|
||||
o1 = create(:order, completed_at: 1.month.ago - 1.day)
|
||||
o2 = create(:order, completed_at: 1.month.ago + 1.day)
|
||||
expect(subject.orders).to eq([o2])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user