diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index ab1762419..056e5db48 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -113,7 +113,7 @@ class YuthonProperty(models.Model): if contract_lines: sorted_lines = sorted( contract_lines, - key=lambda line: line.lease_id.actual_end_time, + key=lambda line: line.lease_id.actual_end_time or date.max, reverse=True ) lease_id = sorted_lines[0]