You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
1.3 KiB

"""Compare snapshots without writing or discarding candidate movements."""
from decimal import Decimal
import unicodedata
def signature(*, account_id, currency, posting_date, amount, description, kind,
installment_number=None, installment_total=None):
return (str(account_id), currency, str(posting_date), Decimal(amount),
" ".join(unicodedata.normalize("NFC", description).casefold().split()),
kind, installment_number, installment_total)
def candidate_signature(candidate, account, decision):
return signature(account_id=account.pk, currency=account.currency,
posting_date=candidate["posting_date"], amount=candidate["amount"],
description=candidate["description"], kind=decision.get("kind", candidate["kind"]),
installment_number=candidate.get("installment_number"),
installment_total=candidate.get("installment_total"))
def transaction_signature(row):
return signature(account_id=row.account_id, currency=row.account.currency,
posting_date=row.posting_date, amount=row.amount, description=row.description,
kind=row.kind, installment_number=row.installment_number,
installment_total=row.installment_plan.total_installments if row.installment_plan_id else None)