Last active
May 20, 2016 08:44
-
-
Save airspeed/01451d19eca5c3c035fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Vgl. #5711 | |
# date_from - date range start | |
# date_until - date range end | |
# custom_search - flag freeze search dates | |
def vouchers_report( date_from = Date.yesterday , date_until = Date.today, custom_search = false ) | |
date_from = Date.today - 3.days if Date.today.wday == 1 && !custom_search # Montags alle Wochenendebestellungen mit reinbeziehen. | |
product_codes = [ 'CLXPXV01', 'CLXPXV02', 'CLXPXV03', 'CLXPXV04' ] | |
Order.where( :state => :printed.to_s, :created_at => date_from .. date_until ).select{ | w | w.order_items.any?{ | i | product_codes.include?( i.product_code ) } }.map{ | w | [ w.id, ( w.user.email if w.user ), w.created_at.to_date.to_s ] } | |
end | |
# vouchers_report Date.today.beginning_of_month - 1.month, Date.today.beginning_of_month, true | |
# vouchers_report | |
vouchers_report Date.today.beginning_of_month - 1.month, Date.tomorrow, true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment