add-preset-shahmatka #141

Merged
aep merged 24 commits from add-preset-shahmatka into main 2026-10-22 17:57:14 +03:00
Showing only changes of commit 2f08ce4155 - Show all commits

View File

@ -174,6 +174,40 @@ async def test_preset_applies_exclusions_to_its_own_side_and_rule_measure(monkey
assert info.article_2_line == rule.article_2_line
async def test_preset_credit_first_uses_second_side_for_debit(monkeypatch: pytest.MonkeyPatch) -> None:
credit_parent = _account(AccountKind.P)
credit_child = _account(AccountKind.P, credit_parent.id)
debit_parent = _account(AccountKind.A)
debit_child = _account(AccountKind.A, debit_parent.id)
accounts = [credit_parent, credit_child, debit_parent, debit_child]
by_id, children = matrix._make_account_tree(accounts)
rule = SimpleNamespace(
version_no=1,
valid_to=None,
statement_type=StatementType.balance,
side_1="K",
measure="turnover",
)
rule_accounts = [
SimpleNamespace(company_no=1, account_id=credit_parent.id, is_excluded=False),
SimpleNamespace(company_no=1, account_id=credit_child.id, is_excluded=True),
SimpleNamespace(company_no=2, account_id=debit_parent.id, is_excluded=False),
]
monkeypatch.setattr(
matrix.elimination_rules_repo, "rule_with_account", AsyncMock(return_value=(rule, rule_accounts))
)
service = matrix.IntercompanyMatrixService(object(), None, object())
selection, selected_rule = await service._resolve_preset_selection(
uuid.uuid4(), SimpleNamespace(elimination_rules_version=1), by_id, children
)
assert selected_rule is rule
assert selection.company_1_account_ids == {debit_parent.id, debit_child.id}
assert selection.company_2_account_ids == {credit_parent.id}
assert selection.measure == "turnover"
async def test_preset_rejects_income_rule_before_selecting_accounts(monkeypatch: pytest.MonkeyPatch) -> None:
rule = SimpleNamespace(
statement_type=StatementType.income,