File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
src/backend/expungeservice Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -119,11 +119,17 @@ def _get_case_has_ineligible_charge(case: Record):
119119
120120 @staticmethod
121121 def _get_future_eligibility_label_on_case (case : Record ):
122+ # Filter to charges with a future eligibility date, excluding ineligible charges (date.max())
123+ future_eligible_charges = [
124+ charge for charge in case .charges
125+ if charge .expungement_result .charge_eligibility .date_to_sort_label_by
126+ and charge .expungement_result .charge_eligibility .date_to_sort_label_by != date .max ()
127+ ]
128+ if not future_eligible_charges :
129+ return None
130+ # Return the label of the charge with the latest date (case can't be expunged until all eligible charges are eligible)
122131 date_sorted_charges = sorted (
123- case . charges ,
124- key = lambda charge : charge .expungement_result .charge_eligibility .date_to_sort_label_by or date . max () ,
132+ future_eligible_charges ,
133+ key = lambda charge : charge .expungement_result .charge_eligibility .date_to_sort_label_by ,
125134 )
126- if date_sorted_charges [0 ].expungement_result .charge_eligibility .date_to_sort_label_by :
127- return date_sorted_charges [0 ].expungement_result .charge_eligibility .label
128- else :
129- return None
135+ return date_sorted_charges [- 1 ].expungement_result .charge_eligibility .label
You can’t perform that action at this time.
0 commit comments