1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 6 (0:50). Accumulation registers. Creating register records of the Services document

Creating register records of the Services document

Now let us set up generation of register records for the Services document.

In Designer mode

Let us use a procedure similar to setting up register records for the Goods receipt document.

  1. Open the configuration object editor for the Services document.
  2. Click the Posting tab and select the BalanceOfMaterials check box.
  3. Click Register records wizard.
  4. 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 Lesson 6 (0:50). Accumulation registers / Creating register records of the Services document / In Designer mode.
  5. 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.
  6. 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.
  7. 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).

    Lesson 6 (0:50). Accumulation registers / Creating register records of the Services document / In Designer mode
    Fig. 6.18. Selecting a document tabular section and filling the expressions for calculating register records
  8. 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.

  1. Open the Services document form.
  2. In the upper left pane, click the Command interface tab.
  3. In the Navigation panel branch, expand the Go to node and select the Visible check box for the command that opens the Balance of materials accumulation register.

In 1C:Enterprise mode

Let us test the changes.

  1. Start 1C:Enterprise in the debug mode.
  2. In the Services section, open the first Services document and click Post and close.

    This reposts the document.
  3. Run the Balance of materials command.

    This opens the accumulation register list (fig. 6.19).

    Lesson 6 (0:50). Accumulation registers / Creating register records of the Services document / In 1C:Enterprise mode
    Fig. 6.19. List of the BalanceOfMaterials accumulation register

    You can see that the Balance of materials accumulation register now has a new record (a single record because the tabular section of the posted document has a single row).

    All register fields are filled with the document data exactly as specified in the posting handler of the Services document.

    The Lesson 6 (0:50). Accumulation registers / Creating register records of the Services document / In 1C:Enterprise mode icon to the left of the record indicates that the register record type is Expense (see fig. 6.19).

    Now you see the full list of register records. You can have it filtered by recorder document if you open it from a document form.
  4. Open the first Services document again.

    The document form now has a navigation panel where you can switch to the list of Balance of materials register records related to this document (fig. 6.20) and then switch back to the document content (the Main link).

    Lesson 6 (0:50). Accumulation registers / Creating register records of the Services document / In 1C:Enterprise mode
    Fig. 6.20. Switching to the accumulation register from the document form

    But the register records generated by this document might be inaccurate.

    In contrast to the Goods receipt document, the Services document can list not only the materials but the services as well. Therefore, records that describe rendered services can appear in the Balance of materials register, which is not what we want.

    For now, we will not change the register records generated by the wizard, but as soon as we proceed to enumerations, you will make the necessary modifications to the posting handler.

Leave a Reply

Your email address will not be published.

 

1C:Enterprise Developer's Community