Skip to content

Commit b3f8cc1

Browse files
authored
Merge pull request #1763 from wittejm/restitution
Restitution
2 parents fee9771 + 56999b0 commit b3f8cc1

File tree

26 files changed

+106
-409
lines changed

26 files changed

+106
-409
lines changed

src/backend/expungeservice/charges_summarizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _primary_sort(charge: Charge, record: Record):
3838

3939
'''
4040
Order is:
41-
0 Needs More Analysis
41+
0 Needs More Analysis / Restitution Owed
4242
1 Ineligible
4343
2 Eligible Now
4444
3 Eligible on case with Ineligible charge
@@ -56,7 +56,7 @@ def _primary_sort(charge: Charge, record: Record):
5656
label = charge_eligibility.label
5757
has_balance = this_case.summary.balance_due_in_cents != 0
5858

59-
if label == "Needs More Analysis":
59+
if label == "Needs More Analysis" or label == "Ineligible If Restitution Owed":
6060
return 0, label, charge.case_number
6161
elif label == "Ineligible":
6262
return 1, label, charge.case_number

src/backend/expungeservice/crawler/crawler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def _read_case(session: Session, case_summary: CaseSummary) -> OeciCase:
8989
case_parser_data = Crawler._parse_case(session, case_summary)
9090
district_attorney_number = case_parser_data.district_attorney_number
9191
sid = case_parser_data.sid
92+
resitution = case_parser_data.restitution
9293
balance_due_in_cents = CaseCreator.compute_balance_due_in_cents(case_parser_data.balance_due)
9394
charges: List[OeciCharge] = []
9495
for charge_id, charge_dict in case_parser_data.hashed_charge_data.items():
@@ -102,6 +103,7 @@ def _read_case(session: Session, case_summary: CaseSummary) -> OeciCase:
102103
district_attorney_number=district_attorney_number,
103104
sid=sid,
104105
balance_due_in_cents=balance_due_in_cents,
106+
restitution=resitution,
105107
edit_status=EditStatus.UNCHANGED,
106108
)
107109
return OeciCase(updated_case_summary, charges=tuple(charges))

src/backend/expungeservice/crawler/parsers/case_parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class CaseParserData:
2222
hashed_charge_data: Dict[int, Dict[str, str]]
2323
hashed_dispo_data: Dict[int, Dict[str, str]]
2424
balance_due: str
25+
restitution: bool
2526
probation_revoked: Optional[date]
2627

2728

@@ -41,8 +42,9 @@ def feed(data) -> CaseParserData:
4142
probation_revoked = date.fromdatetime(datetime.strptime(probation_revoked_date_string, "%m/%d/%Y"))
4243
else:
4344
probation_revoked = None # type: ignore
45+
restitution = "restitution" in soup.text.lower()
4446
return CaseParserData(
45-
district_attorney_number, sid, hashed_charge_data, hashed_dispo_data, balance_due, probation_revoked
47+
district_attorney_number, sid, hashed_charge_data, hashed_dispo_data, balance_due, restitution, probation_revoked
4648
)
4749

4850
@staticmethod

src/backend/expungeservice/crawler/parsers/record_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def __record_case(self):
8383
self.date_location,
8484
self.type_status,
8585
self.case_detail_link,
86+
False,
87+
"0"
8688
)
8789
)
8890

src/backend/expungeservice/demo_records.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def build_search_results(
5050
"date": date_class.today(),
5151
"district_attorney_number": "01234567",
5252
"sid": "OR12345678",
53+
"restitution": False
5354
}
5455
shared_charge_data = {
5556
"balance_due_in_cents": 0,

src/backend/expungeservice/models/case.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class CaseSummary:
2222
violation_type: str
2323
current_status: str
2424
case_detail_link: str
25+
restitution: bool
2526
balance_due_in_cents: int
2627
edit_status: EditStatus
2728

@@ -61,6 +62,7 @@ def empty(case_number: str):
6162
current_status="",
6263
case_detail_link="",
6364
balance_due_in_cents=0,
65+
restitution=False,
6466
edit_status=EditStatus.UNCHANGED,
6567
),
6668
(),
@@ -112,7 +114,8 @@ def create(
112114
date_location,
113115
type_status,
114116
case_detail_link,
115-
balance="0",
117+
restitution,
118+
balance,
116119
) -> CaseSummary:
117120
name = info[0]
118121
birth_year = CaseSummary._parse_birth_year(info)
@@ -133,6 +136,7 @@ def create(
133136
violation_type,
134137
current_status,
135138
case_detail_link,
139+
restitution,
136140
balance_due_in_cents,
137141
EditStatus.UNCHANGED,
138142
)

src/backend/expungeservice/models/expungement_result.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ChargeEligibilityStatus(str, Enum):
2121
POSSIBLY_WILL_BE_ELIGIBLE = "Possibly Will Be Eligible"
2222
INELIGIBLE = "Ineligible"
2323
NEEDS_MORE_ANALYSIS = "Needs More Analysis"
24+
INELIGIBLE_IF_RESTITUTION_OWED = "Ineligible If Restitution Owed"
2425

2526
def __repr__(self):
2627
return f"{self.__class__.__name__}.{self.name}"

src/backend/expungeservice/record_editor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def _edit_case(case: OeciCase, case_edits) -> Tuple[OeciCase, List[Charge]]:
4646
case_summary_edits["balance_due_in_cents"] = CaseCreator.compute_balance_due_in_cents(value)
4747
elif key == "birth_year":
4848
case_summary_edits["birth_year"] = int(value)
49+
elif key == "restitution":
50+
case_summary_edits["restitution"] = value == "True"
4951
else:
5052
case_summary_edits[key] = value
5153
edited_summary = replace(case.summary, **case_summary_edits)

src/backend/expungeservice/record_merger.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def merge(
6161
charge_eligibility,
6262
label=f"Eligibility date dependent on open charge: {charge_eligibility.label}",
6363
)
64+
if case.summary.restitution and charge_eligibility.status != ChargeEligibilityStatus.INELIGIBLE :
65+
charge_eligibility = ChargeEligibility(
66+
ChargeEligibilityStatus.INELIGIBLE_IF_RESTITUTION_OWED, "Ineligible If Restitution Owed"
67+
)
6468
expungement_result = ExpungementResult(
6569
type_eligibility=merged_type_eligibility,
6670
time_eligibility=merged_time_eligibility,

src/backend/expungeservice/serializer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def case_summary_to_json(self, case):
5252
"case_detail_link": case.case_detail_link,
5353
"district_attorney_number": case.district_attorney_number,
5454
"sid": case.sid,
55+
"restitution": case.restitution,
5556
"edit_status": case.edit_status,
5657
}
5758

0 commit comments

Comments
 (0)