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,18 +16,52 @@ class FormF2RecordFactory(factory.django.DjangoModelFactory):
|
||||
model = FormF2Record
|
||||
|
||||
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
|
||||
|
||||
# Активы
|
||||
total_assets = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=1000000, max_value=10000000000, left_digits=15, right_digits=2))
|
||||
fixed_assets = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=100000, max_value=1000000000, left_digits=15, right_digits=2))
|
||||
inventories = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=10000, max_value=100000000, left_digits=15, right_digits=2))
|
||||
cash_and_equivalents = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=10000, max_value=100000000, left_digits=15, right_digits=2))
|
||||
total_assets = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=1000000, max_value=10000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
fixed_assets = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=100000, max_value=1000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
inventories = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=10000, max_value=100000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
cash_and_equivalents = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=10000, max_value=100000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
|
||||
# Пассивы
|
||||
total_liabilities = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=1000000, max_value=10000000000, left_digits=15, right_digits=2))
|
||||
total_equity = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=100000, max_value=5000000000, left_digits=15, right_digits=2))
|
||||
total_liabilities = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=1000000, max_value=10000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
total_equity = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=100000, max_value=5000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
|
||||
# Финрезультаты
|
||||
revenue = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=1000000, max_value=50000000000, left_digits=15, right_digits=2))
|
||||
net_profit = factory.LazyAttribute(lambda _: fake.pydecimal(min_value=-1000000000, max_value=5000000000, left_digits=15, right_digits=2))
|
||||
revenue = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=1000000, max_value=50000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
net_profit = factory.LazyAttribute(
|
||||
lambda _: fake.pydecimal(
|
||||
min_value=-1000000000, max_value=5000000000, left_digits=15, right_digits=2
|
||||
)
|
||||
)
|
||||
|
||||
@@ -19,7 +19,9 @@ class FormF2RecordModelTest(TestCase):
|
||||
|
||||
def test_record_str_representation(self):
|
||||
"""Test string representation."""
|
||||
expected = f"Ф-2: {self.record.organization} ({self.record.load_batch})"
|
||||
expected = (
|
||||
f"Ф-2: {self.record.organization.name} (batch: {self.record.load_batch})"
|
||||
)
|
||||
self.assertEqual(str(self.record), expected)
|
||||
|
||||
def test_organization_relationship(self):
|
||||
@@ -29,7 +31,7 @@ class FormF2RecordModelTest(TestCase):
|
||||
def test_decimal_fields_precision(self):
|
||||
"""Test decimal fields precision."""
|
||||
field = self.record._meta.get_field("total_assets")
|
||||
self.assertEqual(field.max_digits, 18)
|
||||
self.assertEqual(field.max_digits, 20)
|
||||
self.assertEqual(field.decimal_places, 2)
|
||||
|
||||
def test_nullable_fields(self):
|
||||
|
||||
@@ -23,7 +23,7 @@ class FormF2ServiceTest(TestCase):
|
||||
|
||||
def test_get_by_load_batch(self):
|
||||
"""Test getting records by load batch."""
|
||||
batch_id = "test-batch-f2"
|
||||
batch_id = 102
|
||||
FormF2RecordFactory.create(load_batch=batch_id)
|
||||
FormF2RecordFactory.create(load_batch=batch_id)
|
||||
|
||||
@@ -32,10 +32,10 @@ class FormF2ServiceTest(TestCase):
|
||||
|
||||
def test_delete_by_load_batch(self):
|
||||
"""Test deleting records by load batch."""
|
||||
batch_id = "delete-batch-f2"
|
||||
batch_id = 302
|
||||
FormF2RecordFactory.create(load_batch=batch_id)
|
||||
FormF2RecordFactory.create(load_batch=batch_id)
|
||||
other = FormF2RecordFactory.create(load_batch="keep-batch")
|
||||
other = FormF2RecordFactory.create(load_batch=402)
|
||||
|
||||
count = FormF2Service.delete_by_load_batch(batch_id)
|
||||
self.assertEqual(count, 2)
|
||||
@@ -50,21 +50,20 @@ class FormF2ParserTest(TestCase):
|
||||
|
||||
def test_get_column_mappings_returns_mappings(self):
|
||||
"""Test get_column_mappings returns correct mappings."""
|
||||
parser = FormF2Parser()
|
||||
parser = FormF2Parser(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("total_assets", field_names)
|
||||
self.assertIn("revenue", field_names)
|
||||
|
||||
def test_create_record_creates_organization(self):
|
||||
"""Test create_record creates organization if not exists."""
|
||||
parser = FormF2Parser()
|
||||
parser.load_batch = "test-batch"
|
||||
parser = FormF2Parser(report_year=2026, report_quarter=1)
|
||||
parser.load_batch = 502
|
||||
|
||||
row_data = {
|
||||
"inn": "2234567890",
|
||||
|
||||
Reference in New Issue
Block a user