public BankAccount(AccountNumberType numberType, string number, string holderName, string description, string currency, string country) { this.NumberType = numberType; this.Number = number; this.HolderName = holderName; this.Description = description; this.Currency = currency; this.Country = country; }
/// <summary> /// Initializes a new instance of the <see cref="Account"/> class. /// </summary> /// <param name="accountNumberTypeString">The type of the account.</param> /// <param name="accountInfo">The raw information of the account.</param> /// <param name="accountNameInfo">The raw information about the name.</param> public Account(string accountNumberTypeString, string accountInfo, string accountNameInfo) { Helpers.ValidateStringLength(accountInfo, 37, "Account"); Helpers.ValidateStringLength(accountNameInfo, 61, "AccountNameInfo"); var(accountIsIban, accountNumber, accountCurrency, accountCountry) = AddAccountInfo(accountInfo, accountNumberTypeString); NumberType = new AccountNumberType(accountNumberTypeString); Name = new AccountName(accountNameInfo.Substring(0, 26)); Description = new AccountDescription(accountNameInfo.Substring(26, 35)); Number = new AccountNumber(accountNumber, accountIsIban); Currency = new Currency(accountCurrency); Country = new Country(accountCountry); }
protected virtual CodaLine ParseInitialState(string line) { AccountNumberType accountNumberType = (AccountNumberType)int.Parse(line[1].ToString()); int statementSequenceNumber = int.Parse(line.Substring(2, 3).Trim()); string accountInfo = line.Substring(5, 37).Trim(); bool isPositive = line[42] == '0'; decimal balance = decimal.Parse(line.Substring(43, 15).Trim()) / 1000; if (!isPositive) { balance *= -1; } DateTime date = CodaDate.Parse(line.Substring(58, 6).Trim()); string accountHolderName = line.Substring(64, 26).Trim(); string accountDescription = line.Substring(90, 35).Trim(); int paperStatementSequenceNumber = int.Parse(line.Substring(125, 3).Trim()); BankAccount account = BankAccount.Create(accountNumberType, accountInfo, accountHolderName, accountDescription); return(new CodaInitialStateLine(statementSequenceNumber, account, balance, date, paperStatementSequenceNumber)); }
public static BankAccount Create(AccountNumberType numberType, string accountInfo, string holderName, string description) { string number = null; string currency = null; string country = null; switch (numberType) { case AccountNumberType.Belgian: number = accountInfo.Substring(0, 12).Trim(); currency = accountInfo.Substring(13, 3).Trim(); country = "BE"; break; case AccountNumberType.Foreign: if (accountInfo.Length >= 37) { number = accountInfo.Substring(0, 34).Trim(); currency = accountInfo.Substring(34, 3).Trim(); } else { number = accountInfo.Trim(); currency = "EUR"; } country = accountInfo.Substring(0, 2); if (!country.IsAlphabetic()) { country = null; } break; case AccountNumberType.BelgianIban: if (accountInfo.Length >= 37) { number = accountInfo.Substring(0, 31).Trim(); currency = accountInfo.Substring(34, 3).Trim(); } else { number = accountInfo.Trim(); currency = "EUR"; } country = "BE"; break; case AccountNumberType.ForeignIban: if (accountInfo.Length >= 37) { number = accountInfo.Substring(0, 34).Trim(); currency = accountInfo.Substring(34, 3).Trim(); } else { number = accountInfo.Trim(); currency = "EUR"; } country = accountInfo.Substring(0, 2); if (!country.IsAlphabetic()) { country = null; } break; default: throw new NotSupportedException($"The specified account number type '{numberType}' is not supported"); } return(new BankAccount(numberType, number, holderName, description, currency, country)); }
public BankAccount(string id, string name, string holderName, string description, AccountNumberType numberType, string number, string bic, string currency, string country) { this.Id = id; this.Name = name; this.HolderName = holderName; this.Description = description; this.NumberType = numberType; this.Number = number; this.Bic = bic; this.Currency = currency; this.Country = country; }
private static void FixNordeaPersonkonto3300(ref string clearingNumber, ref string accountNumber, ref AccountNumberType accountNumberType) { if (accountNumber.Length == 11 && clearingNumber.Equals("3300")) { clearingNumber = accountNumber.Substring(0, 4); accountNumber = accountNumber.Substring(4, 7); accountNumberType = AccountNumberType.Type2; } }
/// <summary> /// Validates an account number. Throws an exception if the account number is not in valid format. /// </summary> /// <param name="clearingNumber">The clearing number.</param> /// <param name="accountNumber">The account number.</param> /// <param name="accountNumberType">Type of the account number.</param> /// <param name="isSwedbank">true if the current account is belived to be a swedbank account.</param> public static void CheckAccountNumber(ref string clearingNumber, ref string accountNumber, AccountNumberType accountNumberType, bool isSwedbank) { // The stored accounts with clearing 3300 and 11 digits long account number have an incorrect clearing number. The clearing number needs to be changed to // the first 4 digits of the account number, the rest of the string is the actual account number. The AccountNumberType should be changed to Type1, from Type3. if (clearingNumber.Equals("3300") && accountNumber.Length == 11 && accountNumberType.Equals(AccountNumberType.Type3)) { FixNordeaPersonkonto3300(ref clearingNumber, ref accountNumber, ref accountNumberType); } switch (accountNumberType) { case AccountNumberType.Type1: accountNumber = RemoveClearingFromAccountNumber(clearingNumber, accountNumber, 7); ValidateType1(clearingNumber, ref accountNumber); break; case AccountNumberType.Type2: accountNumber = RemoveClearingFromAccountNumber(clearingNumber, accountNumber, 7); ValidateType2(clearingNumber, ref accountNumber); break; case AccountNumberType.Type3: if (clearingNumber.Equals("3300") && accountNumber.Length == 12) { accountNumber = FixNordeaPersonkonto3300(accountNumber); } accountNumber = RemoveClearingFromAccountNumber(clearingNumber, accountNumber, 10); ValidateType3(clearingNumber, ref accountNumber); break; case AccountNumberType.Type4: accountNumber = RemoveClearingFromAccountNumber(clearingNumber, accountNumber, 9); ValidateType4(clearingNumber, ref accountNumber); break; case AccountNumberType.Type5: if (isSwedbank) { FixSwedbankAccount(ref clearingNumber, ref accountNumber); } ValidateType5(clearingNumber, ref accountNumber); break; } }
public static void CheckAccountNumber(ref string clearingNumber, ref string accountNumber, AccountNumberType accountNumberType) { switch (accountNumberType) { case AccountNumberType.Type1: accountNumber = RemoveClearingFromAccountNumber(clearingNumber, accountNumber, 7); ValidateType1(clearingNumber, ref accountNumber); break; } }