public void CanInstantiateOddAccounts(string accountNumber, string sortCode, string expectedSortCode, string expectedAccountNumber)
        {
            var account = new BankAccountDetails(sortCode, accountNumber);

            Assert.AreEqual(expectedAccountNumber, account.AccountNumber.ToString());
            Assert.AreEqual(expectedSortCode, account.SortCode.ToString());
        }
Ejemplo n.º 2
0
        public bool CheckBankAccount(string sortCode, string accountNumber)
        {
            var bankAccountDetails = new BankAccountDetails(sortCode, accountNumber);

            bankAccountDetails.WeightMappings = _weightTable.GetRuleMappings(bankAccountDetails.SortCode);
            return(new ConfirmDetailsAreValidForModulusCheck().Process(bankAccountDetails));
        }
Ejemplo n.º 3
0
        public ModulusCheckOutcome Process(BankAccountDetails bankAccountDetails)
        {
            var firstMapping  = bankAccountDetails.WeightMappings.First();
            var secondMapping = bankAccountDetails.WeightMappings.Second();

            if (firstMapping.Exception == 5)
            {
                var result = bankAccountDetails.FirstResult && bankAccountDetails.SecondResult;
                return(new ModulusCheckOutcome("exception 5 - so first and second check must pass", result));
            }

            if (firstMapping.Exception == 10 && secondMapping.Exception == 11)
            {
                var result = bankAccountDetails.SecondResult || bankAccountDetails.FirstResult;
                return(new ModulusCheckOutcome("exception 10 and 11 - so second or first check must pass", result));
            }

            if (firstMapping.Exception == 12 && secondMapping.Exception == 13)
            {
                var result = bankAccountDetails.SecondResult || bankAccountDetails.FirstResult;
                return(new ModulusCheckOutcome("exception 12 and 13 - so second or first check must pass", result));;
            }

            return(new ModulusCheckOutcome("no exceptions affect result - using second check result", bankAccountDetails.SecondResult));
        }
Ejemplo n.º 4
0
 public ActionResult Details(string Id)
 {
     if (Id != null)
     {
         BankAccountDetails bd = null;
         using (var db = new ApplicationDbContext())
         {
             var ba = (from b in db.BankAccounts where b.Id == Id select b).FirstOrDefault();
             bd = new BankAccountDetails()
             {
                 AccountNumber = ba.AccountNumber,
                 AccountTitle  = ba.AccountTitle,
                 BankName      = ba.Bank,
                 Id            = ba.Id
             };
             if (User.IsInRole("Administrator"))
             {
                 bd.IncomingPaymentsCount    = (from p in db.Payments where p.DonationPack.Ticket.TicketHolderId == ba.Id && p.Confirmed == true select p).ToList().Count();
                 bd.OutgoingPaymentsCount    = (from p2 in db.Payments where p2.DonationPack.DonorId == ba.Id && p2.Confirmed == true select p2).ToList().Count();
                 bd.LastIncomingDonationDate = (from p in db.Payments where p.DonationPack.Ticket.TicketHolderId == ba.Id && p.Confirmed == true orderby p.CreationDate descending select p.CreationDate).FirstOrDefault().ToShortDateString();
                 bd.LastOutgoingDonationDate = (from p2 in db.Payments where p2.DonationPack.DonorId == ba.Id && p2.Confirmed == true orderby p2.CreationDate descending select p2.CreationDate).FirstOrDefault().ToShortDateString();
             }
         }
         return(PartialView("_BankAccountDetails", bd));
     }
     else
     {
         return(HttpNotFound("Record not found"));
     }
 }
Ejemplo n.º 5
0
        private static ICustomerDetails GetJane()
        {
            ICustomerPersonalDetails personalDetails = new CustomerPersonalDetails("Jane", DateTime.Now.AddYears(-29));
            IBankAccountDetails      bankDetails     = new BankAccountDetails("30-98-93", "23435332");

            return(new CustomerDetails((int)UserIdEnum.Jane, personalDetails, bankDetails));
        }
Ejemplo n.º 6
0
        public ModulusCheckOutcome CheckBankAccountWithExplanation(string sortCode, string accountNumber)
        {
            var bankAccountDetails = new BankAccountDetails(sortCode, accountNumber);

            bankAccountDetails.WeightMappings = _weightTable.GetRuleMappings(bankAccountDetails.SortCode);
            return(new HasWeightMappings().Process(bankAccountDetails));
        }
