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

[RFC] Sorting warehouses within channel #10416

Merged
merged 32 commits into from Aug 26, 2022

Conversation

IKarbowiak
Copy link
Member

@IKarbowiak IKarbowiak commented Aug 17, 2022

The goal is to allow staff users to set the warehouse order of stock allocation and reservation. The warehouse order will be configurable per channel

General assumptions

  • Staff users with MANAGE_CHANNELS permission should be able to sort the warehouses within the channel.
  • Newly added warehouses will be added to the end of the sort order.
  • The channel will have a configurable option to choose the default strategy for allocation. The options will be:
    • follow the warehouse order
    • prioritize the stocks with the highest available quantities- it will minimalize the number of allocations by firstly allocating in the warehouses with the highest quantity available value
  • Defining the allocation settings during the channel creation will be not required. When no provided the option PRIORITIZE_SORTING_ORDER will be set.
  • The default allocation strategy for exisitng channels will be PRIORITIZE_HIGH_STOCK.

Allocation and reservations

  • Depend on the channel settings reservations and allocations:
    • will happen with respect to the sort of warehouse order (PRIORITIZE_SORTING_ORDER strategy)
    • will firstly happen in the stocks with the highest available quantity value (PRIORITIZE_HIGH_STOCK strategy)
  • For checkout with the collection point chosen as a delivery method, the chosen collection point will be used as the first choice.

The example of stocks and allocations for:

  • PRIORITIZE_SORTING_ORDER strategy
    image
  • PRIORITIZE_HIGH_STOCK strategy
    image

Database changes

API changes

Introduce StockSettings type.

type StockSettings {
  allocationStrategy: allocationStrategyEnum!
}

enum allocationStrategyEnum {
  PRIORITIZE_SORTING_ORDER
  PRIORITIZE_HIGH_STOCK
}

Extend the channel type with allocationSettings field. Allow defining the allocationSettings in the channelCreate and channelUpdate mutations.

type Channel implements Node {
  ...
  stockSettings: StockSettings
}

input ChannelCreateInput {
  ...
  stockSettings: StockSettingsInput
}

input ChannelUpdateInput{
  ...
  stockSettings: StockSettingsInput
}

input StockSettingsInput {
  allocationStrategy: allocationStrategyEnum!
}

Add a channelReorderWarehouses mutation for sorting the warehouses assigned to the channel.

type Mutation {
  ...
  channelReorderWarehouses(
    channelId: ID!, moves: [ReorderInput!]!
  ): channelReorderWarehouses
}


input ReorderInput {
  id: ID!
  sortOrder: Int
}


type channelReorderWarehouses{
  channel: Channel
  errors: [ChannelError!]!
}

Internal task: SALEOR-7914

Impact

  • New migrations
  • New/Updated API fields or mutations
  • Deprecated API fields or mutations
  • Removed API types, fields, or mutations
  • Documentation needs to be updated

Pull Request Checklist

  • Privileged queries and mutations are guarded by proper permission checks
  • Database queries are optimized and the number of queries is constant
  • Database migration files are up to date
  • The changes are tested
  • GraphQL schema and type definitions are up to date
  • Changes are mentioned in the changelog

@IKarbowiak IKarbowiak self-assigned this Aug 17, 2022
@patrys patrys added the rfc Request For Comments: blueprints of upcoming changes. label Aug 17, 2022
@patrys patrys added this to the Saleor 3.7 milestone Aug 17, 2022
@IKarbowiak IKarbowiak requested review from a team and timuric August 17, 2022 13:30
@IKarbowiak IKarbowiak closed this Aug 17, 2022
@IKarbowiak IKarbowiak deleted the sorting-warehouses-within-shipping-zone branch August 17, 2022 13:40
@IKarbowiak IKarbowiak restored the sorting-warehouses-within-shipping-zone branch August 17, 2022 13:41
@IKarbowiak IKarbowiak reopened this Aug 17, 2022
@patrys
Copy link
Member

patrys commented Aug 18, 2022

@IKarbowiak IKarbowiak changed the title [RFC] Sorting warehouses within shipping zone [RFC] Sorting warehouses within channel Aug 19, 2022
@IKarbowiak IKarbowiak force-pushed the sorting-warehouses-within-shipping-zone branch from f429822 to c1dd989 Compare August 21, 2022 09:32
@IKarbowiak IKarbowiak force-pushed the sorting-warehouses-within-shipping-zone branch from c1dd989 to b83cd16 Compare August 22, 2022 07:12
@IKarbowiak IKarbowiak added the test deployment Deploy test environment for pull request label Aug 24, 2022
@github-actions github-actions bot temporarily deployed to sorting-warehouses-within-shipping-zone August 24, 2022 06:03 Inactive
@IKarbowiak IKarbowiak requested a review from a team August 24, 2022 07:10
@IKarbowiak IKarbowiak marked this pull request as ready for review August 24, 2022 09:00
@IKarbowiak IKarbowiak added test deployment Deploy test environment for pull request and removed test deployment Deploy test environment for pull request labels Aug 24, 2022
@github-actions github-actions bot temporarily deployed to sorting-warehouses-within-shipping-zone August 24, 2022 09:48 Inactive
@github-actions github-actions bot temporarily deployed to sorting-warehouses-within-shipping-zone August 26, 2022 06:58 Inactive
@github-actions github-actions bot temporarily deployed to sorting-warehouses-within-shipping-zone August 26, 2022 07:03 Inactive
@github-actions github-actions bot temporarily deployed to sorting-warehouses-within-shipping-zone August 26, 2022 11:17 Inactive
@maarcingebala maarcingebala merged commit c464bf7 into main Aug 26, 2022
@maarcingebala maarcingebala deleted the sorting-warehouses-within-shipping-zone branch August 26, 2022 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfc Request For Comments: blueprints of upcoming changes. test deployment Deploy test environment for pull request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants