From 2960a89ddf93a9f9f70703ae72fdeb2903884855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Dillk=C3=B6tter?= Date: Sun, 23 Jul 2017 18:35:51 +0200 Subject: [PATCH 1/5] Compatibility fix for more providers --- lib/Classes.js | 2 +- lib/FinTSClient.js | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/Classes.js b/lib/Classes.js index ba91245..35b2129 100644 --- a/lib/Classes.js +++ b/lib/Classes.js @@ -57,7 +57,7 @@ var ByteVal = function (ddd) { var Helper = new function () { this.checkMsgsWithBelongToForId = function (msg, bez, id) { - var array = msg.selectSegByNameAndBelongTo('HIRMS', bez) + var array = msg.selectSegByName('HIRMS') if (array.length > 0) { for (var i = 0; i != array.length; i++) { for (var a = 0; a != array[i].store.data.length; a++) { diff --git a/lib/FinTSClient.js b/lib/FinTSClient.js index 0599d14..4555116 100644 --- a/lib/FinTSClient.js +++ b/lib/FinTSClient.js @@ -419,7 +419,7 @@ var FinTSClient = function (in_blz, in_kunden_id, in_pin, in_bankenlist, logger) try { HIRMG = recvMsg.selectSegByName('HIRMG')[0] } catch (e) {}; - if (HIRMG != null && (HIRMG.getEl(1).getEl(1) == '0010' || HIRMG.getEl(1).getEl(1) == '3060')) { + if (HIRMG != null && (HIRMG.getEl(1).getEl(1) == '0010' || HIRMG.getEl(1).getEl(1) == '3060' || HIRMG.getEl(2).getEl(1) == '3060')) { if (Helper.checkMsgsWithBelongToForId(recvMsg, HKVVB.nr, '0020')) { try { // 1. Dialog ID zuweisen @@ -454,19 +454,21 @@ var FinTSClient = function (in_blz, in_kunden_id, in_pin, in_bankenlist, logger) if (me.konten.length == 0) { var konto_list = recvMsg.selectSegByName('HIUPD') for (var i = 0; i != konto_list.length; i++) { - var konto = new Konto() - konto.iban = konto_list[i].getEl(2) - konto.konto_nr = konto_list[i].getEl(1).getEl(1) - konto.unter_konto = konto_list[i].getEl(1).getEl(2) - konto.ctry_code = konto_list[i].getEl(1).getEl(3) - konto.blz = konto_list[i].getEl(1).getEl(4) - konto.kunden_id = konto_list[i].getEl(3) - konto.kontoar = konto_list[i].getEl(4) - konto.currency = konto_list[i].getEl(5) - konto.kunde1_name = konto_list[i].getEl(6) - konto.product_name = konto_list[i].getEl(8) - konto.sepa_data = null - me.konten.push(konto) + if(konto_list[i].getEl(2)){ + var konto = new Konto() + konto.iban = konto_list[i].getEl(2) + konto.konto_nr = konto_list[i].getEl(1).getEl(1) + konto.unter_konto = konto_list[i].getEl(1).getEl(2) + konto.ctry_code = konto_list[i].getEl(1).getEl(3) + konto.blz = konto_list[i].getEl(1).getEl(4) + konto.kunden_id = konto_list[i].getEl(3) + konto.kontoar = konto_list[i].getEl(4) + konto.currency = konto_list[i].getEl(5) + konto.kunde1_name = konto_list[i].getEl(6) + konto.product_name = konto_list[i].getEl(8) + konto.sepa_data = null + me.konten.push(konto) + } } } // 5. Analysiere BPD From f7f0466ec2497be81292e1a6008a8c9eb961aea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Dillk=C3=B6tter?= Date: Sun, 23 Jul 2017 23:25:36 +0200 Subject: [PATCH 2/5] Cleanup checkMsgsWithBelongToForId function --- lib/Classes.js | 2 +- lib/FinTSClient.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Classes.js b/lib/Classes.js index 35b2129..7bfcc46 100644 --- a/lib/Classes.js +++ b/lib/Classes.js @@ -56,7 +56,7 @@ var ByteVal = function (ddd) { } var Helper = new function () { - this.checkMsgsWithBelongToForId = function (msg, bez, id) { + this.checkMsgsWithBelongToForId = function (msg, id) { var array = msg.selectSegByName('HIRMS') if (array.length > 0) { for (var i = 0; i != array.length; i++) { diff --git a/lib/FinTSClient.js b/lib/FinTSClient.js index 4555116..2030621 100644 --- a/lib/FinTSClient.js +++ b/lib/FinTSClient.js @@ -420,7 +420,7 @@ var FinTSClient = function (in_blz, in_kunden_id, in_pin, in_bankenlist, logger) HIRMG = recvMsg.selectSegByName('HIRMG')[0] } catch (e) {}; if (HIRMG != null && (HIRMG.getEl(1).getEl(1) == '0010' || HIRMG.getEl(1).getEl(1) == '3060' || HIRMG.getEl(2).getEl(1) == '3060')) { - if (Helper.checkMsgsWithBelongToForId(recvMsg, HKVVB.nr, '0020')) { + if (Helper.checkMsgsWithBelongToForId(recvMsg, '0020')) { try { // 1. Dialog ID zuweisen me.dialog_id = recvMsg.selectSegByName('HNHBK')[0].getEl(3) From 3c59171af3c10c02142271be91a69686a898a30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Dillk=C3=B6tter?= Date: Sat, 29 Jul 2017 12:24:54 +0200 Subject: [PATCH 3/5] Error handeling --- lib/FinTSClient.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/FinTSClient.js b/lib/FinTSClient.js index 2030621..d7b3b9d 100644 --- a/lib/FinTSClient.js +++ b/lib/FinTSClient.js @@ -414,6 +414,25 @@ var FinTSClient = function (in_blz, in_kunden_id, in_pin, in_bankenlist, logger) }, 'Unhandled callback Error in HKVVB,HKIDN') } } else { + //Auf fehlerprüfen + + var errorToManyLogin = Helper.checkMsgsWithBelongToForId(recvMsg, '3931') + if (errorToManyLogin) { + console.log("Login Error") + cb(errorToManyLogin.getEl(3), recvMsg, false) + return + + } + var errorpw = Helper.checkMsgsWithBelongToForId(recvMsg, '9942') + if (errorpw) { + console.log("Pw Error") + cb(errorpw.getEl(3), recvMsg, false) + return + + } + + + // Prüfen ob Erfolgreich var HIRMG = null try { @@ -421,6 +440,9 @@ var FinTSClient = function (in_blz, in_kunden_id, in_pin, in_bankenlist, logger) } catch (e) {}; if (HIRMG != null && (HIRMG.getEl(1).getEl(1) == '0010' || HIRMG.getEl(1).getEl(1) == '3060' || HIRMG.getEl(2).getEl(1) == '3060')) { if (Helper.checkMsgsWithBelongToForId(recvMsg, '0020')) { + + + try { // 1. Dialog ID zuweisen me.dialog_id = recvMsg.selectSegByName('HNHBK')[0].getEl(3) @@ -484,6 +506,8 @@ var FinTSClient = function (in_blz, in_kunden_id, in_pin, in_bankenlist, logger) me.log.gv.error(ee, { gv: 'HIBPA' }, 'Error while analyse BPD') + cb("Wrong password") + return } if (me.proto_version == 300) { try { @@ -1090,6 +1114,7 @@ var FinTSClient = function (in_blz, in_kunden_id, in_pin, in_bankenlist, logger) // 3. Abschließende Verbindung aufbauen var perform_step = function (step) { me.MsgInitDialog(function (error, recvMsg, has_neu_url) { + console.log(error) if (error) { me.MsgCheckAndEndDialog(recvMsg, function (error2, recvMsg2) { if (error2) { From 75f0173d292042525bff8b2d9a411badca7b0704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Dillk=C3=B6tter?= Date: Sun, 27 Aug 2017 13:14:37 +0200 Subject: [PATCH 4/5] Bugfix Date --- lib/Classes.js | 1 + lib/FinTSClient.js | 1 + lib/MTParser.js | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Classes.js b/lib/Classes.js index 7bfcc46..e1566a9 100644 --- a/lib/Classes.js +++ b/lib/Classes.js @@ -864,6 +864,7 @@ var Order = function (client) { } } if (act_vers == 0) { + console.log("Angefragte Aktion nicht erlaubt") me_order.error = new Exceptions.GVNotSupportedByKI(in_data.ki_type, client.bpd.gv_parameters[in_data.ki_type]) return false } diff --git a/lib/FinTSClient.js b/lib/FinTSClient.js index d7b3b9d..e4cbc0f 100644 --- a/lib/FinTSClient.js +++ b/lib/FinTSClient.js @@ -954,6 +954,7 @@ var FinTSClient = function (in_blz, in_kunden_id, in_pin, in_bankenlist, logger) 5: recv } }) + req_umsaetze.done(function (error, order, recvMsg) { if (error && !processed) { me.log.gv.error(error, { diff --git a/lib/MTParser.js b/lib/MTParser.js index 57dbed0..0dd1fd8 100644 --- a/lib/MTParser.js +++ b/lib/MTParser.js @@ -159,6 +159,7 @@ module.exports = function () { satz.datum = me.convertMTDateFormatToJS(msg[a][1].substr(0, 6)) if ('0123456789'.indexOf(msg[a][1][6]) != -1) { // optionales feld Buchungstag + satz.buchungsdatum = me.convertMTDateFormatToJS(msg[a][1].substr(0, 2) + msg[a][1].substr(6, 4) ) pos = 10 } else { pos = 6 @@ -173,6 +174,7 @@ module.exports = function () { pos++ if ('0123456789'.indexOf(msg[a][1][pos]) == -1) { // optionales feld Währungsunterscheidung + pos++ } else { @@ -263,7 +265,6 @@ module.exports = function () { var dtYear = parseInt('20' + date.substr(0, 2), 10) var dtMonth = parseInt(date.substr(2, 2), 10) - 1 var dtDate = parseInt(date.substr(4, 2), 10) - - return new Date(dtYear, dtMonth, dtDate) + return new Date(dtYear, dtMonth, dtDate+1) } } From 4237e323b5dea987df182be9533d75065437d0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Dillk=C3=B6tter?= Date: Sun, 27 Aug 2017 21:16:07 +0200 Subject: [PATCH 5/5] Fixed date error --- lib/MTParser.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/MTParser.js b/lib/MTParser.js index 0dd1fd8..63fe6da 100644 --- a/lib/MTParser.js +++ b/lib/MTParser.js @@ -162,6 +162,7 @@ module.exports = function () { satz.buchungsdatum = me.convertMTDateFormatToJS(msg[a][1].substr(0, 2) + msg[a][1].substr(6, 4) ) pos = 10 } else { + satz.buchungsdatum = me.convertMTDateFormatToJS(msg[a][1].substr(0, 6)) pos = 6 } if (msg[a][1][pos] == 'R') { @@ -265,6 +266,6 @@ module.exports = function () { var dtYear = parseInt('20' + date.substr(0, 2), 10) var dtMonth = parseInt(date.substr(2, 2), 10) - 1 var dtDate = parseInt(date.substr(4, 2), 10) - return new Date(dtYear, dtMonth, dtDate+1) + return new Date(dtYear, dtMonth, dtDate, 12) } }