What's the structure: I was to have given to him...

Hi;
In the following sentence:
-did you give john his money?
-No,I was to have given to him,but…
what is the structure of:“I was to have given to him…” ?