Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ach/ach

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ach/ach - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0-alpha

lib/record.js

8

lib/api/calculate.js

@@ -71,3 +71,3 @@ // Generated by CoffeeScript 1.10.0

serviceClassCode: batch.serviceClassCode,
originatingDFIIdentification: batch.originatingDFIIdentification
originId: batch.originId
};

@@ -77,3 +77,3 @@ ref = batch.entries;

entry = ref[j];
footer.entryHash += Number(entry.receivingDFIIdentification);
footer.entryHash += Number(entry.receivingId);
footer.entryAndAddendaCount += entry.addenda != null ? 2 : entry.addendas != null ? entry.addendas.length + 1 : 1;

@@ -99,5 +99,5 @@ switch (entry.transactionCode[1]) {

}
if (options.set && (((ref1 = options.seq) != null ? ref1.entry : void 0) != null) && (entry.traceNumber == null)) {
if (options.set && (((ref1 = options.seq) != null ? ref1.entry : void 0) != null)) {
sequence = ('0000000' + options.seq.entry).slice(-7);
entry.traceNumber = batch.originatingDFIIdentification + sequence;
entry.traceNumber = batch.originId + sequence;
}

@@ -104,0 +104,0 @@ if (options != null) {

@@ -35,3 +35,3 @@ // Generated by CoffeeScript 1.10.0

companyId: this.data.from.fein,
originatingDFIIdentification: this.data["for"].dfi,
originId: this.data["for"].dfi,
effectiveDate: toDate((ref1 = batchData.effectiveDate) != null ? ref1 : tomorrowDate()),

@@ -43,3 +43,3 @@ description: batchData.description,

companyId: this.data.from.fein,
originatingDFIIdentification: this.data["for"].dfi,
originId: this.data["for"].dfi,
num: ach.batches.length + 1,

@@ -46,0 +46,0 @@ entryAndAddendaCount: 0,

@@ -20,8 +20,8 @@ // Generated by CoffeeScript 1.10.0

recordType: '6',
receivingDFIIdentification: toCompany.dfi,
receivingId: toCompany.dfi,
checkDigit: toCompany.routing[8],
dfiAccount: toCompany.account.num,
targetAccount: toCompany.account.num,
amount: entryData.amount,
receivingCompanyName: toCompany.name,
addendaIndicator: entryData.addenda != null ? '1' : '0',
targetName: toCompany.name,
hasAddenda: entryData.addenda != null ? '1' : '0',
traceNumber: this.data["for"].dfi + ('000000' + this.data.entryCount).slice(-7)

@@ -65,4 +65,4 @@ };

}
batch.footer.entryHash += entry.receivingDFIIdentification;
ach.file.footer.entryHash += entry.receivingDFIIdentification;
batch.footer.entryHash += entry.receivingId;
ach.file.footer.entryHash += entry.receivingId;
if (whichKind === 'C') {

@@ -69,0 +69,0 @@ batch.footer.totalCredit += entry.amount;

// Generated by CoffeeScript 1.10.0
var Transform, ach, edit, path, to;
var Record, Transform, edit, path, to;

@@ -10,3 +10,3 @@ Transform = require('stream').Transform;

ach = require('../../lib');
Record = require('../../lib/record');

@@ -26,10 +26,11 @@ module.exports = edit = function(editorsArray) {

transform = new (require(editorTransform))({
ach: ach
Record: Record
});
} else if (editorTransform(instaceof(Transform))) {
transform = new editorTransform({
ach: ach
});
transform = new editorTransform;
} else if ((editorTransform.transform != null) && 'function' === typeof editorTransform.transform) {
transform = new Transform(editorTransform);
editorTransform.Record = Record;
transform = new Transform(editorTransform({
Record: Record
}));
}

@@ -36,0 +37,0 @@ this.streams.unshift(transform != null ? transform : editorTransform);

@@ -17,3 +17,3 @@ // Generated by CoffeeScript 1.10.0

module.exports = from = function(options) {
var From, errorProvider, source, transform;
var From, errorProvider, ref, source, transform;
if (options == null) {

@@ -47,3 +47,3 @@ options = {};

return errorProvider = {
error: 'invalid \'from\' format: ' + options.format,
error: 'invalid \'from\' format: ' + ((ref = options.format) != null ? ref : options),
edit: function() {

@@ -50,0 +50,0 @@ return this;

// Generated by CoffeeScript 1.10.0
var AchFormatter, formats, nines, outputFields, padNum, padString, spaces, zeroes,
var AchFormatter, calculate, formatters, nines, padNum, padString, spaces, zeroes,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
formats = require('./formats');
formatters = require('./formatters');
calculate = require('../api/calculate');
zeroes = '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';

@@ -43,16 +45,2 @@

outputFields = function(source, format, push) {
var field, i, j, len, pad, ref, value;
i = 0;
ref = format.fields;
for (j = 0, len = ref.length; j < len; j++) {
field = ref[j];
value = source[field.name];
pad = field.numeric ? padNum : padString;
value = pad(value, field.length);
push(value);
}
return push('\n');
};
module.exports = AchFormatter = (function(superClass) {

@@ -66,35 +54,12 @@ extend(AchFormatter, superClass);

});
this.on('error', console.log.bind(console));
}
AchFormatter.prototype._transform = function(ach, _, done) {
var addenda, batch, entry, format, i, j, k, l, len, len1, len2, linesNeeded, m, push, ref, ref1, ref2, ref3;
push = this.push.bind(this);
outputFields(ach.file, formats.fileHeader, push);
ref = ach.batches;
for (j = 0, len = ref.length; j < len; j++) {
batch = ref[j];
outputFields(batch, formats.batchHeader, push);
format = formats[batch.entryClassCode];
ref1 = batch.entries;
for (k = 0, len1 = ref1.length; k < len1; k++) {
entry = ref1[k];
outputFields(entry, format.entry, push);
if (entry.addenda != null) {
outputFields(entry.addenda, format.addenda, push);
} else if (entry.addendas != null) {
ref2 = entry.addendas;
for (l = 0, len2 = ref2.length; l < len2; l++) {
addenda = ref2[l];
outputFields(addenda(format.addenda, push));
}
}
AchFormatter.prototype._transform = function(records, _, done) {
var i, len, name, record;
for (i = 0, len = records.length; i < len; i++) {
record = records[i];
if (typeof formatters[name = record.type] === "function") {
formatters[name](record, this);
}
outputFields(batch.footer, formats.batchFooter, push);
}
outputFields(ach.file.footer, formats.fileFooter, push);
linesNeeded = 10 - (ach.file.footer.lineCount % 10);
for (i = m = 1, ref3 = linesNeeded; 1 <= ref3 ? m <= ref3 : m >= ref3; i = 1 <= ref3 ? ++m : --m) {
this.push(nines);
}
return done();

@@ -101,0 +66,0 @@ };

// Generated by CoffeeScript 1.10.0
var AchParser, EachPart, insertTransform, lineParsers,
var AchParser, lineParsers,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
EachPart = require('each-part').EachPart;
lineParsers = require('./line-parsers');
insertTransform = function(source) {
var eacher;
if (source instanceof EachPart) {
return;
}
source.unpipe(this);
eacher = new EachPart({
delim: '\n'
});
return source.pipe(eacher).pipe(this);
};
module.exports = AchParser = (function(superClass) {

@@ -27,23 +13,79 @@ extend(AchParser, superClass);

AchParser.__super__.constructor.call(this, {
objectMode: true
readableObjectMode: true,
writableObjectMode: false
});
this.on('pipe', insertTransform.bind(this));
this.ach = {};
this.pending = '';
}
AchParser.prototype._transform = function(data, encoding, done) {
var line, name;
line = data.string;
if (line.length === 0 || (line[0] === '9' && line[1] === '9')) {
return done();
AchParser.prototype._findStart = function(first) {
if (first == null) {
first = 0;
}
if (lineParsers != null) {
if (typeof lineParsers[name = line[0]] === "function") {
lineParsers[name](line, this.ach);
while (first < this.pending.length) {
switch (this.pending[first]) {
case '1':
case '5':
case '6':
case '7':
case '8':
case '9':
return first;
case '\n':
case '\r':
first++;
}
while (this.pending[first] !== '\n' && first < this.pending.length) {
first++;
}
}
if (line[0] === '9' && (this.ach != null)) {
this.push(this.ach);
this.ach = {};
return this.pending.length;
};
AchParser.prototype._findEnd = function(start) {
var end;
switch (this.pending[start + 94]) {
case '\n':
return start + 94;
case '\r':
if (this.pending[start + 95] === '\n') {
return start + 95;
} else {
}
break;
default:
end = start + 93;
while (this.pending[end] !== '\n' && end > start) {
end--;
}
if (end !== start) {
return end;
} else {
end = start + 95;
while (this.pending[end] !== '\n' && end < this.pending.length) {
end++;
}
return end;
}
}
};
AchParser.prototype._transform = function(data, encoding, done) {
var end, line, name, record, records, ref, start;
this.pending += data.toString('utf8');
records = [];
start = this._findStart(0);
while ((this.pending.length - start) >= 95) {
end = this._findEnd(start);
line = (end - start) >= 94 ? this.pending : this.pending.slice(start, end);
record = lineParsers != null ? typeof lineParsers[name = line[start]] === "function" ? lineParsers[name](line, start, this) : void 0 : void 0;
if (record != null) {
records.push(record);
}
start = this._findStart(end + 1);
}
this.pending = (ref = this.pending.slice(start)) != null ? ref : '';
if (records.length > 0) {
this.push(records);
}
return done();

@@ -50,0 +92,0 @@ };

@@ -164,3 +164,3 @@ // Generated by CoffeeScript 1.10.0

}, {
name: 'originatingDFIIdentification',
name: 'originId',
length: 8,

@@ -217,3 +217,3 @@ validate: aba

}, {
name: 'originatingDFIIdentification',
name: 'originId',
length: 8,

@@ -241,3 +241,3 @@ validate: aba

}, {
name: 'receivingDFIIdentification',
name: 'receivingId',
length: 8,

@@ -251,3 +251,3 @@ numeric: true,

}, {
name: 'dfiAccount',
name: 'targetAccount',
length: 17,

@@ -260,3 +260,3 @@ pattern: alphanumeric

}, {
name: 'identificationNumber',
name: 'idNum',
length: 15,

@@ -266,3 +266,3 @@ pattern: alphanumeric,

}, {
name: 'receivingCompanyName',
name: 'targetName',
length: 22,

@@ -276,3 +276,3 @@ pattern: alphanumeric

}, {
name: 'addendaIndicator',
name: 'hasAddenda',
length: 1,

@@ -331,3 +331,3 @@ pattern: /0|1/

}, {
name: 'receivingDFIIdentification',
name: 'receivingId',
length: 8,

@@ -340,3 +340,3 @@ validate: aba

}, {
name: 'dfiAccount',
name: 'targetAccount',
length: 17,

@@ -349,3 +349,3 @@ pattern: alphanumeric

}, {
name: 'identificationNumber',
name: 'idNum',
length: 15,

@@ -359,3 +359,3 @@ pattern: alphanumeric

}, {
name: 'receivingCompanyName',
name: 'targetName',
length: 16,

@@ -372,3 +372,3 @@ pattern: alphanumeric

}, {
name: 'addendaIndicator',
name: 'hasAddenda',
length: 1,

@@ -375,0 +375,0 @@ pattern: /0|1/

// Generated by CoffeeScript 1.10.0
var getTransform, setTransform, transforms;
var getTransform, path, setTransform, transforms;
path = require('path');
transforms = {

@@ -11,3 +13,4 @@ parsers: {

ach: require('./ach-formatter'),
json: require('./json-formatter')
json: require('./json-formatter'),
en: require('./english-formatter')
}

@@ -17,3 +20,3 @@ };

getTransform = function(format, which) {
var error, error1, otherModule, ref, ref1, transform;
var error, error1, error2, modulePath, otherModule, ref, ref1, ref2, transform;
if (!((format != null) && (which != null))) {

@@ -24,5 +27,3 @@ return;

transform = transforms != null ? (ref = transforms[which]) != null ? ref[format] : void 0 : void 0;
if (transform != null) {
return new transform;
} else {
if (transform == null) {
try {

@@ -38,3 +39,19 @@ otherModule = require('@ach/' + format);

}
try {
modulePath = path.join(__dirname, '..', '..', '..', format + '/');
otherModule = require(modulePath);
transform = otherModule != null ? (ref2 = otherModule[which]) != null ? ref2[format] : void 0 : void 0;
if (transform != null) {
transforms[which][format] = transform;
return new transform;
} else {
}
} catch (error2) {
error = error2;
}
}
if (transform != null) {
return new transform;
}
};

@@ -41,0 +58,0 @@

@@ -16,3 +16,3 @@ // Generated by CoffeeScript 1.10.0

JsonFormatter.prototype._transform = function(data, encoding, done) {
JsonFormatter.prototype._transform = function(record, encoding, done) {
return done(null, JSON.stringify(data, null, 2));

@@ -19,0 +19,0 @@ };

// Generated by CoffeeScript 1.10.0
var extractFields, formats, noop;
var Record, noop;
formats = require('./formats');
Record = require('../record');
extractFields = function(line, format, target) {
var end, field, i, j, len, ref, results, value;
i = 0;
ref = format.fields;
results = [];
for (j = 0, len = ref.length; j < len; j++) {
field = ref[j];
end = i + field.length;
value = line.slice(i, end);
if (field.trim !== false) {
value = value.trim();
}
i = end;
if (field.numeric) {
value = Number(value);
}
results.push(target[field.name] = value);
}
return results;
};
noop = function() {};
module.exports = {
1: function(line, ach) {
ach.file = {};
ach.batches = [];
extractFields(line, formats.fileHeader, ach.file);
},
5: function(line, ach) {
var batch;
batch = {
entries: []
};
if (ach.batches == null) {
ach.batches = [];
1: function(line, start) {
var record, ref, ref1;
record = new Record({
values: {
type: '1',
priority: line.slice(start + 1, +(start + 2) + 1 || 9e9),
destination: line.slice(start + 3, +(start + 12) + 1 || 9e9).trim(),
origin: line.slice(start + 13, +(start + 22) + 1 || 9e9).trim(),
creationDate: line.slice(start + 23, +(start + 28) + 1 || 9e9),
creationTime: line.slice(start + 29, +(start + 32) + 1 || 9e9),
idModifier: line[start + 33],
recordSize: line.slice(start + 34, +(start + 36) + 1 || 9e9),
blockingFactor: line.slice(start + 37, +(start + 38) + 1 || 9e9),
formatCode: line[start + 39],
destinationName: line.slice(start + 40, +(start + 62) + 1 || 9e9).trim(),
originName: line.slice(start + 63, +(start + 85) + 1 || 9e9).trim(),
referenceCode: line.slice(start + 86, start + 94).trim()
}
});
if (((ref = record.destination) != null ? ref.length : void 0) === 9) {
record.destination = ' ' + record.destination;
}
ach.batches.push(batch);
extractFields(line, formats.batchHeader, batch);
},
6: function(line, ach) {
var batch, entry;
batch = ach.batches[ach.batches.length - 1];
entry = {};
if (batch.entries == null) {
batch.entries = [];
if (((ref1 = record.origin) != null ? ref1.length : void 0) === 9) {
record.origin = ' ' + record.origin;
}
batch.entries.push(entry);
extractFields(line, formats[batch.entryClassCode].entry, entry);
return record;
},
7: function(line, ach) {
var addenda, batch, entry;
batch = ach.batches[ach.batches.length - 1];
entry = batch.entries[batch.entries.length - 1];
addenda = {};
if (batch.entryClassCode === 'CTX') {
if (entry.addendas == null) {
entry.addendas = [];
5: function(line, start, hold) {
var type;
hold.batchType = type = line.slice(start + 50, +(start + 52) + 1 || 9e9);
return new Record({
values: {
type: '5',
serviceClassCode: line.slice(start + 1, +(start + 3) + 1 || 9e9),
sourceName: line.slice(start + 4, +(start + 19) + 1 || 9e9).trim(),
note: line.slice(start + 20, +(start + 39) + 1 || 9e9).trim(),
sourceId: line.slice(start + 40, +(start + 49) + 1 || 9e9),
batchType: type,
description: line.slice(start + 53, +(start + 62) + 1 || 9e9).trim(),
date: line.slice(start + 63, +(start + 68) + 1 || 9e9),
effectiveDate: line.slice(start + 69, +(start + 74) + 1 || 9e9),
settlementDate: line.slice(start + 75, +(start + 77) + 1 || 9e9),
statusCode: line[start + 78],
originId: line.slice(start + 79, +(start + 86) + 1 || 9e9),
num: line.slice(start + 87, start + 94)
}
entry.addendas.push(addenda);
});
},
6: function(line, start, hold) {
var record;
record = new Record({
values: {
type: '6',
transactionCode: line.slice(start + 1, +(start + 2) + 1 || 9e9),
receiverId: line.slice(start + 3, +(start + 10) + 1 || 9e9),
checkDigit: line[start + 11],
targetAccount: line.slice(start + 12, +(start + 28) + 1 || 9e9).trim(),
amount: line.slice(start + 29, +(start + 38) + 1 || 9e9),
idNum: line.slice(start + 39, +(start + 53) + 1 || 9e9).trim(),
note: line.slice(start + 76, +(start + 77) + 1 || 9e9).trim(),
hasAddenda: line[start + 78],
traceNumber: line.slice(start + 79, start + 94)
}
});
if (hold.batchType === 'CTX') {
record.addendaCount = line.slice(start + 54, +(start + 57) + 1 || 9e9);
record.targetName = line.slice(start + 58, +(start + 73) + 1 || 9e9).trim();
record.reserved = line.slice(start + 74, +(start + 75) + 1 || 9e9);
} else {
entry.addenda = addenda;
record.targetName = line.slice(start + 54, +(start + 75) + 1 || 9e9).trim();
}
extractFields(line, formats[batch.entryClassCode].addenda, addenda);
return record;
},
8: function(line, ach) {
var batch;
batch = ach.batches[ach.batches.length - 1];
batch.footer = {};
extractFields(line, formats.batchFooter, batch.footer);
7: function(line, start) {
return new Record({
values: {
type: '7',
addendaType: line.slice(start + 1, +(start + 2) + 1 || 9e9),
info: line.slice(start + 3, +(start + 82) + 1 || 9e9),
num: line.slice(start + 83, +(start + 86) + 1 || 9e9),
entryNum: line.slice(start + 87, start + 94)
}
});
},
9: function(line, ach) {
if ((line != null ? line[1] : void 0) === '9') {
return;
8: function(line, start) {
return new Record({
values: {
type: '8',
serviceClassCode: line.slice(start + 1, +(start + 3) + 1 || 9e9),
entryAndAddendaCount: line.slice(start + 4, +(start + 9) + 1 || 9e9),
hash: line.slice(start + 10, +(start + 19) + 1 || 9e9),
totalDebit: line.slice(start + 20, +(start + 31) + 1 || 9e9),
totalCredit: line.slice(start + 32, +(start + 43) + 1 || 9e9),
sourceId: line.slice(start + 44, +(start + 53) + 1 || 9e9),
messageAuthenticationCode: line.slice(start + 54, +(start + 72) + 1 || 9e9),
reserved: line.slice(start + 73, +(start + 78) + 1 || 9e9),
originId: line.slice(start + 79, +(start + 86) + 1 || 9e9),
num: line.slice(start + 87, start + 94)
}
});
},
9: function(line, start) {
if ((line != null ? line[start + 1] : void 0) !== '9') {
return new Record({
values: {
type: '9',
batchCount: line.slice(start + 1, +(start + 6) + 1 || 9e9),
blockCount: line.slice(start + 7, +(start + 12) + 1 || 9e9),
entryAndAddendaCount: line.slice(start + 13, +(start + 20) + 1 || 9e9),
hash: line.slice(start + 21, +(start + 30) + 1 || 9e9),
totalDebit: line.slice(start + 31, +(start + 42) + 1 || 9e9),
totalCredit: line.slice(start + 43, +(start + 54) + 1 || 9e9),
reserved: line.slice(start + 55, start + 94)
}
});
}
ach.file.footer = {};
extractFields(line, formats.fileFooter, ach.file.footer);
},

@@ -84,0 +126,0 @@ ' ': noop,

{
"name": "@ach/ach",
"version": "1.0.3",
"version": "2.0.0-alpha",
"description": "NACHA ACH EFT File Parser/Editor/Formatter for CCD+ / PPD+ / CTX+",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc