Complex Calculations Required – Seeking Advice

I’m working on a scenario where I need to perform a lot of calculations. I’ve started storing the shipping rules in a Datastore, but I’m finding it challenging to find the most efficient method for the calculations. Could you offer some guidance?

FYI, I’ve written a Python script that does what is needed, and it works without any issues: Google Colab.

Below is an example input:

{
    "product_code": "iphone-15-pro-blue-1",
    "order_quantity": 34,
    "shipping_country": "US",
    "US_units": 12,
    "DE_units": 10,
    "FR_units": 10,
    "UK_units": 0
}

For the provided input, the output JSON should be:

{
    "1 business day": "12 units",
    "5 business days": "20 units",
    "Supplier backordered; delivery time to be confirmed": "2 units"
}

The shipping times in days table from each location:

shipping_rules = {
    "US": {"US": 1, "DE": 5, "FR": 5, "UK": 5},
    "FR": {"US": 5, "DE": 3, "FR": 1, "UK": 3},
    "DE": {"US": 5, "DE": 1, "FR": 3, "UK": 3},
    "UK": {"US": 5, "DE": 3, "FR": 3, "UK": 1}
}

Prioritize shipping locations with available stock until the stock is 0. Then, prioritize by shorter delivery times.

Hi Nicolas,

if you already have a pythons script to do the calculations - then you can host it on pythonanywhere and call it with an ssh module from the Make.com scenario. I believe that would be faster/easier way than to figure out how to do the calculations in Make.

2 Likes

Thank you, Stoyan. You’re correct. I had considered hosting the API endpoint on render.com. However, in my current situation, I’m not permitted to use a non-approved solution like Make. That’s why I was thinking of exclusively using Make for that purpose.

Actually, I’m on the enterprise plan and I have access to custom functions where you can write any business logic in JavaScript: https://www.make.com/en/help/functions/custom-functions.

That is exactly what I needed. But it’s a shame that it’s only available on the enterprise plan…

3 Likes