@pga/btrs-generate
Advanced tools
+1
-1
| { | ||
| "name": "@pga/btrs-generate", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "description": "Generator for BTRS", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -29,2 +29,12 @@ const generateTransactionRecord = require('../generateTransactionRecord') | ||
| test('transaction detail generation with max record length', () => { | ||
| const options = { physicalRecordLength: 999 } | ||
| expect(generateTransactionRecord({ ...TRANSACTION, text: LONG_TEXT }, options)) | ||
| .toEqual([ | ||
| '16,399,25000,0,,/', | ||
| '88,ORIG CO NAME=US POSTAL SERVICE,ORIG ID=1135641517,DESC DATE=120126,ENTRY DESC' + | ||
| 'R=PAYMENT,ENTRY CLASS=CCD,TRACE NO=021000023646851,ENTRY DATE=120127,IND IDNO' + | ||
| '=CTAS32160120126,IND NAME=AAAAAAAA AAAAAAAAAA,COMPANY DATA=000067841 26-JAN-12']) | ||
| }) | ||
| test('transaction detail generation with references', () => { | ||
@@ -31,0 +41,0 @@ const transaction = { |
@@ -73,6 +73,8 @@ const generateTransactionRecord = require('./generateTransactionRecord') | ||
| // Account Trailer | ||
| module.exports = (account) => { | ||
| module.exports = (account, options) => { | ||
| const accountHeader = generateAccountHeader(account) | ||
| const transactionRecords = account.transactions.flatMap(generateTransactionRecord) | ||
| const transactionRecords = account | ||
| .transactions | ||
| .flatMap(t => generateTransactionRecord(t, options)) | ||
@@ -79,0 +81,0 @@ const accountTrailer = generateAccountTrailer({ |
@@ -74,6 +74,8 @@ const generateAccountRecord = require('./generateAccountRecord') | ||
| // Bank Trailer | ||
| module.exports = (bank) => { | ||
| module.exports = (bank, options) => { | ||
| const bankHeader = generateBankHeader(bank) | ||
| const accountRecords = bank.accounts.flatMap(generateAccountRecord) | ||
| const accountRecords = bank | ||
| .accounts | ||
| .flatMap(a => generateAccountRecord(a, options)) | ||
@@ -80,0 +82,0 @@ const bankTrailer = generateBankTrailer({ |
@@ -76,4 +76,8 @@ const generateBankRecord = require('./generateBankRecord') | ||
| const bankRecords = file.banks.flatMap(generateBankRecord) | ||
| const options = { physicalRecordLength: file.physicalRecordLength } | ||
| const bankRecords = file | ||
| .banks | ||
| .flatMap(b => generateBankRecord(b, options)) | ||
| const fileTrailer = generateFileTrailer({ | ||
@@ -80,0 +84,0 @@ fileControlTotal: sumBanks(file.banks), |
@@ -21,9 +21,5 @@ const { | ||
| const MAX_PHYSICAL_RECORD_LENGTH = 80 | ||
| // Include record code and field delimiter in count | ||
| const CHUNK_SIZE = MAX_PHYSICAL_RECORD_LENGTH - CONTINUATION_RECORD_CODE.length - 1 | ||
| // Split text accross multiple contiuation records according to the maximum | ||
| // physical record length. | ||
| const generateTextRecords = (text, maxLength = CHUNK_SIZE) => { | ||
| const generateTextRecords = (text, maxLength) => { | ||
| if (!text) { | ||
@@ -33,3 +29,5 @@ return [] | ||
| return chunkify(CHUNK_SIZE, text) | ||
| // Include record code and field delimiter in count | ||
| const chunkSize = maxLength - CONTINUATION_RECORD_CODE.length - 1 | ||
| return chunkify(chunkSize, text) | ||
| .map(generateContinuationRecord) | ||
@@ -52,3 +50,3 @@ } | ||
| // 7. Text (Optional) | ||
| module.exports = (transaction) => { | ||
| module.exports = (transaction, options = {}) => { | ||
| const transactionFields = [ | ||
@@ -71,5 +69,6 @@ TRANSACTION_DETAIL_RECORD_CODE, | ||
| // rather than the transaction record (16) | ||
| const textRecords = generateTextRecords(transaction.text) | ||
| const maxRecordLength = options.physicalRecordLength || MAX_PHYSICAL_RECORD_LENGTH | ||
| const textRecords = generateTextRecords(transaction.text, maxRecordLength) | ||
| return [transactionRecord, ...textRecords] | ||
| } |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
23068
3.45%694
2.51%