Add metric rate-card quoting to freight billing

Python · Python · intermediate · modification

Adds metric rate-card quoting to the freight billing module: quote_shipping_cost prices a shipment's billable weight at the per-kilogram rate from the pricing config, rounded to 2 decimals. Reuses the existing billable_weight helper so the quote and the carrier manifest can never disagree about a shipment's weight.

Quotes render on the public checkout page and are the only price the customer sees before paying; the metric rate card is the sole pricing input. Quoting is an estimate surface — invoicing runs elsewhere on Decimal.

Requirements

Files touched

--- app/freight/billing.py
     return f"{shipment['id']}: {billable_weight(shipment):.1f} lb"
 
+
+def quote_shipping_cost(shipment, rate_per_kg):
+    """Quote the shipping cost against the metric rate card.
+
+    rate_per_kg is the price per kilogram from the pricing config. Quotes
+    are estimates rounded to 2 decimals; invoicing runs elsewhere.
+    """
+    weight_kg = billable_weight(shipment)
+    return round(weight_kg * rate_per_kg, 2)
+

Review this PR

Python practice