Ejemplo n.º 7
0
        private static ICustomerDetails GetJack()
        {
            ICustomerPersonalDetails personalDetails = new CustomerPersonalDetails("Jack", DateTime.Now.AddYears(-35));
            IBankAccountDetails      bankDetails     = new BankAccountDetails("31-94-92", "12423432");

            return(new CustomerDetails((int)UserIdEnum.Jack, personalDetails, bankDetails));
        }
Ejemplo n.º 8
0
        internal List <BankAccountDetails> getBankAccountsDetails()
        {
            List <BankAccountDetails> BankAccountList = new List <BankAccountDetails>();
            List <BankAccount>        BankAccounts    = new List <BankAccount>();

            using (var db = new ApplicationDbContext())
            {
                BankAccounts = (from b in db.BankAccounts select b).ToList();
                foreach (BankAccount ba in BankAccounts)
                {
                    BankAccountDetails bd = new BankAccountDetails
                    {
                        Id            = ba.Id,
                        AccountTitle  = ba.AccountTitle,
                        AccountNumber = ba.AccountNumber,
                        BankName      = ba.Bank
                    };
                    bd.IncomingPaymentsCount    = (from p in db.Payments where p.DonationPack.Ticket.TicketHolderId == ba.Id && p.Confirmed == true select p).ToList().Count();
                    bd.OutgoingPaymentsCount    = (from p2 in db.Payments where p2.DonationPack.DonorId == ba.Id && p2.Confirmed == true select p2).ToList().Count();
                    bd.LastIncomingDonationDate = (from p in db.Payments where p.DonationPack.Ticket.TicketHolderId == ba.Id && p.Confirmed == true orderby p.CreationDate descending select p.CreationDate).FirstOrDefault().ToShortDateString();
                    bd.LastOutgoingDonationDate = (from p2 in db.Payments where p2.DonationPack.DonorId == ba.Id && p2.Confirmed == true orderby p2.CreationDate descending select p2.CreationDate).FirstOrDefault().ToShortDateString();
                    BankAccountList.Add(bd);
                }
            }
            return(BankAccountList);
        }
        public TransactionDto Pay(CreditCardDto from, BankAccountDto to, double amountDollar)
        {
            if (!IsValid(from))
            {
                return(null);
            }
            var         builder     = new TransactionBuilder();
            Transaction transaction = builder
                                      .From(from.CardNumber)
                                      .To(to.Id)
                                      .AmountDollar(amountDollar)
                                      .TimeUtcNow()
                                      .Build();

            using (var db = new BankSystemContext())
            {
                Transaction        saved    = db.Transactions.Add(transaction);
                BankAccountDetails fromBank = db.BankAccounts.FirstOrDefault(bank => bank.CreditCards.Any(card => card.CardNumber == from.CardNumber));
                if (fromBank == null)
                {
                    return(null);
                }
                fromBank.Balance -= transaction.AmountDollar;
                BankAccountDetails toBank = db.BankAccounts.Find(to.Id);
                toBank.Balance += transaction.AmountDollar;

                db.SaveChanges();

                return(mapper.Map <TransactionDto>(transaction));
            }
        }
Ejemplo n.º 10
0
        public JsonResult Deactivate(string Id)
        {
            BankAccountDetails bd = null;

            using (var db = new ApplicationDbContext())
            {
                var acct = (from a in db.BankAccounts where a.Id == Id select a).FirstOrDefault();
                if (acct != null && acct.IsReceiver == true)
                {
                    acct.IsReceiver = false;
                    //remove any existing waiting tickets from the waiting ticket repository
                    WaitingTicket tckt = (from t in db.WaitingList where t.TicketHolderId == acct.Id && t.IsValid == true select t).FirstOrDefault();
                    if (tckt != null)
                    {
                        if (tckt.Donations != null)
                        {
                            foreach (Donation d in tckt.Donations)
                            {
                                db.Donations.Remove(d);
                            }
                            db.WaitingList.Remove(tckt);
                        }
                    }
                    db.SaveChanges();
                    bd = CreateBankAccountDetails(acct);
                }
            }
            return(Json("Done"));
        }
Ejemplo n.º 11
0
 public PartialViewResult Edit(BankAccountDetails values)
 {
     if (values != null)
     {
         var uid = User.Identity.GetUserId();
         using (var db = new ApplicationDbContext())
         {
             var ba = (from a in db.BankAccounts where a.BankAccountOwnerId == uid select a).FirstOrDefault();
             if (ba != null)
             {
                 ba.AccountTitle  = values.AccountTitle;
                 ba.AccountNumber = values.AccountNumber;
                 ba.Bank          = values.BankName;
                 db.SaveChanges();
                 BankAccountDetails bd = new BankAccountDetails()
                 {
                     AccountTitle = ba.AccountTitle, AccountNumber = ba.AccountNumber, BankName = ba.Bank
                 };
                 return(PartialView("_BankAccountDetails", bd));
             }
             else
             {
                 return(PartialView("_Edit", values));
             }
         }
     }
     else
     {
         return(PartialView("_Edit", values));
     }
 }
