diff --git a/supabase/functions/autocall-result/index.ts b/supabase/functions/autocall-result/index.ts index 5e376f1..19f8194 100644 --- a/supabase/functions/autocall-result/index.ts +++ b/supabase/functions/autocall-result/index.ts @@ -196,16 +196,22 @@ Deno.serve(async (request) => { delivery_date_source: "autocall", delivery_status: "agreed", notification_status: "confirmed", - delivery_date: deliveryDate, called: true, called_at: new Date().toISOString(), called_comment: comment, next_notification_check_at: null, }; - if (timeSlot) update.delivery_time = timeSlot; + // Самовывоз и доставка живут в РАЗНЫХ полях (решение владельца): для + // самовывоза пишем только pickup_date + половину дня, delivery_date не + // трогаем — иначе дата дублируется в двух полях и всплывает в плане + // доставки. Маркер «согласовано роботом» общий — delivery_date_source, + // по нему работают и карточка, и SQL-статус autocall_status(og). if (isPickup) { update.pickup_date = deliveryDate; if (timeSlot) update.pickup_time_slot = timeSlot; + } else { + update.delivery_date = deliveryDate; + if (timeSlot) update.delivery_time = timeSlot; } await supabase.from("order_groups").update(update).eq("id", orderGroupId); }