It all started when it came. Mysterious letter from the Vladimir (?!) Customs. Inside, there was a requirement to provide statistical data on trade with Belarus and Kazakhstan for the entire last year. And the link to the decree of the sovereign, as it should be.
“For now, if you are bargaining with the countries of the customs union, please accept the answer. To whom, where, what has sold. All without a write and write especially the number of the CCD do not forget. The eye of the sovereign is not a drowsy eye. The electronic systems of dogs with iron behind you, negligent, are now monitored, therefore not sly. Remember the deadline. ”

The accountants ran in, the managers started to fuss. They did not hear about the decree of the century, there was no such sadness for them. It turned out that it was necessary to register on the Federal Customs Service website a year ago and transfer data on all trade operations with EAEU countries on a monthly basis (
otherwise, an administrative fine of up to 50 thousand rubles for each form. See N 510-FZ of 12/28/2016 ).
Customs and Tax: Twins
- This one doesn't fit. But there was such a switch, domestic ...
- We have one "China", only "China" we sell.
Overheard at the Mitinsky radio market (June 2018)
In this story I was struck by the sender of the letter. Vladimir is a small green city, far from external borders and major airports, in the heart of the Non-Black Earth and suddenly customs. It sounds unusual, as a naval base in the Belarusian marshes.
On the other hand, the process of "customs" of all Russia is logical. There was virtually no production left in the country and imports became the main source of goods. In these circumstances, the role of customs is difficult to overestimate. On the agenda is full tracking of the chain from the border to the counter. Here the number of the "beast" is the CCD - the cargo customs declaration. I pulled the number of GTE and here are all the data on the product - price, weight, quantity, etc.
')
Things are easy - to organize the access of the tax authorities to the customs bases. And this is solved!
In December 2017, there were even rumors about the upcoming merger of the tax department and the Federal Customs Service (FCS), which were dispelled in February 2018 by Igor Shuvalov, now former Deputy Prime Minister.
However, the physical integration of the structures is not required - the process of integrating the information systems of the departments has already been launched after the reassignment of the FCS to the Ministry of Finance and Andrei Belyaninov resigned from the post of head of the customs service in 2016.
The current head of the FCS, Vladimir Bulavin, Colonel-General of the FSB, by the way, according to Interfax, announced in November 2017 the creation of a two-tier intellectual platform:
“The first level is operational, the second is analytical. The intellectual platform will receive information from the created tracking system. In accordance with this information, we will control ourselves in the sense of how objectively the participant of foreign economic activity told us and declared the customs value, country of origin, code of the product mix, weight characteristics .
”As it seems, statistical declaring is one of the elements of this system of tracking the movement of goods. As the introduction of the notorious online cash registers. The level of state automation is growing, and is there any benefit to entrepreneurs?
According to a study by Magram Market Research, conducted in February 2018, the majority of respondents (56%) noted that the replacement of CCP had no effect on the effectiveness of their business. But the head of the Federal Tax Service Mikhail Mishustin noted that after half a year of work of companies on a new technology, business shows revenues one and a half times more than before the reform.
It is worth noting that the information system of statistical declaration is interstate, and by filling in the statistical form you automatically subscribe to the “letters of happiness” of your foreign counterparty and vice versa. Unless, of course, he buys the product is not on an individual.
How to transfer the stat.form
Let's return to our sheep. By joint efforts at the company, we found out that in order to transfer statistical data, it is necessary to register on the FTS website and enter the “Personal Account of the Foreign Economic Activity Participant”. The button with flags - the service "
Statistical Declaration " (Submission of the invoice with EP)
Then there are two alternatives : either we use the pens to drive in the requisites and an unrealistically huge list with the product nomenclature, or we load the file prepared in advance in the unknown simple mortal format of three letters - XML.
We send the form in electronic form with electronic signature. The form is registered and assigned a unique number.
In the absence of EDS, it is necessary to print the form from the site and send it already by registered letter or bring it personally to the customs of the region where the importer / exporter is registered for tax purposes. (Not our case).
They began to dig deeper, how to unload data from "1C". It turned out the program "1C: Accounting 8" with the included service "1C-Reporting" as if it allows you to send the statform via the Internet directly, without going to the portal of the FCS. But in the original ancient “1C” seven it is impossible, at the most - exporting the file to Excel. (It is
impossible to get off the sevens, there are so many sophisticated ones there - like an inoperable fragment in the head of a fighter. )
And there is a little time: already 3 months of the new year have passed, not counting the whole of last year. Appealed to the partners in the customs clearance - a logistics company, but they flatly refused to help. Who are they after that ?!
Accountants found on the Internet a third-party company. Its employees generated XML for download and asked for 3,000 rubles for each month of the report.
The question arose: what to do next?
I tried to distance myself as much as possible from this task. The topic is boring accounting. However, how much string does not curl ... They came as a crowd. A terrible longing rolled at me when listening to the details of this, in general, uncomplicated, history.
It lasted absolutely until the moment when someone uttered the magic word "Alta"! They continued to speak, and in my thoughts I was already transported to the beginning of the "zero".
"Contrabass" is not only a musical instrument
The customs house was located in a long gray building of Brezhnev times of glass and concrete, probably a former scientific research institute. The dining room huddled at the far end and office workers walked for lunch. And hefty customs officers caught a wheelbarrow, packed into it and drove the same 100 meters with a breeze. To go - to lose a lot!
Wow, "Alta" still exists! There were two, two main customs programs. The girl with whom I was then in a romantic relationship, worked as a specialist in customs clearance. From her, I learned something about customs, in particular, that people in uniform and businessmen (brokers, declarants, customs clearance specialists) work under the same roof.
Customs officers are in full view, for they are on guard of state interests. In confirmation of this, each customs officer has a "lichku" -a art print with a personal number. This sacred crimson seal, glowing in the ultraviolet, is affixed to the documents upon release of the cargo: customs clearance.
But it is the private owners who work directly with clients, doing all the black paper work. Theoretically, a person from the street can try to clear their own customs clearance of their goods, bypassing brokers, but this is practically impossible. And all of their documentation customs clearance specialists are slaughtered in Alta. Without it, they are like no hands. (The second similar program, if memory serves, was called "Declarant Plus.")
Once, customs officers ran into our company, see a sample of contractual products for the Federal Customs Service. I was genuinely surprised how unexpectedly these hefty guys in dark green uniform, with thick and bass voices, occupied the whole office space! The technical director was like a little gnome surrounded by big and good bears.
Demo
And it was Alto that the employee from the attracted company advised the accountants to establish. With the blessing of the Alta Soft manager, they downloaded and installed a free demo version from the official site. And the demo scored the entire disk of the accounting company.
And now, for some reason, it was I who had to explain how to feed the Excel file from 1C to the program and get the desired XML at the output.
In my opinion, this is a rare blasphemy to use a powerful and expensive program as a sort of primitive converter. To the credit of the creators of Alta, this perversion could not be accomplished. Well, there is no direct import from Excel.
True, there was a “placeholder” program, just for such data manipulations. All is well, but the total cost of the subscription was prohibitive. Moreover, all these programs did not solve the desired problem by 100%.
And the task seemed primitive - to generate XML from “1C” data, observing certain conditions.
The most logical for me is to transfer the arrows to the incoming aunt of the “1C” programmer and forget about it. But I went the other way. I was affected by memories of past love or something else, however, I suddenly decided to quickly write a script for generating XML. Of course on the good old PHP. Took it up with debugging for two days.
PHP script for XML generation
The scheme is simple: we unload the Excel file with the nomenclature of goods from “1C”, open it in Excel and resave it as text separated by tabs. Now he is ready for feeding php-script.
In the browser, an employee fills out a form, attaches a file, and presses a button to generate XML. The script parses the text file, adds data from the form and generates the required XML.
So, first you need to score data for the supplier and the recipient. Since The recipients are basically the same - we remember their details, like the sender's data, into the database.
For a sample of XML, we take a file from those generated for money reports. We are checking with the annexes to the
Decree of the Government of the Russian Federation dated December 7, 2015 No. 1329 .
In addition, there are additional fields. I filled them in accordance with the finished XML file generated by this company. Basically everything is clear, for example, “Composition of vehicles (tractor with semi-trailer or trailer)”, etc. But what NSF is and why it is “missing” remains a mystery. Sock blue-violet? Left as is. (Probably there is a format description on the customs site, it’s very lazy to go there.)
To feed the customs site was successful - do not forget to save XML in UTF-8 encoding. Glory to the
CPSU iconv!
Underwater pebbles
As always, in practice it turned out to be more difficult. Go through the main points.
The data to be unloaded directly on the goods is the HS code, product name, price, amount, weight, CCD, country of origin.
The HS code is a classifier used for carrying out customs operations. The code length is 10 digits. Paste as is.
The name of the goods is how the goods are called in the accounting program. In my opinion, this is a field for customs on the drum, the TN VED code is important to it.
The price is needed in rubles and dollars. The price in dollars is calculated. The joke is that the dollar is needed at the rate of the Central Bank on the day of shipment. And do not try to fool customs - the site tracks the currency corridor in the reporting month!
Here comes the API of the Central Bank of the Russian Federation. We transfer http-request with date (DD / MM / YYYY).
http://www.cbr.ru/scripts/XML_daily.asp?date_req=16/12/2014
In response, we get XML. Parse it and here is the USD rate for the day you need, with 4 decimal places.
Apparently there is a limit on the frequency of requests to the Central Bank website, during the testing of the script, error messages were issued. After a while, everything worked again.Country of origin - encoded in two Latin letters. I had to write a separate function, the benefit of the necessary countries a bit. We look at the alpha 2 alphabetic code on the site:
https://www.alta.ru/information/oksm/The classifier of the countries of the Customs Union is great and powerful, only he knows that “KM” is the Union of Comoros: the island of Anjouan, and “MO” is the Special Administrative Region of China Macau, and not the Moscow Region at all. By the way, when you fill out a form in some of your fields, a useful tool with a list of currencies, countries, etc. pops up in your Personal Account.
DGT - cargo customs declaration. The most important and unpleasant, for the "gray" schemes, thing. It calculates the legality of the goods. A CCD consists of three, sometimes four groups of digits broken by slashes:
- customs code;
- the date of acceptance of the CCD (DDMMYY);
- the serial number of the customs declaration (starts from one from each calendar year);
- item number in the cargo customs declaration.
For XML, we use only the first three groups. It seemed simple - parseys and insert into XML with separate tags, having previously processed. However, the site of customs began to swear at some positions. It turned out that the code of the customs authority (MOT) should always be eight-digit. If the maintenance code consists of 5 numbers, we add an additional one in front of it: 417 - Kyrgyzstan, 112 - Belarus, 398 - Kazakhstan.
How to calculate: Kazakh MOTs start with a five, Belarusian with a two, Kyrgyz with a one. Like so.
Example of the CCD :
10130050/280514/0004575 .
Weight of goods . Weights are substituted in kilograms. From the end of April 2018, the customs site began to track the corridor of the weights of a group of goods by the TN VED code. And give an error if the weight of a position is lower or higher than the average. Sky-high technology in action!
Depending on the HS code, it is sometimes necessary to specify the quantity and units.
XML loading
The generated XML file is downloaded to the local computer. We upload it to the customs website through a link to download XML. The name of the downloaded XML file should be changed to understandable, because after importing to the Personal Account, the form will be named accordingly.

Then be sure to go to the loaded form on the icon "Edit" and click the button "Check". Errors will be displayed in red, and exclamation marks will appear in the problem fields.

Go to the tab "Information about products" and carefully check:

Send the form with the button “Send” in the Actions column. After this, nothing can be fixed. After some time, a registration number will be assigned to the form.
What is important is that the register of characters of the sender’s company name must match the register in the electronic signature. For example, the company in XML is called
“Romashka” LLC , and the EOC is issued to
“Daisy” LLC - the system will send an error when sending the form.
Script work example
Who is interested to see the generation of the report in action - I posted
an example script on the site.
You can feed the script data and get the XML "humpback" for the site of customs. In a text file with a commodity nomenclature we must preserve the structure of the table. The site has a sample in Excel.
In the future, there is a thought to configure from “1C” the unloading of all possible data fields with details, amount and other. This will allow the site to fill out nothing, except for the course.