git ssb

0+

Rômulo Alves / money-block



Tree: 7cc4808dbfe9bd370a1f0df3485981c9a7b048e4

Files: 7cc4808dbfe9bd370a1f0df3485981c9a7b048e4 / src / domain / group.js

782 bytesRaw
1const { blockTypes, blockIdentifiers } = require('./types');
2
3const IGNORE_GROUP_IN_BALANCE = '-';
4
5function ignoreGroupInBalance(groupLine) {
6 if (groupLine[0] !== blockIdentifiers.GROUP) {
7 throw Error('Line is not a group: ' + groupLine);
8 }
9
10 return groupLine[1] === IGNORE_GROUP_IN_BALANCE;
11}
12module.exports.ignoreGroupInBalance = ignoreGroupInBalance;
13
14module.exports.readGroup = function readGroup(line) {
15 const groupName = line.split(' ').slice(1).join(' ');
16 const shouldIgnoreGroupInBalance = ignoreGroupInBalance(line);
17
18 return {
19 name: groupName,
20 ignoreInBalance: shouldIgnoreGroupInBalance,
21 records: [],
22 total: 0,
23 toString: () => `${blockIdentifiers.GROUP}${shouldIgnoreGroupInBalance ? IGNORE_GROUP_IN_BALANCE : ''} ${groupName}`
24 };
25};
26

Built with git-ssb-web