From 25f518e9a7c52aaebf36b99cd80453bb04dc8ac8 Mon Sep 17 00:00:00 2001 From: Raphael Moutard Date: Sat, 21 Mar 2020 11:57:59 +0100 Subject: [PATCH 1/2] move to typescript --- lib/{sepa.js => sepa.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/{sepa.js => sepa.ts} (100%) diff --git a/lib/sepa.js b/lib/sepa.ts similarity index 100% rename from lib/sepa.js rename to lib/sepa.ts From afc7dbec17591988a1d90d2a10e47063cf333a37 Mon Sep 17 00:00:00 2001 From: Raphael Moutard Date: Sat, 21 Mar 2020 12:01:15 +0100 Subject: [PATCH 2/2] refactor and introduce error --- lib/sepa.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sepa.ts b/lib/sepa.ts index a2ebc94..b095618 100644 --- a/lib/sepa.ts +++ b/lib/sepa.ts @@ -62,8 +62,9 @@ } function getPainXMLVersion(painFormat) { + // 008 is the version by default. var inc = painFormat.indexOf('pain.008') === 0 ? 1 : 0; - return parseInt(painFormat.substr(-2), 10) + inc; + return parseInt(painFormat.substr(2), 10) + inc; } function SepaDocument(painFormat, options) {