Ejemplo n.º 1
0
        public static String CalculateEntryHash(ACHFile file)
        {
            var sum =
                file
                .Batches
                .SelectMany(batch => batch.Entries)
                .Select(entry => entry.ReceivingDFIIdentification)
                .Select(routingNumber => routingNumber.Substring(0, 8))
                .Select(substring => Decimal.Parse(substring))
                .Sum();

            //IF THE SUM OF THE RDFI TRANSIT ROUTING NUMBERS IS A
            //NUMBER GREATER THAN TEN DIGITS, REMOVE OR DROP THE
            //NUMBER OF DIGITS FROM THE LEFT SIDE OF THE NUMBER
            //UNTIL ONLY TEN DIGITS REMAIN. FOR EXAMPLE, IF THE SUM
            //OF THE TRANSIT ROUTING NUMBERS IS 234567898765,
            //REMOVE THE “23” FOR A HASH OF 4567898765.

            var last10 = sum % 10000000000;

            return last10.ToString();
        }
Ejemplo n.º 2
0
        public static int GetNumberOfLines(ACHFile file)
        {
            var lines = 1; // file header

            foreach (var batch in file.Batches)
            {
                lines += 2; // batch header + control
                lines += batch.Entries.Count;
            }

            lines += 1; // file control

            return lines;
        }
Ejemplo n.º 3
0
        internal FileControl(ACHFile file)
        {
            this.BatchCount = file.Batches.Count;

            this.EntryCount = file.Batches.Sum(batch => batch.Entries.Count);

            this.TotalCredits = file.Batches.Sum(batch => batch.Control.TotalCredits);
            this.TotalDebits = file.Batches.Sum(batch => batch.Control.TotalDebits);

            this.BlockCount = (int)Math.Ceiling(ACHFile.GetNumberOfLines(file) / 10m);

            this.EntryHash = CalculateEntryHash(file);
        }