Theme previews are not representative of any particular transaction. They are only meant to show the general appearance of a custom theme. Particular transactions populate variable arrays with different information, depending on context. And they include or exclude variables entirely, again depending on context.
Your sample screen shot also shows quite a bit of content that does not exist for sales invoices. It’s not clear what that screen shot shows, but a sales invoice does not return, and therefore cannot display, a great deal of the information. I don’t know where, for example, you think you will get information on validity periods.
At any rate, the purpose of this forum is not to help users debug their custom themes. Those are you own responsibility. And you are better off seeking guidance on dedicated coding forums. Ask your accounting questions here about features of the program and how to use them.