From 624478bd257b4d2d2ba79a7d74028be5abe0c0b7 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 15 Jun 2023 22:49:05 +0200 Subject: [PATCH] Support new PAIN versions --- README.rst | 6 + sepaxml/debit.py | 10 +- sepaxml/schemas/pain.001.001.09.xsd | 1114 ++++++++++++++++++++++++ sepaxml/schemas/pain.001.001.10.xsd | 1241 ++++++++++++++++++++++++++ sepaxml/schemas/pain.001.001.11.xsd | 1244 +++++++++++++++++++++++++++ sepaxml/schemas/pain.008.001.08.xsd | 1106 ++++++++++++++++++++++++ sepaxml/schemas/pain.008.001.09.xsd | 1125 ++++++++++++++++++++++++ sepaxml/schemas/pain.008.001.10.xsd | 1128 ++++++++++++++++++++++++ sepaxml/transfer.py | 25 +- tests/debit/test_00800108.py | 216 +++++ tests/debit/test_00800109.py | 216 +++++ tests/debit/test_00800110.py | 216 +++++ tests/transfer/test_00100109.py | 136 +++ tests/transfer/test_00100110.py | 136 +++ tests/transfer/test_00100111.py | 136 +++ 15 files changed, 8049 insertions(+), 6 deletions(-) create mode 100644 sepaxml/schemas/pain.001.001.09.xsd create mode 100644 sepaxml/schemas/pain.001.001.10.xsd create mode 100644 sepaxml/schemas/pain.001.001.11.xsd create mode 100644 sepaxml/schemas/pain.008.001.08.xsd create mode 100644 sepaxml/schemas/pain.008.001.09.xsd create mode 100644 sepaxml/schemas/pain.008.001.10.xsd create mode 100644 tests/debit/test_00800108.py create mode 100644 tests/debit/test_00800109.py create mode 100644 tests/debit/test_00800110.py create mode 100644 tests/transfer/test_00100109.py create mode 100644 tests/transfer/test_00100110.py create mode 100644 tests/transfer/test_00100111.py diff --git a/README.rst b/README.rst index 3602bf2..8b11072 100644 --- a/README.rst +++ b/README.rst @@ -18,7 +18,13 @@ Limitations Supported standards: * SEPA PAIN.001.001.03 +* SEPA PAIN.001.001.09 +* SEPA PAIN.001.001.10 +* SEPA PAIN.001.001.11 * SEPA PAIN.008.001.02 +* SEPA PAIN.008.001.08 +* SEPA PAIN.008.001.09 +* SEPA PAIN.008.001.10 Usage ----- diff --git a/sepaxml/debit.py b/sepaxml/debit.py index 74dbd1c..4aac203 100644 --- a/sepaxml/debit.py +++ b/sepaxml/debit.py @@ -232,7 +232,10 @@ def _create_PmtInf_node(self): ED['CdtrAgtNode'] = ET.Element("CdtrAgt") ED['FinInstnId_CdtrAgt_Node'] = ET.Element("FinInstnId") if 'BIC' in self._config: - ED['BIC_CdtrAgt_Node'] = ET.Element("BIC") + if self.schema != 'pain.008.001.02': + ED['BIC_CdtrAgt_Node'] = ET.Element("BICFI") + else: + ED['BIC_CdtrAgt_Node'] = ET.Element("BIC") else: ED['Othr_CdtrAgt_Node'] = ET.Element("Othr") ED['Id_CdtrAgt_Node'] = ET.Element("Id") @@ -263,7 +266,10 @@ def _create_TX_node(self, bic=True): ED['DbtrAgtNode'] = ET.Element("DbtrAgt") ED['FinInstnId_DbtrAgt_Node'] = ET.Element("FinInstnId") if bic: - ED['BIC_DbtrAgt_Node'] = ET.Element("BIC") + if self.schema != 'pain.008.001.02': + ED['BIC_DbtrAgt_Node'] = ET.Element("BICFI") + else: + ED['BIC_DbtrAgt_Node'] = ET.Element("BIC") else: ED['Id_DbtrAgt_Node'] = ET.Element("Id") ED['Othr_DbtrAgt_Node'] = ET.Element("Othr") diff --git a/sepaxml/schemas/pain.001.001.09.xsd b/sepaxml/schemas/pain.001.001.09.xsd new file mode 100644 index 0000000..d967513 --- /dev/null +++ b/sepaxml/schemas/pain.001.001.09.xsd @@ -0,0 +1,1114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sepaxml/schemas/pain.001.001.10.xsd b/sepaxml/schemas/pain.001.001.10.xsd new file mode 100644 index 0000000..86c27c8 --- /dev/null +++ b/sepaxml/schemas/pain.001.001.10.xsd @@ -0,0 +1,1241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sepaxml/schemas/pain.001.001.11.xsd b/sepaxml/schemas/pain.001.001.11.xsd new file mode 100644 index 0000000..bfd1575 --- /dev/null +++ b/sepaxml/schemas/pain.001.001.11.xsd @@ -0,0 +1,1244 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sepaxml/schemas/pain.008.001.08.xsd b/sepaxml/schemas/pain.008.001.08.xsd new file mode 100644 index 0000000..802e29d --- /dev/null +++ b/sepaxml/schemas/pain.008.001.08.xsd @@ -0,0 +1,1106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sepaxml/schemas/pain.008.001.09.xsd b/sepaxml/schemas/pain.008.001.09.xsd new file mode 100644 index 0000000..8e967e0 --- /dev/null +++ b/sepaxml/schemas/pain.008.001.09.xsd @@ -0,0 +1,1125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sepaxml/schemas/pain.008.001.10.xsd b/sepaxml/schemas/pain.008.001.10.xsd new file mode 100644 index 0000000..9c451b7 --- /dev/null +++ b/sepaxml/schemas/pain.008.001.10.xsd @@ -0,0 +1,1128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sepaxml/transfer.py b/sepaxml/transfer.py index 1425dd2..55ac328 100644 --- a/sepaxml/transfer.py +++ b/sepaxml/transfer.py @@ -109,7 +109,10 @@ def add_payment(self, payment): if not self._config.get('domestic', False): PmtInf_nodes['Cd_SvcLvl_Node'].text = "SEPA" if 'execution_date' in payment: - PmtInf_nodes['ReqdExctnDtNode'].text = payment['execution_date'] + if self.schema == "pain.001.001.03": + PmtInf_nodes['ReqdExctnDtNode'].text = payment['execution_date'] + else: + PmtInf_nodes['ReqdExctnDt_Dt_Node'].text = payment['execution_date'] else: del PmtInf_nodes['ReqdExctnDtNode'] @@ -211,6 +214,7 @@ def _create_PmtInf_node(self): ED['SvcLvlNode'] = ET.Element("SvcLvl") ED['Cd_SvcLvl_Node'] = ET.Element("Cd") ED['ReqdExctnDtNode'] = ET.Element("ReqdExctnDt") + ED['ReqdExctnDt_Dt_Node'] = ET.Element("Dt") ED['DbtrNode'] = ET.Element("Dbtr") ED['Nm_Dbtr_Node'] = ET.Element("Nm") @@ -221,7 +225,10 @@ def _create_PmtInf_node(self): ED['DbtrAgtNode'] = ET.Element("DbtrAgt") ED['FinInstnId_DbtrAgt_Node'] = ET.Element("FinInstnId") if 'BIC' in self._config: - ED['BIC_DbtrAgt_Node'] = ET.Element("BIC") + if self.schema != 'pain.001.001.03': + ED['BIC_DbtrAgt_Node'] = ET.Element("BICFI") + else: + ED['BIC_DbtrAgt_Node'] = ET.Element("BIC") ED['ChrgBrNode'] = ET.Element("ChrgBr") return ED @@ -242,7 +249,10 @@ def _create_TX_node(self, bic=True): ED['CdtrAgtNode'] = ET.Element("CdtrAgt") ED['FinInstnId_CdtrAgt_Node'] = ET.Element("FinInstnId") if bic: - ED['BIC_CdtrAgt_Node'] = ET.Element("BIC") + if self.schema != 'pain.001.001.03': + ED['BIC_CdtrAgt_Node'] = ET.Element("BICFI") + else: + ED['BIC_CdtrAgt_Node'] = ET.Element("BIC") ED['CdtrAcctNode'] = ET.Element("CdtrAcct") ED['Id_CdtrAcct_Node'] = ET.Element("Id") ED['IBAN_CdtrAcct_Node'] = ET.Element("IBAN") @@ -267,6 +277,8 @@ def _add_non_batch(self, TX_nodes, PmtInf_nodes): PmtInf_nodes['PmtInfNode'].append(PmtInf_nodes['PmtTpInfNode']) if 'ReqdExctnDtNode' in PmtInf_nodes: PmtInf_nodes['PmtInfNode'].append(PmtInf_nodes['ReqdExctnDtNode']) + if self.schema != "pain.001.001.03": + PmtInf_nodes['ReqdExctnDtNode'].append(PmtInf_nodes['ReqdExctnDt_Dt_Node']) PmtInf_nodes['DbtrNode'].append(PmtInf_nodes['Nm_Dbtr_Node']) if PmtInf_nodes['PstlAdr_Dbtr_Node']: @@ -376,7 +388,10 @@ def _finalize_batch(self): PmtInf_nodes['Cd_SvcLvl_Node'].text = "SEPA" if batch_meta: - PmtInf_nodes['ReqdExctnDtNode'].text = batch_meta + if self.schema == "pain.001.001.03": + PmtInf_nodes['ReqdExctnDtNode'].text = batch_meta + else: + PmtInf_nodes['ReqdExctnDt_Dt_Node'].text = batch_meta else: del PmtInf_nodes['ReqdExctnDtNode'] PmtInf_nodes['Nm_Dbtr_Node'].text = self._config['name'] @@ -412,6 +427,8 @@ def _finalize_batch(self): PmtInf_nodes['PmtInfNode'].append(PmtInf_nodes['PmtTpInfNode']) if 'ReqdExctnDtNode' in PmtInf_nodes: PmtInf_nodes['PmtInfNode'].append(PmtInf_nodes['ReqdExctnDtNode']) + if self.schema != "pain.001.001.03": + PmtInf_nodes['ReqdExctnDtNode'].append(PmtInf_nodes['ReqdExctnDt_Dt_Node']) PmtInf_nodes['DbtrNode'].append(PmtInf_nodes['Nm_Dbtr_Node']) if PmtInf_nodes['PstlAdr_Dbtr_Node']: diff --git a/tests/debit/test_00800108.py b/tests/debit/test_00800108.py new file mode 100644 index 0000000..da9a0c6 --- /dev/null +++ b/tests/debit/test_00800108.py @@ -0,0 +1,216 @@ +import datetime + +import pytest + +from sepaxml import SepaDD +from sepaxml.validation import ValidationError +from tests.utils import clean_ids, validate_xml + + +@pytest.fixture +def sdd(): + return SepaDD({ + "name": "TestCreditor", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "batch": True, + "creditor_id": "DE26ZZZ00000000000", + "currency": "EUR" + }, schema="pain.008.001.08") + + +SAMPLE_RESULT = b""" + + + + 20012017014921-ba2dab283fdd + 2017-01-20T13:49:21 + 2 + 60.12 + + TestCreditor + + + + DE26ZZZ00000000000 + + + + + + + TestCreditor-ecd6a2f680ce + DD + true + 1 + 10.12 + + + SEPA + + + CORE + + FRST + + 2017-01-20 + + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + + + DE26ZZZ00000000000 + + SEPA + + + + + + + + TestCreditor-4431989789fb + + 10.12 + + + 1234 + 2017-01-20 + + + + + BANKNL2A + + + + Test von Testenstein + + + + NL50BANK1234567890 + + + + Test transaction1 + + + + + TestCreditor-d547a1b3882f + DD + true + 1 + 50.00 + + + SEPA + + + CORE + + RCUR + + 2017-01-20 + + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + + + DE26ZZZ00000000000 + + SEPA + + + + + + + + TestCreditor-7e989083e265 + + 50.00 + + + 1234 + 2017-01-20 + + + + + BANKNL2A + + + + Test du Test + + + + NL50BANK1234567890 + + + + Test transaction2 + + + + + +""" + + +def test_two_debits(sdd): + payment1 = { + "name": "Test von Testenstein", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 1012, + "type": "FRST", + "collection_date": datetime.date.today(), + "mandate_id": "1234", + "mandate_date": datetime.date.today(), + "description": "Test transaction1" + } + payment2 = { + "name": "Test du Test", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 5000, + "type": "RCUR", + "collection_date": datetime.date.today(), + "mandate_id": "1234", + "mandate_date": datetime.date.today(), + "description": "Test transaction2" + } + + sdd.add_payment(payment1) + sdd.add_payment(payment2) + xmlout = sdd.export() + xmlpretty = validate_xml(xmlout, "pain.008.001.08") + assert clean_ids(xmlpretty.strip()).decode() == clean_ids(SAMPLE_RESULT.strip()).decode() diff --git a/tests/debit/test_00800109.py b/tests/debit/test_00800109.py new file mode 100644 index 0000000..bd88473 --- /dev/null +++ b/tests/debit/test_00800109.py @@ -0,0 +1,216 @@ +import datetime + +import pytest + +from sepaxml import SepaDD +from sepaxml.validation import ValidationError +from tests.utils import clean_ids, validate_xml + + +@pytest.fixture +def sdd(): + return SepaDD({ + "name": "TestCreditor", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "batch": True, + "creditor_id": "DE26ZZZ00000000000", + "currency": "EUR" + }, schema="pain.008.001.09") + + +SAMPLE_RESULT = b""" + + + + 20012017014921-ba2dab283fdd + 2017-01-20T13:49:21 + 2 + 60.12 + + TestCreditor + + + + DE26ZZZ00000000000 + + + + + + + TestCreditor-ecd6a2f680ce + DD + true + 1 + 10.12 + + + SEPA + + + CORE + + FRST + + 2017-01-20 + + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + + + DE26ZZZ00000000000 + + SEPA + + + + + + + + TestCreditor-4431989789fb + + 10.12 + + + 1234 + 2017-01-20 + + + + + BANKNL2A + + + + Test von Testenstein + + + + NL50BANK1234567890 + + + + Test transaction1 + + + + + TestCreditor-d547a1b3882f + DD + true + 1 + 50.00 + + + SEPA + + + CORE + + RCUR + + 2017-01-20 + + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + + + DE26ZZZ00000000000 + + SEPA + + + + + + + + TestCreditor-7e989083e265 + + 50.00 + + + 1234 + 2017-01-20 + + + + + BANKNL2A + + + + Test du Test + + + + NL50BANK1234567890 + + + + Test transaction2 + + + + + +""" + + +def test_two_debits(sdd): + payment1 = { + "name": "Test von Testenstein", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 1012, + "type": "FRST", + "collection_date": datetime.date.today(), + "mandate_id": "1234", + "mandate_date": datetime.date.today(), + "description": "Test transaction1" + } + payment2 = { + "name": "Test du Test", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 5000, + "type": "RCUR", + "collection_date": datetime.date.today(), + "mandate_id": "1234", + "mandate_date": datetime.date.today(), + "description": "Test transaction2" + } + + sdd.add_payment(payment1) + sdd.add_payment(payment2) + xmlout = sdd.export() + xmlpretty = validate_xml(xmlout, "pain.008.001.09") + assert clean_ids(xmlpretty.strip()).decode() == clean_ids(SAMPLE_RESULT.strip()).decode() diff --git a/tests/debit/test_00800110.py b/tests/debit/test_00800110.py new file mode 100644 index 0000000..8147ddb --- /dev/null +++ b/tests/debit/test_00800110.py @@ -0,0 +1,216 @@ +import datetime + +import pytest + +from sepaxml import SepaDD +from sepaxml.validation import ValidationError +from tests.utils import clean_ids, validate_xml + + +@pytest.fixture +def sdd(): + return SepaDD({ + "name": "TestCreditor", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "batch": True, + "creditor_id": "DE26ZZZ00000000000", + "currency": "EUR" + }, schema="pain.008.001.10") + + +SAMPLE_RESULT = b""" + + + + 20012017014921-ba2dab283fdd + 2017-01-20T13:49:21 + 2 + 60.12 + + TestCreditor + + + + DE26ZZZ00000000000 + + + + + + + TestCreditor-ecd6a2f680ce + DD + true + 1 + 10.12 + + + SEPA + + + CORE + + FRST + + 2017-01-20 + + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + + + DE26ZZZ00000000000 + + SEPA + + + + + + + + TestCreditor-4431989789fb + + 10.12 + + + 1234 + 2017-01-20 + + + + + BANKNL2A + + + + Test von Testenstein + + + + NL50BANK1234567890 + + + + Test transaction1 + + + + + TestCreditor-d547a1b3882f + DD + true + 1 + 50.00 + + + SEPA + + + CORE + + RCUR + + 2017-01-20 + + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + + + DE26ZZZ00000000000 + + SEPA + + + + + + + + TestCreditor-7e989083e265 + + 50.00 + + + 1234 + 2017-01-20 + + + + + BANKNL2A + + + + Test du Test + + + + NL50BANK1234567890 + + + + Test transaction2 + + + + + +""" + + +def test_two_debits(sdd): + payment1 = { + "name": "Test von Testenstein", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 1012, + "type": "FRST", + "collection_date": datetime.date.today(), + "mandate_id": "1234", + "mandate_date": datetime.date.today(), + "description": "Test transaction1" + } + payment2 = { + "name": "Test du Test", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 5000, + "type": "RCUR", + "collection_date": datetime.date.today(), + "mandate_id": "1234", + "mandate_date": datetime.date.today(), + "description": "Test transaction2" + } + + sdd.add_payment(payment1) + sdd.add_payment(payment2) + xmlout = sdd.export() + xmlpretty = validate_xml(xmlout, "pain.008.001.10") + assert clean_ids(xmlpretty.strip()).decode() == clean_ids(SAMPLE_RESULT.strip()).decode() diff --git a/tests/transfer/test_00100109.py b/tests/transfer/test_00100109.py new file mode 100644 index 0000000..b19e793 --- /dev/null +++ b/tests/transfer/test_00100109.py @@ -0,0 +1,136 @@ +import datetime + +import pytest + +from sepaxml import SepaTransfer +from tests.utils import clean_ids, validate_xml + + +@pytest.fixture +def strf(): + return SepaTransfer({ + "name": "TestCreditor", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "batch": True, + "currency": "EUR" + }, schema="pain.001.001.09") + + +SAMPLE_RESULT = b""" + + + + 20180724040432-d24ce3b3e284 + 2018-07-24T16:04:32 + 2 + 60.12 + + TestCreditor + + + + TestCreditor-90102652f82a + TRF + true + 2 + 60.12 + + + SEPA + + + +
2018-07-24
+
+ + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + NOTPROVIDED + + + 10.12 + + + + BANKNL2A + + + + Test von Testenstein + + + + NL50BANK1234567890 + + + + Test transaction1 + + + + + NOTPROVIDED + + + 50.00 + + + + BANKNL2A + + + + Test du Test + + + + NL50BANK1234567890 + + + + Test transaction2 + + +
+
+
+""" + + +def test_two_debits(strf): + payment1 = { + "name": "Test von Testenstein", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 1012, + "execution_date": datetime.date.today(), + "description": "Test transaction1" + } + payment2 = { + "name": "Test du Test", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 5000, + "execution_date": datetime.date.today(), + "description": "Test transaction2" + } + + strf.add_payment(payment1) + strf.add_payment(payment2) + xmlout = strf.export() + xmlpretty = validate_xml(xmlout, "pain.001.001.09") + assert clean_ids(xmlpretty.strip()).decode() == clean_ids(SAMPLE_RESULT.strip()).decode() diff --git a/tests/transfer/test_00100110.py b/tests/transfer/test_00100110.py new file mode 100644 index 0000000..c0f8b42 --- /dev/null +++ b/tests/transfer/test_00100110.py @@ -0,0 +1,136 @@ +import datetime + +import pytest + +from sepaxml import SepaTransfer +from tests.utils import clean_ids, validate_xml + + +@pytest.fixture +def strf(): + return SepaTransfer({ + "name": "TestCreditor", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "batch": True, + "currency": "EUR" + }, schema="pain.001.001.10") + + +SAMPLE_RESULT = b""" + + + + 20180724040432-d24ce3b3e284 + 2018-07-24T16:04:32 + 2 + 60.12 + + TestCreditor + + + + TestCreditor-90102652f82a + TRF + true + 2 + 60.12 + + + SEPA + + + +
2018-07-24
+
+ + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + NOTPROVIDED + + + 10.12 + + + + BANKNL2A + + + + Test von Testenstein + + + + NL50BANK1234567890 + + + + Test transaction1 + + + + + NOTPROVIDED + + + 50.00 + + + + BANKNL2A + + + + Test du Test + + + + NL50BANK1234567890 + + + + Test transaction2 + + +
+
+
+""" + + +def test_two_debits(strf): + payment1 = { + "name": "Test von Testenstein", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 1012, + "execution_date": datetime.date.today(), + "description": "Test transaction1" + } + payment2 = { + "name": "Test du Test", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 5000, + "execution_date": datetime.date.today(), + "description": "Test transaction2" + } + + strf.add_payment(payment1) + strf.add_payment(payment2) + xmlout = strf.export() + xmlpretty = validate_xml(xmlout, "pain.001.001.10") + assert clean_ids(xmlpretty.strip()).decode() == clean_ids(SAMPLE_RESULT.strip()).decode() diff --git a/tests/transfer/test_00100111.py b/tests/transfer/test_00100111.py new file mode 100644 index 0000000..0e93717 --- /dev/null +++ b/tests/transfer/test_00100111.py @@ -0,0 +1,136 @@ +import datetime + +import pytest + +from sepaxml import SepaTransfer +from tests.utils import clean_ids, validate_xml + + +@pytest.fixture +def strf(): + return SepaTransfer({ + "name": "TestCreditor", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "batch": True, + "currency": "EUR" + }, schema="pain.001.001.11") + + +SAMPLE_RESULT = b""" + + + + 20180724040432-d24ce3b3e284 + 2018-07-24T16:04:32 + 2 + 60.12 + + TestCreditor + + + + TestCreditor-90102652f82a + TRF + true + 2 + 60.12 + + + SEPA + + + +
2018-07-24
+
+ + TestCreditor + + + + NL50BANK1234567890 + + + + + BANKNL2A + + + SLEV + + + NOTPROVIDED + + + 10.12 + + + + BANKNL2A + + + + Test von Testenstein + + + + NL50BANK1234567890 + + + + Test transaction1 + + + + + NOTPROVIDED + + + 50.00 + + + + BANKNL2A + + + + Test du Test + + + + NL50BANK1234567890 + + + + Test transaction2 + + +
+
+
+""" + + +def test_two_debits(strf): + payment1 = { + "name": "Test von Testenstein", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 1012, + "execution_date": datetime.date.today(), + "description": "Test transaction1" + } + payment2 = { + "name": "Test du Test", + "IBAN": "NL50BANK1234567890", + "BIC": "BANKNL2A", + "amount": 5000, + "execution_date": datetime.date.today(), + "description": "Test transaction2" + } + + strf.add_payment(payment1) + strf.add_payment(payment2) + xmlout = strf.export() + xmlpretty = validate_xml(xmlout, "pain.001.001.11") + assert clean_ids(xmlpretty.strip()).decode() == clean_ids(SAMPLE_RESULT.strip()).decode()