1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 11 (1:20). Posting documents across multiple registers. Posting goods receipts across two registers

Posting goods receipts across two registers

In Designer mode

In 1C:Enterprise mode

In 1C:Enterprise mode you have to repost all goods receipts. This is required for the documents to create new register records according to the posting algorithm you have just modified.

  1. Start 1C:Enterprise in the debug mode.
  2. In the Inventory section, run the Goods receipts command.

    This opens the list of goods receipts.
  3. Click each goods receipt while holding down Ctrl to select all of them, and then, on the More menu, click Post.
  4. Open the first document (fig. 11.7) and run the Balance of materials and Cost of materials commands.

    You can see that the document created records in both accumulation registers (fig. 11.8 and fig. 11.9).

    Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In 1C:Enterprise mode
    Fig. 11.7. Goods receipt #1

    Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In 1C:Enterprise mode
    Fig. 11.8. Balance of materials register records

    Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In 1C:Enterprise mode
    Fig. 11.9. Cost of materials register records

Modifying the posting procedure

Let us modify the document posting procedure.

  1. In Designer, open the GoodsReceipt document editor window and click the Posting tab.
  2. Add the CostOfMaterials register to the list of registers affected by the document (fig. 11.3).

    Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In Designer mode / Modifying the posting procedure
    Fig. 11.3. Creating records of the GoodsReceipt document in the CostOfMaterials register
  3. Click Register records wizard.
  4. Confirm that you want to replace the previously generated posting procedure.

    By doing this you do not lose any data because you have not changed the previously generated procedure and the new one will add records to both registers.

    In the Register Records Wizard window you can see that all of the fields related to the BalanceOfMaterials register contain data that you specified earlier, when you set up record generation for this register in section Creating register records of a document.
  5. Click the Add Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In Designer mode / Modifying the posting procedure button above the Registers list and add the CostOfMaterials register (fig. 11.4).

    Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In Designer mode / Modifying the posting procedure
    Fig. 11.4. Register records wizard

    The default register record type is Receipt (the Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In Designer mode / Modifying the posting procedure icon is displayed next to the register name).
  6. In the Tabular Section list, select Materials.

    It is the tabular section of the GoodsReceipt document.

    Once you select the tabular section, its attributes are added to the Document attributes list, which already contains the document header attributes.
  7. 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.

    Let us specify the mapping for the Cost register field.
  8. In the Field column, click the Cost field, and then, in the Document attributes list, double-click the CurRowMaterials.Total attribute (fig. 11.5).

    Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In Designer mode / Modifying the posting procedure
    Fig. 11.5. Register records wizard
  9. Click OK.

    The wizard generates a procedure in the GoodsReceipt document module and opens the module. You can see that the new handler procedure includes the generation of records in two registers (listing 11.1).

    Listing 11.1. Records of the GoodsReceipt document

    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 Receipt
        RegisterRecords.BalanceOfMaterials.Write = True;
        For Each CurRowMaterials In Materials Do
            Record = RegisterRecords.BalanceOfMaterials.Add();
            Record.RecordType = AccumulationRecordType.Receipt;
            Record.Period = Date;
            Record.Material = CurRowMaterials.Material;
            Record.Warehouse = Warehouse;
            Record.Quantity = CurRowMaterials.Quantity;
        EndDo;
     
        // register CostOfMaterials Receipt
        RegisterRecords.CostOfMaterials.Write = True;
        For Each CurRowMaterials In Materials Do
            Record = RegisterRecords.CostOfMaterials.Add();
            Record.RecordType = AccumulationRecordType.Receipt;
            Record.Period = Date;
            Record.Material = CurRowMaterials.Material;
            Record.Cost = CurRowMaterials.Total;
        EndDo;
     
        //}}__REGISTER_REGISTERRECORDS_WIZARD
    EndProcedure
    You can see that the script fragment that describes the record generation for the CostOfMaterials register is similar to the script fragment that describes the record generation for the BalanceOfMaterials register.

    But having two loops that iterate through the Materials tabular section is not optimal, you can use a single loop for this.
  10. Combine the two loops into one and delete the comments generated by the wizard.

    Then your procedure should look as shown in listing 11.2.

    Listing 11.2. Records of the GoodsReceipt document

    Procedure Posting(Cancel, Mode)
     	
        RegisterRecords.BalanceOfMaterials.Write = True;
        RegisterRecords.CostOfMaterials.Write = True;
     	
        For Each CurRowMaterials In Materials Do
        // register BalanceOfMaterials Receipt
     
            Record = RegisterRecords.BalanceOfMaterials.Add();
            Record.RecordType = AccumulationRecordType.Receipt;
            Record.Period = Date;
            Record.Material = CurRowMaterials.Material;
            Record.Warehouse = Warehouse;
            Record.Quantity = CurRowMaterials.Quantity;
     
        // register CostOfMaterials Receipt
            Record = RegisterRecords.CostOfMaterials.Add();
            Record.RecordType = AccumulationRecordType.Receipt;
            Record.Period = Date;
            Record.Material = CurRowMaterials.Material;
            Record.Cost = CurRowMaterials.Total;
        EndDo;
    	 
    EndProcedure

Adding the command that opens register records

Finally, let us edit the document form command interface to add the link for viewing the CostOfMaterials register records related to the document to the form navigation panel.

  1. Open the GoodsReceipt 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 (fig. 11.6).

    Lesson 11 (1:20). Posting documents across multiple registers / Posting goods receipts across two registers / In Designer mode / Adding the command that opens register records

    Fig. 11.6. GoodsReceipt document form command interface setup

Leave a Reply

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

1C:Enterprise Developer's Community