1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 12 (0:40). Turnover accumulation registers. Posting Services documents across three registers

Posting Services documents across three registers

Let us first modify the posting procedure of the Services document and then repost all Services documents in 1C:Enterprise mode to create new register records according to the modified posting algorithm.

In Designer mode

Let us modify the document posting procedure.

  1. In Designer, open the Services document editor window and click the Posting tab.
  2. Add the Sales register to the list of registers affected by the document.
  3. Click the Other tab and then click Object module.
  4. Add the script lines that create Sales register records for the Services document to the handler of the Posting event, to the end of the loop, right after the EndIf operator and before the EndDo operator (listing 12.1).

    Listing 12.1. Records of the Services document (fragment)

    // register Sales
    Record = RegisterRecords.Sales.Add();
    Record.Period = Date;
    Record.MaterialOrService = CurRowMaterialsAndServices.MaterialOrService;
    Record.Customer = Customer;
    Record.Technician = Technician;
    Record.Quantity = CurRowMaterialsAndServices.Quantity;
    Record.Revenue = CurRowMaterialsAndServices.Total;
    Record.Cost = CurRowMaterialsAndServices.Quantity * CurRowMaterialsAndServices.Cost;
  5. Before the loop set the Write property of the register record to True. The resulting procedure should look as shown in listing 12.2.

    Listing 12.2. Records of the Service document

    Procedure Posting(Cancel, Mode)
        RegisterRecords.BalanceOfMaterials.Write = True;
        RegisterRecords.CostOfMaterials.Write = True;
        RegisterRecords.Sales.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;
     
            // register Sales
            Record = RegisterRecords.Sales.Add();
            Record.Period = Date;
            Record.MaterialOrService = CurRowMaterialsAndServices.MaterialOrService;
            Record.Customer = Customer;
            Record.Technician = Technician;
            Record.Quantity = CurRowMaterialsAndServices.Quantity;
            Record.Revenue = CurRowMaterialsAndServices.Total;
            Record.Cost = CurRowMaterialsAndServices.Quantity * CurRowMaterialsAndServices.Cost;
            
        EndDo;
    EndProcedure

You already know all the added expressions well.

Just note that the turnover register does not have a RecordType property, since specifying the record type (receipt or expense) only makes sense for balance accounting. As for turnover registers, we are only interested in the value that is written to the register resource.

Also note that you added the commands that create Sales register records to the end of the loop that iterates through the document tabular section, to the part that is not affected by the condition that checks whether an item is a material. This is important because in this register records are created for both materials and services.

Finally, let us edit the document form command interface to add the link for viewing the Sales 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 Sales accumulation register.
  4. Select the Visible check box for this command.

In 1C:Enterprise mode

Let us repost all of the Services documents in 1C:Enterprise mode and check that they create correct records in the Sales register.

  1. Start 1C:Enterprise in the debug mode.
  2. For each Services document, open it, click Post, and then open the Sales register records.

    The sales records should look as shown in fig. 12.3a, 12.3b, 12.4a, 12.4b, 12.5a, and 12.5b.

    Lesson 12 (0:40). Turnover accumulation registers / Posting Services documents across three registers / In 1C:Enterprise mode
    Fig. 12.3a. Services document #1 records in the Sales register

    Lesson 12 (0:40). Turnover accumulation registers / Posting Services documents across three registers / In 1C:Enterprise mode
    Fig. 12.3b. Services document #1 records in the Sales register

    Lesson 12 (0:40). Turnover accumulation registers / Posting Services documents across three registers / In 1C:Enterprise mode
    Fig. 12.4a. Services document #2 records in the Sales register

    Lesson 12 (0:40). Turnover accumulation registers / Posting Services documents across three registers / In 1C:Enterprise mode
    Fig. 12.4b. Services document #2 records in the Sales register

    Lesson 12 (0:40). Turnover accumulation registers / Posting Services documents across three registers / In 1C:Enterprise mode
    Fig. 12.5a. Services document #3 records in the Sales register

    Lesson 12 (0:40). Turnover accumulation registers / Posting Services documents across three registers / In 1C:Enterprise mode
    Fig. 12.5b. Services document #3 records in the Sales register

You can see that the Sales register stores both material and service records.

Now you have virtually all the data you need to analyze operations of Jack of All Trades.

In the next lesson you will create some reports that will provide you with summary information on the company operations.

Leave a Reply

Your email address will not be published. Required fields are marked *

1C:Enterprise Developer's Community