WIP
This commit is contained in:
@@ -400,6 +400,71 @@ class TestAmountNormalizer:
|
||||
result = normalizer.normalize("Reference 12500")
|
||||
assert result.value == "12500.00"
|
||||
|
||||
def test_payment_line_kronor_ore_format(self, normalizer):
|
||||
"""Space between kronor and ore should be treated as decimal separator.
|
||||
|
||||
Swedish payment lines use space to separate kronor and ore:
|
||||
"590 00" means 590.00 SEK, NOT 59000.
|
||||
"""
|
||||
result = normalizer.normalize("590 00")
|
||||
assert result.value == "590.00"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_payment_line_kronor_ore_large_amount(self, normalizer):
|
||||
"""Large kronor/ore amount from payment line."""
|
||||
result = normalizer.normalize("15658 00")
|
||||
assert result.value == "15658.00"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_payment_line_kronor_ore_with_nonzero_ore(self, normalizer):
|
||||
"""Kronor/ore with non-zero ore."""
|
||||
result = normalizer.normalize("736 50")
|
||||
assert result.value == "736.50"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_kronor_ore_not_confused_with_thousand_separator(self, normalizer):
|
||||
"""Amount with comma decimal should NOT trigger kronor/ore pattern."""
|
||||
result = normalizer.normalize("1 234,56")
|
||||
assert result.value is not None
|
||||
# Should parse as 1234.56, not as kronor=1234 ore=56 (which is same value)
|
||||
assert float(result.value) == 1234.56
|
||||
|
||||
def test_european_dot_thousand_separator(self, normalizer):
|
||||
"""European format: dot as thousand, comma as decimal."""
|
||||
result = normalizer.normalize("2.254,50")
|
||||
assert result.value == "2254.50"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_european_dot_thousand_with_sek(self, normalizer):
|
||||
"""European format with SEK suffix."""
|
||||
result = normalizer.normalize("2.254,50 SEK")
|
||||
assert result.value == "2254.50"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_european_dot_thousand_with_kr(self, normalizer):
|
||||
"""European format with kr suffix."""
|
||||
result = normalizer.normalize("20.485,00 kr")
|
||||
assert result.value == "20485.00"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_european_large_amount(self, normalizer):
|
||||
"""Large European format amount."""
|
||||
result = normalizer.normalize("1.234.567,89")
|
||||
assert result.value == "1234567.89"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_european_in_label_context(self, normalizer):
|
||||
"""European format inside label text (like the BAUHAUS invoice bug)."""
|
||||
result = normalizer.normalize("ns Fakturabelopp: 2.254,50 SEK")
|
||||
assert result.value == "2254.50"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_anglo_comma_thousand_separator(self, normalizer):
|
||||
"""Anglo format: comma as thousand, dot as decimal."""
|
||||
result = normalizer.normalize("1,234.56")
|
||||
assert result.value == "1234.56"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_zero_amount_rejected(self, normalizer):
|
||||
"""Test that zero amounts are rejected."""
|
||||
result = normalizer.normalize("0,00 kr")
|
||||
@@ -450,6 +515,18 @@ class TestEnhancedAmountNormalizer:
|
||||
result = normalizer.normalize("Invoice for 1 234 567,89 kr")
|
||||
assert result.value is not None
|
||||
|
||||
def test_enhanced_kronor_ore_format(self, normalizer):
|
||||
"""Space between kronor and ore in enhanced normalizer."""
|
||||
result = normalizer.normalize("590 00")
|
||||
assert result.value == "590.00"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_enhanced_kronor_ore_large(self, normalizer):
|
||||
"""Large kronor/ore amount in enhanced normalizer."""
|
||||
result = normalizer.normalize("15658 00")
|
||||
assert result.value == "15658.00"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_no_amount_fails(self, normalizer):
|
||||
"""Test failure when no amount found."""
|
||||
result = normalizer.normalize("no amount")
|
||||
@@ -472,6 +549,22 @@ class TestEnhancedAmountNormalizer:
|
||||
result = normalizer.normalize("Price: 1 234 567,89")
|
||||
assert result.value is not None
|
||||
|
||||
def test_enhanced_european_dot_thousand(self, normalizer):
|
||||
"""European format in enhanced normalizer."""
|
||||
result = normalizer.normalize("2.254,50 SEK")
|
||||
assert result.value == "2254.50"
|
||||
assert result.is_valid is True
|
||||
|
||||
def test_enhanced_european_with_label(self, normalizer):
|
||||
"""European format with Swedish label keyword."""
|
||||
result = normalizer.normalize("Att betala: 2.254,50")
|
||||
assert result.value == "2254.50"
|
||||
|
||||
def test_enhanced_anglo_format(self, normalizer):
|
||||
"""Anglo format in enhanced normalizer."""
|
||||
result = normalizer.normalize("Total: 1,234.56")
|
||||
assert result.value == "1234.56"
|
||||
|
||||
def test_amount_out_of_range_rejected(self, normalizer):
|
||||
"""Test that amounts >= 10,000,000 are rejected."""
|
||||
result = normalizer.normalize("Summa: 99 999 999,00")
|
||||
|
||||
Reference in New Issue
Block a user