Ejemplo n.º 12
0
        protected static void PrintComparison(IBban bban, BankAccountDetails bankAccountDetails)
        {
            const string format = "{0} == {1} -> {2}";

            WriteLine("ToString()");
            WriteLine(bban.ToString());

            WriteLine("BBAN", 1);
            WriteLine(string.Format(
                          format,
                          GetFieldValue(bban.Value()),
                          GetFieldValue(bankAccountDetails.Bban()),
                          bban.Value() == bankAccountDetails.Bban()));

            WriteLine("Check Digits 1");
            WriteLine(string.Format(
                          format,
                          GetFieldValue(bban.CheckDigits1),
                          GetFieldValue(bankAccountDetails.CheckDigits1),
                          bban.CheckDigits1 == bankAccountDetails.CheckDigits1));

            WriteLine("Bank Code");
            WriteLine(string.Format(
                          format,
                          GetFieldValue(bban.BankCode),
                          GetFieldValue(bankAccountDetails.BankCode),
                          bban.BankCode == bankAccountDetails.BankCode));

            WriteLine("Branch Code");
            WriteLine(string.Format(
                          format,
                          GetFieldValue(bban.BranchCode),
                          GetFieldValue(bankAccountDetails.BranchCode),
                          bban.BranchCode == bankAccountDetails.BranchCode));

            WriteLine("Check Digits 2");
            WriteLine(string.Format(
                          format,
                          GetFieldValue(bban.CheckDigits2),
                          GetFieldValue(bankAccountDetails.CheckDigits2),
                          bban.CheckDigits2 == bankAccountDetails.CheckDigits2));

            WriteLine("Account Number");
            WriteLine(string.Format(
                          format,
                          GetFieldValue(bban.AccountNumber),
                          GetFieldValue(bankAccountDetails.AccountNumber),
                          bban.AccountNumber == bankAccountDetails.AccountNumber));

            WriteLine("Check Digits 3");
            WriteLine(string.Format(
                          format,
                          GetFieldValue(bban.CheckDigits3),
                          GetFieldValue(bankAccountDetails.CheckDigits3),
                          bban.CheckDigits3 == bankAccountDetails.CheckDigits3));

            ReadLine();
            Console.Clear();
        }
        public void CalculatesExceptionSixTestCaseCorrectly()
        {
            var details = new BankAccountDetails("202959", "63748472");
            var mapping = ModulusWeightMapping.From("012345 012346 dblal 2 1 2 1 2 1 2 1 2 1 2 1 2 1");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(60, actual);
        }
        public void ExceptionFiveFirstCheckCorrectSecondIncorrect()
        {
            var details = new BankAccountDetails("938063", "15764273");
            var mapping = ModulusWeightMapping.From("012345 012346 dblal 2 1 2 1 2 1 2 1 2 1 2 1 2 0 5");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(58, actual);
        }
        public void CalculatesSumAsExpected()
        {
            var details = new BankAccountDetails("499273", "12345678");
            var mapping = ModulusWeightMapping.From("012345 012346 dblal 2 1 2 1 2 1 2 1 2 1 2 1 2 1");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(70, actual);
        }
        private CreditCardDetails GenerateRandomMastercardCreditCard(BankAccountDetails bank)
        {
            string prefix = MASTERCARD_PREFIX_LIST[random.Next(MASTERCARD_PREFIX_LIST.Length)];

            const int length = 16;

            return(GenerateRandomCard(prefix, length, bank));
        }
        private CreditCardDetails GenerateRandomVisaCreditCard(BankAccountDetails bank)
        {
            string prefix = VISA_PREFIX_LIST[random.Next(VISA_PREFIX_LIST.Length)];

            const int length = 16;

            return(GenerateRandomCard(prefix, length, bank));
        }
Ejemplo n.º 18
0
        private BankAccountDetails CreateBankAccountDetails(BankAccount bankAccount)
        {
            BankAccountDetails bd = new BankAccountDetails {
                Id = bankAccount.Id, AccountNumber = bankAccount.AccountNumber, AccountTitle = bankAccount.AccountTitle, BankName = bankAccount.Bank, IsReceiver = bankAccount.IsReceiver
            };

            return(bd);
        }
