Last active
July 8, 2019 22:47
-
-
Save adamrunner/760d8aa323c6198ad11e2680397a5ba6 to your computer and use it in GitHub Desktop.
Exports some order and promotion data to a CSV
This file contains hidden or 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
def export_orders_promo_info_csv(start_date, end_date) | |
# start_date and end_date params should be Date objects | |
rows = [] | |
rows << ["order_number", "status", "sub_total", "total", "discount", "promotion_code"] | |
Order::History.where(order_number: /^WO/, finalized_at: start_date..end_date).each do |order| | |
row = [] | |
row << order.order_number | |
row << order.status | |
row << order.final_sub_total | |
row << order.final_total | |
row << order.promotion_code_discount | |
row << order.promotion_code | |
rows << row | |
end | |
File.write("discount_orders_#{start_date}_#{end_date}.csv", rows.map(&:to_csv).join) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment