fix(quotes): show latest receipt time on partial arrivals
For accepted quotes with PM-confirmed (partial) receipts the dashboard row only showed «رسیده X از Y — در راه Z» with no timestamp (quote header arrived_date is set only when everything arrives). The cell now also shows «آخرین رسید: <date time>» computed from the newest item receipt; arrived quotes keep the arrival date with a last-receipt fallback.
This commit is contained in:
@@ -97,6 +97,20 @@ export function QuoteCard({ store, q, expanded, onToggleExpand, onAccept, onEdit
|
||||
}
|
||||
|
||||
let arrivedCell: React.ReactNode;
|
||||
// آخرین لحظهی رسید ثبتشده بین قلمها (رسیدهای جزیی توسط مدیر پروژه)
|
||||
const lastReceiptAt = activeItems.reduce<Date | null>((acc, li) => {
|
||||
if (!li.arrived_date) return acc;
|
||||
const t = new Date(li.arrived_date).getTime();
|
||||
if (Number.isNaN(t)) return acc;
|
||||
return !acc || t > acc.getTime() ? new Date(li.arrived_date) : acc;
|
||||
}, null);
|
||||
const receiptTimeLine =
|
||||
lastReceiptAt != null ? (
|
||||
<span className="block text-[10.5px] font-normal text-muted">
|
||||
آخرین رسید: {fmtDateTime(lastReceiptAt.toISOString())}
|
||||
</span>
|
||||
) : null;
|
||||
|
||||
if (q.status === "accepted") {
|
||||
if (q.arrived_date) {
|
||||
arrivedCell = <span className="tabular-nums">{fmtDateTime(q.arrived_date)}</span>;
|
||||
@@ -104,13 +118,18 @@ export function QuoteCard({ store, q, expanded, onToggleExpand, onAccept, onEdit
|
||||
arrivedCell = (
|
||||
<span className="tabular-nums">
|
||||
رسیده {fmtNum(receivedSum)} از {fmtNum(orderedSum)} — در راه {fmtNum(Math.max(0, orderedSum - receivedSum))}
|
||||
{receiptTimeLine}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
arrivedCell = <span className="text-muted">در انتظار PM</span>;
|
||||
}
|
||||
} else if (q.arrived_date) {
|
||||
arrivedCell = <span className="tabular-nums">{fmtDateTime(q.arrived_date)}</span>;
|
||||
} else if (q.status === "arrived") {
|
||||
arrivedCell = (
|
||||
<span className="tabular-nums">
|
||||
{fmtDateTime(q.arrived_date || (lastReceiptAt ? lastReceiptAt.toISOString() : ""))}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
arrivedCell = <span className="text-muted">—</span>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user