These topics are covered in full here:
Debtors Opening Balances
Creditors Opening Balances
End of Financial Year