Cinchoo / ChoETL.NACHA

A NACHA library for .NET / c#
MIT License
36 stars 32 forks source link

Blank File Header Record in NACHA file #20

Closed kverner closed 5 years ago

kverner commented 5 years ago

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)) { }
                    }
                }
            }
        }
Cinchoo commented 5 years ago

Seems 'ACHCompanyID' value is large, it is causing the library failed to write header. This value must be size of <= 10 chars.

In future if you run into any such issues, you can turn on the trace by setting the below statement at the Main()

ChoETL.ChoETLFrxBootstrap.TraceLevel = System.Diagnostics.TraceLevel.Verbose;

I'll be putting fix, to throw such errors.

Cinchoo commented 5 years ago

Fix is out there, can you please try and let me know if it helped. Appreciate it.