A San Diego man who stole money from a Girl Scout as she sold cookies in front of a grocery store – and then went on to try to buy heroin – will serve a one-year sentence for the crime.

On Friday, a judge sentenced Erik Mullen, 28, to 365 days in custody – the maximum sentence, as requested by the San Diego County District Attorney’s Office. Mullen may serve part of the time in jail or in a residential rehabilitation facility, the DA’s office confirmed.

An accomplice that Mullen met with to buy heroin after the crime was also sentenced; she got 180 days in custody with the same option to serve her time in a rehab facility. The DA’s office said the woman helped Mullen with the identity theft portion of this case, which involved felony ID theft in a check-cashing scheme. Both Mullen and the woman pleaded guilty. They were also both ordered to pay restitution.

On March 12, prosecutors said Mullen homed in on a 12-year-old Girl Scout, Leyla Hayward, who was selling Girl Scout Cookies with her mother, Deema Hayward, in front of a Vons in Clairemont Town Square on Clairemont Drive.

As the duo made their sales, Mullen swooped in and grabbed their cash box, which contained around $400. Mullen ran away; a witness chased after him, causing the thief to drop his cellphone.

The phone helped San Diego Police Department (SDPD) officers track down Mullen as the suspect. Hours later, he was arrested and, by early morning on March 13, was booked into jail.

At the time of the theft, Leyla was just 100 cookie boxes shy of accomplishing her 1,000-box sales goal for her Girl Scout Troop 4565.

The man arrested for taking off with a young girl’s cookie cash box pleaded not guilty. However, it was his role in an ID theft check cashing scheme that carried felony charges. NBC 7’s Steven Luke reports.

The girl’s mother was understandably upset, left trying to make sense of why anyone would steal from a child.

“I think it’s horrible just to steal from anybody, but to steal from a child who has been working so hard day after day to meet their goal, it’s just horrible,” Deema Hayward told NBC 7 after the incident. “She goes out every day door-to-door, booth sale after booth sale, trying to reach her goal."

Days after his arrest, Mullen pleaded not guilty to a series of charges, including petty theft, receiving stolen property and drug possession. He later changed his plea, leading to the judge’s final decision Friday.

A mother and daughter selling Girl Scout cookies outside of a Clairemont Square Vons were robbed Sunday when a man grabbed their cash box and ran. NBC 7’s Alex Presha reports.