Example #1
0
 public AG_ROOT_Cont(IBAN iban, Client client, Suma sold)
 {
     this.iban    = iban;
     this.sold    = sold;
     this.istoric = new Tranzactii();
     this.client  = client;
 }
Example #2
0
        public List <AG_ROOT_Cont> PlatesteFactura(Suma sum, IBAN catre, List <AG_ROOT_Cont> conturi)
        {
            if (this.Sold.getSuma - sum.getSuma >= 0)
            {
                //ia banii din contul celui care transfera
                Tranzactie tranzactie = new Tranzactie(new ID(IstoricTranzactii.getTranzactii.Count()), catre, TipTranzactie.Factura);
                Contract.Requires <ArgumentException>(!tranzactie.Suma.getSuma.Equals(new Suma(0.0)), "suma sa fie !=0");
                tranzactie.SetSumaTranzactionata(sum);
                this.sold.getSuma -= tranzactie.Suma.getSuma;
                this.IstoricTranzactii.AdaugaTranzactie(tranzactie);

                //depune in contul altuia, update contul impactat!!
                int indexDest = GasesteDestinatarul(catre, conturi);
                if (indexDest != -1)
                {
                    AG_ROOT_Cont destinatar = conturi.ElementAt(indexDest);
                    destinatar.sold.getSuma += tranzactie.Suma.getSuma;
                    Tranzactie tranzactie2 = new Tranzactie(new ID(destinatar.IstoricTranzactii.getTranzactii.Count()), this.iban, TipTranzactie.Depunere);
                    tranzactie2.SetSumaTranzactionata(sum);
                    destinatar.IstoricTranzactii.AdaugaTranzactie(tranzactie2);
                    Console.WriteLine("Clientul: " + this.DateClient.Nume + " a platit o factura de " + sum.getSuma + " lei in contul lui " + destinatar.DateClient.Nume);
                    return(conturi); //returneaza lista de conturi cu informatiile updatate
                }
                else
                {
                    throw new AccountNotFoundException();
                }
            }
            else
            {
                throw new InsufficientFundsException();
            }
        }
Example #3
0
 public AG_ROOT_Cont(IBAN iban, Client client)
 {
     this.iban    = iban;
     this.sold    = new Suma(0.0); //incepe de la 0
     this.istoric = new Tranzactii();
     this.client  = client;
 }
Example #4
0
        public void LaCuentaEsValida()
        {
            string CuentaBanco = "00492352082414205416";

            IBAN.esUnCCValido(CuentaBanco);
            Assert.IsTrue(IBAN.esUnCCValido(CuentaBanco));
        }
Example #5
0
        public void ElMetodoParaDividirElIBANLoDivideCorrectamente()
        {
            string CC = "20852066223456789011142800";

            string[] ccDividido = IBAN.dividirIBAN(CC);

            Assert.AreEqual(5, ccDividido.Length);
        }
Example #6
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         return(IBAN.Format(value as string));
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Example #7
0
 public Tranzactie(ID id, IBAN partenerTranzactie, TipTranzactie tip, Suma suma)
 {
     this.id = id;
     this.partenerTranzactie = partenerTranzactie;
     this.tip  = tip;
     this.data = DateTime.Now;
     this.suma = suma;
 }
Example #8
0
 public Tranzactie(ID id, IBAN partenerTranzactie, TipTranzactie tip)
 {
     this.id = id;
     this.partenerTranzactie = partenerTranzactie;
     this.tip  = tip;
     this.data = DateTime.Now;
     suma      = new Suma(0.0); //se va seta apoi
 }
Example #9
0
        public void DevolverErrorCuandoNoHayValor()
        {
            string valor = string.Empty;
            IBAN   iban  = new IBAN();

            bool resultado = iban.EsIBANvalido(valor);

            Assert.AreEqual(false, resultado);
        }
Example #10
0
        public void DevuelveTrueCuandoEsValorCorrecto()
        {
            string valor = "ES6621000418401234567891";
            IBAN   iban  = new IBAN();

            bool resultado = iban.EsIBANvalido(valor);

            Assert.AreEqual(true, resultado);
        }
Example #11
0
        public void ElDigitoDeControlSeCalculaCorrectamente()
        {
            int acumulador1 = 6;    //debe devolver 11 - el numero insertado (5)
            int acumulador2 = 10;   // debe devolver 1
            int acumulador3 = 11;   // debe devolver 0

            Assert.AreEqual("5", IBAN.CalculoAculmulador(acumulador1));
            Assert.AreEqual("1", IBAN.CalculoAculmulador(acumulador2));
            Assert.AreEqual("0", IBAN.CalculoAculmulador(acumulador3));
        }
