fix: align reporting forms and demo analytics
All checks were successful
All checks were successful
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
"""Tests for FormF4 services."""
|
||||
|
||||
from decimal import Decimal
|
||||
from io import BytesIO
|
||||
|
||||
from apps.form_4.models import FormF4Record
|
||||
from apps.form_4.services import FormF4Parser, FormF4Service
|
||||
from django.test import TestCase
|
||||
from openpyxl import Workbook
|
||||
|
||||
from tests.apps.organization.factories import OrganizationFactory
|
||||
|
||||
@@ -48,6 +53,47 @@ class FormF4ServiceTest(TestCase):
|
||||
class FormF4ParserTest(TestCase):
|
||||
"""Tests for FormF4Parser."""
|
||||
|
||||
@staticmethod
|
||||
def _current_template_file() -> BytesIO:
|
||||
headers = [
|
||||
"Наименование организации",
|
||||
"ОКПО",
|
||||
"ОГРН",
|
||||
"ИНН",
|
||||
"Выручка, в соответствии с РСБУ",
|
||||
"Выручка, в соответствии с МСФО",
|
||||
"Чистая прибыль (убыток), в соответствии с РСБУ",
|
||||
"Чистая прибыль (убыток), в соответствии с МСФО",
|
||||
"Кредиты и займы, в соответствии с РСБУ",
|
||||
"Кредиты и займы, в соответствии с МСФО",
|
||||
"EBITDA, в соответствии с РСБУ",
|
||||
"EBITDA, в соответствии с МСФО",
|
||||
]
|
||||
workbook = Workbook()
|
||||
sheet = workbook.active
|
||||
sheet.append(headers)
|
||||
sheet.append([None, None, None, None] + ["тыс. руб."] * 8)
|
||||
sheet.append(
|
||||
[
|
||||
"Тестовая организация Ф-4",
|
||||
"90000001",
|
||||
"1267700000017",
|
||||
"4234567890",
|
||||
477807,
|
||||
499308,
|
||||
442414,
|
||||
462322,
|
||||
42047,
|
||||
43729,
|
||||
138564,
|
||||
62115,
|
||||
]
|
||||
)
|
||||
file = BytesIO()
|
||||
workbook.save(file)
|
||||
file.seek(0)
|
||||
return file
|
||||
|
||||
def test_get_column_mappings_returns_mappings(self):
|
||||
"""Test get_column_mappings returns correct mappings."""
|
||||
parser = FormF4Parser(report_year=2026, report_half_year=1)
|
||||
@@ -59,6 +105,20 @@ class FormF4ParserTest(TestCase):
|
||||
field_names = [m.field_name for m in mappings]
|
||||
self.assertIn("revenue_rsbu", field_names)
|
||||
self.assertIn("net_profit_rsbu", field_names)
|
||||
self.assertIn("ebitda_rsbu", field_names)
|
||||
|
||||
def test_parse_current_template_maps_profit_loans_and_ebitda_columns(self):
|
||||
OrganizationFactory.create(inn="4234567890")
|
||||
parser = FormF4Parser(report_year=2025, report_half_year=2)
|
||||
|
||||
result = parser.parse(self._current_template_file())
|
||||
|
||||
self.assertEqual(result.loaded_count, 1)
|
||||
record = FormF4Record.objects.get()
|
||||
self.assertEqual(record.revenue_rsbu, Decimal("477807"))
|
||||
self.assertEqual(record.net_profit_rsbu, Decimal("442414"))
|
||||
self.assertEqual(record.loans_rsbu, Decimal("42047"))
|
||||
self.assertEqual(record.ebitda_rsbu, Decimal("138564"))
|
||||
|
||||
def test_create_record_uses_existing_organization(self):
|
||||
"""Report imports reuse existing organizations when available."""
|
||||
|
||||
Reference in New Issue
Block a user