Cinchoo / ChoETL.NACHA

A NACHA library for .NET / c#
MIT License
38 stars 31 forks source link

Is it possible to set "File Creation Date" and "File Creation Time" file on 1 - File Header record...? #50

Closed tnfoundry closed 2 years ago

tnfoundry commented 2 years ago

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

Cinchoo commented 2 years ago

Well, I'm not sure about the issue. Need more information.

for your reference, created fiddle for you to play with. Take a look and follow the steps

https://dotnetfiddle.net/sR4G16

tnfoundry commented 2 years ago

Appreciate it the quick response and for the dotfiddle.net. It appears I am doing the same as you are in the fiddle so I'm missing something and can't identify it...

This is the sample code I am using against the nuget package. This creates the attached ACH.TXT which doesn't include the file creation date and time fields that your sample appears to have.

            try
            {
                var fileName = "ACH.TXT";
                var bankRoutingNumber = "0123456789";
                var bankAccountNumber = "55555555";

                ChoNACHAConfiguration nachaConfig = new

ChoNACHAConfiguration { DestinationBankName = "Dest. Bank", DestinationBankRoutingNumber = " 123456789", OriginatingCompanyId = "0123456789", OriginatingCompanyName = "Orig Company", ReferenceCode = "ARef" };

                var payments = GetPayments();
                if (payments != null && payments.Rows.Count > 0)
                {
                    using (var nachaWriter = new

ChoNACHAWriter(fileName, nachaConfig)) { using (var bw1 = nachaWriter.CreateBatch(200, "CCD", companyName: "AA COMPANY")) { foreach (DataRow row in payments.Rows) { var id = row.Field("ID"); var accountNumber = row.Field("AccountNumber");

                                using (var entry1 =

bw1.CreateCreditEntryDetail (27, bankRoutingNumber, bankAccountNumber, row.Field("CheckAmount"), "ID Num", "ID DESC")) { entry1.TraceNumber = Convert.ToString(id);

entry1.CreateAddendaRecord(accountNumber); } } } } } } catch (Exception ex) { Trace.WriteLine(ex.Message); }

            Trace.WriteLine("NACHA file created!");

On Sun, Aug 28, 2022 at 7:40 PM Cinchoo @.***> wrote:

Well, I'm not sure about the issue. Need more information.

for your reference, created fiddle for you to play with. Take a look and follow the steps

https://dotnetfiddle.net/sR4G16

— Reply to this email directly, view it on GitHub https://github.com/Cinchoo/ChoETL.NACHA/issues/50#issuecomment-1229603082, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2Y7UEEQVHNCBCTEFXDLZPDV3QBHHANCNFSM573CGLQA . You are receiving this because you authored the thread.Message ID: @.***>

101 1234567890123456789A094101Dest. Bank Orig. Company ARef
5200TEST COMPANY 0123456789CCD 220828 1123456784661317 820000000000000000000123456789 123456784661317 9000001000001000000000000000000
9999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999

tnfoundry commented 2 years ago

One thing noticed is that your fiddle is using .NET 6 compiler. We will need a version using .NET 6, but for moment we need to support using 4.8 .NET framework and that is where having issue, are you able to easily provide a fiddle compiling against the 4.8?

Cinchoo commented 2 years ago

Well, shouldn't make any difference. Couple of ways, you can investigate

  1. Add ChoETLFrxBootstrap.TraceLevel = System.Diagnostics.TraceLevel.Verbose at the Main() method. This will produce additional log. Post them when u have it.
  2. Make sure ChoETL is 1.2.1.28, ChoETL.NACHA is 1.0.2.3
tnfoundry commented 2 years ago

ChoETL.NACHA version 1.0.2.3 is the referenced DLL, but when attempting to downgraded the required dependency of ChoETL to your requested 1.2.1.28 from 1.2.1.48, Visual Studio throws error:

Unable to uninstall 'ChoETL.1.2.1.48' because 'ChoETL.NACHA.1.0.2.3' depends on it.

When we attempt to do NuGut Package update to try and downgrade to 1.2.1.28 we get

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'ChoETL, Version=1.2.1.48, Culture=neutral, PublicKeyToken=8138733ed69d3172' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'ChoETL, Version=1.2.1.28, Culture=neutral, PublicKeyToken=8138733ed69d3172' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) --- End of inner exception stack trace ---

tnfoundry commented 2 years ago

Additionally, I did test the same code using the .NET Core version and the created ACH file created correctly with File Creation Date and File Creation Date Time generated in the file

.NET Framework version does not

Do you have a fiddle that compiles and works against the .NET Framework so it can be compared?

Cinchoo commented 2 years ago

Now I get the picture, you have conflicts between ChoETL / ChoETL.NACHA libraries.

Pls uninstall both packages from package manager. Just install ChoETL.NACHA. (Don't install ChoETL package)

tnfoundry commented 2 years ago

Woohoo! That did it, but question... Shouldn't FileCreationDate and FileCreationTime properties get hydrated with the values from the file when parsed?? Below is what I get when stepping through...

image

Cinchoo commented 2 years ago

Yes, it should. Unless ur machine culture is different.

image

Cinchoo commented 2 years ago

sample fiddle: https://dotnetfiddle.net/MHewd8

tnfoundry commented 2 years ago

Below appears to the culprit for these issues... Visual Studio automatically added a BindingRedirect to app.config when the reference was added mapping ChoETL assembly to the latest version, instead of the required 1.2.1.28 version.

Cinchoo-Many thanks for your assistance and patience working though the issues and for creating and sharing this nifty tool. Cup of coffee coming your way!

`

    <bindingRedirect oldVersion="0.0.0.0-1.2.1.48" newVersion="1.2.1.48" />
  </dependentAssembly>`

instead of the required 1.2.1.28 version

`

    <bindingRedirect oldVersion="0.0.0.0-1.2.1.28" newVersion="1.2.1.28" />
  </dependentAssembly>`