Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placing order goes to 'Page not found' error screen due to inaccurate 'expires on' inventory lot addition #3458

Closed
rbarreca opened this issue Sep 4, 2018 · 1 comment
Assignees

Comments

@rbarreca
Copy link
Contributor

rbarreca commented Sep 4, 2018

Unvetted Repro!
In this example, when trying to place an order on Sep 3 for 3 units to be delivered on Sep 7, clicking Place Order takes you to 404 page. If you type in a high number for quantity on /cart an error message tells you there are only 14 available which is correct. In debugging this issue, it's likely that the cart code is looking at the order date vs. delivery date to determine what lot inventory is available and thinking there is only 2. There should be 14 in inventory as Sep 7 would include the lot of 12 as well as the 2 undated units.

  1. Log in as alice_at_ohiovalleyfoodconnection.com@example.com
  2. Add 17 LARGE 15 DZ- 22.5 lb eggs (product is https://bluegrassfoodconnection.localorbit.com/admin/products/60685/lots and note your number may be reduced by system on cart)
  3. Click Checkout
  4. Click Place Order

Actual
You'll see 404

Expected

  1. See error message if there is indeed a legit error
  2. Should also fire warning off to rollbar if there is a rescued error in create_order
  3. But in this case there shouldn't be an error, so fix inventory code

Product:

Outstanding Question:

  • Rob thinks Good From and Expires On should be relative to the delivery date not the current time.

screen shot 2018-09-03 at 11 26 11 pm

Tech Notes
Here is the start of debugging. First off, at least it should not show 404 but send back the error message to the user. Secondly, we should do a Rollbar.warning in this case too so we understand how often this is happening. Thirdly, should fix and unify the inventory calculation which seems to be root cause of this particular bug.

My start:

diff --git a/app/interactors/create_order.rb b/app/interactors/create_order.rb
index bf69746f9..422708c47 100644
--- a/app/interactors/create_order.rb
+++ b/app/interactors/create_order.rb
@@ -69,18 +68,21 @@ class CreateOrder
       begin
         order.add_cart_items(cart.items, cart.delivery.deliver_on)
         success = order.save
-      rescue
-        # empty
+      rescue e
+        Rollbar.error(e)
       end
       unless success
+        Rollbar.error('Could not create order', errors: order.errors.full_messages)
         raise ActiveRecord::Rollback
       end
     end
+    binding.pry
+    # Why does rollback_order still get called but method doens't continue after that before rolling back interactor?
     unless success
       rollback_order(order)
     end
@rbarreca rbarreca added this to Icebox in Product Backlog via automation Sep 4, 2018
@rbarreca rbarreca changed the title Placing order goes to 'Page not found' error screen when ordering a product with certain inventory lot combinations Cart inventory check not accurately warning of dated inventory resulting in placing order going to 'Page not found' error screen Sep 4, 2018
@rbarreca rbarreca removed this from Icebox in Product Backlog Sep 4, 2018
@rbarreca rbarreca added this to To do in Project Board via automation Sep 4, 2018
@rbarreca rbarreca changed the title Cart inventory check not accurately warning of dated inventory resulting in placing order going to 'Page not found' error screen Placing order goes to 'Page not found' error screen due to inaccurate 'expires on' inventory lot addition Sep 4, 2018
@thermistor thermistor moved this from To do to In progress in Project Board Sep 6, 2018
@thermistor thermistor self-assigned this Sep 6, 2018
@thermistor thermistor moved this from In progress to Needs review in Project Board Sep 7, 2018
@rbarreca rbarreca moved this from Needs review to Awaiting QA in Project Board Sep 20, 2018
@rbarreca rbarreca added this to the v5.0.12 milestone Oct 15, 2018
@rbarreca
Copy link
Contributor Author

Waiting for @thermistor to fix injection introduced in #3465 to be able to do some click testing on staging for this one.

@rbarreca rbarreca moved this from Awaiting QA to QA Accepted in Project Board Oct 19, 2018
@rbarreca rbarreca moved this from QA Accepted to Released in Project Board Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Project Board
  
Released
Development

No branches or pull requests

2 participants