libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

Iso20022Test.kt (32836B)


      1 /*
      2  * This file is part of LibEuFin.
      3  * Copyright (C) 2024-2025 Taler Systems S.A.
      4 
      5  * LibEuFin is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU Affero General Public License as
      7  * published by the Free Software Foundation; either version 3, or
      8  * (at your option) any later version.
      9 
     10  * LibEuFin is distributed in the hope that it will be useful, but
     11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General
     13  * Public License for more details.
     14 
     15  * You should have received a copy of the GNU Affero General Public
     16  * License along with LibEuFin; see the file COPYING.  If not, see
     17  * <http://www.gnu.org/licenses/>
     18  */
     19 
     20 import org.junit.Test
     21 import tech.libeufin.common.*
     22 import tech.libeufin.nexus.*
     23 import tech.libeufin.nexus.iso20022.*
     24 import tech.libeufin.ebics.*
     25 import kotlin.io.path.*
     26 import kotlin.test.*
     27 import java.time.Instant
     28 
     29 class Iso20022Test {
     30     @Test
     31     fun pain001() {
     32         val creditor = IbanAccountMetadata(
     33             iban = "CH4189144589712575493",
     34             bic = null,
     35             name = "Test"
     36         )
     37         val msg = Pain001Msg(
     38             messageId = "MESSAGE_ID",
     39             timestamp = dateToInstant("2024-09-09"),
     40             debtor = IbanAccountMetadata(
     41                 iban = "CH7789144474425692816",
     42                 bic = "BIC",
     43                 name = "myname"
     44             ),
     45             sum = TalerAmount("CHF:47.32"),
     46             txs = listOf(
     47                 Pain001Tx(
     48                     creditor = creditor,
     49                     amount = TalerAmount("CHF:42"),
     50                     subject = "Test 42",
     51                     endToEndId = "TX_FIRST"
     52                 ),
     53                 Pain001Tx(
     54                     creditor = creditor,
     55                     amount = TalerAmount("CHF:5.11"),
     56                     subject = "Test 5.11",
     57                     endToEndId = "TX_SECOND"
     58                 ),
     59                 Pain001Tx(
     60                     creditor = creditor,
     61                     amount = TalerAmount("CHF:0.21"),
     62                     subject = "Test 0.21",
     63                     endToEndId = "TX_THIRD"
     64                 )
     65             )
     66         )
     67         for (dialect in Dialect.entries) {
     68             assertEquals(
     69                 Path("sample/platform/${dialect}_pain001.xml").readText().replace("VERSION", VERSION),
     70                 createPain001(msg, dialect, false).asUtf8()
     71             )
     72         }
     73     }
     74 
     75     @Test
     76     fun hac() {
     77         assertContentEquals(
     78             parseCustomerAck(Path("sample/platform/hac.xml").inputStream()),
     79             listOf(
     80                 CustomerAck(
     81                     actionType = HacAction.FILE_DOWNLOAD,
     82                     orderId = null,
     83                     code = ExternalStatusReasonCode.TS01,
     84                     info = "",
     85                     timestamp = dateTimeToInstant("2024-09-02T15:47:30.350Z")
     86                 ),
     87                 CustomerAck(
     88                     actionType = HacAction.FILE_UPLOAD,
     89                     orderId = "ORDER_SUCCESS",
     90                     code = ExternalStatusReasonCode.TS01,
     91                     info = "",
     92                     timestamp = dateTimeToInstant("2024-09-02T20:48:43.153Z")
     93                 ),
     94                 CustomerAck(
     95                     actionType = HacAction.ES_VERIFICATION,
     96                     orderId = "ORDER_SUCCESS",
     97                     code = ExternalStatusReasonCode.DS01,
     98                     info = "",
     99                     timestamp = dateTimeToInstant("2024-09-02T20:48:43.153Z")
    100                 ),
    101                 CustomerAck(
    102                     actionType = HacAction.ORDER_HAC_FINAL_POS,
    103                     orderId = "ORDER_SUCCESS",
    104                     code = null,
    105                     info = "Some multiline info",
    106                     timestamp = dateTimeToInstant("2024-09-02T20:48:43.153Z")
    107                 ),
    108                 CustomerAck(
    109                     actionType = HacAction.FILE_DOWNLOAD,
    110                     orderId = null,
    111                     code = ExternalStatusReasonCode.TD01,
    112                     info = "",
    113                     timestamp = dateTimeToInstant("2024-09-02T15:47:31.754Z")
    114                 ),
    115                 CustomerAck(
    116                     actionType = HacAction.FILE_UPLOAD,
    117                     orderId = "ORDER_FAILURE",
    118                     code = ExternalStatusReasonCode.TS01,
    119                     info = "",
    120                     timestamp = dateTimeToInstant("2024-08-23T15:34:11.987")
    121                 ),
    122                 CustomerAck(
    123                     actionType = HacAction.ES_VERIFICATION,
    124                     orderId = "ORDER_FAILURE",
    125                     code = ExternalStatusReasonCode.TD03,
    126                     info = "",
    127                     timestamp = dateTimeToInstant("2024-08-23T15:34:13.307")
    128                 ),
    129                 CustomerAck(
    130                     actionType = HacAction.ORDER_HAC_FINAL_NEG,
    131                     orderId = "ORDER_FAILURE",
    132                     code = null,
    133                     info = "",
    134                     timestamp = dateTimeToInstant("2024-08-23T15:34:13.307")
    135                 ),
    136             )
    137         )
    138     }
    139 
    140     @Test
    141     fun postfinance_camt054() {
    142         assertContentEquals(
    143             parseTx(Path("sample/platform/postfinance_camt054.xml").inputStream()),
    144             listOf(AccountTransactions(
    145                 iban = "CH9289144596463965762",
    146                 currency = "CHF",
    147                 txs = listOf(
    148                     OutgoingPayment(
    149                         id = OutgoingId("ZS1PGNTSV0ZNDFAJBBWWB8015G", "ZS1PGNTSV0ZNDFAJBBWWB8015G", null),
    150                         amount = TalerAmount("CHF:3.00"),
    151                         subject = null,
    152                         executionTime = dateToInstant("2024-01-15"),
    153                         creditor = null
    154                     ),
    155                     IncomingPayment(
    156                         id = IncomingId("62e2b511-7313-4ccd-8d40-c9d8e612cd71", null, "231121CH0AZWCR9T"),
    157                         amount = TalerAmount("CHF:10"),
    158                         subject = "G1XTY6HGWGMVRM7E6XQ4JHJK561ETFDFTJZ7JVGV543XZCB27YBG",
    159                         executionTime = dateToInstant("2023-12-19"),
    160                         debtor = ibanPayto("CH7389144832588726658", "Mr Test")
    161                     ),
    162                     IncomingPayment(
    163                         id = IncomingId("62e2b511-7313-4ccd-8d40-c9d8e612cd71", null, "231121CH0AZWCVR1"),
    164                         amount = TalerAmount("CHF:2.53"),
    165                         subject = "G1XTY6HGWGMVRM7E6XQ4JHJK561ETFDFTJZ7JVGV543XZCB27YB",
    166                         executionTime = dateToInstant("2023-12-19"),
    167                         debtor = ibanPayto("CH7389144832588726658", "Mr Test")
    168                     ),
    169                     OutgoingReversal(
    170                         endToEndId = "50820f78-9024-44ff-978d-63a18c",
    171                         msgId = "50820f78-9024-44ff-978d-63a18c",
    172                         reason = "",
    173                         executionTime = dateToInstant("2024-01-15")
    174                     ),
    175                     OutgoingBatch(
    176                         msgId = "ZS1PGNTSV0ZNDFAJBBWWB8015G",
    177                         executionTime = dateToInstant("2024-01-15")
    178                     )
    179                 )
    180             ))
    181         )
    182     }
    183 
    184     @Test
    185     fun postfinance_camt053() {
    186         assertContentEquals(
    187             parseTx(Path("sample/platform/postfinance_camt053.xml").inputStream()),
    188             listOf(AccountTransactions(
    189                 iban = "CH9289144596463965762",
    190                 currency = "CHF",
    191                 txs = listOf(
    192                     OutgoingReversal(
    193                         endToEndId = "889d1a80-1267-49bd-8fcc-85701a",
    194                         msgId = "889d1a80-1267-49bd-8fcc-85701a",
    195                         reason = "InconsistenWithEndCustomer 'Identification of end customer is not consistent with associated account number, organisation ID or private ID.' - 'more info here ...'",
    196                         executionTime = dateToInstant("2023-11-22")
    197                     ),
    198                     OutgoingReversal(
    199                         endToEndId = "4cc61cc7-6230-49c2-b5e2-b40bbb",
    200                         msgId = "4cc61cc7-6230-49c2-b5e2-b40bbb",
    201                         reason = "MissingCreditorNameOrAddress 'Specification of the creditor’s name and/or address needed for regulatory requirements is insufficient or missing.' - 'more info here ...'",
    202                         executionTime = dateToInstant("2023-11-22")
    203                     ),
    204                     OutgoingBatch(
    205                         msgId = "EB4D22D428214261B2B3012D2A8CEC36",
    206                         executionTime = dateToInstant("2024-08-26")
    207                     )
    208                 )
    209             ))
    210         )
    211     }
    212 
    213     @Test
    214     fun valiant_camt052() {
    215         assertContentEquals(
    216             parseTx(Path("sample/platform/valiant_camt052.xml").inputStream()),
    217             listOf(AccountTransactions(
    218                 iban = "CH7389144832588726658",
    219                 currency = "CHF",
    220                 txs = listOf(
    221                     OutgoingPayment(
    222                         id = OutgoingId("MJDJO2BDDBL7YSL2P96SXHG3TQZEZQD26L", "4UWWIDGTEIGDU6Z721QE95PYJSIEA48PYE", "ZV20251030/511372/1"),
    223                         amount = TalerAmount("CHF:0.1"),
    224                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans"),
    225                         subject = "single 2025-10-30T09:46:04.55293090 9Z",
    226                         executionTime = dateToInstant("2025-10-30")
    227                     ),
    228                     OutgoingPayment(
    229                         id = OutgoingId("5HIS3433VVIBAANHW3GX9DR1AXRS43KZ4U", "SKMU2891PAAYBDW22DBWX2W7KTFZ1CDFO8", "ZV20251030/511373/1"),
    230                         amount = TalerAmount("CHF:0.1"),
    231                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans"),
    232                         subject = "multi 0 2025-10-30T09:46:10.3877961 30Z",
    233                         executionTime = dateToInstant("2025-10-30")
    234                     ),
    235                     OutgoingPayment(
    236                         id = OutgoingId("5HIS3433VVIBAANHW3GX9DR1AXRS43KZ4U", "RC9YD301NZ17YKD6WDWLNOROFHIIN29VJN", "ZV20251030/511373/2"),
    237                         amount = TalerAmount("CHF:0.11"),
    238                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans"),
    239                         subject = "multi 1 2025-10-30T09:46:10.3877961 30Z",
    240                         executionTime = dateToInstant("2025-10-30")
    241                     ),
    242                     OutgoingPayment(
    243                         id = OutgoingId("5HIS3433VVIBAANHW3GX9DR1AXRS43KZ4U", "GKDGTHLB82X6XVHBJIJ1CK8MEGU9XJ2EL7", "ZV20251030/511373/3"),
    244                         amount = TalerAmount("CHF:0.12"),
    245                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans"),
    246                         subject = "multi 2 2025-10-30T09:46:10.3877961 30Z",
    247                         executionTime = dateToInstant("2025-10-30")
    248                     ),
    249                     OutgoingPayment(
    250                         id = OutgoingId("5HIS3433VVIBAANHW3GX9DR1AXRS43KZ4U", "PXCH2VVVTXEXBVDWICP23HZ4NV0H2CWW28", "ZV20251030/511373/4"),
    251                         amount = TalerAmount("CHF:0.13"),
    252                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans"),
    253                         subject = "multi 3 2025-10-30T09:46:10.3877961 30Z",
    254                         executionTime = dateToInstant("2025-10-30")
    255                     ),
    256                     IncomingPayment(
    257                         id = IncomingId(null, "51030655601.0001", "ZV20251030/514778/1"),
    258                         amount = TalerAmount("CHF:0.85"),
    259                         subject = "fun stuff",
    260                         executionTime = dateToInstant("2025-10-30"),
    261                         debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans"),
    262                     ),
    263                     IncomingPayment(
    264                         id = IncomingId(null, "51030655601.0002", "ZV20251030/514779/1"),
    265                         amount = TalerAmount("CHF:0.95"),
    266                         subject = "Taler PC2MKG0B7CK32K1T7DP08P6E1B7FHB6HY6R Q0PT3VTPBPRPYM1B0",
    267                         executionTime = dateToInstant("2025-10-30"),
    268                         debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans"),
    269                     ),
    270                     OutgoingPayment(
    271                         id = OutgoingId("X166701F6RV59LP71RVWVIW9SV2AFZYLG4", "R48UBIIB7B4LX0DMVOSI0ZTJWMMG8FMNKX", "ZV20251030/524078/1"),
    272                         amount = TalerAmount("CHF:0.21"),
    273                         creditor = ibanPayto("CH6208704048981247126", "John Smith"),
    274                         subject = "bad name 2025-10-30T12:03:24.997478 811Z",
    275                         executionTime = dateToInstant("2025-10-30")
    276                     ),
    277                     OutgoingPayment(
    278                         id = OutgoingId("6OZN5T9W7MK6BIZYE01E62NHGP5JLMUD4X", "02WDIX4J90Z1M1WNFHLNSXY59SHXQTQCMQ", "ZV20251030/524079/1"),
    279                         amount = TalerAmount("CHF:0.1"),
    280                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans"),
    281                         subject = "single 2025-10-30T12:04:00.37042083 6Z",
    282                         executionTime = dateToInstant("2025-10-30")
    283                     ),
    284                     OutgoingPayment(
    285                         id = OutgoingId("6OZN5T9W7MK6BIZYE01E62NHGP5JLMUD4X", "XAP5L7HVWPLCEMECU4GZK6GKUPBL0TD13Y", "ZV20251030/524079/2"),
    286                         amount = TalerAmount("CHF:0.21"),
    287                         creditor = ibanPayto("CH6208704048981247126", "John Smith"),
    288                         subject = "bad name 2025-10-30T12:03:53.042190 686Z",
    289                         executionTime = dateToInstant("2025-10-30")
    290                     ),
    291                     OutgoingReversal(
    292                         endToEndId = "XAP5L7HVWPLCEMECU4GZK6GKUPBL0TD13Y",
    293                         reason = "Error msg in german",
    294                         executionTime = dateToInstant("2025-10-30")
    295                     ),
    296                     OutgoingReversal(
    297                         endToEndId = "R48UBIIB7B4LX0DMVOSI0ZTJWMMG8FMNKX",
    298                         reason = "Error msg in german",
    299                         executionTime = dateToInstant("2025-10-30")
    300                     ),
    301                     OutgoingPayment(
    302                         id = OutgoingId("OLAMDPI6YPMNRZHQ5PQ6JCVUQV2AN5NW6P", "TU2WJ54DR9Z6HT5VE494BNH4EXUSM0DRF7", "ZV20251030/524077/1"),
    303                         amount = TalerAmount("CHF:0.23"),
    304                         debitFee = TalerAmount("CHF:5"),
    305                         creditor = ibanPayto("DE48330605920000686018", "Christian Grothoff"),
    306                         subject = "foreign iban 2025-10-30T12:03:44.0972 63765Z",
    307                         executionTime = dateToInstant("2025-10-30")
    308                     ),
    309                     OutgoingPayment(
    310                         id = OutgoingId("6OZN5T9W7MK6BIZYE01E62NHGP5JLMUD4X", "GM8I8GIETR72LP6CFBGRBUDKNO2CEQBGOE", "ZV20251030/524080/1"),
    311                         amount = TalerAmount("CHF:0.23"),
    312                         debitFee = TalerAmount("CHF:5"),
    313                         creditor = ibanPayto("DE48330605920000686018", "Christian Grothoff"),
    314                         subject = "foreign iban 2025-10-30T12:03:58.0046 73747Z",
    315                         executionTime = dateToInstant("2025-10-30")
    316                     ),
    317                     IncomingPayment(
    318                         id = IncomingId("7b76d488-05d5-44ab-9d77-31d4165ec158", "00204EQY370", "ZV20251118/685062/1"),
    319                         amount = TalerAmount("CHF:4.55"),
    320                         subject = "TEST",
    321                         executionTime = dateToInstant("2025-11-18"),
    322                         debtor = null
    323                     ),
    324                 )
    325             ))
    326         )
    327     }
    328 
    329     @Test
    330     fun gls_camt052() {
    331         assertContentEquals(
    332             parseTx(Path("sample/platform/gls_camt052.xml").inputStream()),
    333             listOf(AccountTransactions(
    334                 iban = "DE84500105177118117964",
    335                 currency = "EUR",
    336                 txs = listOf(
    337                     OutgoingPayment(
    338                         id = OutgoingId("COMPAT_SUCCESS", "COMPAT_SUCCESS", "2024041801514102000"),
    339                         amount = TalerAmount("EUR:2"),
    340                         subject = "TestABC123",
    341                         executionTime = dateToInstant("2024-04-18"),
    342                         creditor = ibanPayto("DE20500105172419259181", "John Smith")
    343                     ),
    344                     OutgoingReversal(
    345                         endToEndId = "8XK8Z7RAX224FGWK832FD40GYC",
    346                         reason = "IncorrectAccountNumber 'Format of the account number specified is not correct' - 'IBAN fehlerhaft und ungültig'",
    347                         executionTime = dateToInstant("2024-09-05")
    348                     ),
    349                     IncomingPayment(
    350                         id = IncomingId(null, "BYLADEM1WOR-G2910276709458A2", "2024041210041357000"),
    351                         amount = TalerAmount("EUR:3"),
    352                         subject = "Taler FJDQ7W6G7NWX4H9M1MKA12090FRC9K7DA6N0FANDZZFXTR6QHX5G Test.,-",
    353                         executionTime = dateToInstant("2024-04-12"),
    354                         debtor = ibanPayto("DE84500105177118117964", "John Smith")
    355                     ),
    356                     OutgoingReversal(
    357                         endToEndId = "COMPAT_FAILURE",
    358                         reason = "IncorrectAccountNumber 'Format of the account number specified is not correct' - 'IBAN ...'",
    359                         executionTime = dateToInstant("2024-04-12")
    360                     ),
    361                     OutgoingPayment(
    362                         id = OutgoingId("BATCH_SINGLE_SUCCESS", "FD622SMXKT5QWSAHDY0H8NYG3G", "2024090216552232000"),
    363                         amount = TalerAmount("EUR:1.1"),
    364                         subject = "single 2024-09-02T14:29:52.875253314Z",
    365                         executionTime = dateToInstant("2024-09-02"),
    366                         creditor = ibanPayto("DE89500105173198527518", "Grothoff Hans")
    367                     ),
    368                     OutgoingPayment(
    369                         id = OutgoingId("YF5QBARGQ0MNY0VK59S477VDG4", "YF5QBARGQ0MNY0VK59S477VDG4", "2024041810552821000"),
    370                         amount = TalerAmount("EUR:1.1"),
    371                         subject = "Simple tx",
    372                         executionTime = dateToInstant("2024-04-18"),
    373                         creditor = ibanPayto("DE20500105172419259181", "John Smith")
    374                     ),
    375                     OutgoingBatch(
    376                         msgId = "BATCH_MANY_SUCCESS",
    377                         executionTime = dateToInstant("2024-09-20"),
    378                     ),
    379                     OutgoingPayment(
    380                         id = OutgoingId("BATCH_SINGLE_RETURN", "KLJJ28S1LVNDK1R2HCHLN884M7EKM5XGM5", "2024092100252498000"),
    381                         amount = TalerAmount("EUR:0.42"),
    382                         subject = "This should fail because bad iban",
    383                         executionTime = dateToInstant("2024-09-23"),
    384                         creditor = ibanPayto("DE18500105173385245163", "John Smith")
    385                     ),
    386                     OutgoingReversal(
    387                         endToEndId = "KLJJ28S1LVNDK1R2HCHLN884M7EKM5XGM5",
    388                         reason = "IncorrectAccountNumber 'Format of the account number specified is not correct' - 'IBAN fehlerhaft und ungültig'",
    389                         executionTime = dateToInstant("2024-09-24")
    390                     ),
    391                 )
    392             ))
    393         )
    394     }
    395 
    396     @Test
    397     fun gls_camt053() {
    398         assertContentEquals(
    399             parseTx(Path("sample/platform/gls_camt053.xml").inputStream()),
    400             listOf(AccountTransactions(
    401                 iban = "DE84500105177118117964",
    402                 currency = "EUR",
    403                 txs = listOf(
    404                     OutgoingPayment(
    405                         id = OutgoingId("COMPAT_SUCCESS", "COMPAT_SUCCESS", "2024041801514102000"),
    406                         amount = TalerAmount("EUR:2"),
    407                         subject = "TestABC123",
    408                         executionTime = dateToInstant("2024-04-18"),
    409                         creditor = ibanPayto("DE20500105172419259181", "John Smith")
    410                     ),
    411                     OutgoingReversal(
    412                         endToEndId = "KGTDBASWTJ6JM89WXD3Q5KFQC4",
    413                         reason = "Retoure aus SEPA Überweisung multi line",
    414                         executionTime = dateToInstant("2024-09-04")
    415                     ),
    416                     OutgoingBatch(
    417                         msgId = "BATCH_MANY_PART",
    418                         executionTime = dateToInstant("2024-09-04")
    419                     ),
    420                     IncomingPayment(
    421                         id = IncomingId(null, "BYLADEM1WOR-G2910276709458A2", "2024041210041357000"),
    422                         amount = TalerAmount("EUR:3"),
    423                         subject = "Taler FJDQ7W6G7NWX4H9M1MKA12090FRC9K7DA6N0FANDZZFXTR6QHX5G Test.,-",
    424                         executionTime = dateToInstant("2024-04-12"),
    425                         debtor = ibanPayto("DE84500105177118117964", "John Smith")
    426                     ),
    427                     OutgoingReversal(
    428                         endToEndId = "COMPAT_FAILURE",
    429                         reason = "IncorrectAccountNumber 'Format of the account number specified is not correct' - 'IBAN ...'",
    430                         executionTime = dateToInstant("2024-04-12")
    431                     ),
    432                     OutgoingPayment(
    433                         id = OutgoingId("BATCH_SINGLE_SUCCESS", "FD622SMXKT5QWSAHDY0H8NYG3G", "2024090216552232000"),
    434                         amount = TalerAmount("EUR:1.1"),
    435                         subject = "single 2024-09-02T14:29:52.875253314Z",
    436                         executionTime = dateToInstant("2024-09-02"),
    437                         creditor = ibanPayto("DE89500105173198527518", "Grothoff Hans")
    438                     ),
    439                     OutgoingPayment(
    440                         id = OutgoingId("YF5QBARGQ0MNY0VK59S477VDG4", "YF5QBARGQ0MNY0VK59S477VDG4", "2024041810552821000"),
    441                         amount = TalerAmount("EUR:1.1"),
    442                         subject = "Simple tx",
    443                         executionTime = dateToInstant("2024-04-18"),
    444                         creditor = ibanPayto("DE20500105172419259181", "John Smith")
    445                     ),
    446                 ))
    447             )
    448         )
    449     }
    450 
    451     @Test
    452     fun gls_camt054() {
    453         assertContentEquals(
    454             parseTx(Path("sample/platform/gls_camt054.xml").inputStream()),
    455             listOf(AccountTransactions(
    456                 iban = "DE84500105177118117964",
    457                 currency = "EUR",
    458                 txs = listOf<TxNotification>(
    459                     IncomingPayment(
    460                         id = IncomingId(null, "IS11PGENODEFF2DA8899900378806", null),
    461                         amount = TalerAmount("EUR:2.5"),
    462                         subject = "Test ICT",
    463                         executionTime = dateToInstant("2024-05-05"),
    464                         debtor = ibanPayto("DE84500105177118117964", "Mr Test")
    465                     )
    466                 )
    467             ))
    468         )
    469     }
    470 
    471     @Test
    472     fun maerki_baumann_camt053() {
    473         assertContentEquals(
    474             parseTx(Path("sample/platform/maerki_baumann_camt053.xml").inputStream()),
    475             listOf(AccountTransactions(
    476                 iban = "CH7389144832588726658",
    477                 currency = "CHF",
    478                 txs = listOf<TxNotification>(
    479                     IncomingPayment(
    480                         id = IncomingId("adbe4a5a-6cea-4263-b259-8ab964561a32", "41103099704.0002", "ZV20241104/765446/1"),
    481                         amount = TalerAmount("CHF:1"),
    482                         creditFee = TalerAmount("CHF:0.2"),
    483                         subject = "SFHP6H24C16A5J05Q3FJW2XN1PB3EK70ZPY 5SJ30ADGY68FWN68G",
    484                         executionTime = dateToInstant("2024-11-04"),
    485                         debtor = ibanPayto("CH7389144832588726658", "Mr Test")
    486                     ),
    487                     IncomingPayment(
    488                         id = IncomingId("7371795e-62fa-42dd-93b7-da89cc120faa", "41103099704.0003", "ZV20241104/765447/1"),
    489                         amount = TalerAmount("CHF:1"),
    490                         creditFee = TalerAmount("CHF:0.2"),
    491                         subject = "Random subject",
    492                         executionTime = dateToInstant("2024-11-04"),
    493                         debtor = ibanPayto("CH7389144832588726658", "Mr Test")
    494                     ),
    495                     IncomingPayment(
    496                         id = IncomingId(null, "50523424675.0001", "ZV20250523/851716/1"),
    497                         amount = TalerAmount("CHF:0.5"),
    498                         creditFee = TalerAmount("CHF:0.2"),
    499                         subject = null,
    500                         executionTime = dateToInstant("2025-05-23"),
    501                         debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans")
    502                     ),
    503                     OutgoingPayment(
    504                         id = OutgoingId("BATCH_SINGLE_REPORTING", "5IBJZOWESQGPCSOXSNNBBY49ZURI5W7Q4H", "ZV20241121/773541/1"),
    505                         amount = TalerAmount("CHF:0.1"),
    506                         subject = "multi 0 2024-11-21T15:21:59.8859234 63Z",
    507                         executionTime = dateToInstant("2024-11-27"),
    508                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans")
    509                     ),
    510                     OutgoingPayment(
    511                         id = OutgoingId("BATCH_SINGLE_REPORTING", "XZ15UR0XU52QWI7Q4XB88EDS44PLH7DYXH", "ZV20241121/773541/4"),
    512                         amount = TalerAmount("CHF:0.13"),
    513                         subject = "multi 3 2024-11-21T15:21:59.8859234 63Z",
    514                         executionTime = dateToInstant("2024-11-27"),
    515                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans")
    516                     ),
    517                     OutgoingPayment(
    518                         id = OutgoingId("BATCH_SINGLE_REPORTING", "A09R35EW0359SZ51464E7TC37A0P2CBK04", "ZV20241121/773541/3"),
    519                         amount = TalerAmount("CHF:0.12"),
    520                         subject = "multi 2 2024-11-21T15:21:59.8859234 63Z",
    521                         executionTime = dateToInstant("2024-11-27"),
    522                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans")
    523                     ),
    524                     OutgoingPayment(
    525                         id = OutgoingId("BATCH_SINGLE_REPORTING", "UYXZ78LE9KAIMBY6UNXFYT1K8KNY8VLZLT", "ZV20241121/773541/2"),
    526                         amount = TalerAmount("CHF:0.11"),
    527                         subject = "multi 1 2024-11-21T15:21:59.8859234 63Z",
    528                         executionTime = dateToInstant("2024-11-27"),
    529                         creditor = ibanPayto("CH7389144832588726658", "Grothoff Hans")
    530                     ),
    531                     IncomingPayment(
    532                         id = IncomingId("f203fbb4-6e13-4c78-9b2a-d852fea6374a", "41202060702.0001", "ZV20241202/778108/1"),
    533                         amount = TalerAmount("CHF:0.05"),
    534                         creditFee = TalerAmount("CHF:0.2"),
    535                         subject = "mini",
    536                         executionTime = dateToInstant("2024-12-02"),
    537                         debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans")
    538                     ),
    539                     IncomingPayment(
    540                         id = IncomingId("81b0d8c6-a677-4577-b75e-a639dcc03681", "41120636093.0001", "ZV20241121/773118/1"),
    541                         amount = TalerAmount("CHF:0.1"),
    542                         creditFee = TalerAmount("CHF:0.2"),
    543                         subject = "small transfer test",
    544                         executionTime = dateToInstant("2024-11-21"),
    545                         debtor = ibanPayto("CH7389144832588726658", "Grothoff Hans")
    546                     ),
    547                     OutgoingPayment(
    548                         id = OutgoingId(null, null, "GB20241220/205792/1"),
    549                         amount = TalerAmount("CHF:3000"),
    550                         subject = null,
    551                         executionTime = dateToInstant("2024-12-20"),
    552                         creditor = null
    553                     ),
    554                     IncomingPayment(
    555                         id = IncomingId(null, null, "ZV20250114/796191/1"),
    556                         amount = TalerAmount("CHF:3003"),
    557                         subject = "Fix bad payment by MB.",
    558                         executionTime = dateToInstant("2025-01-27"),
    559                         debtor = null
    560                     ),
    561                     IncomingPayment(
    562                         id = IncomingId(null, "F000787951230001", "ZV20250526/852733/1"),
    563                         amount = TalerAmount("CHF:1.38"),
    564                         creditFee = TalerAmount("CHF:0.2"),
    565                         subject = "Taler XT3D9MADR4V85JBWX47SMJFDQD2FDZDHHPH8R25YDG1KNVTSEH6G",
    566                         executionTime = dateToInstant("2025-05-26"),
    567                         debtor = ibanPayto("DE20500105172419259181", "Mr German")
    568                     ),
    569                 )
    570             ))
    571         )
    572     }
    573 
    574     @Test
    575     fun pain002() {
    576         assertEquals(
    577             parseCustomerPaymentStatusReport(Path("sample/platform/pain002_part.xml").inputStream()),
    578             MsgStatus(
    579                 id = "05BD4C5B4A2649B5B08F6EF6A31F197A",
    580                 code = ExternalPaymentGroupStatusCode.PART,
    581                 reasons = emptyList(),
    582                 payments = listOf(
    583                     PmtStatus(
    584                         id = "NOTPROVIDED",
    585                         code = ExternalPaymentGroupStatusCode.PART,
    586                         reasons = listOf(
    587                             Reason(
    588                                 code = ExternalStatusReasonCode.DT06,
    589                                 information = "Due date is not a working day. Order will be executed on the next working day"
    590                             )
    591                         ),
    592                         transactions = listOf(
    593                             TxStatus(
    594                                 id = "AQCXNCPWD8PHW5JTN65Y5XTF7R",
    595                                 endToEndId = "AQCXNCPWD8PHW5JTN65Y5XTF7R",
    596                                 code = ExternalPaymentTransactionStatusCode.RJCT, 
    597                                 reasons = listOf(
    598                                     Reason(
    599                                         code = ExternalStatusReasonCode.AC04, 
    600                                         information = "Error message"
    601                                     )
    602                                 )
    603                             ),
    604                             TxStatus(
    605                                 id = "EE9SX76FC5YSC657EK3GMVZ9TC",
    606                                 endToEndId = "EE9SX76FC5YSC657EK3GMVZ9TC",
    607                                 code = ExternalPaymentTransactionStatusCode.RJCT,
    608                                 reasons = listOf(
    609                                     Reason(
    610                                         code = ExternalStatusReasonCode.MS03,
    611                                         information = "Error message"
    612                                     )
    613                                 )
    614                             ),
    615                             TxStatus(
    616                                 id = "V5B3MXPEWES9VQW1JDRD6VAET4",
    617                                 endToEndId = "V5B3MXPEWES9VQW1JDRD6VAET4",
    618                                 code = ExternalPaymentTransactionStatusCode.RJCT,
    619                                 reasons = listOf(
    620                                     Reason(
    621                                         code = ExternalStatusReasonCode.RR02,
    622                                         information = "Error message"
    623                                     )
    624                                 )
    625                             )
    626                         )
    627                     )
    628                 )
    629             )
    630         )
    631         assertEquals(
    632             parseCustomerPaymentStatusReport(Path("sample/platform/pain002_accp.xml").inputStream()),
    633             MsgStatus(
    634                 id = "5HIS3433VVIBAANHW3GX9DR1AXRS43KZ4U",
    635                 code = ExternalPaymentGroupStatusCode.ACCP,
    636                 reasons = listOf(
    637                     Reason(
    638                         code = null,
    639                         information = "PN10630020F0297329.20251030104613.EBTUAAAC.PN1.0002372"
    640                     )
    641                 ),
    642                 payments = emptyList()
    643             )
    644         )
    645     }
    646 }