Пример #1
0
        public string Verify()
        {
            string messages = "";

            messages += LengthCheck.CheckLength("Header Record Type", HeaderRecordType, HEADER_RECORD_TYPE_LENGTH);
            messages += ExpectedString.CheckString("Header Record Type", HeaderRecordType, new string[] { HEADER_RECORD_TYPE });
            messages += LengthCheck.CheckLength("Header Service Class", HeaderServiceClass, HEADER_SERVICE_CLASS_LENGTH);
            messages += ExpectedString.CheckString("Header Service Class", HeaderServiceClass, SERVICE_CLASS_CODES);
            messages += LengthCheck.CheckLength("Header Company Name", HeaderCompanyName, COMPANY_NAME_LENGTH);
            messages += LengthCheck.CheckLength("Company Discretionary Data", CompanyDiscretionary, COMPANY_DISCRETIONARY_DATA_LENGTH);
            messages += LengthCheck.CheckLength("Header Company Identification", HeaderCompanyIdentification, HCOMPANY_IDENTIFICATION_LENGTH);
            messages += LengthCheck.CheckLength("Standard Entry", StandardEntry, STANDARD_ENTRY_LENGTH);
            messages += ExpectedString.CheckString("Standard Entry", StandardEntry, STANDARD_ENTRY_CODES);
            messages += LengthCheck.CheckLength("Company Entry", CompanyEntry, COMPANY_ENTRY_LENGTH);
            messages += LengthCheck.CheckLength("Company Description", CompanyDescriptionDate, COMPANY_DESCRIPTION_DATE_LENGTH);
            messages += LengthCheck.CheckLength("Effective Entry Date", EffectiveEntryDate, EFFECTIVE_ENTRY_DATE_LENGTH);
            messages += LengthCheck.CheckLength("Settlement Date", SettlementDate, SETTLEMENT_DATE_LENGTH);
            messages += LengthCheck.CheckLength("Originator Status", OriginatorStatus, ORIGINATOR_STATUS_LENGTH);
            messages += LengthCheck.CheckLength("Header Originator DFI", HeaderOriginatorDFI, HEADER_ORIGINATOR_DFI_LENGTH);
            messages += LengthCheck.CheckLength("Header Batch Number", HeaderBatchNumber, HEADER_BATCH_NUMBER_LENGTH);
            messages += LengthCheck.CheckLength("Control Record Type", ControlRecordType, CONTROL_RECORD_TYPE_LENGTH);
            messages += ExpectedString.CheckString("Control Record Type", ControlRecordType, new string[] { CONTROL_RECORD_TYPE });
            messages += LengthCheck.CheckLength("Control Service Class", ControlServiceClass, CONTROL_SERVICE_CLASS_LENGTH);
            messages += ExpectedString.CheckString("Control Service Class", ControlServiceClass, SERVICE_CLASS_CODES);
            messages += LengthCheck.CheckLength("Entry Count", EntryCount, ENTRY_COUNT_LENGTH);
            messages += LengthCheck.CheckLength("Entry Hash", EntryHash, ENTRY_HASH_LENGTH);
            messages += LengthCheck.CheckLength("Total Debit", TotalDebit, TOTAL_DEBIT_LENGTH);
            messages += LengthCheck.CheckLength("Total Credit", TotalCredit, TOTAL_CREDIT_LENGTH);
            messages += LengthCheck.CheckLength("Control Batch Number", ControlBatchNumber, CONTROL_BATCH_NUMBER_LENGTH);
            messages += LengthCheck.CheckLength("Control Company Identification", ControlCompanyIdentification, CCOMPANY_IDENTIFICATION_LENGTH);
            messages += LengthCheck.CheckLength("Message Authentication", MessageAuthentication, MESSAGE_AUTH_LENGTH);
            messages += LengthCheck.CheckLength("Reserved", Reserved, RESERVED_LENGTH);
            messages += LengthCheck.CheckLength("Control Originating DFI", ControlOriginatingDFI, CONTROL_ORIGINATING_DFI_LENGTH);

            if (!HeaderServiceClass.Equals(ControlServiceClass))
            {
                messages += "\nHeader service class of '" + HeaderServiceClass +
                            "' is different than control service class '" + ControlServiceClass + "'";
            }

            if (!HeaderCompanyIdentification.Equals(ControlCompanyIdentification))
            {
                messages += "\nHeader company ID of '" + HeaderCompanyIdentification +
                            "' is different than control company ID '" + ControlCompanyIdentification + "'";
            }

            if (!HeaderOriginatorDFI.Equals(ControlOriginatingDFI))
            {
                messages += "\nHeader originating DFI of '" + HeaderOriginatorDFI +
                            "' is different than the control originating DFI '" + ControlOriginatingDFI + "'";
            }

            if (!HeaderBatchNumber.Equals(ControlBatchNumber))
            {
                messages += "\nHeader batch number of '" + HeaderBatchNumber +
                            "' is different than the control batch number '" + ControlBatchNumber + "'";
            }

            if (BatchPrinter.PrintHeader(this).Length != 94)
            {
                messages += "\nBatch header is not 94 characters long: '" + BatchPrinter.PrintHeader(this) + "'";
            }

            if (BatchPrinter.PrintControl(this).Length != 94)
            {
                messages += "\nBatch control footer is not 94 characters long: '" + BatchPrinter.PrintControl(this) + "'";
            }

            int entrySequence = 1;

            foreach (Entry entry in Entries)
            {
                string entryMessage = entry.Verify();
                if (!string.IsNullOrEmpty(entryMessage))
                {
                    messages += "\n" + entryMessage;
                }

                string expectedEntryTrace = GenerateEntryTraceNumber(entrySequence);
                if (!expectedEntryTrace.Equals(entry.TraceNumber))
                {
                    messages += "\nEntry has trace number '" + entry.TraceNumber +
                                "' when '" + expectedEntryTrace + "' was expected: " +
                                EntryPrinter.PrintEntryMembers(entry);
                }

                entrySequence++;
            }

            int entryCount = 0;

            if (int.TryParse(EntryCount, out entryCount))
            {
                int actualEntryCount = EntryAddendaCount();
                if (entryCount != actualEntryCount)
                {
                    messages += "\nEntry/Addenda count was '" + EntryCount + "' when '" + actualEntryCount.ToString() + "' was expected";
                }
            }
            else
            {
                messages += "\nEntry count could not be parsed as a number: '" + EntryCount + "'";
            }

            string expectedHash = GenerateHash();

            if (!expectedHash.Equals(EntryHash))
            {
                messages += "\nEntry hash is '" + EntryHash + "' when '" + expectedHash + "' was expected";
            }

            string expectedTotalDebit = GenerateTotalDebit();

            if (!expectedTotalDebit.Equals(TotalDebit))
            {
                messages += "\nTotal debit is '" + TotalDebit + "' when '" + expectedTotalDebit + "' was expected";
            }

            string expectedTotalCredit = GenerateTotalCredit();

            if (!expectedTotalCredit.Equals(TotalCredit))
            {
                messages += "\nTotal credit is '" + TotalCredit + "' when '" + expectedTotalCredit + "' was expected";
            }

            if (!string.IsNullOrEmpty(messages))
            {
                messages = "Errors in batch: " + BatchPrinter.PrintBatchMembers(this) + ": " + messages;
            }

            return(messages);
        }
