-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
Calculate stock from DFC wholesale variants #13049
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, easy to follow the commits and see how the code evolves.
Just one little hiccup at the end:
|
||
return unless offer && wholesale_offer&.stockLimitation.present? | ||
|
||
offer.stockLimiation = wholesale_offer.stockLimitation.to_i * transformation.factor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that spelling doesn't look right:
offer.stockLimiation = wholesale_offer.stockLimitation.to_i * transformation.factor | |
offer.stockLimitation = wholesale_offer.stockLimitation.to_i * transformation.factor |
The test below isn't testing for this. Is it something that can be tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted!
While the standard allows a stock limitation on catalog items and offers, the FDC data stores the stock only on the catalog item and not the offer. So this code path didn't run. I added a test case for that now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
@mkllnk I'll let you handle the conflict |
a167547
to
0bd6fe6
Compare
Initial issues: 1. Session error causes 500 pageWith no explanation of what's wrong. Eg: https://staging.openfoodnetwork.org.uk/admin/dfc_product_imports?enterprise_id=203921&catalog_url=https%3A%2F%2Fenv-0105831.jcloud-ver-jpe.ik-server.com%2Fapi%2Fdfc%2FEnterprises%2Ftest-hodmedod%2FSuppliedProducts&commit=Import Bugsnag reveals Rack::OAuth2::Client::Error - invalid_grant :: Session not active 2. OIDC settings page says it is active, when it is not.https://staging.openfoodnetwork.org.uk/admin/oidc_settings Maybe when we load the page it should perform a check to display current status. I will continue trying to test in the morning. I got a bit lost but I think I found my way. I'm confused why the Wholesale product has dropped from 4 to 2 after making an order but maybe I missed something. |
The first issue you found is on our list to fix: Currently, @rioug is assigned. But who has time first? |
Go for it ! |
Testing
✅ Ok I think that's correct! Look right to you @mkllnk ? Other notesI also played around with updating values in OFN bulk edit products screen, and found that these changes aren't reflected back in Shopify. Price30.20 / 6 = 5.0333333 Product amountsProduct amounts show as weight instead of volume. I can see that Shopify only supports weight (assumed gross weight for shipping, not the net product weight), so that's the best we can do I guess. Unless we were to use a metafield or some other shopify plugin. |
Yes, looking good. Thank you! I'll merge then. |
I think that's probably how we want it for now... Shopify is managing the wholesale variant stock, OFN is managing the retail variant stock Syncromising stock updates across multiple locations would be a lot more complex to manage. That said... we do have local stock of the retail variant, so a check to make sure that doesn't reset on refresh might be handy? Also worth checking how cancellations are handled: stock should be returned to the retail variant, and (where possible) the back order reduced (& local stock readjusted down). |
Good idea. I cancelled an order: I didn't check the stock beforehand, but the other day there were 28 bottles in stock. I found the backorder, which is empty: https://admin.shopify.com/store/test-hodmedod/draft_orders?selectedView=all |
I'm not sure I have the full picture here. But yes, when orders are cancelled, the backorder is adjusted. And if we then don't need to order anything then the backorder ends up being empty. |
The test shop is used in various ways. So I don't think that you can refer to stock levels from a few days ago. |
ℹ️ Funded Feature. Please track ALL ASSOCIATED WORK under the associated tracking code #11678 DFC Orders
What? Why?
When importing DFC products, two products can be coupled as retail variant and wholesale variant of the same product. We aim to sell the retail variant through an OFN shop and then place backorders for the wholesale variant to make use of economies of scale.
We already calculated the price of a retail variant from its wholesale variant:
Now we also calculate the stock level from the wholesale variant.
What should we test?
https://env-0105831.jcloud-ver-jpe.ik-server.com/api/dfc/Enterprises/test-hodmedod/SuppliedProducts
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates