To my knowledge, it is not illegal to invoice in advance, nor to pay in advance, so long as it is in agreement with both parties. As Fidget mentioned, the revenue/expense side of things must comply with GAAP under the percentage of completion method.
Regards
Steve