Whenever a proceeding is held in a superior court under Article 5 (commencing with Section 5275) or Article 6 (commencing with Section 5300) of this chapter or Chapter 3 (commencing with Section 5350) of this part involving a person who has been placed in a facility located outside the county of residence of the person, the provisions of this section shall apply. The appropriate financial officer or other designated official of the county in which the proceeding is held shall make out a statement of all of the costs incurred by the county for the investigation, preparation, and conduct of the proceedings, and the costs of appeal, if any. The statement shall be certified by a judge of the superior court of the county. The statement shall then be sent to the county of residence of the person, which shall reimburse the county providing the services. If it is not possible to determine the actual county of residence of the person, the statement shall be sent to the county in which the person was originally detained, which shall reimburse the county providing the services.