bonded_inmates = {
let highest_bond_charges = [];
const inmate_charges = d3.group(
snapshot.filter(
(d) =>
!no_bond.has(d.Inmateid) && d.Bondtype !== "" && d["Current Bond"] > 0
),
(d) => d.Inmateid
);
for (const charges of inmate_charges.values()) {
const bails = charges.map((d) =>
d.Bondtype === "Cash Bond" ? d["Current Bond"] : d["Current Bond"] * 0.1
);
const max_bail = Math.max(...bails);
const highest_bond_charge = charges[bails.indexOf(max_bail)];
highest_bond_charge.bail = max_bail;
highest_bond_charges = [...highest_bond_charges, highest_bond_charge];
}
return highest_bond_charges.map((d) => ({
inmate: d.Inmateid,
booking_date: d.Bookingdate,
bond_type: d.Bondtype,
bond: d["Current Bond"],
bail: d.bail
}));
}