I think your first problem is using a table box. You would be ebtter off with a straight table and use a default expression like =1 to display all lines.
that aside I think also you will have issue joining your tables (unless you haven't put all your code in your first post).
If you have create a 3rd table calles InvoicesAmount with the staement you have posted this will simply create a single column table. that field is called SumAmount and is not linked to the other two tables.
If then in a table box you wish to display fields comng from Project, Invoices and this it will display SumAmount against every record it find from the first two tables.
[Hit ctrl T in your qvw document to see how your tables are linked together].
What is the purpose of thsi SumAmount field? Why do you want/need to create this in the script and not simply in a chart when you need it?
Answering these two questions will help define how how and when this calculation shoud be done.