Use 54 FZ for the benefit of home bookkeeping

    When the next edition of Federal Law number 54 "On the use of cash registers" came into force, most of the population met her negatively.

    Something like this (18+, contains obscene language)

    I was one of the few who jumped, clapped their hands and was generally happy as a child.
    For the maintenance of accounting from a separate domestic work has become the most elementary business.

    What for?

    There will be no answer to the question "why do we need home accounting". If you do not know the answer, then you do not need it.

    Also forget about the savings based on the analysis of accounting. The classic example of “you will see that a cup of coffee for 130 rubles eats up to 4,000 a month every day” is divorced from reality. If a person is not an idiot, he will see it without tedious bookkeeping.

    The foundation

    Let's start with the simple. Software for accounting.

    There are a billion programs for home accounting.

    I was superficially acquainted with the general trends and refused to use specialized software.
    The high threshold of entry, limited support, the inability to expand on the one hand, and redundant functionality - on the other, dubious prospects and the life of the software ...
    As a result, my wife and I settled on Google Docs. We have been conducting bookkeeping since 2014, and during this time we have not failed (although the birth of a child has become a serious temptation) and have not regretted choosing a tool.

    Everything looks very simple:
    Three main sheets:
    Categories - a list of categories for validating the input
    Current month - not to get lost
    Current year - throw the current month here

    It looks like this (I think everything is clear from the screenshot):

    Categories are automatically substituted from the corresponding sheet. If you enter something that is not in the list, the validator will curse.

    I wanted to make tags, but in the end I refused this idea - objectively tagging is not at all simpler, and no need was found for this. Approximate destination category is enough.

    This is what my list of categories looks like (it is not perfect, some of the categories duplicate each other, some of the categories are subcategories of others, but such a list has been formed over 4 years and covers our family needs for analyzing expenses):

    Sheet: Categories
    Культурный отдых
    Бытовая химия
    Обслуживание и ремонт дома
    Покупка недвижимости
    Готовая еда
    Умный дом


    In theory, bookkeeping looks very simple.

    Well, what do we have to come home after the purchase and quickly enter the list of purchased goods into the document? A couple of packages of milk, a loaf of bread, cookies ...

    The theory does not take into account trips to supermarkets, when food is bought in a bunch at once ...

    And here it is - a “handful of nails”:

    One type of such garter demotivates wildly. And entering with the union and counting items by category takes a long time. My wife and I sat down in the evenings and together we hammered in all the checks that had accumulated during the week.

    Periodically, there was a desire to make text recognition check, to simplify the input.
    But further thoughts did not go.

    The reason is as simple as 5 kopecks: it takes time to write software. And at that moment it was obvious that the time spent on writing software capable of more or less qualitatively recognizing all checks and generating on their basis at least some useful data — about 10 years will overlap manual hammering in checks.

    So it was until July 1, 2017. On this day, the “same” version of 54 FZ came into effect.
    “That's it!”, I thought, “You can take the data from the check without hammering it in manually” ... And then we continued to hammer in the checks with our hands. Because inertia, laziness and conservatism.

    In February 2018, my son was born ... This has greatly changed the priorities in business.

    As a result - we did not find the time to keep accounts.

    Checks have accumulated a huge amount.

    Nail bucket

    And here comes the understanding that either I am doing automation, or all checks have to be thrown away, because I simply don’t have the strength to drive them.


    It's time to talk about 54 FZ and what it gives us.

    This law obliges sellers to conduct checks through the OFD (Fiscal Data Operator). If without clever words - all cash desks merge checks into the Internet.

    And they can be accessed.

    I don’t know how now, but when I understood, I couldn’t find any information about the protocol on the Internet.

    Fortunately, the FTS have released their mobile application that can download checks.

    Things are easy - we take a sniffer, put it on the phone and see what it sends an application for downloading data.

    And it sends that
    GET запрос по адресу:*/kkts/*/fss/{FN}/tickets/{FD}?fiscalSign={FPD}&sendToEmail=no
    Заголовок содержит следующие обязательные поля:
    «Authorization»: «Basic {BASE64(телефон: пароль)}»
    Device-Id": "{Любая белиберда}"
    «Device-OS»: «Android 5.1» — скорее всего тоже можно слать белиберду, не проверял.
    «Version»: «2»
    «ClientVersion»: «»

    Ответ в виде json, смысла приводить структуру не вижу, она простая и на практике её легко поймет тот, кому это будет актуально.

    Link to sniffer
    Ссылки на снифер не будет. Я взял первый попавшийся в гугл плее. Сработало всё отлично, но рекомендовать не могу. Стоит помнить, что для перехвата https трафика приложение устанавливает свои сертификаты и вообще достаточно активно хозяйничает в телефоне. Никакой уверенности в том, что приложение не содержит зловредного кода у меня нет. Поэтому если надо — гуглите и используйте сами на свой страх и риск.

    As you can see, the protocol requires a phone and a password to download the check.
    I did not register, since it is easy to register through the official application and then use the phone and password to receive checks.

    As I said above, writing automation software only makes sense if the costs of writing overlap with the gain from automation.

    Therefore, I am a bit ashamed of the application code .

    On the other hand, the application is written in a few hours and works great.

    With the help of QZXing and a webcam, we scan the QR code, retrieve the OP, FD, FPD from it and make a request for the contents of the check.

    By the way, the expensive webcam worked very poorly as a QR code scanner.

    I was even a little upset and already wanted to recognize the application as unusable, since it took a few minutes to scan one code, which is completely unacceptable.
    However, for the sake of experiment, I decided to try using a cheap Chinese webcam as a scanner ... And, oh, a miracle, she scans QR codes from checks without any problems! I did not expect this in any way ... I suppose the fact is that the Chinese webcam has a backlight, which is useless for normal use, but works well for close viewing of checks.


    If you've suddenly read this far, you're probably interested in trying out the check reading software yourself.

    Categories are stored in the categories.txt file.

    We enter the phone and password that we received during registration in the official application.
    Enter once, then it is saved locally in the application settings.

    Click Request Bill, select the source of the video stream to scan a check and scan the receipt, or enter the data manually and click Manual to use the entered data.

    If it is possible to recognize the data on the video stream, the window will automatically close and a request for a check will be sent.

    What we have already entered is automatically substituted: We

    fill in the fields: everything except the guarantee is mandatory.

    Then click Generate Result and get the data in text form, suitable for insertion into the table editor, this text is also placed in the clipboard.

    Automation requires minimizing data entry. Therefore, everything that we have already entered is saved.
    Buy something a second time - all fields of the goods will be already filled.

    Everything entered is stored in the items.csv file. The

    application sources are hung on GitHub.

    In the same section, you can pick up a build for Linux and Windows in the releases section. Under the poppy, too, no problem going, but this is not for me.

    API authors have slightly changed its behavior.
    1) Now it is necessary to first ask a valid check from the API, and only then request it. Otherwise, get invalid public API usage
    2) Introduced a limit on the number of free requests from one user per day. Specially did not check, but the feeling of limitation in the region of 20 checks. In general, the restriction does not affect the home bookkeeping, so it may not be noticed.

    Also popular now: