updates on the changes arelated toe the order creation and delivery fixes as well

This commit is contained in:
2026-08-13 11:26:58 +05:30
parent fabb74c326
commit b1efd14749
10 changed files with 125 additions and 56 deletions

View File

@@ -7,7 +7,7 @@ import {
MdAccessTime,
MdInventory2
} from 'react-icons/md';
import dayjs from 'dayjs';
import { parseDoormileTimestamp } from 'utils/doormileTimestamp';
import { CircularProgress } from '@mui/material';
import { getStatusStyle, getActiveOrder } from './dispatchShared';
import { OpenToast } from 'components/third-party/OpenToast';
@@ -147,7 +147,9 @@ const ActiveSection = ({
</span>
{o.deliverytime && (
<span className="adcard-time" style={{ fontSize: '11px', color: '#64748b' }}>
{dayjs(o.deliverytime).isValid() ? dayjs(o.deliverytime).format('HH:mm:ss') : String(o.deliverytime)}
{parseDoormileTimestamp(o.deliverytime).isValid()
? parseDoormileTimestamp(o.deliverytime).format('HH:mm:ss')
: String(o.deliverytime)}
</span>
)}
</div>

View File

@@ -1459,11 +1459,16 @@ const Dispatch = ({
const status = String(r.orderstatus ?? r.status ?? '').toLowerCase();
if (SKIPPED_STATUSES.has(status)) return;
// Filter by selectedDate to align with daily slot aggregations
// Filter by selectedDate to align with daily slot aggregations.
// parseDoormileTimestamp (not bare dayjs()) avoids the false-trailing-Z
// parse bug (utils/doormileTimestamp.js) — near a midnight boundary an
// unstripped Z could shift a row +5:30 into the wrong calendar day,
// silently dropping it from (or wrongly adding it to) a rider's daily
// profit total for selectedDate.
const dateStr = r.assigntime
? dayjs(r.assigntime).format('YYYY-MM-DD')
? parseDoormileTimestamp(r.assigntime).format('YYYY-MM-DD')
: r.deliverydate
? dayjs(r.deliverydate).format('YYYY-MM-DD')
? parseDoormileTimestamp(r.deliverydate).format('YYYY-MM-DD')
: 'unknown';
if (selectedDate && dateStr !== selectedDate) return;
@@ -2071,10 +2076,15 @@ const Dispatch = ({
}
const kmDelta = actualKm - plannedKm;
const kmDeltaPct = plannedKm > 0 ? (kmDelta / plannedKm) * 100 : null;
// parseDoormileTimestamp on both sides (not bare dayjs()) — even though
// a false-Z shift would cancel out in the diff below if BOTH fields
// always had it consistently, that's not guaranteed per-field, and an
// inconsistent shift on just one side would corrupt timeDeltaMin and
// the anomaly flag it drives.
const expectedTs = order?.expecteddeliverytime
? dayjs(order.expecteddeliverytime)
? parseDoormileTimestamp(order.expecteddeliverytime)
: null;
const actualTs = order?.deliverytime ? dayjs(order.deliverytime) : null;
const actualTs = order?.deliverytime ? parseDoormileTimestamp(order.deliverytime) : null;
const timeDeltaMin =
expectedTs?.isValid() && actualTs?.isValid()
? actualTs.diff(expectedTs, 'minute')
@@ -5063,7 +5073,9 @@ const Dispatch = ({
<span className="pu-info-label">Last Seen</span>
<span className="pu-info-value pu-time-stamp">
<MdAccessTime className="inline-icon" />{' '}
{dayjs(r.logdate).isValid() ? dayjs(r.logdate).format('hh:mm:ss A') : r.logdate}
{parseDoormileTimestamp(r.logdate).isValid()
? parseDoormileTimestamp(r.logdate).format('hh:mm:ss A')
: r.logdate}
</span>
</div>
)}
@@ -5339,7 +5351,7 @@ const Dispatch = ({
</div>
<div className="cmp-tip-sub">
{t.deliverytime
? `Delivered ${dayjs(t.deliverytime).format('hh:mm A')}`
? `Delivered ${parseDoormileTimestamp(t.deliverytime).format('hh:mm A')}`
: `${t.coords.length} GPS pings`}
</div>
</div>

View File

@@ -1,6 +1,7 @@
import React, { useState, useMemo, useCallback } from 'react';
import PropTypes from 'prop-types';
import dayjs from 'dayjs';
import { parseDoormileTimestamp } from 'utils/doormileTimestamp';
import {
MdTrendingUp,
MdTrendingDown,
@@ -93,10 +94,13 @@ function calcRiderMetrics(rider, selectedDate, batches) {
// context. Only the money/km math below excludes them.
const orders = (rider.orders ?? []).filter((o) => {
if (!selectedDate) return true;
// parseDoormileTimestamp (not bare dayjs()) avoids the false-trailing-Z
// parse bug (utils/doormileTimestamp.js) — near a midnight boundary an
// unstripped Z could shift a row +5:30 out of selectedDate entirely.
const dateStr = o.assigntime
? dayjs(o.assigntime).format('YYYY-MM-DD')
? parseDoormileTimestamp(o.assigntime).format('YYYY-MM-DD')
: o.deliverydate
? dayjs(o.deliverydate).format('YYYY-MM-DD')
? parseDoormileTimestamp(o.deliverydate).format('YYYY-MM-DD')
: 'unknown';
return dateStr === selectedDate;
});
@@ -116,9 +120,9 @@ function calcRiderMetrics(rider, selectedDate, batches) {
if (!slot) continue;
const dateStr = o.assigntime
? dayjs(o.assigntime).format('YYYY-MM-DD')
? parseDoormileTimestamp(o.assigntime).format('YYYY-MM-DD')
: o.deliverydate
? dayjs(o.deliverydate).format('YYYY-MM-DD')
? parseDoormileTimestamp(o.deliverydate).format('YYYY-MM-DD')
: null;
if (!dateStr) continue;