-
Notifications
You must be signed in to change notification settings - Fork 11
Admin: Repair Order payment status
annamuth edited this page Mar 3, 2015
·
3 revisions
How to use the Heroku Toolbelt Rails console to find an Order and update its payment status (and the payment status of each item).
- SSH into the remote LO developer instance
- Launch the Rails console for the localorbit-production application
- Enter a series of Ruby statements to find and modify the proper Order data
(We call this machine "lodev" for short.)
- IP Address:
107.170.160.9
- Username:
vagrant
- Password: (see Anna for shared dev password)
To login via SSH, you can either...
-
ssh vagrant@107.170.160.9
from the command-line, if you're familiar with cmd-line ssh tools, or... - Use the Windows app Putty
Once logged in, you should see a prompt like
vagrant@localorbit:~ 2.1.2
] _
heroku run rails console --app localorbit-production
This takes a few moments. Eventually you'll see a prompt like:
Running `rails console` attached to terminal... up, run.6749
Loading production environment (Rails 4.1.6.rc2)
irb(main):001:0>
The commands to find an Order by its order number, and to update payment status to Paid, as well as update its items to Paid:
number = "LO-15-APPLERIDGEFARM-0000139" # Set a variable for the order number
order = Order.find_by_order_number(number) # Find the order in the database
order.payment_status # Shows the current order status; useful for double checking. Does NOT affect order.
order.items.where(payment_status: "refunded").count # Tells you how many items are marked "refunded". Does NOT affect order.
order.items.where(payment_status: "refunded").each do |item| item.update(payment_status: "paid") end # Any items with "refunded" status are now updated to "paid". Affects all matching order items immediately.
order.update(payment_status: "paid") # The order's payment status is now "paid". Affects order immediately.
NOTE: The "#" symbols delineate comments; you may cut-n-paste safely along with the rest of the command, or omit them entirely.
NOTE: The "where" segment on line 3 limits the update to items whose payment status currently "refunded".
See below for a capture of a session updating an Apple Ridge order.
irb(main):001:0> number = "LO-15-APPLERIDGEFARM-0000139"
=> "LO-15-APPLERIDGEFARM-0000139"
irb(main):002:0> order = Order.find_by_order_number(number)
=> #<Order id: 7458, organization_id: 1054, market_id: 18, delivery_id: 4238, order_number: "LO-15-APPLERIDGEFARM-0000139", placed_at: "2015-02-27 12:34:48", invoiced_at: nil, invoice_due_date: nil, delivery_fees: #<BigDecimal:7f9c0331ea10,'0.0',9(18)>, total_cost: #<BigDecimal:7f9c0331e808,'3.5',18(18)>, delivery_address: "1198 Pennel Road", delivery_city: "Saylorsburg", delivery_state: "PA", delivery_zip: "18353", delivery_phone: "610-381-6152", billing_organization_name: "Apple Ridge Farm", billing_address: "1198 Pennel Road", billing_city: "Saylorsburg", billing_state: "PA", billing_zip: "18353", billing_phone: "610-381-6152", payment_status: "refunded", payment_method: "credit card", payment_note: nil, notes: "", created_at: "2015-02-27 12:34:49", updated_at: "2015-03-02 14:09:18", placed_by_id: 1029, paid_at: "2015-02-27 12:34:53", legacy_id: nil, deleted_at: nil, discount_id: nil, delivery_status: "delivered", invoice_pdf_uid: nil, invoice_pdf_name: nil>
irb(main):003:0> order.payment_status
=> "refunded"
irb(main):004:0> order.items.where(payment_status: "refunded").count
=> 4
irb(main):005:0> order.items.where(payment_status: "refunded").each do |item| item.update(payment_status: "paid") end
=> [#<OrderItem id: 39188, order_id: 7458, product_id: 8480, name: "Yogurt Smoothie- Strawberry", seller_name: "Ironstone Creamery & Farm", quantity: 1, unit: "Pint", discount_seller: #<BigDecimal:7f9c03393950,'0.0',9(18)>, market_seller_fee: #<BigDecimal:7f9c03393680,'0.35',9(18)>, local_orbit_seller_fee: #<BigDecimal:7f9c03393450,'0.14',9(18)>, local_orbit_market_fee: #<BigDecimal:7f9c033930e0,'0.0',9(18)>, payment_seller_fee: #<BigDecimal:7f9c03392d48,'0.11',9(18)>, payment_market_fee: #<BigDecimal:7f9c03392a00,'0.0',9(18)>, unit_price: #<BigDecimal:7f9c012d0538,'3.5',18(18)>, created_at: "2015-02-27 12:34:49", updated_at: "2015-03-02 22:22:23", delivery_status: "delivered", delivered_at: "2015-03-01 14:41:23", legacy_id: nil, quantity_delivered: #<BigDecimal:7f9c012d0830,'1.0',9(18)>, payment_status: "paid", discount_market: #<BigDecimal:7f9c033905c0,'0.0',9(18)>>, #<OrderItem id: 39187, order_id: 7458, product_id: 8402, name: "Clover Fromage Blanc", seller_name: "Valley Milkhouse", quantity: 1, unit: "Each, 6 ounce log", discount_seller: #<BigDecimal:7f9c02df3e00,'0.0',9(18)>, market_seller_fee: #<BigDecimal:7f9c02df3b30,'0.0',9(18)>, local_orbit_seller_fee: #<BigDecimal:7f9c02df3888,'0.0',9(18)>, local_orbit_market_fee: #<BigDecimal:7f9c02df35b8,'0.0',9(18)>, payment_seller_fee: #<BigDecimal:7f9c02df3248,'0.0',9(18)>, payment_market_fee: #<BigDecimal:7f9c02df2d70,'0.0',9(18)>, unit_price: #<BigDecimal:7f9c038b28a0,'7.0',9(18)>, created_at: "2015-02-27 12:34:49", updated_at: "2015-03-02 22:22:23", delivery_status: "canceled", delivered_at: nil, legacy_id: nil, quantity_delivered: #<BigDecimal:7f9c038b2dc8,'0.0',9(18)>, payment_status: "paid", discount_market: #<BigDecimal:7f9c02df0908,'0.0',9(18)>>, #<OrderItem id: 39186, order_id: 7458, product_id: 8407, name: "Grass-Fed Cultured Butter", seller_name: "Valley Milkhouse", quantity: 1, unit: "Block, 6 ounce block", discount_seller: #<BigDecimal:7f9c02debbd8,'0.0',9(18)>, market_seller_fee: #<BigDecimal:7f9c02deb958,'0.0',9(18)>, local_orbit_seller_fee: #<BigDecimal:7f9c02deb688,'0.0',9(18)>, local_orbit_market_fee: #<BigDecimal:7f9c02deb430,'0.0',9(18)>, payment_seller_fee: #<BigDecimal:7f9c02deb0c0,'0.0',9(18)>, payment_market_fee: #<BigDecimal:7f9c02deacd8,'0.0',9(18)>, unit_price: #<BigDecimal:7f9c0371f6f0,'5.0',9(18)>, created_at: "2015-02-27 12:34:49", updated_at: "2015-03-02 22:22:23", delivery_status: "canceled", delivered_at: nil, legacy_id: nil, quantity_delivered: #<BigDecimal:7f9c0371fb50,'0.0',9(18)>, payment_status: "paid", discount_market: #<BigDecimal:7f9c02de99c8,'0.0',9(18)>>, #<OrderItem id: 39185, order_id: 7458, product_id: 8409, name: "Yogurt", seller_name: "Valley Milkhouse", quantity: 1, unit: "Quart, 1 glass quart jar", discount_seller: #<BigDecimal:7f9c02de9130,'0.0',9(18)>, market_seller_fee: #<BigDecimal:7f9c02de8e38,'0.0',9(18)>, local_orbit_seller_fee: #<BigDecimal:7f9c02de8b68,'0.0',9(18)>, local_orbit_market_fee: #<BigDecimal:7f9c02de8848,'0.0',9(18)>, payment_seller_fee: #<BigDecimal:7f9c02de8528,'0.0',9(18)>, payment_market_fee: #<BigDecimal:7f9c02de82a8,'0.0',9(18)>, unit_price: #<BigDecimal:7f9c034afd98,'6.0',9(18)>, created_at: "2015-02-27 12:34:49", updated_at: "2015-03-02 22:22:23", delivery_status: "canceled", delivered_at: nil, legacy_id: nil, quantity_delivered: #<BigDecimal:7f9c034b42d0,'0.0',9(18)>, payment_status: "paid", discount_market: #<BigDecimal:7f9c02de28f8,'0.0',9(18)>>]
irb(main):006:0> order.items.where(payment_status: "refunded").count
=> 0
irb(main):007:0> order.update(payment_status: "refunded")
=> true