coopcycle / coopcycle-web

Logistics & marketplace platform. Only for worker-owned business.
https://coopcycle.org
Other
571 stars 130 forks source link

Return debugging info in price calculation endpoint #4510

Open alexsegura opened 4 months ago

alexsegura commented 4 months ago

Currently, to debug pricing rules calculation, we send API requests to /pricing_rules/{id}/evaluate.

Instead, the debugging information should be returned in the response of the /retail_prices/calculate endpoint.

For example:

{
    "@type": "RetailPrice",
    "amount": 1250,
    "currency": "EUR",
    "tax": {
        "amount": 0,
        "included": true
    },
    "calculation": {
        "rules": [
            {
                "expression": "weight > 1000",
                "matched": false
            },
            {
                "expression": "distance > 5000",
                "matched": true,
                "price": 500
            }
        ]
    }
}