Merge dev into main for customer release #17

Merged
avm merged 14 commits from feature/customer-release-20260811 into main 2026-08-11 13:35:31 +03:00
3 changed files with 48 additions and 4 deletions
Showing only changes of commit 1415220061 - Show all commits

Binary file not shown.

Binary file not shown.

View File

@@ -3,6 +3,9 @@
import re
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_4.services import FormF4Parser
from apps.form_6.services import FormF6Parser
@@ -15,10 +18,51 @@ class DemoPeriodWorkbooksTest(TestCase):
def test_form_f3_workbooks_match_current_schema(self):
for path in sorted(DEMO_DIR.glob("Ф-3_*.xlsx")):
year = int(re.search(r"_(\d{4})", path.name).group(1))
with self.subTest(path=path.name), path.open("rb") as file:
result = FormF3Parser(report_year=year).parse(file)
self.assertEqual(result.loaded_count, 20)
self.assertEqual(result.skipped_count, 0)
f1_path = max(
DEMO_DIR.glob(f"Ф-1_{year}-*.xlsx"),
key=lambda item: int(re.search(r"-(\d{2})", item.name).group(1)),
)
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):
for path in sorted(DEMO_DIR.glob("Ф-4_*.xlsx")):