Ejemplo n.º 19
0
        public void KnownSortCodeIsTested(string sc, string an)
        {
            var accountDetails = new BankAccountDetails(sc, an);

            accountDetails.WeightMappings = _mockModulusWeightTable.Object.GetRuleMappings(accountDetails.SortCode);
            _ruleStep.Process(accountDetails);
            _firstModulusCalculatorStep.Verify(nr => nr.Process(accountDetails));
        }
        public void ExceptionFiveValidationTestSumCheck()
        {
            var details = new BankAccountDetails("938611", "07806039");
            var mapping = ModulusWeightMapping.From("012345 012346 dblal 2 1 2 1 2 1 2 1 2 1 2 1 2 0 5");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(51, actual);
        }
        public void CanSetWeightMappings(string sc, string an, int desiredMappings, int expectedCount)
        {
            var target = new BankAccountDetails(sc, an)
            {
                WeightMappings = BuildMappingList(sc, desiredMappings, ModulusExceptionFlag)
            };

            Assert.AreEqual(expectedCount, target.WeightMappings.Count());
        }
Ejemplo n.º 22
0
        public void CanPassBasicModulus11Test()
        {
            var accountDetails = new BankAccountDetails("202959", "63748472");

            accountDetails.WeightMappings = new ModulusWeightTable(Resources.valacdos).GetRuleMappings(accountDetails.SortCode);
            var result = _calculator.Process(accountDetails);

            Assert.IsTrue(result);
        }
        public void CanGetSecondAlternativeExceptionTwoValue()
        {
            var target = new BankAccountDetails("123456", "10000090")
            {
                WeightMappings = BuildMappingList("123456", 1, 1)
            };

            Assert.AreEqual(BankAccountDetails.AisNotZeroAndGisNineWeights, target.GetExceptionTwoAlternativeWeights(new int[1]));
        }
        public void ExceptionSixButNotAForeignAccount()
        {
            var accountDetails = new BankAccountDetails("202959", "63748472");

            accountDetails.WeightMappings = ModulusWeightTable.GetInstance.GetRuleMappings(accountDetails.SortCode);
            var result = _secondStepDblAlCalculator.Process(accountDetails);

            Assert.IsTrue(result);
        }
Ejemplo n.º 25
0
        public void ExceptionThreeWhereCisNeitherSixNorNine()
        {
            var accountDetails = new BankAccountDetails("827101", "28748352");

            accountDetails.WeightMappings = new ModulusWeightTable(Resources.valacdos).GetRuleMappings(accountDetails.SortCode);
            var result = _calculator.Process(accountDetails);

            Assert.IsTrue(result);
        }
        public void CanProcessDoubleAlternateCheck()
        {
            var accountDetails = new BankAccountDetails("499273", "12345678");

            accountDetails.WeightMappings = _fakedModulusWeightTable.Object.GetRuleMappings(accountDetails.SortCode);
            var result = _firstStepDblAlCalculator.Process(accountDetails);

            Assert.True(result);
        }
        public void CanProcessVocaLinkDoubleAlternateWithExceptionOne()
        {
            var accountDetails = new BankAccountDetails("118765", "64371389");

            accountDetails.WeightMappings = _fakedModulusWeightTable.Object.GetRuleMappings(accountDetails.SortCode);
            var result = _firstStepDblAlCalculator.Process(accountDetails);

            Assert.True(result);
        }
        public void ExceptionThreeWhereCisNeitherSixNorNine()
        {
            var accountDetails = new BankAccountDetails("827101", "28748352");

            accountDetails.WeightMappings = ModulusWeightTable.GetInstance.GetRuleMappings(accountDetails.SortCode);
            var result = _secondStepDblAlCalculator.Process(accountDetails);

            Assert.IsTrue(result);
        }
        public void ExceptionFiveWhereFirstCheckPasses()
        {
            var accountDetails = new BankAccountDetails("938611", "07806039");

            accountDetails.WeightMappings = ModulusWeightTable.GetInstance.GetRuleMappings(accountDetails.SortCode);
            var result = _firstStepDblAlCalculator.Process(accountDetails);

            Assert.IsFalse(result);
        }
        public void ExceptionFiveSecondCheckDigitIncorrect()
        {
            var accountDetails = new BankAccountDetails("938063", "15764273");

            accountDetails.WeightMappings = ModulusWeightTable.GetInstance.GetRuleMappings(accountDetails.SortCode);
            var result = _firstStepDblAlCalculator.Process(accountDetails);

            Assert.IsFalse(result);
        }