Beispiel #1
0
 def clean_vat_code(self):
     vat_code = self.cleaned_data["vat_code"].strip()
     if vat_code:
         prefix, parts = verify_vat(vat_code, "FI")  # TODO: 'fi' isn't the best default
         if not vat_code.startswith(prefix):
             vat_code = prefix + vat_code  # Always add prefix
     return vat_code
Beispiel #2
0
 def clean_vat_code(self):
     vat_code = self.cleaned_data["vat_code"].strip()
     if vat_code:
         prefix, parts = verify_vat(vat_code, "FI")  # TODO: 'fi' isn't the best default
         if not vat_code.startswith(prefix):
             vat_code = prefix + vat_code  # Always add prefix
     return vat_code
Beispiel #3
0
def test_vat_prefix_for_country():
    prefix, result = verify_vat("12345678", get_vat_prefix_for_country("fi"))
    assert prefix == "FI"
    assert result == ('12345678', )
Beispiel #4
0
def test_vat_autoprefix():
    prefix, result = verify_vat("12345678", "FI")
    assert prefix == "FI"
    assert result == ('12345678', )
Beispiel #5
0
def test_vat_invalid(input, expected_code):
    with pytest.raises(ValidationError) as excinfo:
        verify_vat(input)
    assert excinfo.value.code == expected_code
Beispiel #6
0
def test_vat_valid(input, expected):
    prefix, result = verify_vat(input)
    assert result == expected, ("%s works" % input)
Beispiel #7
0
def test_vat_prefix_for_country():
    prefix, result = verify_vat("12345678", get_vat_prefix_for_country("fi"))
    assert prefix == "FI"
    assert result == ('12345678',)
Beispiel #8
0
def test_vat_autoprefix():
    prefix, result = verify_vat("12345678", "FI")
    assert prefix == "FI"
    assert result == ('12345678',)
Beispiel #9
0
def test_vat_invalid(input, expected_code):
    with pytest.raises(ValidationError) as excinfo:
        verify_vat(input)
    assert excinfo.value.code == expected_code
Beispiel #10
0
def test_vat_valid(input, expected):
    prefix, result = verify_vat(input)
    assert result == expected, ("%s works" % input)