diff --git a/src/index.ts b/src/index.ts index 82b1a90..348d1a2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -56,6 +56,7 @@ export interface Statement { closingAvailableBalance?: BalanceInfo; forwardAvailableBalance?: BalanceInfo; transactions: Transaction[]; + additionalInformation?: string; } export interface ReadOptions { diff --git a/src/tags/information-for-account-owner.ts b/src/tags/information-for-account-owner.ts index 42d6371..07c32b3 100644 --- a/src/tags/information-for-account-owner.ts +++ b/src/tags/information-for-account-owner.ts @@ -40,10 +40,22 @@ const informationTag: Tag = { } } - statement.transactions[state.transactionIndex].description = String.fromCharCode.apply( + var informationToAccountOwner = String.fromCharCode.apply( String, description ).trim(); + + var transactionHasDescription = statement.transactions[state.transactionIndex].description !== ''; + + // All :86: fields must be directly preceded by a transaction statement line (:61:), + // so if the current transaction already has a description, we may assume this is + // yet another :86: field, and therefore contains additional information about + // the statement as a whole rather than just about the transaction. + if (transactionHasDescription === false) { + statement.transactions[state.transactionIndex].description = informationToAccountOwner; + } else { + statement.additionalInformation = informationToAccountOwner; + } } }; diff --git a/test/cases/ing-1.json b/test/cases/ing-1.json index 49769fd..8fe495d 100644 --- a/test/cases/ing-1.json +++ b/test/cases/ing-1.json @@ -3,6 +3,7 @@ "referenceNumber": "INGEB", "accountId": "0111111111", "number": "100", + "additionalInformation": "D000001C000002D10000,99C11,01ING TESTREKENINGXXX", "openingBalance": { "isCredit": true, "date": "2010-07-22", diff --git a/test/cases/ing-1.mta b/test/cases/ing-1.mta index a5bb023..6cdaf4f 100644 --- a/test/cases/ing-1.mta +++ b/test/cases/ing-1.mta @@ -22,6 +22,6 @@ POSTEN :64:D100723EUR9945,09 :65:D100724EUR9945,09 :65:D100726EUR9945,09 -:86 :D000001C000002D10000,99C11,01 +:86:D000001C000002D10000,99C11,01 ING TESTREKENING XXX \ No newline at end of file