19 lines
1.2 KiB
Python
19 lines
1.2 KiB
Python
from datetime import date
|
|
from decimal import Decimal
|
|
from roborto_accounting.persistence.base import Base
|
|
from roborto_accounting.persistence.db import make_engine,make_session_factory
|
|
from roborto_accounting.persistence.models import ImportedBankTransaction
|
|
from roborto_accounting.services.reconciliation import approve_match,propose_match
|
|
|
|
def test_proposals_do_not_reconcile_until_explicit_approval():
|
|
e=make_engine("sqlite://");Base.metadata.create_all(e);s=make_session_factory(e)()
|
|
imported=ImportedBankTransaction(financial_account_id=1,transaction_date=date.today(),description="Payment",
|
|
amount=Decimal("10"),currency="EUR",source_format="test",source_hash="a"*64,raw_json="{}",status="PENDING")
|
|
s.add(imported);s.flush()
|
|
first=propose_match(s,imported=imported,record_type="payment",record_id=1,score_ppm=900000)
|
|
second=propose_match(s,imported=imported,record_type="payment",record_id=2,score_ppm=890000)
|
|
assert imported.status=="PENDING" and first.status==second.status=="PROPOSED"
|
|
approve_match(s,first,reason="User selected exact reference")
|
|
assert imported.status=="RECONCILED" and first.status=="APPROVED" and second.status=="PROPOSED"
|
|
s.close();e.dispose()
|