In Designer mode

In contrast to the GoodsReceipt document that generates a single accounting posting, the Services document will generate two postings.

Remember that the accounting process at Jack of All Trades is simpler than real-life accounting since to make the job easier we only perform accounting for receipts and expenses of materials. The services provided by the company do not exist for the purposes of accounting.

Therefore, the Services document should generate accounting register records only for rows that include expenses of materials.

  1. In Designer, open the editor of the Services document configuration object.
  2. On the Posting tab, specify that the document creates records in the Primary accounting register.
  3. On the Other tab, open the object module.
  4. Open the Posting event handler procedure.
    Since you only need to create records related to materials, your additions will perfectly fit the If… clause that includes the generation of records for the BalanceOfMaterials and CostOfMaterials registers.
  5. Add the records for the Primary accounting register to the end of the condition, before the EndIf line (listing 16.3).

    Listing 16.3. Register records of the Services document (fragment)

    ...
    If SelectionDetailRecords.MaterialServiceType = Enums.MaterialServiceTypes.Material Then
     
        // register BalanceOfMaterials Expense
        ...
     
        // register CostOfMaterials Expense
        ...
     
        // register Primary
        // First posting: Dr 2000 (AccountsReceivable) – Cr 9000 (Income) Total
        Record = RegisterRecords.Primary.Add();
        Record.AccountDr = ChartsOfAccounts.Main.AccountsReceivable;
        Record.AccountCr = ChartsOfAccounts.Main.Income;
        Record.Period = Date;
        Record.Sum = SelectionDetailRecords.TotalInDocument;
        Record.ExtDimensionsDr[ChartsOfCharacteristicTypes.ExtraDimensionTypes.Customers] =
            Customer;
     
        // Second posting: Dr 9000 (Income) – Cr 5000 (Inventory) Cost
        Record = RegisterRecords.Primary.Add();
        Record.AccountDr = ChartsOfAccounts.Main.Income;
        Record.AccountCr = ChartsOfAccounts.Main.Inventory;
        Record.Period = Date;
        Record.Sum = MaterialCost * SelectionDetailRecords.QuantityInDocument;
        Record.QuantityCr = SelectionDetailRecords.QuantityInDocument;
        Record.ExtDimensionsCr[ChartsOfCharacteristicTypes.ExtraDimensionTypes.Materials] =
            SelectionDetailRecords.MaterialOrservice;
     
    EndIf;
    ...
    In the first posting you specify the document total as the record amount. The debit extra dimension for Accounts receivable is extended by customer.

    In the second posting you specify the cost of materials as the record amount. Additionally, you specify the quantity and the selected items as the credit extra dimension because the Inventory account features quantitative accounting and is divided by material.
  6. At the very beginning of the procedure, set the Write property of the accounting register to True (listing 16.4).
    This means that the register changes are recorded to the database.

    Listing 16.4. Writing register records

    Procedure Posting(Cancel, Mode)
     
        RegisterRecords.BalanceOfMaterials.Write = True;
        RegisterRecords.CostOfMaterials.Write = True;
        RegisterRecords.Sales.Write = True;
        RegisterRecords.Primary.Write = True;
        ... 

Finally, let us edit the command interface of the document form to add the command that opens the list of the Primary register records related to that 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 and select the Visible checkbox for the Primary command.
Next page: In 1C:Enterprise mode
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.