Esempio n. 1
0
        internal BatchControl(Batch batch)
        {
            this.ServiceClass = batch.Header.ServiceClass;
            this.CompanyId = batch.Header.CompanyId;
            this.BatchNumber = batch.Header.BatchNumber;

            this.EntryCount = batch.Entries.Count;

            this.EntryHash = CalculateEntryHash(batch);

            var debits = new[] { TransactionCode.Checking_Debit, TransactionCode.Checking_Debit_Prenote, TransactionCode.Saving_Debit, TransactionCode.Saving_Debit_Prenote };

            var credits = new[] { TransactionCode.Checking_Credit, TransactionCode.Checking_Credit_Prenote, TransactionCode.Saving_Credit, TransactionCode.Saving_Credit_Prenote };

            this.TotalDebits = batch.Entries.Where(entry => debits.Contains(entry.Transaction_Code)).Sum(entry => entry.Amount);

            this.TotalCredits = batch.Entries.Where(entry => credits.Contains(entry.Transaction_Code)).Sum(entry => entry.Amount);

            this.HasDebits = batch.Entries.Where(entry => debits.Contains(entry.Transaction_Code)).Any();
            this.HasCredits = batch.Entries.Where(entry => credits.Contains(entry.Transaction_Code)).Any();

            if (HasCredits && HasDebits)
            {
                this.ServiceClass = batch.Header.ServiceClass = ServiceClassCode.Mixed_Debits_And_Credits;
            }
            else if (HasDebits)
            {
                this.ServiceClass = batch.Header.ServiceClass = ServiceClassCode.Debits_Only;
            }
            else if (HasCredits)
            {
                this.ServiceClass = batch.Header.ServiceClass = ServiceClassCode.Credits_Only;
            }
        }
Esempio n. 2
0
        public static String CalculateEntryHash(Batch batch)
        {
            var sum =
                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();
        }
Esempio n. 3
0
        internal BatchControl(Batch batch)
        {
            this.ServiceClass = batch.Header.ServiceClass;
            this.CompanyId = batch.Header.CompanyId;
            this.BatchNumber = batch.Header.BatchNumber;
            this.OriginatingDFIId = batch.Header.OriginatingDFIIdentification;

            this.EntryCount = batch.Entries.Count;

            this.EntryHash = CalculateEntryHash(batch);

            this.TotalDebits = batch.Entries.Where(entry => !IsCredit(entry.Transaction_Code)).Sum(entry => entry.Amount);
            this.NumberOfDebits = batch.Entries.Where(entry => !IsCredit(entry.Transaction_Code)).Count();

            this.TotalCredits = batch.Entries.Where(entry => IsCredit(entry.Transaction_Code)).Sum(entry => entry.Amount);
            this.NumberOfCredits = batch.Entries.Where(entry => IsCredit(entry.Transaction_Code)).Count();

            if (NumberOfCredits > 0 && NumberOfDebits > 0)
            {
                this.ServiceClass = batch.Header.ServiceClass = ServiceClassCode.Mixed_Debits_And_Credits;
            }
            else if (NumberOfDebits > 0)
            {
                this.ServiceClass = batch.Header.ServiceClass = ServiceClassCode.Debits_Only;
            }
            else if (NumberOfCredits > 0)
            {
                this.ServiceClass = batch.Header.ServiceClass = ServiceClassCode.Credits_Only;
            }
        }