Introduction
Imagine: the end of the quarter, the deadline for submitting the simplified tax system (USN) declaration is tomorrow. You're frantically gathering receipts, bank statements, payments from counterparties. One mistake—and the tax office fines you. Sound familiar? I've been through this dozens of times until I automated the process with Python and AI. Today, I'll show you how you can do the same—without hiring a development team and with a cloud services budget starting from 500 rubles per month.
Automating tax reporting isn't about complex scripts. It's about having your data automatically collected, checked, and turned into ready-to-submit files for the Federal Tax Service (FNS). In 2025–2026, the tools have become more accessible: Python libraries for working with FNS XML schemas, AI for receipt recognition and income/expense classification. I'll show specific steps for freelancers and small business owners.
1. Regulatory Framework: What You Need to Know Before Automating
Before writing code, understand which regulations govern your reporting. Without this, automation will lead to fines, not savings.
Key Articles of the Tax Code of the Russian Federation (NK RF) Related to Reporting:
- Article 80 NK RF — Tax declaration: form, submission procedure, deadlines. Electronic submission is mandatory for companies with more than 100 employees, but voluntary for others; however, it's more convenient to submit via TCS (telecommunication channels).
- Article 119 NK RF — Fine for failure to submit a declaration: 5% of the tax amount for each month of delay, but not more than 30% and not less than 1000 rubles.
- Article 346.23 NK RF — Deadlines for submitting the USN declaration: for organizations—until March 31, for individual entrepreneurs—until April 30.
- Article 227 NK RF — For freelancers on personal income tax (NDFL): 3-NDFL declaration is submitted until April 30, tax is paid until July 15.
Important nuance for 2026: The FNS is actively implementing an automated control system—AIS "Tax-3." It cross-checks data from banks, marketplaces, and your declaration. If discrepancies exceed 5%, the system generates a request for explanations. Automation helps avoid such discrepancies—you collect data from the same sources as the tax office.
For a deep understanding of all the nuances—from taxpayer rights to appealing audit reports—asibiont.com offers a comprehensive course on Russian tax law. It covers all NK RF articles with practical examples.
2. Concepts and Rates: What We Automate
For freelancers and micro-businesses, typical taxes are:
- USN (Simplified Taxation System): rate 6% (income) or 15% (income minus expenses). Declaration once a year, advance payments quarterly.
- NDFL (13% for residents, 30% for non-residents): for freelancers without IP status—3-NDFL declaration.
- NPD (Professional Income Tax, self-employed): 4% (individuals) or 6% (legal entities). Reporting via the "My Tax" app; automation here is minimal.
- Insurance premiums: fixed payments for individual entrepreneurs (in 2026—about 50,000 rubles per year) plus 1% on income over 300,000 rubles.
What we automate:
1. Collection of income data (bank statements, client payments).
2. Classification of expenses (for USN 15%).
3. Calculation of tax and advance payments.
4. Generation of declaration in XML format (for FNS).
5. Submission via TCS API (if you have an electronic signature).
3. Step-by-Step Guide: From Data Collection to Submission
Step 1. Setting Up Data Collection from Banks and Payment Systems
Python and AI allow you to extract data from bank statements (1C format, CSV, PDF) and payment systems (e.g., Stripe, PayPal, Yandex.Checkout).
Example: Parsing a Tinkoff Business Statement
Tinkoff provides export in Excel (XLSX). Here's a minimal Python script:
import pandas as pd
from datetime import datetime
# Load the statement
df = pd.read_excel('tin_2026_q1.xlsx', header=2) # Headers may vary
# Keep only necessary columns
cols = ['Date', 'Amount', 'Category', 'Description', 'Counterparty']
df = df[cols]
# Filter by date (e.g., Q1 2026)
df['Date'] = pd.to_datetime(df['Date'])
df_q1 = df[(df['Date'] >= '2026-01-01') & (df['Date'] <= '2026-03-31')]
# Save to CSV for further processing
df_q1.to_csv('income_q1_2026.csv', index=False)
print(f'Collected {len(df_q1)} transactions')
PDF statements from Sber or VTB are more complex: they are often unstructured. Here, AI helps—libraries like pdfplumber for text extraction and spaCy or transformers for entity recognition (dates, amounts, payment purpose).
Example: Recognizing receipts from PDF using AI
import pdfplumber
from transformers import pipeline
# Load the entity recognition model (can be trained on your data)
ner = pipeline('ner', model='dslim/bert-base-NER')
with pdfplumber.open('check_20260620.pdf') as pdf:
text = ''
for page in pdf.pages:
text += page.extract_text()
# Search for amounts and dates
entities = ner(text)
for ent in entities:
if ent['entity'] in ['B-AMOUNT', 'B-DATE']:
print(f'Found: {ent["word"]} with probability {ent["score"]:.2f}')
Step 2. Classification of Income and Expenses Using AI
For USN 15%, it's important to separate income and expenses, and categorize expenses (rent, purchase of goods, advertising). AI models (e.g., GPT-4o or local Llama 3) handle classification based on transaction descriptions well.
Example: Expense classification
import openai
openai.api_key = 'your-api-key'
categories = ['rent', 'purchase of goods', 'advertising', 'transport', 'other']
def classify_expense(description):
response = openai.ChatCompletion.create(
model='gpt-4o',
messages=[
{'role': 'system', 'content': f'Classify the transaction description into one of the categories: {categories}. Answer only with the category name.'},
{'role': 'user', 'content': description}
],
temperature=0
)
return response.choices[0].message.content.strip()
# Example
transaction = 'Payment for hosting for June'
print(classify_expense(transaction)) # 'other'
Important: AI can make mistakes. I always add manual verification for large amounts (e.g., >10,000 rubles).
Step 3. Tax Calculation and Declaration Generation
After data collection, calculate the tax base. For USN 6%:
# Quarterly income
income = df_q1[df_q1['Amount'] > 0]['Amount'].sum()
tax_usn = income * 0.06
print(f'USN tax (6%): {tax_usn:.2f} rub.')
For USN 15%:
income = df_q1[df_q1['Amount'] > 0]['Amount'].sum()
expenses = df_q1[df_q1['Amount'] < 0]['Amount'].abs().sum()
tax_usn_15 = (income - expenses) * 0.15
if tax_usn_15 < 0:
tax_usn_15 = 0 # minimum tax 1% of income
min_tax = income * 0.01
tax_usn_15 = max(tax_usn_15, min_tax)
print(f'USN tax (15%): {tax_usn_15:.2f} rub.')
Generating XML declaration:
The FNS accepts declarations in XML format according to XSD schemas. The Python library xml.etree.ElementTree allows generating valid files. Here's a simplified example for USN (the real schema is more complex, including OKVED codes, KBK, etc.):
import xml.etree.ElementTree as ET
root = ET.Element('TaxDeclaration')
# Fill in data
ET.SubElement(root, 'INN').text = '1234567890'
ET.SubElement(root, 'KPP').text = '123456789'
ET.SubElement(root, 'TaxPeriod').text = '34' # year
ET.SubElement(root, 'ReportingYear').text = '2026'
# Tax amount payable
ET.SubElement(root, 'TaxAmount').text = f'{tax_usn:.2f}'
tree = ET.ElementTree(root)
tree.write('usn_declaration_2026.xml', encoding='windows-1251', xml_declaration=True)
The ready XML can be uploaded to the taxpayer's personal account on the FNS website or sent via TCS (e.g., through the Diadoc or SBIS API).
Step 4. Submission via TCS API (Optional but Convenient)
If you have an electronic signature (ES), you can set up submission through an EDI operator. For example, via the SBIS or Diadoc API. This requires additional code for authentication and signing.
Alternative: Use ready-made services (e.g., "My Business," "Elba") that automatically fetch data from the bank and generate reports. But that's not about Python and AI.
4. Reporting and Declarations: What to Keep in Mind
Even with automation, you can't forget about deadlines and forms:
- USN: declaration once a year (until March 31 for LLCs, until April 30 for individual entrepreneurs). Advance payments—until April 25, July 25, October 25.
- NDFL (3-NDFL): until April 30. Can be submitted online via the FNS personal account—there is partial auto-loading of data from banks.
- Insurance premiums for individual entrepreneurs: fixed payment until December 31, 1%—until July 1 of the following year.
- NPD (self-employed): reporting via the "My Tax" app—a receipt is generated automatically upon payment.
Life hack: Set up a Python script to run once a day (via cron or Windows Task Scheduler) to collect data and send you a summary via Telegram: "Today received 15,000 rubles, USN tax—900 rubles." This helps avoid missing the income limit (for USN—200 million rubles per year, for NPD—2.4 million rubles).
5. Benefits and Deductions: How Not to Overpay
Automation is useful not only for data collection but also for tracking deductions:
- Insurance premiums for individual entrepreneurs can be deducted from USN tax (6%) or from the USN base (15%). A Python script can easily calculate the remaining limit.
- Professional deduction (Article 221 NK RF) for freelancers on NDFL: you can reduce income by documented expenses. AI can help classify expenses as professional.
- Property deduction (up to 2 million rubles)—not automated, but a script can remind you that you haven't used it yet.
Example of calculating the deduction for insurance premiums for USN 6%:
income_q1 = 500000 # quarterly income
fixed_insurance = 12000 # fixed contribution for the quarter (example)
tax_before = income_q1 * 0.06 # 30000 rub.
tax_after = max(tax_before - fixed_insurance, 0)
print(f'Tax payable after deduction: {tax_after:.2f} rub.')
6. Conclusions
Automating tax reporting with Python and AI is a real way to save dozens of hours per year and reduce the risk of errors. My USN script (bank data collection, classification, calculation, XML generation) has been running for three quarters—not a single fine, although I previously received two requests due to discrepancies.
What you need to start:
- Basic Python knowledge (pandas, requests, xml.etree.ElementTree).
- Access to bank statements (CSV/Excel/PDF).
- AI model API (OpenAI or local Llama 3).
- Understanding of tax regulations—without it, automation is dangerous.
Main advice: Don't automate everything at once. Start with one tax (e.g., USN 6%) and one data source (Tinkoff Business). Once the system runs stably, add other banks and taxes.
If you want to delve deeper into Russian tax law—from taxpayer rights to special regimes and appeals—the asibiont.com platform has a course covering all this with real examples. In the meantime, take my code and try it—the best way to learn automation is by doing.
Comments