Let us use a procedure similar to setting up register records for the Goods receipt document.
- Open the configuration object editor for the Services document.
- Click the Posting tab and select the BalanceOfMaterials checkbox.
- Click Register records wizard.
- In the wizard window, set Register Record Type to Expense.
Indeed, the Services document is intended to record expenses of materials. Note that the icon to the left of the register name changed to the minus sign . - In the Tabular Section list, select MaterialsAndServices.
It is the only tabular section in the document. Its attributes are added to the list of document attributes. - Click Fill Expressions.
In the bottom pane, the mapping between the register fields (dimensions and resources) and the expressions for calculating their values is generated. But the Material field is not filled automatically.
This is because the name of the tabular section field (MaterialOrService) does not match the name of the register dimension (Material). If you leave it as is, products will not be recorded to accumulation register rows with Expense register record type. Let us fix that. - Select the Material register field and then, in the Document attributes list, double-click CurRowProductList.MaterialOrService.
This ensures that the materials for the accumulation register records are selected from the document tabular section (fig. 6.18).
Fig. 6.18. Selecting a document tabular section and filling the expressions for calculating register records - Click OK.
The wizard generates a procedure in the Services document module (listing 6.2).
Listing 6.2. Posting() procedure
Procedure Posting(Cancel, Mode) //{{__REGISTER_REGISTERRECORDS_WIZARD // This fragment was built by the wizard. // Warning! All manually made changes will be lost next time you use the wizard. // register BalanceOfMaterials Expense RegisterRecords.BalanceOfMaterials.Write = True; For Each CurRowMaterialsAndServices In MaterialsAndServices Do Record = RegisterRecords.BalanceOfMaterials.Add(); Record.RecordType = AccumulationRecordType.Expense; Record.Period = Date; Record.Material = CurRowMaterialsAndServices.MaterialOrService; Record.Warehouse = Warehouse; Record.Quantity = CurRowMaterialsAndServices.Quantity; EndDo; //}}__REGISTER_REGISTERRECORDS_WIZARD EndProcedure
It is the Posting event handler for the Services document configuration object.
Note that the line Record.RecordType = AccumulationRecordType.Expense defines the type of the accumulation register record generated by this document as Expense. The rest of the procedure is similar to the posting handler of the GoodsReceipt document (see listing 6.1) that we have discussed in detail earlier.
Finally, let us edit the command interface of the document. You will add the command that opens the Balance of materials list with records generated by that document to the navigation panel.
- Open the Services document form.
- In the upper left pane, click the Command interface tab.
- In the Navigation panel branch, expand the Go to node and select the Visible checkbox for the command that opens the Balance of materials accumulation register.