Different Patterns of Revenue Recognition

What are the accounting rules for revenue recognition, what determines whether it is recognized up front or over a period of time.