Example #12
0
 /// <summary>
 /// Binds to entity.
 /// </summary>
 /// <param name="data"></param>
 protected override void BindToEntity(BankaUcetCis data)
 {
     data.Nazov      = Nazov;
     data.Kod        = Kod;
     data.IBAN       = IBAN?.Replace(" ", "");
     data.BIC        = BIC;
     data.Poradie    = Poradie;
     data.PlatnostOd = PlatnostOd;
     data.PlatnostDo = PlatnostDo;
     data.C_Mena_Id  = C_Mena_Id;
 }
        public void iban_is_valid(string identification)
        {
            // Arrange
            IBAN iban = new IBAN(identification);

            // Act

            // Assert
            Assert.That(iban.IsValid, Is.True);
            Assert.That(iban.ElectronicVersion, Is.Not.Null);
            Assert.That(iban.PaperVersion, Is.Not.Null);
        }
Example #14
0
        private int GasesteDestinatarul(IBAN iban, List <AG_ROOT_Cont> conturi)
        {
            foreach (AG_ROOT_Cont c in conturi)
            {
                if (c.IBAN.Equals(iban))
                {
                    return(conturi.IndexOf(c));
                }
            }

            return(-1);
        }
Example #15
0
        static void Main(string[] args)
        {
            IBAN ibanThatIsPalindrome = new IBAN();

            ibanThatIsPalindrome.SetIBAN("RO41RZBR1234567887654321");
            IBAN ibanThatIsNotPalindrome = new IBAN();

            ibanThatIsNotPalindrome.SetIBAN("RO41RZBR1764567821546321");

            Console.WriteLine(ibanThatIsPalindrome.IsPalindrome());
            Console.WriteLine(ibanThatIsNotPalindrome.IsPalindrome());
        }
        public string check_paperversion(string identification)
        {
            // Arrange
            IBAN bban = new IBAN(identification);

            // Act

            // Assert
            Assert.That(bban.IsValid, Is.True);
            Assert.That(bban.ElectronicVersion, Is.Not.Null);
            return(bban.PaperVersion);
        }
Example #17
0
        public void bban_can_not_convert_invalid_identifications_to_iban(string identification)
        {
            // Arrange
            BBAN bban = new BBAN(identification);

            Assert.That(bban.IsValid, Is.False);

            // Act
            IBAN actual = bban.AsIBAN;

            // Assert
            Assert.That(actual, Is.Null);
        }
        public void iban_can_not_convert_invalid_identifications_to_bban(string identification)
        {
            // Arrange
            IBAN iban = new IBAN(identification);

            Assert.That(iban.IsValid, Is.False);

            // Act
            BBAN actual = iban.AsBBAN;

            // Assert
            Assert.That(actual, Is.Null);
        }
Example #19
0
        public void AlValidarIBANConFormatoIncorrectoSaltaExcepcion()
        {
            try
            {
                string iban = "ESgM12345678101023749586";

                IBAN.ValidarIBAN(iban);
                Assert.Fail("Formato de los numeros de control del IBAN incorrecto");
            }
            catch (NumerosControlIBANFormatoIncorrectoException)
            {
                //algo
            }
        }
Example #20
0
        public void ElCCTieneUnformatoIncorrecto()
        {
            try
            {
                string CC = "12345j6789001234h56h";

                IBAN.ValidarCC(CC);
                Assert.Fail("Formato mal");
            }
            catch (ParametroFormatoIncorrecto)
            {
                //algo
            }
        }
Example #21
0
        public void ElCCNoTieneLaLongitudCorrecta()
        {
            try
            {
                string CC = "123458001234567890";

                IBAN.ValidarCC(CC);
                Assert.Fail("Longitud Incorrecta");
            }
            catch (LongitudIncorrectaException)
            {
                //algo
            }
        }
Example #22
0
        public void LaCuentaNoTieneLongitudValida()
        {
            try
            {
                string CuentaBanco = "92352082414205416";

                IBAN.esUnCCValido(CuentaBanco);
                Assert.Fail("Numero Incorrecto");
            }
            catch (LongitudIncorrectaException)
            {
                //Tiene que fallar la longitud de la cuenta
            }
        }
        public void iban_is_strict_valid(string identification)
        {
            // Arrange
            IBAN iban = new IBAN(identification);

            // Act

            // Assert
            Assert.That(iban.IsValid, Is.True);
            Assert.That(iban.IsStrictValid, Is.True);
            Assert.That(iban.ElectronicVersion, Is.EqualTo(iban.CleanedVersion));
            Assert.That(iban.ElectronicVersion, Is.EqualTo(iban.RawVersion));
            Assert.That(iban.PaperVersion, Is.Not.Null);
        }
Example #24
0
        public void AlIntroducirCaracterIncorrectoFalla()
        {
            try
            {
                string CuentaBanco = "P0492352082414205416";

                IBAN.esUnCCValido(CuentaBanco);
                Assert.Fail("Caracter no Válido");
            }
            catch (ParametroFormatoIncorrecto)
            {
                //Tiene que fallar por meterle un caracter incorrecto
            }
        }
Example #25
0
        public void AlValidarIBANNoEspanolSaltaExcepcion()
        {
            try
            {
                string iban = "FR0212345678101023749586";

                IBAN.ValidarIBAN(iban);
                Assert.Fail("iban no español");
            }
            catch (IbanNoEspanolExeption)
            {
                //algo
            }
        }
        public void iban_can_convert_valid_BE_identifications_to_bban(string identification)
        {
            // Arrange
            IBAN iban = new IBAN(identification);

            Assert.That(iban.IsValid, Is.True);

            // Act
            BBAN actual = iban.AsBBAN;

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.IsValid, Is.True);
            Assert.That(actual.IsStrictValid, Is.True);
        }
Example #27
0
 public async Task CreateValueObjectUser(IFormCollection form)
 {
     try { this._name = new Text(form["strName"]); } catch { }
     try{ this._surename = new Text(form["strSurename"]); } catch { }
     try{ this._username = new Text(form["strUsername"]); }catch { }
     try{ this._password = new Text(CryptoManager.ComputeSha256Hash(form["strPassword"])); }catch { }
     try{ this._cnp = new CNP(new Text(form["strCNP"])); }catch { }
     try{ this._iban = new IBAN(new Text(form["strIBAN"])); }catch { }
     try{ this._emailAddress = new EmailAddress(new Text(form["strEmail"])); }catch { }
     try{ if (this._iban != null)
          {
              this._bankAccount = new BankAccount(this._iban, 0);
          }
     }catch { }
 }
Example #28
0
        public async Task UpdateValueObjectUser(IFormCollection form)
        {
            try { this._name = new Text(form["strName"]); } catch { }
            try { this._surename = new Text(form["strSurename"]); } catch { }


            try { this._cnp = new CNP(new Text(form["strCNP"])); } catch { }
            try { this._iban = new IBAN(new Text(form["strIBAN"])); } catch { }

            try { if (this._iban != null)
                  {
                      this._bankAccount = new BankAccount(this._iban, 0);
                  }
            } catch { }
        }
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Virtual Bank Barcode Generator");
                Console.WriteLine("Creates Finnish virtual bank barcode");
                Console.WriteLine("Either national or internation reference can be used");

                Console.Write("\nEnter IBAN: ");
                string ibanInput = Console.ReadLine();
                IBAN   iban      = IBAN.Parse(ibanInput);

                Console.Write("Enter reference: ");
                string        referenceInput = Console.ReadLine();
                BankReference reference      = ReferenceCreator.SelectReference(referenceInput);

                Console.Write("Enter sum: ");
                string  sumInput = Console.ReadLine();
                decimal sum      = decimal.Parse(sumInput);

                Console.Write("Enter due date (DD.MM.YYYY): ");
                string   dateInput = Console.ReadLine();
                DateTime date      = DateTime.Parse(dateInput);

                Console.WriteLine("\nIBAN: {0}", iban.ToString());
                Console.WriteLine("Reference: {0}", reference.ToString());
                Console.WriteLine("Sum: {0} EUR", sum.ToString("F2"));
                Console.WriteLine("Date: {0}", date.ToString("dd.MM.yyyy"));

                BankBarcode barcode = new BankBarcode(iban, reference, sum, date);
                Console.WriteLine("\nVirtual barcode: {0}", barcode.ToString());
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(String.Format("\n{0}", e.Message));
            }
            catch (Exception)
            {
                Console.WriteLine("\nInvalid input!");
            }
            Console.WriteLine("\nPress Enter to exit!");
            Console.ReadLine();
        }
Example #30
0
        public bool Check(string IBAN)
        {
            try
            {
                var client = new RestClient(string.Format("https://openiban.com/validate/{0}", IBAN));
                client.Timeout = -1;
                var           request  = new RestRequest(Method.GET);
                IRestResponse response = client.Execute(request);

                IBAN myDeserializedIBAN = JsonConvert.DeserializeObject <IBAN>(response.Content);

                return(myDeserializedIBAN.valid);
            }
            catch (Exception ex)
            {
                Logger.log(string.Format("CheckIBAN.Check(): {0}", ex.Message));
                throw ex;
            }
        }