Skip to content

Storage Cost Calculation

Description

Calculate storage cost based on item dimensions, weight, quantity, rental period, and tariff mode. The result is returned in EUR and USD (using the dynamic currency rate).

HTTP Request

http
POST /api/calculate-storage-cost

Request Body

The request body must be in JSON format and contain the following fields:

FieldTypeRequiredDescription
unitsstringYesMeasurement units: cm or m
widthnumberYesItem width in selected units
lengthnumberYesItem length in selected units
heightnumberYesItem height in selected units
weightnumberYesWeight of the item (kg)
quantityintegerYesNumber of identical items
periodintegerYesStorage duration in months
tariff_modestringNoTariff mode: low, peak or auto (default: auto)

💡 Info

If units = cm, all dimensions will be automatically converted to meters.

If tariff_mode = auto, the system chooses the best tariff automatically.

If tariff_mode = low, the system uses the default tariff.

If tariff_mode = peak, the system uses the highest tariff for 10-12 months.

Example Request Body

json
{
  "units": "cm",
  "width": 50,
  "length": 40,
  "height": 30,
  "weight": 12,
  "quantity": 3,
  "period": 2,
  "tariff_mode": "auto"
}

Responses

✅ 200 OK — Successful calculation

json
{
  "eur": 15.38,
  "usd": 17.75,
  "eur_to_usd_rate": 1.1544,
  "total_volume": 0.18
}

💡 Info

total_volume is calculated as width × length × height × quantity.

The currency rate is fetched dynamically at the moment of calculation.


❌ 400 Bad Request - Invalid JSON

json
{
  "message": "Could not decode JSON, syntax error - malformed JSON.",
  "code": 0,
  "trace": [],
  "class": "JMS\\Serializer\\Exception\\RuntimeException"
}

❌ 400 Bad Request — Invalid fields

json
{
  "errors": {
    "units": "This value should not be blank.",
    "width": "This value should not be blank.",
    "length": "This value should not be blank.",
    "height": "This value should not be blank.",
    "weight": "This value should not be blank.",
    "quantity": "This value should not be blank.",
    "period": "This value should not be blank."
  }
}

Possible reasons:

  • Missing required fields
  • width, length, height, weight, or quantity is negative
  • units has an invalid value
  • Invalid tariff_mode: only low, peak, or auto allowed

❌ 503 — Service Unavailable

json
{
    "message": "Couldn't resolve host name for \"https://api.frankfurter.app/latest?from=EUR&to=USD\".",
    "code": 0,
    "trace": [],
    "class": "Symfony\\Component\\HttpClient\\Exception\\TransportException"
}

Possible reasons:

  • External currency rate provider failed
  • Internal service error during calculation

© 2025 | SIA "QWQER EU" | qwqer.lv ™