|
|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
import json |
|
|
|
|
from contextlib import contextmanager |
|
|
|
|
from datetime import date |
|
|
|
|
from decimal import Decimal |
|
|
|
|
from pathlib import Path |
|
|
|
|
from types import SimpleNamespace |
|
|
|
|
@ -18,8 +19,8 @@ from core.backup import (
|
|
|
|
|
verify_backup, |
|
|
|
|
) |
|
|
|
|
from finance.exports import build_export |
|
|
|
|
from finance.models import SourceRecord, Transaction |
|
|
|
|
from finance.services import Actor, create_account, create_category |
|
|
|
|
from finance.models import ReconciliationCheckpoint, SourceRecord, Transaction |
|
|
|
|
from finance.services import Actor, create_account, create_category, record_transaction |
|
|
|
|
from ingestion import services as import_services |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,6 +29,61 @@ ACTOR = Actor(kind="AGENT", identifier="synthetic-mvp-acceptance")
|
|
|
|
|
FIXTURE = Path("tests/fixtures/synthetic/ingestion/bank.csv") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_owner_reconciliation_workflow_reports_backdated_activity(): |
|
|
|
|
account = create_account( |
|
|
|
|
name="Synthetic acceptance reconciliation account", |
|
|
|
|
kind="BANK", |
|
|
|
|
currency="BRL", |
|
|
|
|
actor=ACTOR, |
|
|
|
|
) |
|
|
|
|
record_transaction( |
|
|
|
|
account_id=account.pk, |
|
|
|
|
amount=Decimal("-50.00"), |
|
|
|
|
posting_date=date(2026, 4, 10), |
|
|
|
|
kind="EXPENSE", |
|
|
|
|
actor=ACTOR, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
browser = Client() |
|
|
|
|
checkpoint = { |
|
|
|
|
"account": account.pk, |
|
|
|
|
"as_of_date": "2026-04-30", |
|
|
|
|
"institution_balance": "-50.00", |
|
|
|
|
} |
|
|
|
|
preview = browser.post( |
|
|
|
|
reverse("reconciliation-index"), |
|
|
|
|
{"action": "preview", **checkpoint}, |
|
|
|
|
) |
|
|
|
|
assert preview.status_code == 200 |
|
|
|
|
assert "Preview" in preview.content.decode() |
|
|
|
|
assert "0.00 BRL" in preview.content.decode() |
|
|
|
|
assert ReconciliationCheckpoint.objects.count() == 0 |
|
|
|
|
|
|
|
|
|
confirmed = browser.post( |
|
|
|
|
reverse("reconciliation-index"), |
|
|
|
|
{"action": "confirm", **checkpoint}, |
|
|
|
|
) |
|
|
|
|
assert confirmed.status_code == 302 |
|
|
|
|
assert confirmed.url == reverse("reconciliation-history", args=[account.pk]) |
|
|
|
|
assert ReconciliationCheckpoint.objects.count() == 1 |
|
|
|
|
|
|
|
|
|
record_transaction( |
|
|
|
|
account_id=account.pk, |
|
|
|
|
amount=Decimal("-5.00"), |
|
|
|
|
posting_date=date(2026, 4, 15), |
|
|
|
|
kind="EXPENSE", |
|
|
|
|
actor=ACTOR, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
dashboard = browser.get( |
|
|
|
|
reverse("home"), |
|
|
|
|
{"month": "2026-04", "currency": "BRL"}, |
|
|
|
|
) |
|
|
|
|
assert dashboard.status_code == 200 |
|
|
|
|
assert "Synthetic acceptance reconciliation account" in dashboard.content.decode() |
|
|
|
|
assert "Changed since reconciliation" in dashboard.content.decode() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_synthetic_import_to_report_export_and_backup_workflow( |
|
|
|
|
tmp_path, settings, monkeypatch |
|
|
|
|
): |
|
|
|
|
|