Comparing version 0.0.16 to 0.1.0
@@ -70,6 +70,5 @@ "use strict"; | ||
function parseTito(txt) { | ||
var headerInfo, | ||
entries = [], | ||
balances = [], | ||
summaries = []; | ||
var titos = [] | ||
, currentEntry; | ||
txt.split("\n").forEach(function(line) { | ||
@@ -84,4 +83,6 @@ line = line.replace(/\}/g, 'å') | ||
if (basicInfoRe.test(line)) { | ||
currentEntry = { entries: [], balances: [], transactionSummaries: [] } | ||
titos.push(currentEntry); | ||
m = XRegExp.exec(line, basicInfoRe); | ||
headerInfo = { | ||
currentEntry.header = { | ||
accountName: m.accountName.trim(), | ||
@@ -106,3 +107,3 @@ accountOwnerName: m.accountOwnerName.trim(), | ||
m = XRegExp.exec(line, entryInfoRe); | ||
entries.push({ | ||
currentEntry.entries.push({ | ||
additionalInformation: [], | ||
@@ -122,3 +123,3 @@ amount: Number(m.amount) / 100 * (m.sign === '-' ? -1 : 1), | ||
m = XRegExp.exec(line, additionalEntryInfoRe); | ||
var entry = entries[entries.length - 1]; | ||
var entry = currentEntry.entries[currentEntry.entries.length - 1]; | ||
if (['00', '07', '06', '08'].indexOf(m.infoType) !== -1 ) { | ||
@@ -133,3 +134,3 @@ var totalLength = Number(m.infoLength), parts = []; | ||
m = XRegExp.exec(line, balanceRe); | ||
balances.push({ | ||
currentEntry.balances.push({ | ||
bookingDate: stringToDateString(m.bookingDate), | ||
@@ -141,3 +142,3 @@ amount: Number(m.amount) / 100 * (m.amountSign === '-' ? -1 : 1), | ||
m = XRegExp.exec(line, summaryRe); | ||
summaries.push({ | ||
currentEntry.transactionSummaries.push({ | ||
depositAmount: Number(m.depositAmount) / 100 * (m.depositAmountSign === '-' ? -1 : 1), | ||
@@ -152,8 +153,3 @@ depositCount: Number(m.depositCount), | ||
}); | ||
return { | ||
header: headerInfo, | ||
entries: entries, | ||
balances: balances, | ||
transactionSummaries: summaries | ||
}; | ||
return titos; | ||
} | ||
@@ -160,0 +156,0 @@ |
{ | ||
"name": "corporate", | ||
"version": "0.0.16", | ||
"version": "0.1.0", | ||
"description": "A module for parsing (mostly) ISO20022 messages", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
165489
699