Пример #2
0
        public string Verify()
        {
            string entryMessage = "";


            entryMessage += LengthCheck.CheckLength("Entry Record Type", RecordType, RECORD_TYPE_LENGTH);
            entryMessage += ExpectedString.CheckString("Entry Record Type", RecordType, new string[] { RECORD_TYPE });
            entryMessage += LengthCheck.CheckLength("Transaction Code", TransactionCode, TRANSACTION_CODE_LENGTH);
            entryMessage += ExpectedString.CheckString("Transaction Code", TransactionCode, TRANSACTION_CODE_TYPES);
            entryMessage += LengthCheck.CheckLength("Receiving DFI", ReceivingDFI, RECEIVING_DFI_LENGTH);
            entryMessage += ExpectedString.CheckNumericNoSpaces("Receiving DFI", ReceivingDFI);
            entryMessage += LengthCheck.CheckLength("Check Digit", CheckDigit, CHECK_DIGIT_LENGTH);

            /*
             * string expectedCheckDigit = GenerateCheckDigit(ReceivingDFI);
             * if (!CheckDigit.Equals(expectedCheckDigit))
             * {
             *  entryMessage += "\nCheck Digit is '" + CheckDigit + "' when '" + expectedCheckDigit + "' was expected";
             * }*/

            entryMessage += LengthCheck.CheckLength("DFI Account", DFIAccount, DFI_ACCOUNT_LENGTH);
            entryMessage += ExpectedString.CheckAlphaNumericWithSpaces("DFI Account", DFIAccount);
            entryMessage += LengthCheck.CheckLength("Amount", Amount, AMOUNT_LENGTH);
            entryMessage += ExpectedString.CheckNumericNoSpaces("Amount", Amount);
            entryMessage += LengthCheck.CheckLength("Individual Identification", IndividualIdentification, INDIVIDUAL_IDENTIFICATION_LENGTH);
            entryMessage += LengthCheck.CheckLength("Individual Name", IndividualName, INDIVIDUAL_NAME_LENGTH);
            entryMessage += LengthCheck.CheckLength("Discretionary Data", DiscretionaryData, DISCRETIONARY_DATA_LENGTH);
            entryMessage += LengthCheck.CheckLength("Addenda Record", AddendaRecord, ADDENDA_RECORD_LENGTH);

            entryMessage += ExpectedString.CheckString("Addenda Record", AddendaRecord, new string[] { "0", "1" });

            if (EntryPrinter.PrintEntry(this).Length != 94)
            {
                entryMessage += "\nEntry does not contain 94 characters: '" + EntryPrinter.PrintEntry(this) + "'";
            }

            if (AddendaRecord.Equals("0") && AddendaList != null && AddendaList.Count > 0)
            {
                entryMessage += "\nAddenda Record is '0' when there are addenda records when none were expected";
            }
            else if (AddendaRecord.Equals("1") && (AddendaList == null || AddendaList.Count <= 0))
            {
                entryMessage += "\nAddenda Record is '1' when there are no addedna records when at least one was expected";
            }

            int expectedAddendaSequence = 1;

            if (AddendaList != null)
            {
                foreach (Addenda addenda in AddendaList)
                {
                    string addendaVerify = addenda.Verify();
                    if (!string.IsNullOrEmpty(addendaVerify))
                    {
                        entryMessage += "\n" + addendaVerify;
                    }

                    int addendaSequence = -1;
                    if (int.TryParse(addenda.AddendaSequence, out addendaSequence))
                    {
                        if (expectedAddendaSequence != int.Parse(addenda.AddendaSequence))
                        {
                            entryMessage += "\nAddenda has incorrect addenda sequence when " + expectedAddendaSequence.ToString()
                                            + " was expected: " + AddendaPrinter.PrintAddendaVerbose(addenda);
                        }
                    }

                    if (!TraceNumber.Substring(8, 7).Equals(addenda.EntrySequence))
                    {
                        entryMessage += "\nAddenda did not have expected entry sequence: " + AddendaPrinter.PrintAddendaVerbose(addenda);
                    }
                }
            }

            entryMessage += LengthCheck.CheckLength("Trace Number", TraceNumber, TRACE_NUMBER_LENGTH);

            if (!string.IsNullOrEmpty(entryMessage))
            {
                entryMessage = "Errors in Entry with " + EntryPrinter.PrintEntryMembers(this) + ": " + entryMessage;
            }

            return(entryMessage);
        }