Accounting info. Accounting info BP 3.0 control of negative balances

This article is intended for 1C implementers - and especially for those who are preparing for the 1C Certification: Platform Specialist.

Today we will look 2 methods for controlling balances - not only balances in the warehouse, but also, for example, mutual settlements (“What is the client’s current debt and is it possible to ship goods to him?”)

Both methods are used in standard configurations and in Certification tasks. And since there are two of them - you need to clearly understand when the “new” technique is applicable, and when only the “old” one.

This is basic knowledge for 1C programmers; we recommend not leaving gaps in such areas. It should take you to study 15 minutes :)

Formulation of the problem

Let’s take a simple configuration with the documents “Receipt of goods” and “Sales of goods”:

To account for balances, the accumulation register “Free balances” is used:

When posting the document “Receipt of goods” the following movements are performed:

ProcessingProcedure(Failure, Mode)


For Each TechStringProducts From Products Cycle
Movement = Movements.FreeRemains.Add();
Movement.MovementType = AccumulationMovementType.Incoming;
Movement.Period = Date;
Movement.Nomenclature = TechStringProducts.Nomenclature;
Movement.Quantity = TechStringProducts.Quantity;
EndCycle;

End of Procedure

Processing of posting the document “Receipt of goods” was carried out using the movement designer and is not of interest, since when it arrives at the warehouse, control of balances is not needed.

Sometimes balance control is also implemented for the “Receipt of goods” document - so that when the document is canceled or re-posted, a negative balance does not form.

For example, 10 new LG TVs arrived at the warehouse, 6 of them were sold. If the receipt document contains 10 pieces. fix by 5 pcs. – a negative balance “minus 1 piece” is formed.

In the standard UT 11, such control is enabled using the functional option “Control goods of organizations when canceling receipts.”

When posting the document “Sales of goods” it is necessary to organize control of residues. If there is not enough product left, the document is not posted and a diagnostic message is issued. This is the problem being solved.

We are intentionally working on a simple problem where the write-off cost is not calculated. This will allow us to focus specifically on the nuances of residue control.

Note– the algorithms presented below are designed for training and should be as clear as possible.
They can be optimized, but then the “comprehension coefficient” will be lower, so we do not dwell on this in this article.

Naturally, you can optimize them yourself, or take our course on Acceleration and Optimization of 1C :)

As you already understood, solving the problem can be done in two ways. Let's start with a technique that has been used since the days of 1C:Enterprise 8.0.

Old method of residue control

The principle of the old residue control technique is as follows: We check whether there are remaining goods in the required quantity. If there is, we write it off, if not, we report an error..

The algorithm in the old method consists of several blocks:

  1. The request retrieves product balances and document data
  2. The cycle monitors the sufficiency of goods
  3. If there are not enough goods, then the document is not posted
  4. If there are enough goods, consumption movements are performed

This is what the program code looks like:

// 1. Clearing old register movements
Movements.FreeRemainders.Write = True;
Movements.Record();

// 2. Receiving document data and register balances by request
Request = New Request;
Request.Text =
"CHOOSE

|PLACE Products
|FROM
|WHERE
| Products.Link = &Link
|GROUP BY
| Products.Nomenclature
|INDEX BY
| Nomenclature
|;

