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

[DFC Orders] Backorder stock controlled products #12888

Merged
merged 6 commits into from
Oct 7, 2024

Conversation

mkllnk
Copy link
Member

@mkllnk mkllnk commented Oct 3, 2024

What? Why?

We now want stock controlled items to trigger backorders as well.

What should we test?

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

We want to trigger the backordering for any linked product now. So let's
do that check early and then select the variants in the background.
It means less data passed to the job and less space for race conditions.
We aggregate quantities over the whole order cycle to account for
cancelations and order adjustments by admins.
@mkllnk mkllnk added the user facing changes Thes pull requests affect the user experience label Oct 3, 2024
@mkllnk mkllnk self-assigned this Oct 3, 2024
@dacook dacook self-requested a review October 4, 2024 02:14
Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, a few minor comments but it looks good to me so far 👍

@order = order
@linked_variants = linked_variants
@linked_variants = order.variants
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now lists all variants associated with an order, whether they're linked or not. Hmm, regardless we probably only want to know about variants that had errors. I'll wait to see where the PR goes..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we don't actually know what users want. We have no data on that. In the pilots, I think, all variants will be linked. Looking at errors could be good but also another source for errors. I think that we should wait until this actually happens and what people say about it.

# We are only supporting producer stock at the moment.
variant = item.variant
variant.semantic_links.present? &&
(variant.on_demand == false || variant.on_hand&.negative?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the model (or a module like VariantStock) should be deciding what is backorderable? Perhaps it can even be a scope.

needed_quantity = -1 * variant.on_hand
# We look at linked variants which are either stock controlled or
# are on demand with negative stock.
def backorder_items(order)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method sounds like it performs the action (make a backorder), but it just selects the items. Perhaps:

Suggested change
def backorder_items(order)
def backorderable_items(order)

@RaggedStaff RaggedStaff added the pr-staged-uk staging.openfoodnetwork.org.uk label Oct 4, 2024
@mkllnk mkllnk marked this pull request as ready for review October 4, 2024 07:07
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@rioug
Copy link
Collaborator

rioug commented Oct 6, 2024

@mkllnk in case you missed it, deployment to staging failed.

@mkllnk mkllnk merged commit 6f2c5b5 into openfoodfoundation:master Oct 7, 2024
52 of 53 checks passed
@mkllnk mkllnk deleted the dfc-stock branch October 7, 2024 23:58
@dacook dacook removed the pr-staged-uk staging.openfoodnetwork.org.uk label Oct 8, 2024
@RaggedStaff RaggedStaff added pr-staged-uk staging.openfoodnetwork.org.uk and removed pr-staged-uk staging.openfoodnetwork.org.uk labels Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user facing changes Thes pull requests affect the user experience
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants