Answer the question
In order to leave comments, you need to log in
How to allocate goods with options and warehouses to orders?
I can’t solve the combinatorics problem, I don’t even know what this problem is called, but for sure there are ready-made libraries / functions / scripts for solving it.
There are goods and options that are in stock. A product or option can have a fixed quantity or be infinite (None is specified instead of the quantity). When ordering, you can combine one product with several options, respectively, you need to distribute the ordered products with options by warehouse into orders. If the goods in the order can be sent from several warehouses, then you need to select all of them, if not, then split them into several orders by warehouses. Does anyone have a solution or at least a name for this problem?
For clarity (Python syntax). IDs of options, products, warehouses are taken at random, you can insert your own.
Dictionary with all available goods, warehouses where it is available and quantities (None - infinite) in these warehouses {product_id: {warehouse_id: quantity}, ...}:
{1: {2: 7, 4: 3}, 13: {2: 7, 4: 3}, 21: {2: None, 4: None}}
{3: {2: None, 4: None}, 10: {2: 10}, 9: {2: 10, 4: 10}, 8: {4: 2}}
[{'product_id': 1, 'quantity': 2, 'options': [3, 10, 9]}, {'product_id': 1, 'quantity': 1, 'options': [3, 9]}, {'product_id': 13, 'quantity': 5, 'options': [10, 9]}]
[{'warehouses': [4], order_products: [0, 1]}, {'warehouses': [2], order_products: [2, 3]}]
[{'warehouses': [2, 4], order_products: [0, 1, 2, 3]}]
[{'warehouses': [2, 4], order_products: [0, 1]}, {'warehouses': [6], order_products: [3]}]
limit_exceeded = [{'order_product': 1, 'max_quantity': 2}, ...]
Answer the question
In order to leave comments, you need to log in
Make selections from IDs by features (availability in stock, USB version) in advance, then cross. Otherwise, faceted search on good volumes will be stupid.
https://youtu.be/Pqm88cqI-4A?t=276
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question