Task. Provide users with the option to see the turnover of the specified period. It is a common scenario when users want to know how much money they spent during a day, month, or year.
Solution. Open the desktop form module and find the FillExpenses() procedure. Place the cursor to the Turnovers() method and press Ctrl+F1 to call the Syntax Assistant. You can see that Begin of period and End of period can be specified for the Turnovers() method.
Figure 17-1. Register method details in the Syntax assistant
All you have to do is add two attributes of the data type and pass them to the Turnovers() method.
It is time to do it. Add a group where the attributes will be placed to the form. Click , then, click Group - Regular group no visual presentation) and click OK.
Figure 17-2. New group
Name the new group PeriodGroup and place it above the Expense table. Set the Group property value to Horizontal.
Figure 17-3. Group properties and position
Add two form attributes BeginDate and EndDate. Set the type to Date and Date Contents to Date and time.
Figure 17-4. New form attributes
Drag the attributes you have created to PeriodGroup. Check that BeginDate is the first attribute in the group.
Figure 17-5. New form attributes
Note that the preview pane contains a group with two attributes of the Date type above the Expenses table.
Now change the form module as it is shown on the figure 17-6.
Figure 17-6. FillExpenses() procedure
Run the application in 1C:Enterprise mode to test the changes. To do it, analyze the Expenses register records and choose the period where only a part of posted documents are included.
Figure 17-7. New desktop
Figure 17-8. Expenses register records
On the desktop, set Begin date and End date and click Refresh.
Figure 17-9. Setting the period
Now you see turnovers of the specified period only. If you clear the dates and click Refresh, you see all of the turnovers again.Next page: Homework 3