As par IAS*18 revenue is recognized only when risk and reward is transferred to the party and it amount can be measured reliably
In case where payment is received before the event triggering recognition of revenue happens, the debit goes to cash and credit to unearned revenue. In case the event triggering revenue recognition occurs before payment is received, the debit goes to accounts receivable and credit to revenue.
Revenue is the item which is the easiest to misstate, hence more stringent rules and guidance is required in this area. IAS18 as it is always material item for a company.