Add initial implementations for forms and organization apps with serializers, factories, and admin configurations
Some checks failed
CI/CD Pipeline / Run Tests (push) Failing after 45s
CI/CD Pipeline / Code Quality Checks (push) Failing after 48s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped
Some checks failed
CI/CD Pipeline / Run Tests (push) Failing after 45s
CI/CD Pipeline / Code Quality Checks (push) Failing after 48s
CI/CD Pipeline / Build Docker Images (push) Has been skipped
CI/CD Pipeline / Push to Gitea Registry (push) Has been skipped
CI/CD Pipeline / Deploy to Server (push) Has been skipped
This commit is contained in:
@@ -16,24 +16,72 @@ class FormF4RecordFactory(factory.django.DjangoModelFactory):
|
||||
model = FormF4Record
|
||||
|
||||
organization = factory.SubFactory(OrganizationFactory)
|
||||
load_batch = factory.LazyAttribute(lambda _: fake.uuid4())
|
||||
load_batch = factory.Sequence(lambda n: n + 1)
|
||||
report_year = 2026
|
||||
report_quarter = 1
|
||||
|
||||
# Выручка
|
||||
revenue_rsbu = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=1000000, max_value=100000000000, left_digits=15, right_digits=2))
|
||||
revenue_ifrs = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=1000000, max_value=100000000000, left_digits=15, right_digits=2))
|
||||
revenue_rsbu = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=1000000, max_value=100000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
revenue_ifrs = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=1000000, max_value=100000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
|
||||
# Прибыль
|
||||
net_profit_rsbu = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=-10000000000, max_value=50000000000, left_digits=15, right_digits=2))
|
||||
net_profit_ifrs = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=-10000000000, max_value=50000000000, left_digits=15, right_digits=2))
|
||||
net_profit_rsbu = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=-10000000000,
|
||||
max_value=50000000000,
|
||||
left_digits=15,
|
||||
right_digits=2,
|
||||
)
|
||||
)
|
||||
net_profit_ifrs = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=-10000000000,
|
||||
max_value=50000000000,
|
||||
left_digits=15,
|
||||
right_digits=2,
|
||||
)
|
||||
)
|
||||
|
||||
# EBITDA
|
||||
ebitda_rsbu = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=0, max_value=50000000000, left_digits=15, right_digits=2))
|
||||
ebitda_ifrs = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=0, max_value=50000000000, left_digits=15, right_digits=2))
|
||||
ebitda_rsbu = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=0, max_value=50000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
ebitda_ifrs = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=0, max_value=50000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
|
||||
# Долг
|
||||
net_debt_rsbu = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=0, max_value=100000000000, left_digits=15, right_digits=2))
|
||||
net_debt_rsbu = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=0, max_value=100000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
|
||||
# Рентабельность
|
||||
roe = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=-100, max_value=100, left_digits=5, right_digits=2))
|
||||
roa = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=-100, max_value=100, left_digits=5, right_digits=2))
|
||||
ros = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=-100, max_value=100, left_digits=5, right_digits=2))
|
||||
roe = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=-100, max_value=100, left_digits=5, right_digits=2
|
||||
)
|
||||
)
|
||||
roa = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=-100, max_value=100, left_digits=5, right_digits=2
|
||||
)
|
||||
)
|
||||
ros = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=-100, max_value=100, left_digits=5, right_digits=2
|
||||
)
|
||||
)
|
||||
|
||||
@@ -19,7 +19,9 @@ class FormF4RecordModelTest(TestCase):
|
||||
|
||||
def test_record_str_representation(self):
|
||||
"""Test string representation."""
|
||||
expected = f"Ф-4: {self.record.organization} ({self.record.load_batch})"
|
||||
expected = (
|
||||
f"Ф-4: {self.record.organization.name} (batch: {self.record.load_batch})"
|
||||
)
|
||||
self.assertEqual(str(self.record), expected)
|
||||
|
||||
def test_organization_relationship(self):
|
||||
@@ -29,13 +31,13 @@ class FormF4RecordModelTest(TestCase):
|
||||
def test_decimal_fields_precision(self):
|
||||
"""Test decimal fields precision."""
|
||||
field = self.record._meta.get_field("revenue_rsbu")
|
||||
self.assertEqual(field.max_digits, 18)
|
||||
self.assertEqual(field.max_digits, 20)
|
||||
self.assertEqual(field.decimal_places, 2)
|
||||
|
||||
def test_ratio_fields_precision(self):
|
||||
"""Test ratio fields precision."""
|
||||
field = self.record._meta.get_field("roe")
|
||||
self.assertEqual(field.max_digits, 8)
|
||||
self.assertEqual(field.max_digits, 10)
|
||||
self.assertEqual(field.decimal_places, 2)
|
||||
|
||||
def test_load_batch_index(self):
|
||||
|
||||
@@ -23,7 +23,7 @@ class FormF4ServiceTest(TestCase):
|
||||
|
||||
def test_get_by_load_batch(self):
|
||||
"""Test getting records by load batch."""
|
||||
batch_id = "test-batch-f4"
|
||||
batch_id = 104
|
||||
FormF4RecordFactory.create(load_batch=batch_id)
|
||||
FormF4RecordFactory.create(load_batch=batch_id)
|
||||
|
||||
@@ -32,10 +32,10 @@ class FormF4ServiceTest(TestCase):
|
||||
|
||||
def test_delete_by_load_batch(self):
|
||||
"""Test deleting records by load batch."""
|
||||
batch_id = "delete-batch-f4"
|
||||
batch_id = 304
|
||||
FormF4RecordFactory.create(load_batch=batch_id)
|
||||
FormF4RecordFactory.create(load_batch=batch_id)
|
||||
other = FormF4RecordFactory.create(load_batch="keep-batch")
|
||||
other = FormF4RecordFactory.create(load_batch=404)
|
||||
|
||||
count = FormF4Service.delete_by_load_batch(batch_id)
|
||||
self.assertEqual(count, 2)
|
||||
@@ -50,21 +50,20 @@ class FormF4ParserTest(TestCase):
|
||||
|
||||
def test_get_column_mappings_returns_mappings(self):
|
||||
"""Test get_column_mappings returns correct mappings."""
|
||||
parser = FormF4Parser()
|
||||
parser = FormF4Parser(report_year=2026, report_quarter=1)
|
||||
mappings = parser.get_column_mappings()
|
||||
|
||||
self.assertIsInstance(mappings, list)
|
||||
self.assertTrue(len(mappings) > 0)
|
||||
|
||||
field_names = [m.field_name for m in mappings]
|
||||
self.assertIn("inn", field_names)
|
||||
self.assertIn("revenue_rsbu", field_names)
|
||||
self.assertIn("net_profit_rsbu", field_names)
|
||||
|
||||
def test_create_record_creates_organization(self):
|
||||
"""Test create_record creates organization if not exists."""
|
||||
parser = FormF4Parser()
|
||||
parser.load_batch = "test-batch"
|
||||
parser = FormF4Parser(report_year=2026, report_quarter=1)
|
||||
parser.load_batch = 504
|
||||
|
||||
row_data = {
|
||||
"inn": "4234567890",
|
||||
|
||||
Reference in New Issue
Block a user