if b"'HKSPA:" in message:
result.append(b"HISPA::1:4+J:DE111234567800000001:GENODE00TES:00001::280:1234567890'")
+ hkccs = re.search(rb"'HKCCS:(\d+):1.*@\d+@(.*)/Document>'", message)
+ if hkccs:
+ segno = hkccs.group(1).decode('us-ascii')
+ pain = hkccs.group(2).decode('utf-8')
+
+ memomatch = re.search(r"<RmtInf[^>]*>\s*<Ustrd[^>]*>\s*([^<]+)\s*</Ustrd", pain)
+ recvrmatch = re.search(r"<CdtrAcct[^>]*>\s*<Id[^>]*>\s*<IBAN[^>]*>\s*([^<]+)\s*</IBAN", pain)
+ amountmatch = re.search(r"<Amt[^>]*><InstdAmt[^>]*>\s*([^<]+)\s*</InstdAmt", pain)
+
+ if memomatch and recvrmatch and amountmatch:
+ if memomatch.group(1).endswith('1step'):
+ result.append("HIRMS::2:{}+0010::Transfer {} to {} re {}'".format(segno, amountmatch.group(1), recvrmatch.group(1), repr(memomatch.group(1)).replace("'", "?'")).encode('iso-8859-1'))
+
return b"".join(result)
-from fints.client import FinTS3PinTanClient
+from fints.client import FinTS3PinTanClient, TransactionResponse, NeedTANResponse, ResponseStatus
+from decimal import Decimal
import pytest
@pytest.fixture
with fints_client.resume_dialog(d_data):
assert dialog_id == fints_client._standing_dialog.dialogue_id
assert fints_client.bpd_version == 78
+
+def test_transfer_1step(fints_client):
+ with fints_client:
+ accounts = fints_client.get_sepa_accounts()
+ a = fints_client.simple_sepa_transfer(
+ accounts[0],
+ 'DE111234567800000002',
+ 'GENODE00TES',
+ 'Test Receiver',
+ Decimal('1.23'),
+ 'Test Sender',
+ 'Test transfer 1step'
+ )
+
+ assert isinstance(a, TransactionResponse)
+ assert a.status == ResponseStatus.SUCCESS
+
+ assert a.responses[0].code == '0010'
+ assert a.responses[0].text == "Transfer 1.23 to DE111234567800000002 re 'Test transfer 1step'"
+
+def test_transfer_1step_regression(fints_client):
+ # Passing a float is not officially supported, but should not fail with wrong values
+ # Decimal(1.23) is Decimal('1.229999999999999982236431605997495353221893310546875')
+ # which emphatically should not be cut to 122 cents.
+
+ with fints_client:
+ accounts = fints_client.get_sepa_accounts()
+ a = fints_client.simple_sepa_transfer(
+ accounts[0],
+ 'DE111234567800000002',
+ 'GENODE00TES',
+ 'Test Receiver',
+ 1.23,
+ 'Test Sender',
+ 'Test transfer 1step'
+ )
+
+ assert isinstance(a, TransactionResponse)
+ assert a.responses[0].text == "Transfer 1.23 to DE111234567800000002 re 'Test transfer 1step'"