First you need to understand that each country has its own tax laws which vary.
In the United States companies have a choice of using either the cash or accrual basis of accounting. Under the cash basis the revenue counts in the tax year that the payment was actually received (or paid in the case of the company making the payment).
Under the accrual system, the revenue (or cost) is recognized in the year the work was done. Payment could have occurred either before (pre-payment) or after the work.