Desktop version

Main > Knowledge Base > Knowledge Base > Knowledge base > Practical developer guide 8.3 > Lesson 11 (1:20). Posting documents across multiple registers > Posting Services documents across two registers > In Designer mode > Modifying the posting procedure > Practical developer guide 8.3 > Lesson 11 (1:20). Posting documents across multiple registers > Posting Services documents across two registers > In Designer mode > Modifying the posting procedure

Modifying the posting procedure

Let us modify the document posting procedure. 

  1. In Designer, open the Services document editor window and click the Posting tab. 
  2. Add the CostOfMaterials register to the list of registers affected by the document.
    To preserve the changes that you made in the posting procedure in the previous lesson, do not use the Register records wizard this time. Instead, let us make the required changes in the Posting event handler of the Services document manually.
  3. Click the Other tab and then click Object module.
  4. Add the script lines that create CostOfMaterials register records for the Services document to the handler of the Posting event, to the end of the loop, right before the EndIf operator (listing 11.3).

    Listing 11.3. Records of the Services document (fragment)

    // register CostOfMaterials Expense
    Record = RegisterRecords.CostOfMaterials.Add();
    Record.RecordType = AccumulationRecordType.Expense;
    Record.Period = Date;
    Record.Material = CurRowMaterialsAndServices.MaterialOrService;
    Record.Cost = CurRowMaterialsAndServices.Quantity * CurRowMaterialsAndServices.Cost;
  5. Before the loop set the Write property of the register record set to True and remove the comments generated by the wizard. The resulting procedure should look as shown in listing 11.4.

    Listing 11.4.  Records of the Services document

    Procedure Posting(Cancel, Mode)
     
        RegisterRecords.BalanceOfMaterials.Write = True;
        RegisterRecords.CostOfMaterials.Write = True;
            
        For Each CurRowMaterialsAndServices In MaterialsAndServices Do
            If CurRowMaterialsAndServices.MaterialOrService.MaterialServiceType = Enums.MaterialServiceTypes.Material Then
     
                // register BalanceOfMaterials Expense
                Record = RegisterRecords.BalanceOfMaterials.Add();
                Record.RecordType = AccumulationRecordType.Expense;
                Record.Period = Date;
                Record.Material = CurRowMaterialsAndServices.MaterialOrService;
                Record.Warehouse = Warehouse;
                Record.Quantity = CurRowMaterialsAndServices.Quantity;
            
                // register CostOfMaterials Expense
                Record = RegisterRecords.CostOfMaterials.Add();
                Record.RecordType = AccumulationRecordType.Expense;
                Record.Period = Date;
                Record.Material = CurRowMaterialsAndServices.MaterialOrService;
                Record.Cost = CurRowMaterialsAndServices.Quantity
                    * CurRowMaterialsAndServices.Cost;
    
            EndIf;
        EndDo;
            
    EndProcedure

Note that the Cost register dimension is calculated by multiplying the cost and the quantity specified in the document tabular section.

Finally, let us edit the document form command interface to add the link for viewing the CostOfMaterial register records related to the document to the form 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.
    It contains the command that opens the list of the Cost of materials accumulation register.
  4. Select the Visible check box for this command.
Next page: In 1C:Enterprise mode



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.