The procedure for recording register movements when posting a document. Documents, accumulation registers, SKD 1s 8.3 movements to the accumulation register
It's time to talk about accumulation registers. Registers are needed to accumulate information about the movements of funds. Simply put, with their help you can find out the amount of cash balances, materials and their movements.
Let's take an example, if you have read previous articles (and if not, I advise you to read them in the 1C Enterprise section) in which I talked about how to create a new information base, how to create a document and a reference book, and also discussed many other nuances. So we have a document Arrival of Goods. Which contains the following details, supplier, name of the goods supplied, quantity, price and amount.
It would be nice for us to see how much product we have left in our warehouse and in what quantity. To solve this problem we will use an accumulation register. In the example I will use the creation of an accumulation register in 1C 8.2, but for 1 8.3 this instruction is also suitable.
How to create an accumulation register in 1C example
And so let’s start by opening our database in configurator mode, looking for the Accumulation Registers item and adding a new one. You already know how to add it, if not, then right-click and click add. Write the name of the register, say Balance in warehouse.
Let's add it to the reports subsystem so this is also a kind of report.
On the data tab, add Dimension, write the name Name and Resources, write Quantity.
Go to the Registrars tab and mark our document.
Now you need to open the Goods Receipt document and go to the Movements tab. And mark on the created accumulation register. Next, click on Motion Builder.
In the movement designer, you need to indicate what will be filled in from where and from which fields. Set the register movement type to Incoming. Just below you need to select the tabular part of our document, i.e. Materials. Now fill in the expressions opposite Name, write or select from the right window TekStrokMaterials.Name and opposite Quantity write TekStrokMaterials.Quantity and click ok.
In order for our register to be visible in the document, you need to open the document form. Go to the Command Interface tab and check it in the Visibility column.
We launch our database and check the result. We open the Goods Arrival document, go through it, go to the register and see what we have there.
If you did everything correctly, you should see the following. All fields must be completed.
Well, you and I have created the first accumulation register. At the moment, the register is only accumulating information. In the next lesson we will do the expense, but for now that’s all.
Algorithm for document posting taking into account event subscriptions
Document settings:
If you look at the document properties through the properties palette, you can see two important properties: “Deleting movements” and “Recording movements when conducting”, and the second is NOT listed on the “Movements” tab of the document editing window.
1. Removing movements.
If the "Delete movements" property is set to "Delete automatically", then BEFORE starting execution, the program clears all movements in registers. In fact, this means writing an empty set of register records with the record type - replacement. This means that the program executes code from the “BeforeWrite” and “OnWrite” procedures of the register record set module.
If a register has a subscription to the On Write event, the code from the associated procedure is executed.
2. Procedure "Processing" of the document module.
Please note: at the beginning of execution processing, all movements have a modified flag of False (the value is returned by the method Movement.Register.Modification()).
When working with a set of register entries (for example, Motion.Register.Clear(), Movement.Register.Add() etc.) the modified flag becomes True.
After recording the movement into the database Motion.Register.Write() modification is a lie again.
If a register set is written explicitly in the subscription procedure module (.Write() ), then the program executes the code from the “BeforeWrite” and “OnWrite” procedures of the register record set module and the procedure from the subscription to the “On Write” event of the register.
3. Subscriptions to the event "When posting" a document
It is important to understand: if in the processing of document posting or in event subscriptions called earlier, register movements were not recorded explicitly (Movements.Register.Write()), then the document movements have NOT yet been recorded in the database. Therefore, they cannot be retrieved using a query, but can be retrieved from the source's motion collection.
Procedure When Posting a Document (Source, Refusal, Posting Mode) Export Register = Source.Movement.Accounting; ..... End of Procedure
The order of subscriptions to the same event is not explicitly defined by 1C, but in practice, subscriptions are called up in the order they appear in the “Event Subscriptions” branch of the configuration editing window.
If registers are written using the Write method () , then all related procedures are executed.
4. Recording movements.
Let's remember about the "Record movements when swiping" property from the document settings.
If it is equal to “Write modified”, then all document movements that have the “Modified” flag set to True will be recorded in the database.
If it is equal to “Write selected”, then register movements for which we have explicitly indicated the need for recording will be recorded in the database.
Motion.Register.Write = True;
Movements are recorded in the database with substitution regime Truth. This means that records from the current set of Motion collection register records will be written and previous records cleared.
And at the end Let's look at a few examples:
Let the document property “Recording movements during execution” be equal to “Record modified”, and “Deleting movements” - “Do not delete automatically”.
Example 1.
ProcedureProcessingProcessing(Failure,ProcessMode) NewRecord = Movements.Register.Add(); .... Motion.Register.Write(False); //***EndProcedure
With this procedure of posting, the document will add an entry to the register each time it is re-posted, and the entries will multiply. Because line //*** adds entries to the register, the Modified flag is removed.
It would be more correct to write the line //*** as
Motion.Register.Write()
or omit it altogether, and then the program itself will record the modified movements.
Example 2.
In 1C 8, document movements can be generated not only in processing of posting, but also from the outside, for example, from some service processing (this is how additional processing of documents, restoration of advances, etc. is implemented).
Receipt = Documents.Receipt Invoice.Select(); Transactions = Accounting Registers.Register.CreateRecordSet(); While Arrival.Next() Loop DocLink = Arrival.Link;
In this case, when re-posting a document, if there is a change in the movements of the accounting register (Modification flag True), the entries will be replaced by the entries generated by the document.
Example 3.
Before the document is processed, all the document details are recorded in the database (i.e., the programmer can obtain them using a request). A Document Object is created in the internal memory, and this object has a collection of movements that will be recorded after the execution procedure is completed (see step 4).
If, in the process of posting a document, movements in registers are not formed using the Movements collection belonging to internal object, and in other ways (manually in the form of a set of records or as in example 2, etc.), then at stage 4 these records will be replaced!!! To avoid substitution in standard databases, for the document "OperationAccount" the document property "Posting" is set to "Prohibit".
If a document must be posted to other registers and posting cannot be prohibited, then you need to carefully configure the document properties:
Select the movement recording option "Record selected" and make sure that Movements.Register.Record = False
Select the “Record modified” movement recording option and control the Modification attribute for the set of records in this register.
Example 4.
You need to understand that the object received by reference (let's call it "ObjectDoc") and the internal object ("ThisObject") created in memory at the time of execution are two different instances of objects.
Accordingly, their collections of movements will be different. For "ObjectDoc" the collection of movements will include only the set of register records written to the database, and for "ThisObject" - both recorded and added and unwritten records. At the end of the process (stage 4), sets of records of “This Object” will be written to the database, with the attribute Replace = True.
If records are added to a recordset using the method described above, they can be replaced in step 4.
the cost of the materials available in the organization, we will need to access the documents, look through each of them, writing out the necessary data, and then summarize them, obtaining the necessary data. This approach is inconvenient - it is too slow both for our imaginary “manual” case and for automated accounting.It would be more logical, in addition to documents, to keep special tables in which, when receiving materials and when writing them off, to enter brief information about this. If, say, on a daily basis, you summarize these tables and display the remaining materials, then, in order to say how much and what materials the organization has on a certain date, it is enough to refer to the corresponding column of the table. In the 1C:Enterprise system, such tables are accumulation registers. As the name suggests, they are designed to reflect, accumulate, and certain indicators. And reflection in the registers of receipt and consumption of materials is one of the typical examples of their use.
Our organization keeps records of materials in connection with the responsible persons who receive them and from whom these materials are written off when released into production. We need to store information about the quantity of materials and their cost, and also, when written off for production, have information about which particular craftsman these materials were transferred to. These considerations allow us to design the structure accumulation register, which we will now create.
When planning a squad accumulation register we need to understand exactly what data we are going to store in it, and then “decompose” this data into dimensions, resources and register details.
So, we need to store the following data:
- Nomenclature position
- Responsible employee for this position
- Quantity of items
- Item cost
- Data about the master to whom the materials were transferred for use.
Register measurements, or the cuts in which data is stored, allow us to answer questions about what data is stored in the ledger. In our case, we need to know two main characteristics - this is what responsible person fixed one way or the other nomenclature position. Obviously, the dimensions from our data list will be item item and responsible employee.
Registry Resources– these are always numerical values characterizing the stored data. Numerical values are quantity and sum, and they will be the resources of our register.
Register details play a supporting role, and, in our case, it would be logical to store in the register details information about the craftsman who received the materials for the work - in case we need to find out who exactly used these materials.
Another important question to decide when designing a register is whether the register will balance register or revolution register. We are interested in both information about the remaining materials and information about turnover, so when setting up the register, you should specify the type of register - Leftovers. Register with a view Leftovers allows us to work with both balances and turnover
The structure proposed here accumulation register– this is just one of the options for how to organize the storage of the described data. Such an accounting scheme can be implemented, say, using a pair of registers, one of which is used exclusively for the purpose of storing the total balances of materials - that is, the data that is needed for financial reports, the other - for storing data on responsibility centers. In any case, each specific accounting scheme may require its own register structure, and our example is just a demonstration of one of the possible options.
Having discussed the theoretical part of the issue, let's move on to practice. Let's create a new one accumulation register, let's call it Remaining Materials, parameter Register type let's leave it at that value Leftovers, rice. 6.12.
Rice. 6.12.
Let's turn it on accumulation register into the subsystem Operational Materials Accounting.
On the tab Data Let's create the following dimensions, resources and details:
Measurements:
Name: Nomenclature, Type: DirectoryLink.Nomenclature, Prohibition of blank values – set.
Name: ResponsibleEmployee, Type: DirectoryLink.Employees, Prohibition of empty values – set.
Resources
Name: Quantity, Type: number, length 10, precision 3
Name: Sum, Type: number, length 10, precision 2
Requisites:
Name: Recipient of Materials, Type: DirectoryLink.Employees
Pay attention to the names of these details, their types, as well as the standard register details (Fig. 6.13.) - this data will be useful to us when working on the procedure carrying out the document.
Let’s exclude the general attribute from the register details Organization. There is no need for it now. To organize the storage of data in the register across various organizations, we would need a new dimension - Organization, thanks to which we would be able to work with materials from various organizations.
Let's go to the tab Registrars window for editing an object and select documents as recorder documents - Receipt of Materials And Release of Materials to the Master.
At this stage the setup accumulation register finished, let's move on to document settings. Let's start with the document Receipt of Materials.
Let's open the object editing window for this document, go to the tab Movements(Fig. 6.14.) and press the button
Rice. 6.14.
In the constructor, select the type of register movement - Coming, in field Tabular part indicate the tabular part of the document Materials, click on the button Complete expressions. The automatic mechanism for establishing a correspondence between document and register data does not always work correctly (in the event that it cannot unambiguously determine the correspondence, or when the correspondence determined by it according to its logic differs from the desired one), so we will check the correctness of the established correspondences. As a result, the window Designer register movements should look like shown in Fig.
6.15.
Rice. 6.15.
After clicking the OK button, the following execution processing procedure will be generated in the document object module (this is how it looks after removing the comments that the code was built by the motion designer):
Procedure ProcessingProcessing(Failure, Mode) // register Remaining Materials Arrival of Movement. Remaining Materials. Write = True;
For Each TekStrowMaterials From Materials Cycle Movement = Movements.RemainingMaterials.Add(); Movement.MovementType = AccumulationMovementType.Incoming;
Movement.Period = Date;
Movement.Nomenclature = TexStringMaterials.Nomenclature;
- Movement.ResponsibleEmployee = ResponsibleEmployee;
Motion.Quantity = TechStringMaterials.Quantity;
Movement.Amount = TexStringMaterials.Amount;
- Leftovers
EndCycle; End of Procedure
This procedure is declared in the object module, it is executed on
1C accumulation register
this is a structured data set that contains information about all movements (receipt / expense or turnover) of selected documents.
Measurements Types of accumulation register
You can also set the measurement properties to check whether the measurement is filled in (an empty value will cause an error)
Resources needed to store summary data in a register: quantity, amount, etc. In the future, we will receive resources by measurements.
Requisites are mainly needed to store related information and are rarely used.
Standard details are as follows:
- period - the date when the register movement was performed
- registrar - a document with which an entry was made in the register
- type of movement - income or expense (arrival increases the amount of resources, and expense decreases)
Registrars
Registrars are documents that can make movements in the accumulation register. Movements to the 1C accumulation register can only be made using documents (registrars). Most of the algorithms for creating movement in the accumulation register are formed when posting a document in the object module, the “Processing Posting” procedure.
Indexing dimensions
Indexing is required to increase the performance of the information base.
The “Index” property must be specified for dimensions for which you plan to perform multiple selections and which have a large number of elements.
For example: the accumulation register “Lots of Goods in Warehouses”. There is a dimension “Nomenclature” and “StatusParties”. It is more expedient to set the indexation attribute for the “Nomenclature” dimension than for “Part Status”, since the number of nomenclature options is much higher than for batch status.
Uniqueness of records
1C Enterprise controls the uniqueness of entries in the accumulation register, and therefore you will not find two identical entries.
Capabilities of the accumulation register
- a selection of records for a certain period according to specified dimensions
- selection of records by registrar
- obtaining balances and turnover for a selected date with specified measurements
- calculating totals for a specified date
Examples of working with the accumulation register
An example of obtaining balances for the current date
Procedure GetBalanceOnDate()
NewRequest = New Request;
NewQuery.Text =
"CHOOSE
| Commodity Remains.Nomenclature,
| ItemRemaining.QuantityRemaining
|FROM
| RegisterAccumulation.GoodsInWarehouses.Remains(&CurrentDate,) AS ProductRemains";
NewQuery.SetParameter("CurrentDate", CurrentDate());
EndCycle;
End of Procedure
An example of obtaining turnover for the current year
NewRequest = New Request;
NewQuery.Text =
"CHOOSE
| CommodityTurnover.Nomenclature,
| CommodityTurnover.QuantityTurnover
|FROM
| Accumulation Register.GoodsInWarehouses.Turnover(&StartPeriod, &EndPeriod,) AS Turnover";NewQuery.SetParameter("StartPeriod", StartYear(CurrentDate()));
NewQuery.SetParameter("ConPeriod", CurrentDate());SelectQuery = NewQuery.Execute().Select();
While QuerySelect.Next() Loop
EndCycle;
Example of how to select movements in the accumulation register
NewRequest = New Request;
NewQuery.Text =
"CHOOSE
| ProductsInWarehouses.Period,
| GoodsInWarehouses.Registrar,
| Products in Warehouses. Type of Movement,
| Products in Warehouses. Nomenclature,
| ProductsIn Warehouses.Quantity
|FROM
| Accumulation Register.GoodsInWarehouses AS GoodsInWarehouses";SelectQuery = NewQuery.Execute().Select();
While QuerySelect.Next() Loop
EndCycle;
Accumulation register list forms
Forms are used to visually view all movements of a selected register. In it you can see which documents record the expense or receipt, and also see what measurements are used. You can also sort movements or make selections there.
The system will automatically generate a list form or you can customize it yourself.
Hello dear readers, today the idea came to talk about 1C registers. Yes, I haven’t written about reference books or documents yet, but we’ll look at that later.
Now let’s look at the purpose of registers, types of registers, depict how registers are designed, and talk about their design and data storage.
Purpose of registers
Registers are intended to increase the speed of reading certain (analytical) indicators on the activities of the enterprise. Indicators are stored in registers in certain sections, taking into account frequency. Those. registers store time; for example, you can find out the stock balance of a certain product a month ago.
Register— a structure of a certain type that allows you to receive data at the same speed, regardless of the size of the database; without them, the output of the result will be slow.
Scheme of using registers in 1C:Enterprise
Documents => Registers => Reports
From the diagram you can see that registers are the basis for reports, and data is added to registers only when posting documents.
Types of analytical indicators
Registers are designed to store various indicators:
ACCUMULATION INDICATORS: Balances and Turnovers. Accumulation registers are designed to record them.
- Accumulation register(residual). Increases upon receipt and decreases upon sale. At each point in time, the register must remember the balance of a given product.
Some indicators can only grow in one direction (reversible indicator).
- Accumulation register(reverse). For example, sales data (there cannot be negative sales). If the product is returned, it will be registered with a negative sign.
CONDITION INDICATORS, a characteristic of an object, a register of information is intended.
- Register of information, has absolutely any data type. This value is valid until the next state change.
There are other types of registers: Accounting registers, Calculations.
Register image
The indicators that are stored in the register are called resources. Analytical sections - measurements.
Key register task– storage of indicators in terms of measurements and time
If you imagine the register as a coordinate system, you get:
Axes - Register Dimensions
Separate axis for change over time
Indicators at the intersection - resources
As an example, the figure shows the storage of goods in warehouses
The number of dimensions in the register can be quite large. In this case, the register can be presented in the form of a table, where each column corresponds to a dimension and there are also columns with resources.
Register: Remaining goods
Dimensions: Product, Warehouse
Resources: Quantity, Cost
Register design
The redundant structure of the register leads to an increase in the volume of the database, the time required to write to the register increases (documents take longer to process), and the complexity of development increases. The register structure must be determined immediately, because changing it in the future is a very complex process.
When determining measurements It is recommended to specify a reference data type (for directories, documents, enumerations). Order measurements affects the speed of receiving data from the register. Therefore, when designing a register, it is important to understand how often the user will receive balances for each dimension. All measurements are in order.
Resources— numerical data that characterize certain indicators (the information register resource can have any type of data). Resources represent values that are stored at the intersection of a dimension.
Props— some additional characteristic of the register that is not displayed when receiving totals. Register details can have any data type.
Storing data in registers
Registers can be represented by one or more tables. The composition of the tables depends on the register properties. There are no classes such as RegisterReference or RegisterObject for working with registers, because the register storage structure is different from object tables. Information is stored in the form of records. A register entry cannot be marked for deletion.
You can view the contents of the register in user mode using the main menu button “All functions”.
This is the end of this short review. 1C registers if you have any suggestions, additions then write in the comments.
1C Programmer was with you, I’ll help you with .
P.S. The girl is dancing