const { blockTypes, blockIdentifiers } = require('./types'); const IGNORE_GROUP_IN_BALANCE = '-'; function ignoreGroupInBalance(groupLine) { if (groupLine[0] !== blockIdentifiers.GROUP) { throw Error('Line is not a group: ' + groupLine); } return groupLine[1] === IGNORE_GROUP_IN_BALANCE; } module.exports.ignoreGroupInBalance = ignoreGroupInBalance; module.exports.readGroup = function readGroup(line) { const groupName = line.split(' ').slice(1).join(' '); const shouldIgnoreGroupInBalance = ignoreGroupInBalance(line); return { name: groupName, ignoreInBalance: shouldIgnoreGroupInBalance, records: [], total: 0, toString: () => `${blockIdentifiers.GROUP}${shouldIgnoreGroupInBalance ? IGNORE_GROUP_IN_BALANCE : ''} ${groupName}` }; };