fix: capacity planning validation (#20317)

diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 6798dd2..914260b 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -278,10 +278,11 @@
 				enable_capacity_planning=enable_capacity_planning, auto_create=True)
 
 			if enable_capacity_planning and job_card_doc:
-				row.planned_start_time = job_card_doc.time_logs[0].from_time
+				row.planned_start_time = job_card_doc.time_logs[-1].from_time
 				row.planned_end_time = job_card_doc.time_logs[-1].to_time
 
 				if date_diff(row.planned_start_time, original_start_time) > plan_days:
+					frappe.message_log.pop()
 					frappe.throw(_("Unable to find the time slot in the next {0} days for the operation {1}.")
 						.format(plan_days, row.operation), CapacityError)