fix: reconcile 2026 personnel demo totals
All checks were successful
CI/CD Pipeline / Code Quality Checks (push) Successful in 3m4s
CI/CD Pipeline / Run Tests (push) Successful in 4m40s
CI/CD Pipeline / Build and Push Dev Images (push) Successful in 3s
CI/CD Pipeline / Deploy Dev via Compose (push) Successful in 26s

This commit is contained in:
2026-07-28 11:28:16 +02:00
parent df0f41b9c0
commit 1415220061
3 changed files with 48 additions and 4 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -3,6 +3,9 @@
import re import re
from pathlib import Path from pathlib import Path
from apps.form_1.models import FormF1Record
from apps.form_1.services import FormF1Parser
from apps.form_3.models import FormF3Record
from apps.form_3.services import FormF3Parser from apps.form_3.services import FormF3Parser
from apps.form_4.services import FormF4Parser from apps.form_4.services import FormF4Parser
from apps.form_6.services import FormF6Parser from apps.form_6.services import FormF6Parser
@@ -15,10 +18,51 @@ class DemoPeriodWorkbooksTest(TestCase):
def test_form_f3_workbooks_match_current_schema(self): def test_form_f3_workbooks_match_current_schema(self):
for path in sorted(DEMO_DIR.glob("Ф-3_*.xlsx")): for path in sorted(DEMO_DIR.glob("Ф-3_*.xlsx")):
year = int(re.search(r"_(\d{4})", path.name).group(1)) year = int(re.search(r"_(\d{4})", path.name).group(1))
with self.subTest(path=path.name), path.open("rb") as file: f1_path = max(
result = FormF3Parser(report_year=year).parse(file) DEMO_DIR.glob(f"Ф-1_{year}-*.xlsx"),
self.assertEqual(result.loaded_count, 20) key=lambda item: int(re.search(r"-(\d{2})", item.name).group(1)),
self.assertEqual(result.skipped_count, 0) )
report_month = int(re.search(r"-(\d{2})", f1_path.name).group(1))
with (
self.subTest(path=path.name),
f1_path.open("rb") as f1_file,
path.open("rb") as f3_file,
):
f1_result = FormF1Parser(
report_year=year,
report_month=report_month,
).parse(f1_file)
f3_result = FormF3Parser(report_year=year).parse(f3_file)
self.assertEqual(f1_result.loaded_count, 20)
self.assertEqual(f1_result.skipped_count, 0)
self.assertEqual(f3_result.loaded_count, 20)
self.assertEqual(f3_result.skipped_count, 0)
for f3_record in FormF3Record.objects.filter(
load_batch=f3_result.batch_id
).select_related("organization"):
f1_record = FormF1Record.objects.get(
organization=f3_record.organization,
load_batch=f1_result.batch_id,
)
age_group_total = sum(
(
f3_record.employees_under_20,
f3_record.employees_20_29,
f3_record.employees_30_39,
f3_record.employees_40_49,
f3_record.employees_50_59,
f3_record.employees_over_60,
)
)
self.assertEqual(
age_group_total,
int(f1_record.avg_employees),
msg=(
f"{path.name}: возрастные группы не совпадают "
f"с {f1_path.name} для ИНН {f3_record.organization.inn}"
),
)
def test_form_f4_workbooks_match_current_schema(self): def test_form_f4_workbooks_match_current_schema(self):
for path in sorted(DEMO_DIR.glob("Ф-4_*.xlsx")): for path in sorted(DEMO_DIR.glob("Ф-4_*.xlsx")):