예제 #1
0
파일: NachaFile.cs 프로젝트: evkap/DVS
		public NachaFile(NachaFileInfo info, List<NachaFileAppraiserEntry> listOfEntry)
			: this()
		{
			ValidateParams(info, listOfEntry);

			double totalAmount = 0;
			long entryHash = 0;
			_fileHeaderSection = new FileHeaderSection(info.CreationDate, info.CreationDate, info.FileIdModifier);
			_companyBatchHeaderSection = new CompanyBatchHeaderSection(info.CompanyDescriptiveDate, info.EffectiveEntryDate,
																																 info.BatchNumber);
			foreach (var entry in listOfEntry)
			{
				var parsedRoutingNumber = GetParsedRoutingNumber(entry.RoutingNumber);
				totalAmount += (double)entry.Amount;
				entryHash = (entryHash + parsedRoutingNumber.ReceivingDfiIdentification) % MaxEntryhashLength;
				int typeOfAccount = entry.TypeOfAccount == AccountType.Savings ? SavingTypeOfAccount : CheckingOrMoneymarketTypeOfAccount;
				_listOfEntryDetailSection.Add(new EntryDetailSection(typeOfAccount, parsedRoutingNumber.ReceivingDfiIdentification, parsedRoutingNumber.CheckDigit, entry.AccountNumber, (double)entry.Amount, entry.AppraiserOrCompanyId, entry.AppraiserOrCompanyName, entry.UniqueTraceNumber, entry.IsAppraiserWithCompany));
			}
			_companyBatchControlSection = new CompanyBatchControlSection(_listOfEntryDetailSection.Count, entryHash, totalAmount, info.BatchNumber);
			_fileTrailerSection = new FileTrailerSection(GetBlockCount(), _listOfEntryDetailSection.Count, entryHash, totalAmount);
		}
예제 #2
0
파일: NachaFile.cs 프로젝트: evkap/DVS
		private void ValidateParams(NachaFileInfo info, List<NachaFileAppraiserEntry> listOfEntry)
		{
			if (info == null)
			{
				throw new ArgumentNullException();
			}
			if (info.BatchNumber < BatchMinValue || info.BatchNumber > BatchMaxValue)
			{
				throw new ArgumentException("Batch number should be  1..9999999");
			}
			if (info.FileIdModifier.Length != 1)
			{
				throw new ArgumentException("FileIdModifier should be 1 character");
			}
			if (listOfEntry == null)
			{
				throw new ArgumentNullException();
			}
			for (int el = 0; el < listOfEntry.Count; el++)
			{
				if (listOfEntry[el].RoutingNumber.Length != RoutingnumberLength)
				{
					throw new ArgumentException("Routing Number length should be 9");
				}
				if (el + 1 < listOfEntry.Count && (listOfEntry[el + 1].UniqueTraceNumber - 1) != listOfEntry[el].UniqueTraceNumber)
				{
					throw new ArgumentException("Unique Trace Number should have correct increment");
				}

			}
		}