In the last tutorial, you created a formula field to calculate Line Item Totals. In this tutorial, you implement some more common business logic: an Invoice Total summary field in the parent Invoice object. To create summary fields based on master-detail relationships in Force.com, you can use a roll-up summary field.
You must complete Quick Tutorial 1: Build a Cloud App in 5 Minutes before continuing with this tutorial.
To add a rollup summary field to the Invoice object:
Invoice Total, press Tab, and click Next.
Click Next, Next, and then Save.
To see the new field, click the Invoices tab and examine an Invoice. Notice the new Invoice Total field that rolls up the values from all of the detail Line Items.
Look carefully at an Invoice detail page, the two new fields you recently added don't appear in the Line Items list. Indeed, you must add them to the Invoice layout. You already edited page layouts in Quick Tutorial 8: Customize a User Interface — Modify a Page Layout, see if you can figure out how to add the Unit Price and Line Item Total to the Invoices layout. When you're done, create a new invoice, add some line items, and make sure it looks something like this: