public void ICanRegisterMoreThanOneDirectDebitInitiationContract()
        {
            Creditor creditor = new Creditor("G35008770", "Real Club Náutico de Gran Canaria");

            BankCode bankCode = new BankCode("2038", "Bankia, S.A.", "CAHMESMMXXX");
            CreditorAgent creditorAgent = new CreditorAgent(bankCode);
            BankAccount creditorAccount = new BankAccount(new ClientAccountCodeCCC("20381111401111111111"));
            DirectDebitInitiationContract directDebitInitiationContract = new DirectDebitInitiationContract(
                creditorAccount, creditor.NIF, "777", creditorAgent);
            creditor.AddDirectDebitInitiacionContract(directDebitInitiationContract);

            BankCode bankCode2 = new BankCode("2100", "CaixaBank, S.A.", "CAIXESBBXXX");
            CreditorAgent creditorAgent2 = new CreditorAgent(bankCode2);
            BankAccount creditorAccount2 = new BankAccount(new ClientAccountCodeCCC("21001111301111111111"));
            DirectDebitInitiationContract directDebitInitiationContract2 = new DirectDebitInitiationContract(
                creditorAccount2, creditor.NIF, "333", creditorAgent2);
            creditor.AddDirectDebitInitiacionContract(directDebitInitiationContract2);

            Assert.AreEqual("20381111401111111111", creditor.DirectDebitInitiationContracts["777"].CreditorAcount.CCC.CCC);
            Assert.AreEqual("CAHMESMMXXX", creditor.DirectDebitInitiationContracts["777"].CreditorAgent.BankBIC);
            Assert.AreEqual("777", creditor.DirectDebitInitiationContracts["777"].CreditorBussinessCode);
            Assert.AreEqual("ES90777G35008770", creditor.DirectDebitInitiationContracts["777"].CreditorID);

            Assert.AreEqual("21001111301111111111", creditor.DirectDebitInitiationContracts["333"].CreditorAcount.CCC.CCC);
            Assert.AreEqual("CAIXESBBXXX", creditor.DirectDebitInitiationContracts["333"].CreditorAgent.BankBIC);
            Assert.AreEqual("333", creditor.DirectDebitInitiationContracts["333"].CreditorBussinessCode);
            Assert.AreEqual("ES90333G35008770", creditor.DirectDebitInitiationContracts["333"].CreditorID);
        }
 public void AcceptsNullOnAcountNumbers()
 {
     BankAccountFields bankAccountFields = new BankAccountFields(null, "", "02", "aaaaa");
     BankAccount testAccount = new BankAccount(bankAccountFields);
     Assert.IsFalse(testAccount.HasValidBankAccountFields);
     Assert.AreEqual(null, testAccount.BankAccountFieldCodes.BankCode);
 }
 public DirectDebitTransaction(int internalDirectDebitReferenceNumber, BankAccount debtorAccount, string accountHolderName, DateTime mandateSignatureDate)
 {
     this.internalDirectDebitReferenceNumber = internalDirectDebitReferenceNumber;
     this.debtorAccount = debtorAccount;
     this.accountHolderName = accountHolderName;
     this.mandateSignatureDate = mandateSignatureDate;
     billsInTransaction = new List<Bill>();
 }
 public void ABankTransferPaymentMethodIsCorrectlyCreated()
 {
     BankAccount transferorAccount = new BankAccount(new ClientAccountCodeCCC("20381111401111111111"));
     BankAccount transfereeAccount = new BankAccount(new ClientAccountCodeCCC("21001111301111111111"));
     BankTransferPaymentMethod bankTransferPaymentMethod = new BankTransferPaymentMethod(transferorAccount, transfereeAccount);
     Assert.AreEqual(transferorAccount, bankTransferPaymentMethod.TransferorAccount);
     Assert.AreEqual(transfereeAccount, bankTransferPaymentMethod.TransfereeAccount);
 }
 public DirectDebitTransaction(List<Bill> billsInTransaction, int internalDirectDebitReferenceNumber, BankAccount debtorAccount, string accountHolderName, DateTime mandateSignatureDate)
 {
     this.billsInTransaction = billsInTransaction;
     this.internalDirectDebitReferenceNumber = internalDirectDebitReferenceNumber;
     this.debtorAccount = debtorAccount;
     this.accountHolderName = accountHolderName;
     this.mandateSignatureDate = mandateSignatureDate;
     UpdateAmountAndNumberOfBills();
 }
 public void ADirectDebitMandateCanBeDeactivated()
 {
     ClientAccountCodeCCC ccc = new ClientAccountCodeCCC("12345678061234567890");
     BankAccount bankAccount = new BankAccount(ccc);
     DirectDebitMandate directDebitMandate = new DirectDebitMandate(1, DateTime.Now.Date, bankAccount, "NoName");
     Assert.AreEqual(DirectDebitMandate.DirectDebitmandateStatus.Active, directDebitMandate.Status);
     directDebitMandate.DeactivateMandate();
     Assert.AreEqual(DirectDebitMandate.DirectDebitmandateStatus.Inactive, directDebitMandate.Status);
 }
 public void GivenTheseAccountNumbers(Table accountNumbers)
 {
     directDebitContextData.bankAccounts = new Dictionary<string, BankAccount>();
     foreach (var row in accountNumbers.Rows)
     {;
         string iBAN = (string)row["IBAN"];
         BankAccount bankAccount = new BankAccount(new InternationalAccountBankNumberIBAN(iBAN));
         directDebitContextData.bankAccounts.Add(iBAN, bankAccount);
     }
 }
 public void GivenIHaveADirectDebitInitiationContractRegisteredWithBussinesCode(string creditorBussinessCode)
 {
     Creditor creditor = (Creditor)ScenarioContext.Current["Creditor"];
     BankCode bankCode = new BankCode("2100", "CaixaBank, S.A.", "CAIXESBBXXX");
     CreditorAgent creditorAgent = new CreditorAgent(bankCode);
     BankAccount creditorAccount = new BankAccount(new ClientAccountCodeCCC("21001111301111111111"));
     DirectDebitInitiationContract directDebitInitiationContract = new DirectDebitInitiationContract(
         creditorAccount, creditor.NIF, "333", creditorAgent);
     creditor.AddDirectDebitInitiacionContract(directDebitInitiationContract);
 }
 public void GivenIHaveADirectDebitInitiationContract()
 {
     Creditor creditor = (Creditor)ScenarioContext.Current["Creditor"];
     BankCode bankCode = new BankCode("2100", "CaixaBank, S.A.", "CAIXESBBXXX");
     CreditorAgent creditorAgent = new CreditorAgent(bankCode);
     BankAccount creditorAccount = new BankAccount(new ClientAccountCodeCCC("21001111301111111111"));
     DirectDebitInitiationContract directDebitInitiationContract = new DirectDebitInitiationContract(
         creditorAccount, creditor.NIF, "333", creditorAgent);
     ScenarioContext.Current.Add("Contract333", directDebitInitiationContract);
 }
 public void ABankAccountHistoricalDataIsCorrectlyCreated()
 {
     ClientAccountCodeCCC ccc = new ClientAccountCodeCCC("12345678061234567890");
     BankAccount bankAccount = new BankAccount(ccc);
     DateTime activationDate = new DateTime(2013, 11, 11);
     DateTime deactivationDate = new DateTime(2013, 11, 30);
     BankAccountHistoricalData ephemeralBankAcount = new BankAccountHistoricalData(bankAccount, activationDate, deactivationDate);
     Assert.AreEqual(bankAccount, ephemeralBankAcount.BankAccount);
     Assert.AreEqual(activationDate, ephemeralBankAcount.AccountActivationDate);
     Assert.AreEqual(deactivationDate, ephemeralBankAcount.AccountDeactivationDate);
 }
 public void AcceptsEmptyAcountNumbers()
 {
     BankAccountFields bankAccountFields = new BankAccountFields("", "", "", "");
     BankAccount testAccount = new BankAccount(bankAccountFields);
     string storedData =
         testAccount.BankAccountFieldCodes.BankCode +
         testAccount.BankAccountFieldCodes.OfficeCode +
         testAccount.BankAccountFieldCodes.CheckDigits +
         testAccount.BankAccountFieldCodes.AccountNumber;
     Assert.IsFalse(testAccount.HasValidBankAccountFields);
     Assert.AreEqual("", storedData);
 }
 public void GivenAClubMemberWithADefaultPaymentMethod(Table clientsTable)
 {
     membersManagementContextData.clubMember = new ClubMember(clientsTable.Rows[0]["MemberID"], clientsTable.Rows[0]["Name"], clientsTable.Rows[0]["FirstSurname"], clientsTable.Rows[0]["SecondSurname"]);
     string electronicIBANString = clientsTable.Rows[0]["Spanish IBAN Bank Account"].Replace(" ","").Substring(4);
     InternationalAccountBankNumberIBAN iban = new InternationalAccountBankNumberIBAN(electronicIBANString);
     BankAccount bankAccount = new BankAccount(iban);
     string debtorName = membersManagementContextData.clubMember.FullName;
     DirectDebitMandate directDebitmandate = new DirectDebitMandate(2345, DateTime.Now.Date, bankAccount, debtorName);
     PaymentMethod paymentMethod = new DirectDebitPaymentMethod(directDebitmandate, null);
     membersManagementContextData.clubMember.AddDirectDebitMandate(directDebitmandate);
     membersManagementContextData.clubMember.SetDefaultPaymentMethod(paymentMethod);
 }
        public DirectDebitMandate(int internalReferenceNumber, DateTime directDebitMandateCreationDate, BankAccount bankAccount, string accountHolderName)
        {
            this.billingDataManager = BillingDataManager.Instance;

            this.status = DirectDebitmandateStatus.Active;
            this.directDebitMandateCreationDate = directDebitMandateCreationDate;
            this.bankAccount = bankAccount;
            this.accountHolderName = accountHolderName;
            this.bankAccountActivationDate = directDebitMandateCreationDate;
            bankAccountHistory = new Dictionary<DateTime, BankAccountHistoricalData>();
            SetInternalReferenceNumber(internalReferenceNumber);
        }
 public void ANewDirectDebitInitiationContractIsCorrectlyCreated()
 {
     Creditor creditor = new Creditor("G35008770", "Real Club Náutico de Gran Canaria");
     BankAccount creditorAccount = new BankAccount(new ClientAccountCodeCCC("20381111401111111111"));
     BankCode bankCode = new BankCode("2038", "Bankia, S.A.", "CAHMESMMXXX");
     CreditorAgent creditorAgent = new CreditorAgent(bankCode);
     DirectDebitInitiationContract directDebitInitiationContract = new DirectDebitInitiationContract(
         creditorAccount, creditor.NIF, "777", creditorAgent);
     Assert.AreEqual("20381111401111111111", directDebitInitiationContract.CreditorAcount.CCC.CCC);
     Assert.AreEqual("CAHMESMMXXX", directDebitInitiationContract.CreditorAgent.BankBIC);
     Assert.AreEqual("777", directDebitInitiationContract.CreditorBussinessCode);
     Assert.AreEqual("ES90777G35008770", directDebitInitiationContract.CreditorID);
 }
 public void AcceptsInvalidAcountNumbers()
 {
     BankAccountFields bankAccountFields = new BankAccountFields("124", "1 00", " 4", "100/234-1");
     BankAccount testAccount = new BankAccount(bankAccountFields);
     string givenData = "124" + "1 00" + " 4" + "100/234-1";
     string storedData =
         testAccount.BankAccountFieldCodes.BankCode +
         testAccount.BankAccountFieldCodes.OfficeCode +
         testAccount.BankAccountFieldCodes.CheckDigits +
         testAccount.BankAccountFieldCodes.AccountNumber;
     Assert.IsFalse(testAccount.HasValidBankAccountFields);
     Assert.AreEqual(givenData, storedData);
 }
        public void AccounNumberMaxLenghtIs10()
        {
            try
            {
                BankAccountFields bankAccountFields = new BankAccountFields(null, "", "02", "1234561234578909");
                BankAccount testAccount = new BankAccount(bankAccountFields);
            }

            catch (System.ArgumentException e)
            {
                Assert.AreEqual("número de cuenta", e.ParamName);
                throw e;
            }
        }
 public void CantInitializeADirectDebitWithAnOutOfRangeSequenceNumber()
 {
     BankAccount bankAccount = new BankAccount(new ClientAccountCodeCCC("12345678061234567890"));
     DateTime directDebitMandateCreationDate = new DateTime(2013, 11, 11);
     try
     {
         DirectDebitMandate directDebitMandate = new DirectDebitMandate(100000, directDebitMandateCreationDate, bankAccount, "NoName");
     }
     catch (ArgumentOutOfRangeException exception)
     {
         Assert.AreEqual("Direct Debit Sequence Number out of range (1-99999)", exception.GetMessageWithoutParamName());
         throw exception;
     }
 }
 public void WhenTheBillIsPaidByBankTransfer()
 {
     Invoice invoice = (Invoice)ScenarioContext.Current["Invoice"];
     Bill bill = (Bill)ScenarioContext.Current["Bill"];
     BankAccount transferorAccount = new BankAccount(new ClientAccountCodeCCC("20381111401111111111"));
     BankAccount transfereeAccount = new BankAccount(new ClientAccountCodeCCC("21001111301111111111"));
     BankTransferPaymentMethod bankTransferPaymentMethod = new BankTransferPaymentMethod(transferorAccount, transfereeAccount);
     Payment payment = new Payment(bill.Amount, new DateTime(2013, 11, 11), bankTransferPaymentMethod);
     billsManager.PayBill(invoice, bill, payment);
 }
 public void WhenIAssignToBePaidWithADirectDebit()
 {
     int internalReferenceNumber = 2645;
     BankAccount bankAccount = new BankAccount(new ClientAccountCodeCCC("12345678061234567890"));
     DateTime directDebitMandateCreationDate = new DateTime(2013, 11, 11);
     string debtorname = membersManagementContextData.clubMember.FullName;
     DirectDebitMandate directDebitMandate = new DirectDebitMandate(internalReferenceNumber, directDebitMandateCreationDate, bankAccount, debtorname);
     DirectDebitPaymentMethod directDebitPaymentMethod = new DirectDebitPaymentMethod(directDebitMandate, null);
     ScenarioContext.Current.Add("DirectDebitpaymentMethod", directDebitPaymentMethod);
     Invoice invoice = (Invoice)ScenarioContext.Current["Invoice"];
     string billID= (string)ScenarioContext.Current["BillID"];
     Bill bill = invoice.Bills[billID];
     bill.AssignPaymentMethod(directDebitPaymentMethod);
 }
 public void WhenIProcessTheIBAN()
 {
     BankAccount bankAccount;
     try
     {
         InternationalAccountBankNumberIBAN iban = new InternationalAccountBankNumberIBAN(bankAccountContextData.iban);
         bankAccount = new BankAccount(iban);
         ScenarioContext.Current.Add("Bank_Account", bankAccount);
     }
     catch
     {
         ScenarioContext.Current.Add("Bank_Account", null);
     }
 }
 public void WhenIProcessTheCCC()
 {
     BankAccount bankAccount;
     try
     {
         ClientAccountCodeCCC ccc = new ClientAccountCodeCCC(bankAccountContextData.ccc);
         bankAccount = new BankAccount(ccc);
         ScenarioContext.Current.Add("Bank_Account", bankAccount);
     }
     catch
     {
         ScenarioContext.Current.Add("Bank_Account", null);
     }
 }
 public void WhenIProcessTheBankAccount()
 {
     BankAccount bankAccount;
     try
     {
         BankAccountFields bankAccountFields= new BankAccountFields(
              bankAccountContextData.bank,
              bankAccountContextData.office,
              bankAccountContextData.checkDigits,
              bankAccountContextData.accountNumber);
         bankAccount = new BankAccount(bankAccountFields);
         ScenarioContext.Current.Add("Bank_Account", bankAccount);
     }
     catch
     {
         ScenarioContext.Current.Add("Bank_Account", null);
     }
 }
 public void ChangeBankAccount(BankAccount bankAccount, DateTime changingDate)
 {
     AddCurrentAccountToHistorical(changingDate);
     this.bankAccount = bankAccount;
     this.bankAccountActivationDate = changingDate;
 }
 public DirectDebitMandate(DateTime directDebitMandateCreationDate, BankAccount bankAccount, string accountHolderName)
     : this(1, directDebitMandateCreationDate, bankAccount, accountHolderName)
 {
     GetInternalReferenceSequenceNumber();
 }
 public void GivenTheseClubMembers(Table membersTable)
 {
     Dictionary<string, ClubMember> membersCollection = new Dictionary<string, ClubMember>();
     Dictionary<string, string> bICDictionary = new Dictionary<string, string>();
     foreach (var row in membersTable.Rows)
     {
         BankAccount memberAccount = new BankAccount(new ClientAccountCodeCCC((string)row["Account"]));
         bICDictionary.Add(memberAccount.BankAccountFieldCodes.BankCode, row["BIC"]);
         ClubMember clubMember = new ClubMember(
             row["MemberID"],
             row["Name"],
             row["FirstSurname"],
             row["SecondSurname"]);
         DateTime mandateCreationDate = new DateTime(2009, 10, 30);
         int directDebitReferenceNumber = int.Parse(row["Reference"]);
         DirectDebitMandate directDebitMandate = new DirectDebitMandate(
             directDebitReferenceNumber,
             mandateCreationDate,
             memberAccount,
             clubMember.FullName);
         clubMember.AddDirectDebitMandate(directDebitMandate);
         membersCollection.Add(clubMember.MemberID, clubMember);
     }
     ScenarioContext.Current.Add("BICDictionary", bICDictionary);
     ScenarioContext.Current.Add("Members", membersCollection);
 }
 public void GivenMyDirectDebitInitiationContractIs(Table contractTable)
 {
     Creditor creditor = new Creditor(contractTable.Rows[0]["NIF"], contractTable.Rows[0]["Name"]);
     BankCode creditorAgentBankCode = new BankCode(
         contractTable.Rows[0]["LocalBankCode"],
         contractTable.Rows[0]["CreditorAgentName"],
         contractTable.Rows[0]["BIC"]);
     CreditorAgent creditorAgent = new CreditorAgent(creditorAgentBankCode);
     BankAccount creditorAccount = new BankAccount(new InternationalAccountBankNumberIBAN(contractTable.Rows[0]["CreditorAccount"]));
     string creditorBussinessCode = contractTable.Rows[0]["CreditorBussinesCode"];
     DirectDebitInitiationContract directDebitContract = new DirectDebitInitiationContract(
         creditorAccount,
         creditor.NIF,
         contractTable.Rows[0]["CreditorBussinesCode"],
         creditorAgent);
     ScenarioContext.Current.Add("Creditor", creditor);
     ScenarioContext.Current.Add("CreditorAgent", creditorAgent);
     ScenarioContext.Current.Add("DirectDebitInitiationContract", directDebitContract);
 }
 public BankAccountHistoricalData(BankAccount bankAccount, DateTime accountActivationDate, DateTime accountDeactivationDate)
 {
     this.bankAccount = bankAccount;
     this.accountActivationDate = accountActivationDate;
     this.accountDeactivationDate = accountDeactivationDate;
 }
 public void WhenTheBillIsPaidByDirectDebit()
 {
     Invoice invoice = (Invoice)ScenarioContext.Current["Invoice"];
     Bill bill = (Bill)ScenarioContext.Current["Bill"];
     int internalReferenceNumber = 2645;
     BankAccount bankAccount = new BankAccount(new ClientAccountCodeCCC("12345678061234567890"));
     DateTime directDebitMandateCreationDate = new DateTime(2013, 11, 11);
     string debtorname = membersManagementContextData.clubMember.FullName;
     DirectDebitMandate directDebitMandate = new DirectDebitMandate(internalReferenceNumber, directDebitMandateCreationDate, bankAccount, debtorname);
     string directDebitTransactionPaymentIdentification = "201311110000123456";
     DirectDebitPaymentMethod directDebitPaymentMethod = new DirectDebitPaymentMethod(directDebitMandate, directDebitTransactionPaymentIdentification);
     DateTime paymentDate = new DateTime(2013, 11, 11);
     Payment payment = new Payment(bill.Amount, paymentDate, directDebitPaymentMethod);
     billsManager.PayBill(invoice, bill, payment);
 }
 public void ChangeDirectDebitContractAccount(string creditorBussinessCode, BankAccount bankAccount)
 {
     DirectDebitInitiationContract contractToChange = directDebitInitiationContracts[creditorBussinessCode];
     contractToChange.ChangeCreditorBank(bankAccount);
 }
 public void AddingAnInvalidAccountDoesNotGenerateAValidIBAN()
 {
     BankAccountFields bankAccountFields = new BankAccountFields("1234", "5678", "05", "1234567890");
     BankAccount testAccount = new BankAccount(bankAccountFields);
     Assert.IsFalse(testAccount.HasValidIBAN);
 }