Exemple #1
0
 public bankslipShort(bankslip _bankslip)
 {
     this.Id             = _bankslip.Id;
     this.due_date       = _bankslip.due_date;
     this.total_in_cents = _bankslip.total_in_cents;
     this.customer       = _bankslip.customer;
     this.status         = _bankslip.status;
 }
Exemple #2
0
        public void Teste_Add_Boleto()
        {
            var boleto = new bankslip.Models.bankslip()
            {
                due_date       = new DateTime(2018, 12, 20),
                customer       = "Felipe Tibério de Oliveira",
                total_in_cents = 40005
            };
            var controller = new BankslipsController(new bankslipService());
            var result     = controller.Post(boleto);

            Assert.IsNotNull(result);
            ObjectResult objResult = result as ObjectResult;

            Assert.IsNotNull(objResult);
            Assert.AreEqual(201, (int)objResult.StatusCode);
        }
Exemple #3
0
        private static void AplicaRegraJuros(ref bankslip boleto)
        {
            if (boleto.status != Status.CANCELED && boleto.status != Status.PAID)
            {
                var diasDiff   = (DateTime.Now - boleto.due_date).Days;
                var totalJuros = 0m;
                if (diasDiff >= 10)
                {
                    totalJuros = boleto.total_in_cents * Convert.ToDecimal(diasDiff * 0.01);
                }

                if (diasDiff >= 1 && diasDiff < 10)
                {
                    totalJuros = boleto.total_in_cents * Convert.ToDecimal(diasDiff * 0.005);
                }

                boleto.fine         = totalJuros;
                boleto.payment_date = DateTime.Now.Date;
            }
        }
Exemple #4
0
 public static bankslipShort CriarBoleto(bankslip bankslip)
 {
     try
     {
         var _bankslip = bankslip;
         _bankslip.Id           = Guid.NewGuid();
         _bankslip.status       = Status.PENDING;
         _bankslip.payment_date = DateTime.MinValue;
         using (var db = new DataBase())
         {
             db.Bankslip.Add(_bankslip);
             db.SaveChanges();
         }
         return(new bankslipShort(_bankslip));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #5
0
 public static void PagaBoleto(string id, ref bankslip bankslip)
 {
     try
     {
         var boleto = new bankslip();
         var _id    = new Guid(id);
         using (var db = new DataBase())
         {
             boleto              = db.Bankslip.SingleOrDefault(x => x.Id == _id);
             boleto.status       = Status.PAID;
             boleto.payment_date = bankslip.payment_date;
             db.SaveChanges();
             bankslip = boleto;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #6
0
 public static void CancelaBoleto(string id)
 {
     try
     {
         var boleto = new bankslip();
         var _id    = new Guid(id);
         using (var db = new DataBase())
         {
             boleto = db.Bankslip.SingleOrDefault(x => x.Id == _id);
             if (boleto == null)
             {
                 throw new Exception("bankslip not found!");
             }
             boleto.status = Status.CANCELED;
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }