fix: авто-статус delivered при полной отгрузке (включая с комментарием)

Раньше: все позиции отгружены → delivered, иначе → problem
Теперь: все отгружены ИЛИ все неотгруженные с комментарием → delivered
Только если есть неотгруженные без комментария → problem
This commit is contained in:
root 2026-06-16 06:33:55 +00:00
parent c288251cec
commit 6184f5aeed
1 changed files with 3 additions and 1 deletions

View File

@ -395,6 +395,8 @@ export const saveShipmentData = async ({ orderGroupId, shipmentData }) => {
const client = requireSupabase();
const unshipped = shipmentData.filter((i) => !i.shipped);
const allShipped = unshipped.length === 0 && shipmentData.length > 0;
const unshippedWithoutComment = unshipped.filter((i) => !i.comment?.trim()).length;
const canMarkDelivered = allShipped || unshippedWithoutComment === 0;
const hasProblem = unshipped.length > 0;
const problemNote = hasProblem
? unshipped.map((i) => `${i.name}${i.quantity ? ` (${i.quantity}${i.unit ? ` ${i.unit}` : ""})` : ""}${i.comment ? `${i.comment}` : ""}`).join("; ")
@ -402,7 +404,7 @@ export const saveShipmentData = async ({ orderGroupId, shipmentData }) => {
// Auto-update delivery status based on shipment
let newDeliveryStatus = undefined;
if (allShipped) {
if (canMarkDelivered) {
newDeliveryStatus = "delivered";
} else if (hasProblem) {
newDeliveryStatus = "problem";