fix: mirror current-year test finance lines
This commit is contained in:
@@ -10,6 +10,7 @@ from uuid import UUID, uuid5
|
||||
|
||||
from apps.parsers.models import (
|
||||
FinancialReport,
|
||||
FinancialReportLine,
|
||||
GenericParserRecord,
|
||||
IndustrialCertificateRecord,
|
||||
IndustrialProductRecord,
|
||||
@@ -130,7 +131,11 @@ class TestCompanyDatasetService:
|
||||
record.legacy_pk = str(legacy_record.pk)
|
||||
record.save(update_fields=["legacy_model", "legacy_pk", "updated_at"])
|
||||
if source == ParserLoadLog.Source.FNS_REPORTS:
|
||||
cls._refresh_financial_lines(record=record, index=index)
|
||||
cls._refresh_financial_lines(
|
||||
record=record,
|
||||
legacy_report=legacy_record,
|
||||
index=index,
|
||||
)
|
||||
|
||||
OrganizationSourceRecord.objects.filter(
|
||||
extension__organization=organization,
|
||||
@@ -423,6 +428,7 @@ class TestCompanyDatasetService:
|
||||
|
||||
@classmethod
|
||||
def _record_defaults(cls, *, source: str, index: int, organization):
|
||||
report_year = timezone.localdate().year
|
||||
common = {
|
||||
"inn": organization.inn,
|
||||
"ogrn": organization.ogrn,
|
||||
@@ -433,8 +439,11 @@ class TestCompanyDatasetService:
|
||||
url = f"https://example.test/{source}/{index}"
|
||||
values = {
|
||||
ParserLoadLog.Source.FNS_REPORTS: {
|
||||
"title": f"Бухгалтерская отчетность за 2025 год — {organization.name}",
|
||||
"record_date": "2025",
|
||||
"title": (
|
||||
f"Бухгалтерская отчетность за {report_year} год — "
|
||||
f"{organization.name}"
|
||||
),
|
||||
"record_date": str(report_year),
|
||||
"status": "processed",
|
||||
"payload": {
|
||||
**common,
|
||||
@@ -660,7 +669,7 @@ class TestCompanyDatasetService:
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _refresh_financial_lines(*, record, index: int) -> None:
|
||||
def _refresh_financial_lines(*, record, legacy_report, index: int) -> None:
|
||||
report_year = timezone.localdate().year
|
||||
expected = {
|
||||
("1", "1600", "Баланс (актив)", 10_000_000 + index * 100_000),
|
||||
@@ -682,11 +691,23 @@ class TestCompanyDatasetService:
|
||||
"period_end": period_end,
|
||||
},
|
||||
)
|
||||
FinancialReportLine.objects.update_or_create(
|
||||
report=legacy_report,
|
||||
form_code=form_code,
|
||||
line_code=line_code,
|
||||
year=report_year,
|
||||
defaults={
|
||||
"line_name": line_name,
|
||||
"period_start": period_end - 100_000,
|
||||
"period_end": period_end,
|
||||
},
|
||||
)
|
||||
lines = OrganizationSourceFinancialLine.objects.filter(source_record=record)
|
||||
for line in lines:
|
||||
key = (line.form_code, line.line_code, line.year)
|
||||
if key not in expected_keys:
|
||||
line.delete()
|
||||
legacy_report.lines.exclude(year=report_year).delete()
|
||||
|
||||
@staticmethod
|
||||
def _refresh_extension_counters(*, organization) -> None:
|
||||
|
||||
Reference in New Issue
Block a user