Let us create the Services document.
- Create a Document configuration object and name it Services.
On the Main tab let us define the document names used in 1C:Enterprise interface. Do not specify Object presentation, the platform will use the object synonym instead. - In the List presentation field, type Services.
- On the Subsystems tab, specify that the document is available in the Services and Accounting subsystems.
- On the Data tab, add the following document attributes:
- Warehouse. Type: CatalogRef.Warehouses, fill value: Main (the predefined item of the Warehouses catalog)
- Customer. Type: CatalogRef.Customers, fill check: display error
- Technician. Type: CatalogRef.Employees, fill check: display error
- Create a tabular section named MaterialsAndServices with the following attributes:
- MaterialOrService. Type: CatalogRef.MaterialsAndServices
- Quantity. Type: Number, length: 15, precision: 3, non-negative
- Price. Type: Number, length: 15, precision: 2, non-negative
- Total. Type: Number, length: 15, precision: 2, non-negative
- For the entire tabular section and for all its attributes, set the Fill check property to Display error.
- On the Forms tab, create the default document form.
- For the MaterialsAndServicesQuantity field, create the OnChange event handler that is executed on the client.
Later you will add a call of the CalculateTotal procedure from the DocumentProcessing common module to the handler.
Once you create a handler, the form module with a template for the MaterialsAndServicesQuantityOnChange event handler is opened. Do not fill the handler procedure body at that point. - In the form editor window, click the Form tab and create the OnChange event handler for the MaterialsAndServicesPrice field in a similar manner.
- Replace the script in the Services document form module with the following (listing 4.5).
Listing 4.5. Services document form module
&AtClient Procedure MaterialsAndServicesQuantityOnChange(Item) TabularSectionRow = Items.MaterialsAndServices.CurrentData; DocumentProcessing.CalculateTotal(TabularSectionRow); EndProcedure &AtClient Procedure MaterialsAndServicesPriceOnChange(Item) TabularSectionRow = Items.MaterialsAndServices.CurrentData; DocumentProcessing.CalculateTotal(TabularSectionRow); EndProcedure
Finally, let us edit the command interface to make the document creation commands available in the Services section. - Open the editor of the Services subsystem configuration object and click the Command interface button.
This opens the window that lists all commands of the selected subsystem. - In the Actions panel.Create group, select the check box next to the Services: create command (fig. 4.26).
Fig. 4.26. Specifying subsystem command interface settings
The Services document now looks as follows in the configuration object tree (fig. 4.27).
Fig. 4.27. The Services document in the configuration object tree