Ben Affleck and Jennifer Garner have settled their divorce and will sign and file the paperwork once he leaves rehab. Picture: Bang Showbiz

Ben Affleck and Jennifer Garner announced they were going their separate ways in June 2015, before filing documents two years later, and their final settlement will be filed with the court after Ben leaves the Los Angeles rehab facility, The Canyon, where he recently checked in.

A source told TMZ that Ben and Jen, both 46, have agreed how to split their property and earnings from their 12-year marriage.

They have also agreed to joint custody of their children - Violet, 12, Seraphina, nine, and Samuel, six - and have decided to work with their schedules rather than a rigid custody plan. 

Jennifer and Ben were recently sent a legal warning by the court for "dragging their feet" over their divorce.

The Blast reported that the Los Angeles Superior Court told the former couple that their case is not completed because the final judgement hasn't been entered and it could be dismissed in its entirety.

The court is said to have told them: "If you fail to take the appropriate steps in your case, the court may dismiss your case for delay in prosecution."

However, TMZ reports that the divorce was delayed due to Ben's intermittent relapsing over the past 18 months.

One Ben leaves rehab, the pair are expected to sign the agreement and file it with the courts.

Earlier this week, a source claimed that Ben's decision to go to rehab is a "major step in the right direction".

The insider said: "One of the key elements with taking control of your addiction is knowing when to seek help, which he did, and it is a major step in the right direction. 

"One crucial aspect of Ben's recovery is for him to be able to seek help when he feels as though he is not in control - when his ongoing treatment and meetings with sober coaches aren't quite enough. The best case scenario is for him to seek help, which he has done willingly, and for that, we are all very grateful and hopeful."