Format legacy backend test files
This commit is contained in:
parent
b248c94e2d
commit
58a2894fe3
@ -343,18 +343,33 @@ def test_rejects_duplicate_ids(period, rules):
|
||||
assert issue_codes(error) == {"DUPLICATE_COMPONENT_ID"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind,expected", [
|
||||
(LineKind.ADJUSTMENT_CREDIT, "81000.00"),
|
||||
(LineKind.ADJUSTMENT_DEBIT, "79000.00"),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"kind,expected",
|
||||
[
|
||||
(LineKind.ADJUSTMENT_CREDIT, "81000.00"),
|
||||
(LineKind.ADJUSTMENT_DEBIT, "79000.00"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("retroactive", [False, True])
|
||||
def test_adjustments_calculate_without_a_reason(period, rules, kind, expected, retroactive):
|
||||
request = make_request(period, lines=(input_line(
|
||||
"correction:1", "CORRECTION", kind, "1000", reason="",
|
||||
is_retro=retroactive,
|
||||
source_period=PayrollPeriod(date(2026, 5, 1), date(2026, 5, 31))
|
||||
if retroactive else None,
|
||||
),))
|
||||
def test_adjustments_calculate_without_a_reason(
|
||||
period, rules, kind, expected, retroactive
|
||||
):
|
||||
request = make_request(
|
||||
period,
|
||||
lines=(
|
||||
input_line(
|
||||
"correction:1",
|
||||
"CORRECTION",
|
||||
kind,
|
||||
"1000",
|
||||
reason="",
|
||||
is_retro=retroactive,
|
||||
source_period=PayrollPeriod(date(2026, 5, 1), date(2026, 5, 31))
|
||||
if retroactive
|
||||
else None,
|
||||
),
|
||||
),
|
||||
)
|
||||
result = DeterministicPayrollCalculator().calculate(request, rules)
|
||||
assert result.totals.gross_after_adjustments == Decimal(expected)
|
||||
|
||||
|
||||
@ -69,11 +69,14 @@ def test_closure_migration_preserves_latest_policy_and_historical_records(
|
||||
assert Configuration.objects.count() == 3
|
||||
assert all(c.component_codes == ["BONUS"] for c in Configuration.objects.all())
|
||||
# The old application release can still read its column during deployment.
|
||||
OldConfiguration = old_apps.get_model("finance", "PayrollInputCopyConfiguration")
|
||||
OldConfiguration = old_apps.get_model(
|
||||
"finance", "PayrollInputCopyConfiguration"
|
||||
)
|
||||
assert OldConfiguration.objects.count() == 3
|
||||
assert list(
|
||||
OldConfiguration.objects.filter(auto_apply_on_period_creation=True)
|
||||
.values_list("owner_id", flat=True)
|
||||
OldConfiguration.objects.filter(
|
||||
auto_apply_on_period_creation=True
|
||||
).values_list("owner_id", flat=True)
|
||||
) == ([expected_owner] if enabled_count else [])
|
||||
Period = new_apps.get_model("finance", "PayrollPeriod")
|
||||
Input = new_apps.get_model("finance", "PayrollInputLine")
|
||||
|
||||
@ -2807,14 +2807,25 @@ def test_workspace_blocks_period_outside_ruleset_effective_dates(
|
||||
assert PayrollRun.objects.count() == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize("component_code", [
|
||||
"VACATION_PAY", "BONUS", "CORRECTION_CREDIT", "CORRECTION_DEBIT",
|
||||
"ONE_TIME_PAYMENT", "DEDUCTION", "ADVANCE",
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"component_code",
|
||||
[
|
||||
"VACATION_PAY",
|
||||
"BONUS",
|
||||
"CORRECTION_CREDIT",
|
||||
"CORRECTION_DEBIT",
|
||||
"ONE_TIME_PAYMENT",
|
||||
"DEDUCTION",
|
||||
"ADVANCE",
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("retroactive", [False, True])
|
||||
@pytest.mark.parametrize("include_empty_reason", [False, True])
|
||||
def test_input_reason_is_optional_for_every_operation_and_period(
|
||||
user_factory, auth_client_factory, component_code, retroactive,
|
||||
user_factory,
|
||||
auth_client_factory,
|
||||
component_code,
|
||||
retroactive,
|
||||
include_empty_reason,
|
||||
):
|
||||
maker = user_factory(email="optional.reason.maker@example.test")
|
||||
@ -2824,14 +2835,20 @@ def test_input_reason_is_optional_for_every_operation_and_period(
|
||||
grant(checker, "approve_payroll_inputs")
|
||||
period = make_period(creator=maker)
|
||||
previous = PayrollPeriod.objects.create(
|
||||
code="2026-05", date_from="2026-05-01", date_to="2026-05-31",
|
||||
pay_date="2026-06-05", currency="RUB", created_by=maker,
|
||||
code="2026-05",
|
||||
date_from="2026-05-01",
|
||||
date_to="2026-05-31",
|
||||
pay_date="2026-06-05",
|
||||
currency="RUB",
|
||||
created_by=maker,
|
||||
status="closed",
|
||||
)
|
||||
client = auth_client_factory(maker)
|
||||
payload = {
|
||||
"period_id": period.pk, "employee_id": employee.pk,
|
||||
"component_code": component_code, "amount": "100.00",
|
||||
"period_id": period.pk,
|
||||
"employee_id": employee.pk,
|
||||
"component_code": component_code,
|
||||
"amount": "100.00",
|
||||
"relates_to_period_id": previous.pk if retroactive else None,
|
||||
}
|
||||
if include_empty_reason:
|
||||
@ -2846,18 +2863,29 @@ def test_input_reason_is_optional_for_every_operation_and_period(
|
||||
|
||||
# A previously entered note can also be removed from an existing draft.
|
||||
detail_url = api_url("admin-input-line-detail", pk=data["id"])
|
||||
noted = client.patch(detail_url, {
|
||||
"reason": "Дополнительная заметка", "expected_lock_version": data["lock_version"],
|
||||
}, format="json")
|
||||
noted = client.patch(
|
||||
detail_url,
|
||||
{
|
||||
"reason": "Дополнительная заметка",
|
||||
"expected_lock_version": data["lock_version"],
|
||||
},
|
||||
format="json",
|
||||
)
|
||||
assert noted.status_code == 200, noted.content
|
||||
cleared = client.patch(detail_url, {
|
||||
"reason": "", "expected_lock_version": noted.json()["lock_version"],
|
||||
}, format="json")
|
||||
cleared = client.patch(
|
||||
detail_url,
|
||||
{
|
||||
"reason": "",
|
||||
"expected_lock_version": noted.json()["lock_version"],
|
||||
},
|
||||
format="json",
|
||||
)
|
||||
assert cleared.status_code == 200, cleared.content
|
||||
assert cleared.json()["reason"] == ""
|
||||
approved = auth_client_factory(checker).post(
|
||||
api_url("admin-input-line-approve", pk=data["id"]),
|
||||
{"expected_lock_version": cleared.json()["lock_version"]}, format="json",
|
||||
{"expected_lock_version": cleared.json()["lock_version"]},
|
||||
format="json",
|
||||
)
|
||||
assert approved.status_code == 200, approved.content
|
||||
assert approved.json()["status"] == "approved"
|
||||
@ -2886,7 +2914,8 @@ def test_period_inputs_can_be_created_for_inactive_employees(
|
||||
employee["id"] for employee in workspace.json()["employees"]
|
||||
}
|
||||
employee_option = next(
|
||||
employee for employee in workspace.json()["rate_employees"]
|
||||
employee
|
||||
for employee in workspace.json()["rate_employees"]
|
||||
if employee["id"] == inactive_employee.pk
|
||||
)
|
||||
assert employee_option["full_name"] == "Семёнов Иван Петрович"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user