miler map

This commit is contained in:
2026-09-09 12:55:23 +05:30
parent 074cc0eccf
commit 127fa062ed
143 changed files with 4315 additions and 2291 deletions

View File

@@ -1,6 +1,7 @@
import 'package:miler/Models/stop_status.dart';
import 'package:miler/views/Dashboard/pickups/stop_type.dart';
import 'package:miler/data/pickup_locations.dart';
import 'package:miler/data/next_leg.dart';
import 'package:miler/data/service_profile.dart';
/// ─────────────────────────────────────────────────────────────────────────
@@ -227,6 +228,20 @@ class MilkRun {
);
if (resolved.isNotEmpty) return resolved;
// ── The counter's own name, ahead of the account's ──
//
// `pickup_source_name` ships with request 28 and is what the hub holds for
// the place. `sourcename` is filled from `providercompany` /
// `providerlocation`, and what lands there is whoever is on the account
// rather than the counter — which is how the biggest type on Home once read
// `Sudharsan`, a person, above a distance and an ETA to a place that name
// does not identify.
//
// Below the locations table, which is still the canonical name for a base,
// and above every legacy spelling, which are guesses by comparison.
final named = (stop['pickup_source_name'] ?? '').toString().trim();
if (named.isNotEmpty) return named;
return (stop['sourcename'] ??
stop['SourceName'] ??
stop['kitchenname'] ??
@@ -281,7 +296,35 @@ class MilkRun {
static bool navigatesToCustomer(
Map<String, dynamic> stop, {
Set<String> collectedIds = const {},
/// `next_action` per order, from the pivot. See [NextLegResolver].
Map<String, String> pivotActions = const {},
}) {
// ── The order's own routing outranks the line's shape ──
//
// The two lines below are the whole logistics fix, and they are checked
// first because a per-order fact must not be overruled by a per-line one.
//
// • **hub** is the safety case. A Gandhipuram → Chennai parcel is in this
// rider's hands and its receiver is 500km away; pointing a Navigate
// button at that address sends a Coimbatore rider down a national
// highway. He is going to a hub, and the customer is context, not a
// destination.
// • **customer** is the case the line-level test could never reach.
// `deliversToCustomer` is false on logistics, so a hyperlocal parcel the
// pivot had already released into this rider's own hands could not get a
// customer destination out of this function at all.
final leg = NextLegResolver.resolve(
stop,
pivotAction: pivotActions[idOf(stop)] ?? '',
);
if (leg.isHub) return false;
if (leg.isCustomer) return true;
// No per-order answer — [NextLeg.unknown], or a stop that has not been
// collected yet. Fall back to the line's own shape, which is exactly what
// this function did before and is still right for a milk run, whose rows
// often carry no consignment state at all.
if (!ServiceProfile.active.deliversToCustomer) return false;
if (collectedIds.contains(idOf(stop))) return true;
final status = stopStatusOf(stop);