Application framework for .NET
cinchoo / choetl.nacha Goto Github PK
View Code? Open in Web Editor NEWA NACHA library for .NET / c#
License: MIT License
A NACHA library for .NET / c#
License: MIT License
Application framework for .NET
am I missing something ?
(I have updated code today)
When a NACHA file is read using "ChoNACHAReader", the record of type "ChoETL.NACHA.ChoNACHAEntryDetailRecord" and field ReceivingDFIID is removing any leading zeros from the number.
The following code should show you what I am talking about with any file that has a routing number with a leading zero in the Entry Detail record.
using (ChoNACHAReader fr = new ChoNACHAReader(fileName))
{
foreach (var r in fr)
{
if (r.ToString() == "ChoETL.NACHA.ChoNACHAEntryDetailRecord")
{
ChoNACHAEntryDetailRecord detail = (ChoNACHAEntryDetailRecord)r;
Console.WriteLine(detail.ReceivingDFIID.ToString());
}
}
}
I downloaded the latest nuget version (ChoETL.NACHA = 1.0.1.5) and using ChoETL (1.1.0.1).
According to NACHA specs:
CCD --> Field # 8 Receiving Company Name has a length of 22 (position 55 to 76)
CTX --> Starting from field # 8
NumberOfAddendaRecords: length 4 from 55 to 58
ReceivingCompanyName/IDNumber: length 16 from 59-74
Reserved: length 2 from 75 to 76
3 fields of CTX are combined into 1 field (total length = 22).
There should be a CTXEntryDetailRecord just to get the right value for ReceivingCompanyName. The generic NachaEntryDetailRecord is fine for TEL, CCD, PPD and WEB.
Also, the amount seems to be that is not parsed correctly, the specs says that it has 2 decimal places, the last 2 of the right, so, if the string value is 123468, the decimal should be 1234.68.
Running the ACH test file provided with the solution:
This is the row:
6261211403993300911569 0000002536GKGQT9VK NAME TWO 1121140390280738
The amount converted is:
-- ChoETL.NACHA.ChoNACHAEntryDetailRecord State --
RecordTypeCode: EntryDetail
TransactionCode: 26
ReceivingDFIID: 12114039
CheckDigit: 9
DFIAccountNumber: 3300911569
-->>Amount: 2536 <<--- It should be 25.36
IndividualIDNumber: GKGQT9VK
IndividualName: NAME TWO
DiscretionaryData:
AddendaRecordIndicator: True
TraceNumber: 121140390280738
OriginatingCompanyId is not accepting characters few companyid have a starting character, adding character to the OriginatingCompanyId is causing empty header record in file.
Hi
I have seen below code in your test project to override header values
ChoActivator.Factory = (t, args) =>
{
if (t == typeof(ChoNACHAFileHeaderRecord))
{
var header = new ChoNACHAFileHeaderRecord();
header.Initialize();
//Overrride any values here...
header.FileCreationDate = DateTime.Today.AddDays(100);
return header;
}
return null;
};
If multiple files are being written with separate ChoNACHAWriters (separate ChoNACHAConfigurations) concurrently, sometimes generated files has wrong filecreationdates. One file had another files FileCreationDate. What do you think?
When I try to get untrimed text, it will always return trimed text.
I am not sure if it is related to ChoETL or ChoETL.NACHA, but I got some exceptions while running a couple of unittests:
Can't convert '121015' value from 'System.String' type to 'System.DateTime' type.
Can't convert '121015' value from 'System.String' type to 'System.DateTime' type.
Can't convert '1518' value from 'System.String' type to 'System.DateTime' type.
Below code can simulate the exceptions:
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 3; i++)
{
string filename = "20151027B0000327P018CHK_" + i + ".ACH";
var t = Task.Run(() => Parse(filename));
}
Console.ReadLine();
}
public static List<object> Parse(string fileName)
{
System.Threading.Thread.Sleep(100);
List<object> records = new List<object>();
try
{
using (var file = new ChoNACHAReader(fileName))
{
foreach (var record in file)
{
records.Add(record);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return records;
}
}
Thanks
In EntryHash field, when total value exceeds 10 character length, is it possible to ignore the overflow out of the high order (leftmost) position instead of the right order position?
Example:
EntryHash: 98765432000
Current: 9876543200
Requested: 8765432000
Thank you.
Batch number is unique for daily.
If I need to generate two file, how do I add batch number ?
thanks.
While nothing is preventing ChoETL.NACHA from being licensed MIT. It's a bit precarious when it's dependent on ChoETA which is GPLv3. It means that any project consuming ChoETL.NACHA must be GPLV3 compliant, but it's not obvious since ChoETL.NACHA is MIT licensed.
Hello and many thanks for developing this project.
Are hopes are that it will assist with helping speed up development, but we are running into an error and wanted to see if you could help point in the right direction.
Using the sample from the repo README, we created a sample file and then tried to use the tool to read that file, but receive error record length error below. Digging into it, it appears that the "File Creation Date" and "File Creation Time" fields of the NACHA File Header record spec do not get set and can't find the properties on the ChoNACHA... interface to manually set them.
When we manually add 10 spaces to that section of the 1 - File Header record that was created, we can then parse successfully using the tool.
Is it possible to those fields? or are we using tool incorrectly?
...
2) Exception Information
Exception Type: ChoETL.ChoParserException
Message: Incorrect record length [Length: 84] found. Expected record length: 94
Data: System.Collections.ListDictionaryInternal
TargetSite: Boolean FillRecord(System.Object, System.Tuple`2[System.Int64,System.String])
HelpLink: NULL
Source: ChoETL
HResult: -2146232832
I'm trying to write an ACH file but for some reason I am not getting a space on the file header line between the Priority Code and the Immediate Destination. I've tried different configuration options but I haven't been able to find the right one.
This is what I'm expecting:
101 888888888 777777777 1912061623A094101FIRST BANK SOME COMPANY NAME
but this is what I'm getting:
101888888888 777777777 1912061623A094101FIRST BANK SOME COMPANY NAME
Here is the code I'm using to generate the file:
ChoNACHAConfiguration config = new ChoNACHAConfiguration
{
DestinationBankRoutingNumber = "88888888",
OriginatingCompanyId = "777777777",
DestinationBankName = "FIRST BANK",
OriginatingCompanyName = "SOME COMPANY NAME",
BlockingFactor = 10,
ErrorMode = ChoErrorMode.ThrowAndStop,
};
using ( var nachaWriter = new ChoNACHAWriter( FileName, config ) )
{
using ( var bw1 = nachaWriter.CreateBatch( 200 ) )
{
int idnum = 1;
// Add info for each application
foreach ( var app in applications )
{
// Transaction Code, Routing Number, Account Number, Amount, ID Number, Name, [Descritionary Info]
using ( var entry = bw1.CreateDebitEntryDetail( transactionCode, app.DepositForm.RoutingNumber,
app.DepositForm.AccountNumber,
22.505M, idnum.ToString(), app.FirstName.ToUpper() + " " + app.LastName.ToUpper() ) )
{
}
// Increment the ID number
idnum++;
}
}
}
Am I doing something wrong? The test file I have from the bank has the space as does the example in the https://github.com/Cinchoo/ChoETL.NACHA/blob/master/ChoETL.NACHATest/20151027B0000327P018CHK.ACH.
I'm running your test code but it produces an empty ach.txt file. What am I doing wrong?
ChoNACHAConfiguration config = new ChoNACHAConfiguration();
config.DestinationBankRoutingNumber = "123456789";
config.DestinationBankName = "PNC Bank";
config.OriginatingCompanyId = "123456789";
config.OriginatingCompanyName = "Microsoft Inc.";
config.ReferenceCode = "Internal Use Only.";
//config.BlockCount = 10;
using (var nachaWriter = new ChoNACHAWriter(@"C:\Temp\ACH.txt", config))
{
using (var bw1 = nachaWriter.CreateBatch(200))
{
using (var entry2 = bw1.CreateCreditEntryDetail(22, "123456789", "1313131313", 10M, null, "ID Name", "Desc Data"))
{
}
using (var entry2 = bw1.CreateCreditEntryDetail(22, "123456789", "1313131313", 20M, null, "ID Name", "Desc Data"))
{
}
}
using (var bw2 = nachaWriter.CreateBatch(200))
{
}
}
Thank you for your NACHA plug-in. It has saved us time implementing our own version.
In most cases _configuration.DestinationBankRoutingNumber
for the beginning of the Entry Detail TraceNumber
works out fine, but we have come across some clients wanting to use the OriginatingDFIID
instead. This Chase spec for example https://www.chase.com/content/dam/chaseonline/en/demos/cbo/pdfs/cbo_nacha_filespecs.pdf seems to utilize it (pages 8 and 9).
Would it make sense to maybe add a configuration enum for EntryDetailTraceSource
with options of DestinationBankRoutingNumber
or OriginatingDFI
? I would be happy to make the code changes and pull request it.
If there is a way to handle this currently, please let me know.
Regards,
Jim
Hi there
The CTX entry detail record has additional fields like Number of Addenda Records
and Reserved
fields in there. I see that the ChoNACHAEntryDetailRecord
has a single implementation. How are these additional fields handled?
And thanks for the amazing work on this package!
Cheers
Hi,
After the last update (to CHOETL?) the ACH files are now coming out without the record type code at the start of each row.
This code:
ChoNACHAConfiguration config = new ChoNACHAConfiguration(); config.DestinationBankRoutingNumber = "123456789"; config.OriginatingCompanyId = "123456789"; config.DestinationBankName = "PNC Bank"; config.OriginatingCompanyName = "Microsoft Inc."; config.ReferenceCode = "Internal Use Only."; config.BlockingFactor = 10; using (var nachaWriter = new ChoNACHAWriter("C:\\Temp\\Test1_ACH.txt", config)) { using (var bw1 = nachaWriter.CreateBatch(200)) { using (var entry1 = bw1.CreateDebitEntryDetail(20, "123456789", "1313131313", 22.505M, "ID Number", "ID Name", "Desc Data")) { entry1.CreateAddendaRecord("Monthly bill"); } using (var entry2 = bw1.CreateCreditEntryDetail(20, "123456789", "1313131313", 22.505M, "ID Number", "ID Name", "Desc Data")) { } } using (var bw2 = nachaWriter.CreateBatch(200)) { } }
Creates this output:
001123456789 123456789 0101010000A000101PNC Bank Microsoft Inc. Internal 0200Microsoft Inc. 123456789 PPD 1123456784758536 0201234567891313131313 0000002251ID Number ID Name De1123456780000001 005Monthly bill 00010000001 0201234567891313131313 0000002251ID Number ID Name De0123456780000002 02000000030024691356000000002251000000002251123456789 123456784758536 0200Microsoft Inc. 123456789 PPD 1123456784442501 02000000000000000000000000000000000000000000123456789 123456784442501 0000002000001000000030024691356000000002251000000002251 0999999999999999999999999999999999999999900999999999900999999999999999999999999999999999999999
Will downgrade in the meantime.
By the way, this is an excellent library, thanks for sharing.
Cheers,
Chris.
I'm using a memory stream as I want to return the file in a file download directly and it doesn't seem to be updated as I'm writing the information.
I can't copy the exact code but basically doing :
var nachaWriter = new ChoNACHAWriter(stream, config);
then create a batch using this writer and entries using the batch writer. Nothing seems to update the stream in the back.. stream length stays at 0 at all time and file end up empty in the end.
I don't see anything like write to stream in the end so I'm not sure how what the problem is.
Pier
We have employees who have apostrophes in their name, i.e. Harris, D'Andre. I use the following code to read the NACHA file line by line to pick out the data in each section.
using (ChoNACHAReader fr = new ChoNACHAReader(fileName))
{
foreach (var r in fr)
{
}
}
When this code comes across a line that has the name of the Employee with an Apostrophe, it creates an exception of "Failed to parse line to 'ChoETL.NACHA.ChoNACHAEntryDetailRecord' object." and will not continue. Can this be fixed so the record doesn't cause an exception?
FYI...I can make this happen on any NACHA detail record just by adding an apostrophe to the employee's name.
Thank you
I've used this library for 2 years on NACHA files then suddenly it stops parsing because of an Addenda (type 7) record has '0000000' for the Entry Detail Sequence Number. The ChoNACHAAddendaRecord is defined as:
[ChoFixedLengthRecordField(87, 7)]
[Range(1, 1.8446744073709552E+19, ErrorMessage = "Entry Detail Sequence Number must be > 0.")]
public ulong EntryDetailSequenceNumber { get; set; }
However, the NACHA file is sending '0000000' and nowhere can I find in the NACHA specs where the Entry Detail Sequence Number must be > 0. The Addenda Sequence Number always starts with 1 but nothing about the Entry Detail Sequence Number. The Trace Number to which it's referencing the last 7 digits in the type 6 detail records does have seven zeroes for the last seven digits.
Is this a bug or am I missing something in the NACHA specs?
I have been trying to configure EntryDetailSequenceNumber in the CreateAddendaRecord method, I need it to be incremental with respect to the last digit of the Record Type = 6, however even after creating extension method it is not possible to achieve. Is there is a way to customize or extend the library's functionality to modify the trace number. Is there any documentation regaring this or am I missing something here ?
Upon hitting this line of code, seeing this error below. Any ideas on what is going on with this?
Line of code blowing up is this (trying to use this ChoETL in a .NET 7 console app by the way):
foreach (var data in new ChoNACHAReader(filename))
Exception Type: System.MethodAccessException
TargetSite: Void .ctor(System.String, ChoETL.NACHA.ChoNACHAConfiguration)
Message: Attempt by method 'ChoETL.NACHA.ChoNACHAReader..ctor(System.String, ChoETL.NACHA.ChoNACHAConfiguration)' to access method 'ChoETL.ChoFileRecordConfiguration.GetEncoding(System.String)' failed.
Data: System.Collections.ListDictionaryInternal
HelpLink: NULL
Source: ChoETL.NACHA.NETStandard
HResult: -2146233072
An unhandled exception of type 'System.MethodAccessException' occurred in ChoETL.NACHA.NETStandard.dll
Attempt by method 'ChoETL.NACHA.ChoNACHAReader..ctor(System.String, ChoETL.NACHA.ChoNACHAConfiguration)' to access method 'ChoETL.ChoFileRecordConfiguration.GetEncoding(System.String)' failed.
ChoNACHAWriter is creating a blank header file record.
ChoNACHAConfiguration config = new ChoNACHAConfiguration();
config.DestinationBankRoutingNumber = " 051000017";
config.DestinationBankName = "BANK OF AMERICA";
config.OriginatingCompanyId = ACHCompanyID;
config.OriginatingCompanyName = ACHCompanyName.ToUpper();
using (var nachaWriter = new ChoNACHAWriter(strFileName, config))
{
using (var bw1 = nachaWriter.CreateBatch(
serviceClassCode: (int)ServiceClassCodes.CreditsOnly,
standardEntryClassCode: StandardEntryClassCodes.PPD.ToString(),
companyEntryDescription: strCompanyEntryDesc,
companyDiscretionaryData: "QBB" + BatchID.ToString(),
effectiveEntryDate: BatchDate))
{
using (CheckBatchDS.ACHPaymentsDataTable ACHTable = InvestorCheck.GetACHPayments(BatchID))
{
foreach (CheckBatchDS.ACHPaymentsRow dr in ACHTable.Rows)
{
string strInvestorName = Utils.SQLStripBadChars(dr.LNameFName).ToUpper();
if (strInvestorName.Length > 22)
strInvestorName = strInvestorName.Substring(0, 22);
int iTransCode = 0;
if (dr.Type == "Checking")
iTransCode = (int)TransactionCodes.CheckingCredit;
else if (dr.Type == "Savings")
iTransCode = (int)TransactionCodes.SavingsCredit;
using (var ced = bw1.CreateCreditEntryDetail(iTransCode, dr.BankRoutingNo, dr.BankAccountNo, dr.CheckTotal,
dr.IndividualID.ToString(), strInvestorName)) { }
}
}
}
}
This is targetting .net core, not .net standard. The moment you try to instantiate NachaWriter in a .netstandard library, it errors with System.Runtime incompatibility.
Took days to figure this out, because the name of the project is literally ChoETL.NACHA.NetStandard. Should be NetCore.
I have two background jobs, one job is read the return file from Chase, another job is generated the ach file.
I found a very stranger case, after reading the ach return file using the ChoNACHAReader, then another job generated the ach file will lose the 6, 8 and 9 records, please see bellow:
if the reading ach file job didn't execute, the generated ach file job will work as expected. once the reading ach file job executed, all the rest of generated ach file jobs will lose the 6, 8 and 9 records.
Can someone help me?
update: after many tests, i found that after foreach the ChoNACHAReader, the generated ach file job will lose the 6, 8 and 9 records
It seems like PPD is the only type of 6 record available, there doesn't appear to be a way to specify CCD or CTX for example?
I am calling this line of code twice in the same controller method, trying to create two different ACH files:
var nachaWriter1 = new ChoNACHAWriter(filePath, nachaConfig);
[...]
var nachaWriter2 = new ChoNACHAWriter(filePath, nachaConfig);
The first one writes the ACH file correctly. On the second call, I get this error:
"Duplicate record type '5' code defined in 'ChoNACHABatchHeaderRecord'."
Where is this error coming from and how do I fix it?
@Cinchoo
i am reading a nacha file for processing and ,i want to get the addendarecord from entrydetail but when I am accessing entrydetail it only shows me addendarecordindicator ,
i am using V 1.0.2.3
can you please guide me or show me some snippet
There is one more issue, the Total Credit amount is placed on Total Debit amount position
As per specification Position 33-44, Total Credit Entry Dollar Amount in Batch
As per specification Field 7, Position 44-55, Total Credit Entry Dollar Amount in File
I have identified an issue while generating a NACHA file. In the attached image there are two versions of an ACH file. Correct file has less length for the data in the middle column while the incorrect version has four more numbers with it. The correct file is generated using some other software while the incorrect version was generated by using the ChoETL.NACHA library. Can you please comment on this why the values are different.
When I generate a nacha file, the first 3 bytes of the file contain unprintable characters (values 239, 187, 191). Other ACH viewers catch this and won't open the file (see https://sourceforge.net/projects/achviewer/). Perhaps this is some header code I'm not aware of?
Here's the test program I'm using:
ChoNACHAConfiguration config = new ChoNACHAConfiguration();
config.DestinationBankRoutingNumber = " 123456789";
config.OriginatingCompanyId = "1234567890";
config.DestinationBankName = "PNC Bank";
config.OriginatingCompanyName = "Microsoft Inc.";
config.ReferenceCode = "Internal Use Only.";
config.ErrorMode = ChoErrorMode.ThrowAndStop;
using (var nachaWriter = new ChoNACHAWriter(@"c:\src\testACH.txt", config))
{
using (var writer = nachaWriter.CreateBatch(200))
{
using (var entry = writer.CreateCreditEntryDetail(22, "123456789", "1313131313", 10M, null, "ID Name", "Desc Data"))
{
}
}
}
using(var stream = File.OpenRead(@"c:\src\testACH.txt"))
{
using(BinaryReader reader = new BinaryReader(stream))
{
byte[] bytes = reader.ReadBytes(10);
bool correctByte = bytes[0] == (byte)'1';
if(!correctByte)
throw new Exception("first character is NOT 1");
}
}
I downloaded the nuget package of these project and ran locally in my machine, I am able to generate the file but in the file header where we need to mention current date and time its not working insted its displaying 0101010000. can you help me in fixing that issue.
Is there a way to override the batch number check function when using the enumerator Read() or MoveNext() for the BatchHeader record validation.
We have a vendor who is providing 0 batch number. The batch number isn't needed for the context of reading this data into an analysis database.
Isn't this package in nuget uptodate?
For example, I cannot see below property in ChoNACHAConfiguration which was added in #39
public ChoEntryDetailTraceSource EntryDetailTraceSource { get; set; }
Using ChoETL.NACHA 1.0.1.3 I am seeing padding rows that contain some zeros rather than 94 9's. I believe the standard requires all 9's (but I could be mistaken).
Here is an example:
101123456789 123456789 1806061329A094101PNC Bank Microsoft Inc. Internal 5200Microsoft Inc. 123456789 PPD 1123456785044382 6201234567891313131313 0000002251ID Number ID Name De1123456780000001 705Monthly bill 00010000001 6201234567891313131313 0000002251ID Number ID Name De0123456780000002 82000000030024691356000000002251000000002251123456789 123456785044382 5200Microsoft Inc. 123456789 PPD 1123456785872809 82000000000000000000000000000000000000000000123456789 123456785872809 9000002000001000000030024691356000000002251000000002251 9999999999999999999999999999999999999999900999999999900999999999999999999999999999999999999999
How can I do this currently? I am getting a log output file each time I create an ACH that has no useful information to me (currently).
I searched the project for the term "Time taken to run the application" and could not find where it is used.
Thanks.
I've received feedback that I need to turn ON the offset entry (aka balancing entry, auto settle line, etc..).
Is this something that the software is capable of?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.