SHARE
TWEET

Untitled

a guest Jul 20th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def export_orders_promo_info_csv(start_date, end_date)
  2.   # start_date and end_date params should be Date objects
  3.   rows = []
  4.   rows << ["order_number", "status", "sub_total", "total", "discount", "promotion_code"]
  5.   Order::History.where(order_number: /^WO/, finalized_at: start_date..end_date).each do |order|
  6.     row = []
  7.     row << order.order_number
  8.     row << order.status
  9.     row << order.final_sub_total
  10.     row << order.final_total
  11.     row << order.promotion_code_discount
  12.     row << order.promotion_code
  13.     rows << row
  14.   end
  15.   File.write("discount_orders_#{start_date}_#{end_date}.csv", rows.map(&:to_csv).join)
  16. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top