Ejemplo n.º 1
0
 public void RoundUP_Correct_3()
 {
     Assert.AreEqual(25.54, MoneyConversor.RoundUp(25.5350));
 }
Ejemplo n.º 2
0
        public ActionResult VendorAccountability(int AllocatedId, int VendorId, string QuantityReturned = "0", string TotalPaid = "0")
        {
            Users LoggedUser = Login.GetLoggedUser();
            if (LoggedUser == null)
            {
                return View("NoPermission");
            }
            if (LoggedUser.Role == Roles.Vendedor)
            {
                return View("NoPermission");
            }

            Users vendor = Users.ListVendors(LoggedUser).Find(i => i.Id == VendorId);
            ProductsAllocated product = ProductsAllocated.AlocatedProductsOnVendor(vendor).Find(i => i.Id == AllocatedId);
            #region Validation
            bool error = false;
            Validation vld = new Validation();
            vld.Amount(QuantityReturned, product.Amount);
            try
            {
                vld.Amount(QuantityReturned);

            }
            catch (Exception ex)
            {

                ViewBag.QuantityError = ex.Message;
                error = true;
            }
            try
            {
                vld.Amount(TotalPaid);

            }
            catch (Exception ex)
            {

                ViewBag.TotalPaidError = ex.Message;
                error = true;
            }
            try
            {
                vld.Amount(TotalPaid, product.Amount);
            }
            catch (Exception ex)
            {

                ViewBag.TotalPaidError = ex.Message;
                error = true;
            }
            #endregion Validation

            ViewBag.Vendors = Users.ListVendors(LoggedUser);
            ViewBag.SelectedVendor = vendor;
            if (product.Amount - (Convert.ToInt32(QuantityReturned) + Convert.ToInt32(TotalPaid)) >= 0 && !error)
            {
                product.Amount -= (Convert.ToInt32(TotalPaid) + (Convert.ToInt32(QuantityReturned)));
                product.Product.Amount += Convert.ToInt32(QuantityReturned);
                product.Update();
                Charges charge = new Charges()
                {
                    Amount = Convert.ToInt32(TotalPaid),
                    Client = LoggedUser,
                    Data = DateTime.Now,
                    Products = product.Product,
                    Type = Models.ChargesExtensions.ChargesTypes.Venda,
                    Value = MoneyConversor.RoundUp((MoneyConversor.RemoveComission(product.Price * Convert.ToInt32(TotalPaid), product.Commision))),
                    Vendor = vendor
                };
                charge.Save();
                ViewBag.Save = "Salvo com sucesso";
                return View("AccountabilityPerVendor");
            }
            ViewBag.vendorId = VendorId;
            ViewBag.Product = product;
            ViewBag.error = error;
            return View("AccountabilityPerVendor");

        }