reconcile changes

This commit is contained in:
2026-07-06 15:48:56 +05:30
parent 871981035a
commit 7d60556131
6 changed files with 99 additions and 18 deletions

View File

@@ -1044,13 +1044,17 @@ class RouteOptimizer:
order["previouskms"] = int(round(step_dist)) # Bug fix: was hardcoded 0 for step 1
order["cumulativekms"] = int(round(cumulative_dist))
# actualkms = direct pickup-to-door distance (for billing)
plat, plon = start_lat, start_lon
# actualkms = direct pickup-to-door distance (for billing).
# Always the order's own kitchen, never the routing depot: when
# start_coords is the rider's current position (e.g. reconcile
# mid-route) rather than the kitchen, start_lat/start_lon no
# longer equals the pickup location.
plat, plon = (
_to_float(order.get("pickuplat")),
_to_float(order.get("pickuplon") or order.get("pickuplong")),
)
if plat == 0:
plat, plon = (
_to_float(order.get("pickuplat")),
_to_float(order.get("pickuplon") or order.get("pickuplong")),
)
plat, plon = start_lat, start_lon
dlat, dlon = locations[solver_idx]
true_dist = self.haversine_distance(plat, plon, dlat, dlon) * 1.3