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

sp-nacha

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sp-nacha - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

lib/entry-addenda/fieldsWithTraceNumber.js

53

lib/entry-addenda/index.js

@@ -9,7 +9,54 @@ // Entry

function EntryAddenda(options) {
function EntryAddenda(options, standardEntryClassCode) {
// Allow the file header defaults to be overriden if provided
// Allow the file header defaults to be override if provided
this.fields = options.fields ? _.merge(options.fields, require('./fields'), _.defaults) : _.cloneDeep(require('./fields'));
if (['MTE', 'POS', 'SHR', 'IAT'].indexOf(standardEntryClassCode) !== -1 && ['17', '18'].indexOf(options.addendaTypeCode) === -1) {
this.fields = _.merge(options.fields, require('./fieldsWithTraceNumber'), _.defaults)
if (standardEntryClassCode === 'IAT') {
let reservedWith;
let paymentRelatedInfoWidth
switch (options.addendaTypeCode) {
case '10':
reservedWith = 6;
paymentRelatedInfoWidth = 78
break;
case '13':
reservedWith = 10;
paymentRelatedInfoWidth = 74
break;
case '14':
reservedWith = 10;
paymentRelatedInfoWidth = 74
break;
case '15':
reservedWith = 34;
paymentRelatedInfoWidth = 50
break;
default:
reservedWith = 14;
paymentRelatedInfoWidth = 70
break;
}
this.fields.paymentRelatedInformation.width = paymentRelatedInfoWidth;
this.fields.reserved = {
name: 'Reserved',
width: reservedWith,
position: 4,
required: false,
type: 'alphanumeric',
value: '',
blank: true
}
this.fields.entryDetailSequenceNumber = {
name: 'Entry Detail Sequence Number',
width: 7,
position: 5,
required: false,
type: 'numeric',
value: ''
}
delete this.fields.traceNumber
}
}
// Set our high-level values

@@ -16,0 +63,0 @@ utils.overrideLowLevel(highLevelOverrides, options, this);

2

package.json
{
"name": "sp-nacha",
"description": "NACHA file format is a set of instructions that, when uploaded into a bank portal, successfully initiates a batch of ACH payments. NACHA file format is the protocol for structuring those instructions in a way that successfully initiates the payments. NACHA is a highly customizable Node.js module exposing a high & low-level API for generating ACH files for use within the ACH network.",
"version": "1.1.6",
"version": "1.1.7",
"keywords": [

@@ -6,0 +6,0 @@ "Seerportal Nacha",

@@ -154,2 +154,61 @@ let chai = require('chai')

})
let MTERecords = [{
"id": 20514,
"standardEntryClassCode": "MTE",
"immediateDestination": "011002725",
"immediateOrigin": "121042882",
"immediateDestinationName": "BERKSHIRE BANK",
"immediateOriginName": "WELLS FARGO BANK NA",
"referenceCode": " ",
"batchChildren": [{
"id": 20514,
"companyName": "Compan NamePRDEE",
"companyIdentification": "1022337788",
"serviceClassCode": "200",
"standardEntryClassCode": "MTE",
"companyDiscretionaryData": "NA",
"companyEntryDescription": "Accounting",
"companyDescriptiveDate": "",
"effectiveEntryDate": Moment().toDate(),
"originatingDFI": "121042882",
"entryChildren": [{
"id": 20514,
"transactionCode": "27",
"receivingDFI": "011002725",
"DFIAccount": "12345678",
"amount": "1000",
"idNumber": "ICICI Bank ",
"individualName": "45678654 ",
"discretionaryData": "21",
"transactionType": "Debit",
"addendaRecords": [{
"id": 204,
"queued_transaction_id": 20514,
"addenda_type_code": "02",
"payment_related_information": "This is211TERM021000490614101010Target Store 0049 ANYTOWN VA",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-12-04 13:01:15",
"modified_at": "2023-12-04 13:01:15"
}]
}]
}],
"recordCount": 1,
"fileCharCount": "PHIN"
}]
describe('Generate MTE ACH File', async function () {
it('should create an MTE ACH file successfully', function (done) {
GenerateAchFile(MTERecords, './test/ach_file','MTE_').then((result) => {
expect(result.error).to.equal(false);
expect(result.message).to.equal('Successfully writing file.');
return done()
}).catch(error => {
console.log('===========', error)
expect(true).to.be.false;
expect(error.message).to.equal('Successfully writing file.');
return done();
})
}).timeout(10000);
})
});

@@ -61,3 +61,3 @@ const Moment = require('moment')

