1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 18 (3:40). Using calculation registers. Adding a document that describes accruals

Adding a document that describes accruals

You need a new document for recording accruals to Jack of All Trades employees to the database.

In Designer mode

Let us create the document.

  1. In Designer, create a Document object named EmployeeAccruals.
  2. In the Object presentation field, enter Employee accrual.
  3. On the Numbering tab, set the number type to Number, and set the number length to 5 (fig. 18.1).

    Lesson 18 (3:40). Using calculation registers / Adding a document that describes accruals / In Designer mode
    Fig. 18.1. Document numbering
  4. On the Subsystems tab, specify that the document is displayed in the Payroll subsystem.
  5. On the Data tab, add a tabular section named Accruals with the following attributes:
    • Employee. Type: CatalogRef.Employees
    • WorkSchedule. Type: CatalogRef.WorkScheduleTypes
    • StartDate. Type: Date
    • EndDate. Type: Date
    • CalculationType. Type: ChartOfCalculationTypesRef.MainAccruals
    • Accrual. Type: Number, length: 15, precision: 2
    You need the StartDate and EndDate attributes for specifying the period where each calculation record is effective.
  6. On the Posting tab, prohibit real-time posting.
  7. Specify that the document creates records in the Accruals calculation register and run the register records wizard (fig. 18.2).

    Lesson 18 (3:40). Using calculation registers / Adding a document that describes accruals / In Designer mode
    Fig. 18.2. Document register records
  8. In the wizard, select the Accruals tabular section and then click Fill Expressions.
  9. For the EndOfActionPeriod and EndOfBasePeriod attributes, specify the following expression: EndOfDay(CurRowAccruals.EndDate).
  10. For the RegistrationPeriod field, specify the following expression: Date.
  11. For the SourceData attribute, specify the Accrual tabular section attribute.
  12. For the Result resource, leave the expression field empty (fig. 18.3).

    You will calculate this expression later.

    Lesson 18 (3:40). Using calculation registers / Adding a document that describes accruals / In Designer mode
    Fig. 18.3. EmployeeAccruals document records in the calculation register
  13. Click OK and review the handler script generated by the wizard (listing 18.1).

    Listing 18.1. Handler script generated by the register records wizard

    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 Accruals
        RegisterRecords.Accruals.Write = True;
     
        For Each CurRowAccruals In Accruals Do
     
            Record = RegisterRecords.Accruals.Add();
            Record.ReversingEntry = False;
            Record.CalculationType = CurRowAccruals.CalculationType;
            Record.BegOfActionPeriod = CurRowAccruals.StartDate;
            Record.EndOfActionPeriod = EndOfDay(CurRowAccruals.EndDate);
            Record.RegistrationPeriod = Date;
            Record.BegOfBasePeriod = CurRowAccruals.StartDate;
            Record.EndOfBasePeriod = EndOfDay(CurRowAccruals.EndDate);
            Record.Employee = CurRowAccruals.Employee;
            Record.WorkSchedule = CurRowAccruals.WorkSchedule;
            Record.SourceData = CurRowAccruals.Accrual;
     
        EndDo;
        //}}__REGISTER_REGISTERRECORDS_WIZARD
     
    EndProcedure

Let us review this script.

In general, it does not have any major differences with other event handlers that create register records.

The only thing we will remind you here is that Accruals is the name of the calculation register so the expressions RegisterRecords.Accruals.Write() and RegisterRecords.Accruals.Add() are intended to call the methods of the register record set.

The line For Each CurRowAccruals In Accruals Do calls the document tabular section by its name (Accruals) and iterates through this tabular section.

The script inside the loop adds a register record and assigns values taken from the document tabular section to the record fields.

The EndOfDay() function is used to assign values to the EndOfActionPeriod and EndOfBasePeriod fields. You did the same thing when you created reports in order to include the last day of a period to a report.

Finally, let us edit the command interface to make the document creation command available in the Payroll section.

  1. In the configuration tree, right-click the Payroll subsystem and then click Open command interface.
  2. In the Actions panel.create group, select the check box next to the Employee accrual: create command (fig. 18.4).

    Lesson 18 (3:40). Using calculation registers / Adding a document that describes accruals / In Designer mode
    Fig. 18.4. Editing subsystem command interface

In 1C:Enterprise mode

Let us test the document.

  1. Start 1C:Enterprise in the debug mode.
  2. In the Payroll section, run the Employee accruals command and record September salary for all Jack of All Trades employees (fig. 18.5).

    Lesson 18 (3:40). Using calculation registers / Adding a document that describes accruals / In 1C:Enterprise mode
    Fig. 18.5. Employee accrual document # 1
  3. Post the document and look at the records it generated in the Accruals register (fig. 18.6, 18.7, and 18.8).

    Lesson 18 (3:40). Using calculation registers / Adding a document that describes accruals / In 1C:Enterprise mode
    Fig. 18.6. Employee accrual  #1 register records in the Accruals calculation register

    Lesson 18 (3:40). Using calculation registers / Adding a document that describes accruals / In 1C:Enterprise mode

    Fig. 18.7. Employee accrual #1 register records in the Accruals calculation register

    Lesson 18 (3:40). Using calculation registers / Adding a document that describes accruals / In 1C:Enterprise mode
    Fig. 18.8. Employee accrual #1 register records in the Accruals calculation register

    Note that the platform set the registration period for each record to the beginning of the calculation register period (in the posting event handler you specified that it uses the document date, which is 9/23/2014 in this example).

    Also note that the SourceData record attribute stores the employee salary amount specified in the document. This lets you subsequently calculate the total payment, which is based on the salary.

    To learn more of calculation register functionality, you need a utility report that shows the contents of recalculation records.

Leave a Reply

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

1C:Enterprise Developer's Community