|SELECT
,
| REPRESENTATIONLINK(Products.Nomenclature) AS NomenclatureRepresentation,
| Products.Quantity AS Quantity,
| ISNULL(Remaining.NumberRemaining, 0) AS Remainder
|FROM
| Products AS Products
| LEFT JOIN RegisterAccumulations.FreeRemains.Remains(
| &Moment of time,
| Nomenclature B
| (CHOOSE
| Products.Nomenclature AS Nomenclature
| FROM
| Software Products.Nomenclature = Remaining.Nomenclature";
Request.SetParameter("TimePoint", TimePoint());

// 3. Traversing query results

// 4. Checking the sufficiency of goods
Deficit = SampleProducts.Quantity - SampleProducts.Remaining;
If Deficit>0 Then
Refuse = True;
Message.Text = "Product "+SelectionProducts.NomenclaturePresentation+" is not enough in quantity "+Shortage+" pcs.";
Message.Message();
endIf;

// 5. Go to the beginning of the loop if there were errors
If Failure Then
Continue;
endIf;

// 6. Performing movements into registers
Movement.Period = Date;

EndCycle;

// 7. Setting the flag for recording movements at the end of the transaction
Movements.FreeRemainders.Write = True;

End of Procedure

Let us comment on the key points of the algorithm.

1. Clearing old register movements

Below in the algorithm there will be a request to the remainder of the register.

If the current document was previously posted, then there is probability of receiving old document movements in a request– this is a serious problem.

When is such a situation possible? When is the document date moves forward.

Let's show with an example what this will lead to:

  1. Remaining table lamps 10 pcs.
  2. The document dated 02/16/17 is being processed, we are writing off 6 lamps
  3. The date in the document is changed to 02/17/17 (the date can be shifted forward by at least 1 second), let’s repost the document.

If you do not clear movements, the system will report a shortage of 2 pieces. Why? Yes, because the old document movements wrote off 6 out of 10 existing lamps. Next, the system tries to write off 6 more pieces, but there are only 4 left.

The problem is solved in 3 lines of code:

  • The recordset is being cleared (it may have been read on the form or in previous handlers)
  • The record set has the “Write” flag set
  • All sets that have the “Record” flag set are recorded.

Strictly speaking, we can control the cleanup of movements when posting documents:

The option of deleting movements when canceling the execution is recommended - we ourselves control when it is necessary to actually delete movements.

2. Receiving document data and register balances by request

The request consists of two packages:

  • In the first, grouped data from the tabular part is obtained - a temporary table is created
  • In the second request, the remainders from the register are appended to the document data.

What you should pay attention to in this request:

  1. When creating a temporary table, the field on which the join will be performed is indexed - this is done for optimal performance
  2. The moment of receipt of balances – corresponds to the position of the document on the time axis
  3. There may be no remainders in the register - therefore, a left join is performed and the “ECTNULL” function is used for the “Quantity” resource - the NULL value is reduced to zero.

3. Bypassing query results

The developed request contains grouped document data and balances by item items.

In a loop we go through the result of this request.

4. Check for sufficiency of goods

We determine the shortage of goods.

If the deficit is greater than zero, it means there is a shortage of goods:

  • We issue a diagnostic message
  • Set the “Refusal” parameter for posting processing to “True”

If “Refusal” is equal to “True”, then the result of the document posting transaction will not be recorded. In simple terms, this is a command to the system not to process this document.

5. Go to the beginning of the cycle if there were errors

If there were errors at this or previous steps of the cycle (Failure = True), then there is no point in forming movements. All the same, they will not be recorded in the database.

6. Performing movements in registers

If the check of balances was successful, we create the expense movement.

7. Setting the motion recording flag at the end of the transaction

If this flag is not set, then movements will NOT be recorded.

At the end of the document posting transaction, only those sets of records are written that have the “Write” flag set.

To be fair, we note that setting the “Record” property of a set of records makes sense under one condition - in the document property “Record movements during execution” the value “Record selected” must be specified:

However, it is the “Record selected” value that is the de facto standard:

  • It is used in standard solutions
  • Set by default when creating new documents.

Another value of the property – “Write modified” – is outdated and practically never occurs in modern configurations.

New method for residue control

The new method uses the principle: we write off the necessary goods, then check whether negative balances have been formed for the goods of the document. If yes, then you need to roll back the document.

As you can see, there is a fundamental difference in the moment of control of balances:

  • The old method is to first check the balance, then write it off
  • New technique - first we write off, then we check the balance.

As a result, the program code will look like this:

ProcessingProcedure(Failure, Mode)

// 1. Receiving document data by request
Request = New Request;
Query.TemporaryTableManager = NewTemporaryTableManager;
Request.Text =
"CHOOSE
| Products.Nomenclature AS Nomenclature,
| SUM(Items.Quantity) AS Quantity
|PLACE Products
|FROM
| Document. Sales of Goods and Services. Goods AS Goods
|WHERE
| Products.Link = &Link
|GROUP BY
| Products.Nomenclature
|INDEX BY
| Nomenclature
|;
|////////////////////////////////////////////////////////////////////////////////
|SELECT
| Products.Nomenclature AS Nomenclature,
| Products.Quantity AS Quantity
|FROM
| Products AS Products";
Request.SetParameter("Link", Link);
RequestResult = Request.Execute();

// 2. Formation of movements - register consumption
Movements.FreeRemains.Clear();
SelectionProducts = Query Result.Select();
While SelectProducts.Next() Loop
Movement = Movements.Free Remainings.AddExpense();
Movement.Period = Date;
Movement.Nomenclature = SelectionProducts.Nomenclature;
Movement.Quantity = SampleProducts.Quantity;
EndCycle;

// 3. Recording movements in the database
Movements.FreeRemainders.Write = True;
Movements.Record();

// 4. Query that receives negative remainders from the register
Request.Text =
"CHOOSE
| Remains. Nomenclature AS Nomenclature,
| REPRESENTATIONLINK(Remains.Nomenclature) AS NomenclatureRepresentation,
| -Remaining.QuantityRemaining AS Deficit
|FROM
| RegisterAccumulations.FreeRemains.Remains(
| &Moment of time,
| Nomenclature B
| (CHOOSE
| Products.Nomenclature AS Nomenclature
| FROM
| Products AS Products)) AS Leftovers
|WHERE
| Remaining.QuantityRemaining< 0";

Control Border = New Boundary(TimePoint(), BorderView.Including);
Request.SetParameter("TimePoint", Control Boundary);
RequestResult = Request.Execute();

// 5. Displaying messages about shortages of goods
If Not QueryResult.Empty() Then
Refuse = True;
ErrorSelect = QueryResult.Select();
While SelectErrors.Next() Loop
Message = New MessageToUser;
Message.Text = "The product "+SampleErrors.NomenclaturePresentation+" is not enough in quantity "+SampleErrors.Deficiency+" pcs.";
Message.Message();
EndCycle;
endIf;

End of Procedure

Let's look at the key points of the algorithm.

1. Receiving document data by request

This query is needed to group the data in the tabular part of the document.

Note that the first query in the batch creates a temporary table - it will be used in the next query. This is possible thanks to the temporary table manager that is created for this query.

2. Formation of movements - register consumption

In the cycle, data from the document is written to the register - that is, an unconditional (without verification) write-off of goods is performed.

3. Recording movements in the database

In order for the balances in the register to change, movements must be recorded.

4. Query receiving negative remainders from the register

Now, with a simple request, we select negative balances for document goods.

This is where the temporary table created in the first step is used - a condition is imposed on the item (for this we do not create a new object of the “Request” type, but use the one created earlier).

Pay attention to how the moment in time is transmitted - the “Boundary” data type is used. Remaining balances must be received at a point in time immediately AFTER the current document.

Was it possible to get balances without a border, for example, by adding 1 second to the document date?

No! After all, in one second there can be a large number of documents. Therefore, the only correct option is to use the “Including” border type.

5. Displaying messages about shortages of goods

If the query result is not empty, then there are negative remainders - in this case, the document is not processed and messages about all errors are displayed.

Benefits of residue control using the new method

So, both algorithms solve the same problem.

The difference between the algorithms is visible, but the advantages are not obvious.

So let's highlight them:

  1. No need to clear old document movements. Essentially, this is the operation of writing an empty set of movements to the database and deleting existing movements - these are quite resource-intensive operations
  2. A query that retrieves data on negative balances accesses only one table - there is no need to do a left join with the document data and use the “ISNULL()” function

In addition, during the normal course of business processes, the user indicates a quantity that does not exceed the balance in the warehouse.

In this case, the second request will not return any data and document processing will be as fast as possible.

Are these milliseconds really that important?

On databases with a small amount of data and users, the difference will not be noticeable. But in busy systems with dozens of users, the cost of every millisecond is high.

In addition, during the 1C:Platform Specialist exam, you must definitely use a new method of controlling balances, if a specific task allows it.

Ok, so you should always use a new technique, right?

No, that's not true!

The new technique can only be used if all the necessary data for processing the document is in the document itself.

That is, to obtain data, you do not need to access the registers that control balances.

So, for example, if the amount was also taken into account in the “Free balances” register, then the old control method would have to be used.

By the way, in the standard “1C: Trade Management 11” balance control is implemented using the new method, and in “1C: Accounting 8” - according to the old method.

But that is not all!

The algorithms presented above can be used for educational purposes only. The point is that they do not take into account controlled locks, which must be used if there is more than one user on the system.

Blocks for both residue control methods are discussed. Also in this article we solve a more complex problem - in addition to controlling balances, we calculate the cost of written-off items. We recommend that you study it carefully.

And for starters, let’s just say that installing a lock in the new method is very simple– and this is another advantage of the new method of residue control.

Results

Let's summarize briefly.

We looked at two residue control techniques, each of which is used in modern typical configurations.

Key difference between the techniques at the moment of control of balances:

  • Old technique - control before recording movements in registers
  • New technique - control after recording movements in registers

In general, the new technique is more effective, but it is not always applicable.

Applicability criterion– if there is no need to access data from a controlled register to generate movements, a new technique can be used.

If we talk about control of product balances, then the use of a new technique is possible when data on cost and warehouse balances are stored in different registers.

And finally, examples from typical configurations:

  • IN UT 11 there are 2 main registers for accounting for items: Free balances (quantity) and Cost of goods (cost data) - a new methodology is used
  • IN BP 3.0 data on costs and balances are stored in one accounting register - the old method of controlling balances is used.

Any organization must monitor stock balances. And often a situation arises when the product is actually available, but it is not in the program. And then the accountant is forced to make a decision:

  • allow it to be sold;
  • postpone until it becomes clear why this situation arose.

The decision, as a rule, is made based on the policy that is followed in the organization in relation to the accounting of balances. Sometimes you can put the product aside and tell the buyer that it is not possible to sell it now. Sometimes this is impossible to do. For example, when the buyer sees this product or is already holding it in his hands.

You can, of course, simply generate a sales document and not post the document, but not all organizations allow this. Therefore, in the 1C 8.3 program (as in 8.2) it is possible to disable the control of negative balances.

If balance control is enabled, then when selling an item that is not in stock (or on the required account), the program will issue the following warning:

The “Quantity” column in line 1 of the “Products” list is filled in incorrectly.
The indicated quantity exceeds the balance. Remaining: 18; Missing: 111,093

Get 267 video lessons on 1C for free:

Disabling control of negative balances in 1C 8.3

To disable or enable balance control in 1C, you need to go to the “Main” menu, then in the “Settings” section select “ “.

In some versions of 1C Accounting, these settings are located in the “Administration - Document Posting Settings” menu.

In the “Accounting Parameters” you need to go to the 1C “Inventories” tab and check the “Allow write-off of inventories if there are no balances according to accounting data” checkbox:

Then all you have to do is click the “Save and close” button. Now, when writing off, balances will not be controlled.

But such a method will inevitably lead to the appearance of negative balances in the warehouse (meaning, in the program). Let's look at how to deal with this.

Report “Control of negative balances”

In the simplest case, you just need to select a period and click the “Generate” button. And it was here that the first surprise awaited me.

I specifically simulated in the test program a situation where I sold more goods than I have in stock. Moreover, he made this sale in 2013. Logically, I still have the same product in the red now, in 2016. Therefore, I didn’t even touch the period, but immediately clicked “Generate”. It didn't work out for me. It turns out that the report can display information about negative balances only for the selected period.

In my video tutorials, I often talk about the fact that the 1C database must be prepared for period closure and reporting. And one of the important points of such preparation is the control of negative balances of goods, materials and finished products. What reports should you use to check the status of inventory accounts in 1C: Accounting? Let's look at some of them.

1. Report “Account balance sheet”

Many accountants are accustomed to working with account balance sheets. This report can indeed be used to control inventory balances, you just need to make sure that the settings are set to display quantitative indicators.
Click the “Show settings” button and go to the “Indicators” tab.

Then we carefully review the report and analyze the detected errors

The balance sheet is convenient because it allows you to evaluate not only the presence of negative quantitative balances, but also to detect other problematic situations:
- quantitative balance of inventory items without amount;
- total balance without quantity;
- negative balance.
However, if a large number of item items are involved in accounting, then such a check can be quite labor-intensive. In addition, SALT will have to be generated separately for each accounting account (10, 41, 43), which also somewhat complicates the work process.

2. Report "Control of negative balances"

The 1C: Enterprise Accounting 8 edition 3.0 configuration provides a report that is ideal for monitoring negative quantitative balances of inventory items. The report is located on the “Warehouse” tab.

We indicate the period, organization and generate a report.

The report includes only those item items for which a negative quantitative balance was detected. The big advantage is that data on all inventory accounts is analyzed. In my opinion, it is more convenient to work with the report than with OSV.
But there is also a minus - the report allows you to monitor only negative quantitative balances, leaving behind the scenes other problems that SALT allows you to detect.

3. Report “Analysis of subconto”

I have talked about this report more than once. Subconto analysis is one of my favorite reports, which allows you not only to detect errors, but also, in many situations, to understand their causes.
Go to the “Reports” - “Subconto Analysis” section.

Select the “Nomenclature” subconto and check that the display of quantitative indicators is enabled in the report settings.

Subconto analysis is good because it allows you to obtain information about the movement of inventory items across all accounting accounts. For example, to track situations where a product arrived at one accounting account, but was sold from another.

However, with a large number of items, it can be difficult to analyze the data.
I talked more about working with this report in the video tutorial How to work with the “Subconto Analysis” report in 1C - VIDEO.
Thus, each of the reviewed reports has its pros and cons. In my work, I would recommend combining them:
- find gross errors using the “Control of Negative Balances” report;
- then view the SALT for all inventory accounts;
- to identify the reasons for an incorrect balance, use the “Subconto Analysis” report.
I also discussed interesting examples related to finding and correcting errors when accounting for inventory items in two useful videos:

Control over warehouse balances is a mandatory accounting procedure at any enterprise working with goods. Often you may encounter a situation where there is no product in the program, but it is actually in the warehouse. In such a situation, there are two options:

  • Send it for sale;
  • Leave it in the warehouse until the circumstances of this situation are clarified.

The choice depends on several factors, such as organizational policies or the specific situation. If the product is on the counter and the buyer is interested in it (holding it in his hands), it is not advisable to refuse the sale.

Some enterprises practice generating a sales document without posting it, but not all use this practice. In case of such situations, the 1C program in its latest versions offers the ability to disable control of negative balances.

When control is activated, the sale of goods that are not in stock according to the program will give the user a warning: “The “Quantity” column in line 1 of the “Products” list is filled in incorrectly. “The indicated quantity exceeds the balance. Remaining: 18. Missing 111.093.”

Disabling control of negative balances in 1C

The operation of turning on/off control of balances in 1C is carried out through the menu “Main” - “Settings” - “Accounting parameters” - “Inventories”. Here you need to check the box “Allow write-off of inventory if there is no inventory according to accounting data.”

After this, the action is confirmed with the “Record and close” button. In turn, such actions are guaranteed to become the basis for the formation of negative balances in accounting. They will need to be eliminated.

Report “Control of negative balances”

This report is generated through the “Warehouse” - “Reports” menu, where the document is presented. The user is required to determine the request interval and click on the “Generate” button. The absence of a specified period will not allow you to show negative balances, which is a feature of the system that requires mandatory completion of the “Period” column.

The finished report has the following appearance.

A standard set of filters is available for the report itself, including grouping, sorting and other data transformations in accordance with user requests and needs. Using the “Show Settings” button, you can manually include additional rows in the report.

This report helps to obtain summary or detailed information about negative balances on 41 accounts at any time. The result of the report is displayed with default detail (see Fig. 1)

Because Since the report is completely written using a data layout scheme, it will not be difficult for the user to change report sections from user mode (see Fig. 2)

The external report is intended for the configuration "1C: Enterprise Accounting 8, edition 3.0" and "edition 3.0 (KORP)", running on platform version 8.2 in the “MANAGED APPLICATION” mode.

Free support period: 1 month.

Reasons to buy

Negative balances are always a headache for any accountant. Negative balances on 41 accounts doubly aggravate this situation. This report quickly and clearly shows all "redness" in 41 counts in a convenient and visual form. Moreover lAny negative balance on 41 accounts can be deciphered using the “Subconto Analysis” and “Account Card” reports. At the same time, by combining the use of these reports, it is possible to go straight down to the level of the record documents that caused the movement of goods. To do this, just click on the required number in the report and select the report for decoding.

According to numerous requests from users, a separate version of the report “Control of negative balances on inventory accounts” was created, which added the ability to control negative balances, not only for 41 accounts, but also other main accounts for the movement of inventory items:

Account 07 Equipment for installation
- Account 08.04 Acquisition of fixed assets
- Account 10 all, except 10.07 (Materials transferred for processing to third parties)
- Account 21 Semi-finished products of own production
- Account 41 all, except 41.12 (Goods in retail trade (in NTT at sales value))
- Account 42.01 Trade margin in automated retail outlets
- Account 43 Finished products

Also, remember that negative balances can arise not only in inventory accounts, but also in the customs declaration account. If you need to control this account too, we recommend that you familiarize yourself with the external report

Advantages

  1. Connection through the mechanism of external processing and reporting. This allows you to use the report without making any changes to the standard configuration. It is also possible to open a standard report via “File” -> “Open”.
  2. Possibility to customize the report “for yourself” from the user mode.

Money back guarantee

Infostart LLC guarantees you a 100% refund if the program does not correspond to the declared functionality from the description. The money can be returned in full if you request this within 14 days from the date the money is received in our account.

The program has been so proven to work that we can give such a guarantee with complete confidence. We want all our customers to be satisfied with their purchase.