reconciler: Handle whitespace-only Citizen Bank transaction description
This commit is contained in:
parent
e21142f0ba
commit
78407779d6
3 changed files with 27 additions and 5 deletions
|
@ -414,11 +414,12 @@ def first_word_exact_match(a: str, b: str) -> float:
|
||||||
is useful and the rest is garbage.
|
is useful and the rest is garbage.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if len(a) == 0 or len(b) == 0:
|
a_words, b_words = a.split(), b.split()
|
||||||
|
if len(a_words) == 0 or len(b_words) == 0:
|
||||||
return 0.0
|
return 0.0
|
||||||
first_a = a.split()[0].strip()
|
first_a = a_words[0].strip().casefold()
|
||||||
first_b = b.split()[0].strip()
|
first_b = b_words[0].strip().casefold()
|
||||||
if first_a.casefold() == first_b.casefold():
|
if first_a == first_b:
|
||||||
return min(1.0, 0.2 * len(first_a))
|
return min(1.0, 0.2 * len(first_a))
|
||||||
else:
|
else:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = conservancy_beancount
|
name = conservancy_beancount
|
||||||
version = 1.22.0
|
version = 1.23.0
|
||||||
author = Software Freedom Conservancy
|
author = Software Freedom Conservancy
|
||||||
author_email = info@sfconservancy.org
|
author_email = info@sfconservancy.org
|
||||||
description = Plugin, library, and reports for reading Conservancy’s books
|
description = Plugin, library, and reports for reading Conservancy’s books
|
||||||
|
|
|
@ -459,3 +459,24 @@ month_test_data = [
|
||||||
@pytest.mark.parametrize('input_dates,rounded_dates', month_test_data)
|
@pytest.mark.parametrize('input_dates,rounded_dates', month_test_data)
|
||||||
def test_rounds_to_full_month(input_dates, rounded_dates):
|
def test_rounds_to_full_month(input_dates, rounded_dates):
|
||||||
assert round_to_month(*input_dates) == rounded_dates
|
assert round_to_month(*input_dates) == rounded_dates
|
||||||
|
|
||||||
|
|
||||||
|
def test_handles_payee_whitespace_only():
|
||||||
|
"""Sometimes Citizen Bank statements have a single space in the transaction desc."""
|
||||||
|
statement = [
|
||||||
|
{
|
||||||
|
'date': datetime.date(2022, 1, 1),
|
||||||
|
'amount': decimal.Decimal('10.00'),
|
||||||
|
'payee': ' ',
|
||||||
|
'check_id': '',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
books = [
|
||||||
|
{
|
||||||
|
'date': datetime.date(2022, 1, 1),
|
||||||
|
'amount': decimal.Decimal('10.00'),
|
||||||
|
'payee': ' ',
|
||||||
|
'check_id': '',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
assert match_statement_and_books(statement, books)
|
||||||
|
|
Loading…
Add table
Reference in a new issue