📜 ⬆️ ⬇️

Kazakhstan: How I helped to submit 100 forms of tax reporting. Start 200 form

Greetings to the society! A long time ago (a couple of days ago, the number March 25), in a galaxy far far away (in Almaty, Kazakhstan) ...

My friend, an accountant, called me with the words:

"- Hello Rinat! You are fond of programming! I got a new job here, in LLP. Last year several tax accountants changed here. And I need to submit an annual report. I have already requested an extension, and I have a month to to figure out the numbers. I’ll certainly figure it out for a week, but not the fact that everything will be right. Help. You need to automate a little checking of already submitted declarations. "
')
I decided to help without hesitation, the girl is not bad, and sometimes useful, in an applied sense.

And here the ambush was waiting for me ...
A remark to the article: There will be 3 articles in total, 200 form, 300 form and invoice accounting.

trouble :

Accounting automation systems such as 1C: Enterprise show the situation as a whole without associating it with submitted tax returns. They can create a file to import into existing online services, but they cannot check whether reports are submitted correctly.

problem solution:

I had to learn the basics of accounting boo.

In Kazakhstan, since 2009, tax returns can be submitted online. There are two options:

1. The office of the taxpayer
2. Tax Reporting Processing System (hereinafter referred to as SONO)

For LLP there are several tax regimes:


I needed a standardized procedure for taxation .

In this mode, three main types of declarations are submitted, most of them, as well as in my case:

100.00 Corporate Income Tax Declaration
200.00 Declaration on the individual income tax and social tax on citizens of the Republic of Kazakhstan
300.00 Value Added Tax Declaration

100 form is given once a year.
200 and 300 forms are submitted quarterly.

I needed to give a summary of 200 and 300 forms.

First of all, I started looking for an API to access online services. Unfortunately, no API in the service portal of the company has ever existed. Closed loop system You can request public data on the taxpayer, but unfortunately the declaration will not work.

Since I am not looking for easy ways, I decided to stop the search.

I went to the "Cabinet of the taxpayer" and unloaded all 200 forms to get started.

What does the 'taxpayer cabinet' look like?



As a result, I received 5 declarations for 2016. 4 alternate and 1 additional. Declarations are uploaded in xml format.

What it looks like



The main element in this xml is fno .

<fno code="200.00" version="26" id="83970683" documentId="304374645967031219" formatVersion="1"> 

Here it is necessary to distinguish two properties:

 var version = "26"; var formatVersion = "1"; 

I do not need the other properties, since the internal structure does not change from them. After checking all xml 200 forms, I discovered that they have two version values, these are “25” and “26”. And formatVersion is only one value, "1".

Then, after clarifying with a friend (hereinafter referred to as the customer), what kind of information she needed from 200 forms I began to write the code. By the way, the customer changed the initial task, and instead of one LLP-shki asked to write a code to account for several LLP-nis.

Concepts of TRN, IIN and other accounting cuts
Taxpayer Registration Number (TIN)
Individual Identification Number (IIN)
Business Identification Number (BIN) is a complete analogue of IIN for business.
Individual Income Tax (IIT)
Mandatory Pension Contributions (OPV)
Mandatory Occupational Pension Contributions (OPVA)
Social Tax (CH)
Social deductions (JI)

I decided to filter by IIN / BIN and TIN. They are embedded inside the xml:

 <field name="iin">      </field> 

Those task for the fields for which the summary is required:

Iin
TIN
Quarter
Year of completion (yes, yes, the Customer decided if everything worked out and go through the past periods to put everything in order)
Reporting Date.
IIT (amount of the declaration)
OPV (amount on the declaration)
REL (amount on the declaration)
CH (the amount of the declaration)
CO (amount on the declaration)
Type of declaration.

First, create the elements:

 <input type="file" id="file" onchange="seeXML();"> 

Having studied the structure of the filing required for the summary data on versions 26 and 25, I realized that there is no difference in the submission of these data.
Datafield name
Iiniin
TINrnn
Quarterperiod_quarter
Year of deliveryperiod_year
Reporting Date.submit_date
IIT (amount of the declaration)field_200_00_001_4
OPV (amount on the declaration)field_200_00_002_4 +
field_200_00_004_4
REL (amount on the declaration)field_200_00_003_4
CO (amount on the declaration)field_200_00_005_4 +
field_200_00_006_4 +
field_200_00_007_4
Type of declaration.field_200_00_008_4 +
field_200_00_009_4

As a result, I got a function that returns an object with all the required data.

 var frame = document.createElement("IFRAME"); function getValue(a,b,fnoVersion = "25",fnoFormatVersion = "1") { try { switch(true) { case((fnoVersion == "25")&&(fnoFormatVersion == "1")): return frame.contentWindow.document.querySelector("form[name='form_200_0" + a + "'] field[name='" + b + "']").innerHTML.split("<")[0];; break; } return ""; } catch (ex) { return ""; } } function seeXML() { var fno = {}; if (document.querySelector("#file").files.length < 1) return; var fReader = new FileReader(); fReader.addEventListener("load", function(){ frame.contentWindow.document.documentElement.innerHTML = fReader.result; fno["iin"] = getValue(0,"iin"); fno["rnn"] = getValue(0,"rnn"); fno["period_quarter"] = getValue(0,"period_quarter"); fno["period_year"] = getValue(0,"period_year"); fno["submit_date"] = getValue(0,"submit_date"); fno["ipn"] = (getValue(0,"field_200_00_001_4") - 1) + 1; fno["opv"] = (getValue(0,"field_200_00_002_4") - 1) + (getValue(0,"field_200_00_004_4") - 1) + 2; fno["oppv"] = (getValue(0,"field_200_00_003_4") - 1) + 1; fno["sn"] = (getValue(0,"field_200_00_005_4")) - 1 + (getValue(0,"field_200_00_006_4") - 1) + (getValue(0,"field_200_00_007_4") - 1) + 3; fno["so"] = (getValue(0,"field_200_00_008_4") - 1) + (getValue(0,"field_200_00_009_4") - 1) + 2; switch(true) { case (getValue(0,"dt_main") == "true"): fno["dt"] = "dt_main/"; break; case (getValue(0,"dt_regular") == "true"): fno["dt"] = "dt_regular/"; break; case (getValue(0,"dt_additional") == "true"): fno["dt"] = "dt_additional/"; break; case (getValue(0,"dt_notice") == "true"): fno["dt"] = "dt_notice/  "; break; case (getValue(0,"dt_final") == "true"): fno["dt"] = "dt_final/"; break; } console.log(fno); }, false); fReader.readAsText(document.querySelector("#file").files[0]); } 

Then you can do anything with this object. To whom how to please and I made a small system of accounting for the submitted declarations in form 200.

In the end, what I did, I am not a designer, I’m not a visual designer.




ps The customer began to write with joy at the sight of at least such an account of the submitted forms.
pps But with the form of 300, I very much tormented.

2 article here

Source: https://habr.com/ru/post/325292/


All Articles