async function GenerateAchFile(queuedTransaction = [], fileFullPath = './') {
async function GenerateAchFile(queuedTransaction = [], fileFullPath = './', prefix = '') {
return new Promise((resolve, reject) => {

@@ -68,2 +68,3 @@ let totalRunsFile = [];

try {
let standardEntryClassCode = restField.standardEntryClassCode
let Nacha2AimPointFile = new NachaAimPoint.File(restField);

@@ -90,3 +91,3 @@ let totalBatchNumber = batchChildren.length;

paymentRelatedInformation: addenda.payment_related_information
});
}, standardEntryClassCode);
entryRecord.addAddenda(addendaEntry);

@@ -107,3 +108,3 @@ })

})
let fileName = `ACH${restField.immediateOrigin}PEIN${Moment().format('YYYYMMDDHHmmssSS')}.ach`;
let fileName = `${prefix}ACH${restField.immediateOrigin}PEIN${Moment().format('YYYYMMDDHHmmssSS')}.ach`;
if (successRecords.length > 0) {

@@ -110,0 +111,0 @@ Nacha2AimPointFile.generateFile(function (result) {

@@ -9,82 +9,150 @@ let chai = require('chai')

let queuedTransaction = [{
"id": 70,
"immediateDestination": "231380104",
"immediateOrigin": "121042882",
"immediateDestinationName": "CITADEL FED C U",
"immediateOriginName": "WELLS FARGO BANK NA",
"standardEntryClassCode": "IAT",
"referenceCode": " ",
"batchChildren": [{
"id": 70,
"serviceClassCode": "200",
"iatIndicator": "Iat Indiacator p",
"foreignExchangeIndicator": "IN",
"foreignExchangeReferenceIndicator": "3",
"foreignExchangeReference": "pradeepvish1213",
"isoDestinationCountryCode": "US",
"originatorIdentification": "2345432443",
let queuedTransaction = [
{
"id": 97,
"standardEntryClassCode": "IAT",
"companyEntryDescription": "SANdeepviS",
"isoOriginatingCurrencyCode": "IND",
"isoDestinationCurrencyCode": "CAD",
"effectiveEntryDate": Moment().toDate(),
"originatorStatusCode": "",
"originatingDFI": "121042882",
"entryChildren": [{
"id": 70,
"receivingDFI": "231380104",
"DFIAccount": "23456787654323",
"amount": "92345678",
"idNumber": null,
"individualName": "",
"discretionaryData": "",
"transactionCode": "21",
"transactionType": "Credit",
"traceNumber": '000000001234567',
"addendaRecords": [{
"id": 78,
"queued_transaction_id": 70,
"addenda_type_code": "10",
"payment_related_information": "UAS123454323454323.008765432345670000000001The abbreviation INDN on a bank sta",
"created_at": "2023-10-05 20:35:59",
"modified_at": "2023-10-05 20:35:59"
}]
}, {
"id": 70,
"receivingDFI": "231380104",
"DFIAccount": "23456787654323",
"amount": "92345678",
"idNumber": null,
"individualName": "",
"discretionaryData": "",
"transactionCode": "21",
"transactionType": "Credit",
"traceNumber": '000000001234567',
"addendaRecords": [{
"id": 78,
"queued_transaction_id": 70,
"addenda_type_code": "10",
"payment_related_information": "UAS123454323454323.008765432345670000000001The abbreviation INDN on a bank sta",
"created_at": "2023-10-05 20:35:59",
"modified_at": "2023-10-05 20:35:59"
}, {
"id": 78,
"queued_transaction_id": 70,
"addenda_type_code": "11",
"payment_related_information": "UAS123454323454323.008765432345670000000001The abbreviation INDN on a bank sta",
"created_at": "2023-10-05 20:35:59",
"modified_at": "2023-10-05 20:35:59"
}, {
"id": 78,
"queued_transaction_id": 70,
"addenda_type_code": "12",
"payment_related_information": "UAS123454323454323.008765432345670000000001The abbreviation INDN on a bank sta",
"created_at": "2023-10-05 20:35:59",
"modified_at": "2023-10-05 20:35:59"
}]
}]
}],
"recordCount": 1
}]
"immediateDestination": "031300012",
"immediateOrigin": "121042882",
"immediateDestinationName": "PNCBANK, N.A.",
"immediateOriginName": "WELLS FARGO BANK NA",
"referenceCode": " ",
"batchChildren": [
{
"iatIndicator": "Compan Name",
"foreignExchangeIndicator": "FF",
"foreignExchangeReferenceIndicator": "3",
"foreignExchangeReference": "USA",
"isoDestinationCountryCode": "CA",
"originatorIdentification": "1234567890",
"isoOriginatingCurrencyCode": "IND",
"isoDestinationCurrencyCode": "CAD",
"originatorStatusCode": "",
"id": 97,
"serviceClassCode": "200",
"standardEntryClassCode": "IAT",
"companyDiscretionaryData": null,
"companyEntryDescription": "Accounting",
"companyDescriptiveDate": "",
"effectiveEntryDate": Moment().toDate(),
"originatingDFI": "121042882",
"entryChildren": [
{
"id": 97,
"transactionCode": "27",
"receivingDFI": "031300012",
"DFIAccount": "12345643212354211",
"amount": "1000",
"idNumber": null,
"individualName": " ",
"discretionaryData": "",
"transactionType": "Debit",
"addendaRecords": [
{
"id": 141,
"queued_transaction_id": 97,
"addenda_type_code": "10",
"payment_related_information": "UAS1234543234543200 werw c~~~ M",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
},
{
"id": 142,
"queued_transaction_id": 97,
"addenda_type_code": "11",
"payment_related_information": "Pradeep JTahne K",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
},
{
"id": 143,
"queued_transaction_id": 97,
"addenda_type_code": "12",
"payment_related_information": "Tahen MINDIA N",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
},
{
"id": 144,
"queued_transaction_id": 97,
"addenda_type_code": "13",
"payment_related_information": "demo O12q23453 PUSA",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
},
{
"id": 145,
"queued_transaction_id": 97,
"addenda_type_code": "14",
"payment_related_information": "sdfsfsdf Q12wesfdsfsdf RUSA",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
},
{
"id": 146,
"queued_transaction_id": 97,
"addenda_type_code": "15",
"payment_related_information": "2345trgfvdswegSThane T",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
},
{
"id": 147,
"queued_transaction_id": 97,
"addenda_type_code": "16",
"payment_related_information": "Thane Pradeep Vishwakarma U4000400000 V",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
},
{
"id": 148,
"queued_transaction_id": 97,
"addenda_type_code": "17",
"payment_related_information": "payment_related_information W",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
},
{
"id": 149,
"queued_transaction_id": 97,
"addenda_type_code": "18",
"payment_related_information": "sdfsdf XISsdfsdf YUSA",
"ach_return_code": null,
"original_entry_trace_number": null,
"date_of_death": null,
"created_at": "2023-11-02 09:09:31",
"modified_at": "2023-12-04 16:52:07"
}
]
}
]
}
],
"recordCount": 1,
"fileCharCount": "PKIN"
}
]

@@ -100,23 +168,23 @@ describe('IAT Records', function () {

});
describe('Create IAT Entry with addenda', function () {
it('should create an entry with an addenda successfully', function () {
let entry = new NachaAimPoint.EntryIAT(queuedTransaction[0].batchChildren[0].entryChildren[0]);
let addenda = new EntryAddenda(queuedTransaction[0].batchChildren[0].entryChildren[0].addendaRecords);
expect(entry.getRecordCount()).to.equal(1);
entry.addAddenda(addenda);
expect(entry.get('addendaId')).to.equal('1');
expect(entry.getRecordCount()).to.equal(2);
expect(addenda.get('addendaSequenceNumber')).to.equal(1);
expect(addenda.get('entryDetailSequenceNumber')).to.equal('1234567');
let addenda2 = new EntryAddenda(queuedTransaction[0].batchChildren[0].entryChildren[1].addendaRecords);
entry.addAddenda(addenda2);
expect(entry.get('addendaId')).to.equal('1');
expect(entry.getRecordCount()).to.equal(3);
expect(addenda.get('addendaSequenceNumber')).to.equal(1);
expect(addenda.get('entryDetailSequenceNumber')).to.equal('1234567');
entry.generateString(function (string) {
console.log(string);
});
});
});
// describe('Create IAT Entry with addenda', function () {
// it('should create an entry with an addenda successfully', function () {
// let entry = new NachaAimPoint.EntryIAT(queuedTransaction[0].batchChildren[0].entryChildren[0]);
// let addenda = new EntryAddenda(queuedTransaction[0].batchChildren[0].entryChildren[0].addendaRecords);
// expect(entry.getRecordCount()).to.equal(1);
// entry.addAddenda(addenda);
// expect(entry.get('addendaId')).to.equal('1');
// expect(entry.getRecordCount()).to.equal(2);
// expect(addenda.get('addendaSequenceNumber')).to.equal(1);
// expect(addenda.get('entryDetailSequenceNumber')).to.equal('1234567');
// let addenda2 = new EntryAddenda(queuedTransaction[0].batchChildren[0].entryChildren[1].addendaRecords);
// entry.addAddenda(addenda2);
// expect(entry.get('addendaId')).to.equal('1');
// expect(entry.getRecordCount()).to.equal(3);
// expect(addenda.get('addendaSequenceNumber')).to.equal(1);
// expect(addenda.get('entryDetailSequenceNumber')).to.equal('1234567');
// entry.generateString(function (string) {
// console.log(string);
// });
// });
// });

@@ -127,2 +195,3 @@ describe('Create IAT Entry', function () {

try {
let standardEntryClassCode = restField.standardEntryClassCode
let Nacha2AimPointFile = new NachaAimPoint.File(restField);

@@ -148,4 +217,5 @@ let totalBatchNumber = batchChildren.length;

let addendaEntry = new NachaAimPoint.EntryAddenda({
addendaTypeCode: addenda.addenda_type_code,
paymentRelatedInformation: addenda.payment_related_information
});
}, standardEntryClassCode);
entryRecord.addAddenda(addendaEntry);

@@ -152,0 +222,0 @@ })

Sorry, the diff of this file is not supported yet

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