Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("PayExpenseId,ProductId,ExpenseId,Description,Amount,Tax,PayExpenseDate")] PayExpense payExpense)
        {
            if (ModelState.IsValid)
            {
                payExpense.Product = await _context.Product.SingleOrDefaultAsync(p => p.ProductId == payExpense.ProductId);

                payExpense.Expense = await _context.Expense.SingleOrDefaultAsync(e => e.ExpenseId == payExpense.ExpenseId);

                if (payExpense.Product.Balance < (payExpense.Amount + payExpense.Tax))
                {
                    CreateInitial(payExpense.ProductId, payExpense.ExpenseId);
                    ModelState.AddModelError("", "Balance de Producto origen insuficiente.");
                    return(View(payExpense));
                }

                FunctionsConvert functionsConvert = new FunctionsConvert(_context);
                var _payExpense = functionsConvert.ConvertCurrency(payExpense, 0, 0);

                //restar el balance del producto origen
                payExpense.Product.Balance = payExpense.Product.Balance - _payExpense.Amount - _payExpense.Tax;

                payExpense.StatusPayExpense = Models.Enum.StatusCashFlow.Activo;
                payExpense.CreatedDate      = DateTime.Today;
                _context.Add(payExpense);
                //_context.Update(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            CreateInitial(payExpense.ProductId, payExpense.ExpenseId);
            return(View(payExpense));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("BankId,Description,Country,StatusBank")] Bank bank)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bank);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bank));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("CurrencyId,Description,StatusCurrency")] Currency currency)
        {
            if (ModelState.IsValid)
            {
                _context.Add(currency);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(currency));
        }
        public async Task <IActionResult> Create([Bind("ReminderTypeId,Description,RecurrenceHour,RecurrenceDay,RecurrenceMonth,RecurrenceYear")] ReminderType reminderType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(reminderType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(reminderType));
        }
        public async Task <IActionResult> Create([Bind("CurrencyConvertId,Multiple,CurrencyFromCurrencyId,CurrencyToCurrencyId,DateValidFrom,DateValidTo,StatusCurrency")] CurrencyConvert currencyConvert)
        {
            if (ModelState.IsValid)
            {
                _context.Add(currencyConvert);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CurrencyFromCurrencyId"] = new SelectList(_context.Currency, "CurrencyId", "Description", currencyConvert.CurrencyFromCurrencyId);
            ViewData["CurrencyToCurrencyId"]   = new SelectList(_context.Currency, "CurrencyId", "Description", currencyConvert.CurrencyToCurrencyId);
            return(View(currencyConvert));
        }
        public async Task <IActionResult> Create([Bind("PaymentReminderId,ReminderTypeId,ProductId,ExpenseId,StartDate,StartTime,EndDate,EndTime,StatusPaymentReminder")] PaymentReminder paymentReminder)
        {
            if (ModelState.IsValid)
            {
                paymentReminder.CreatedDate           = DateTime.Today;
                paymentReminder.StatusPaymentReminder = Models.Enum.StatusPaymentReminder.Activo;
                _context.Add(paymentReminder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ExpenseId"]      = new SelectList(_context.Expense, "ExpenseId", "Description", paymentReminder.ExpenseId);
            ViewData["ProductId"]      = new SelectList(_context.Product, "ProductId", "Alias", paymentReminder.ProductId);
            ViewData["ReminderTypeId"] = new SelectList(_context.ReminderType, "ReminderTypeId", "Description", paymentReminder.ReminderTypeId);
            return(View(paymentReminder));
        }
        public async Task <IActionResult> Create([Bind("CreditCardCutId,ProductId,PayDayCut,PayDayLimit,AmountCut")] CreditCardCut creditCardCut)
        {
            if (ModelState.IsValid)
            {
                creditCardCut.AmountPayment = 0;
                creditCardCut.AmountPending = creditCardCut.AmountCut;

                creditCardCut.CreatedDate = DateTime.Now;

                _context.Add(creditCardCut);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Alias", creditCardCut.ProductId);
            return(View(creditCardCut));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("ExpenseId,ExpenseTypeId,Description,CurrencyId,Amount,CutDay,PayDayLimit")] Expense expense)
        {
            if (ModelState.IsValid)
            {
                expense.CreatedDate   = DateTime.Today;
                expense.StatusExpense = Models.Enum.StatusExpense.Activo;
                var _user = await _userManager.GetUserAsync(User);

                expense.UserId = _user.Id;

                _context.Add(expense);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CurrencyId"] = new SelectList(_context.Currency, "CurrencyId", "Description", expense.CurrencyId);
            return(View(expense));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("CashOutcomeId,ProductId,Description,Amount,OutcomeDate")] CashOutcome cashOutcome)
        {
            if (ModelState.IsValid)
            {
                cashOutcome.Product = await _context.Product.SingleOrDefaultAsync(p => p.ProductId == cashOutcome.ProductId);

                //product.Balance = product.Balance - cashOutcome.Amount;
                cashOutcome.Product.Balance = cashOutcome.Product.Balance - cashOutcome.Amount;

                cashOutcome.CreatedDate   = DateTime.Today;
                cashOutcome.StatusOutcome = Models.Enum.StatusCashFlow.Activo;
                _context.Add(cashOutcome);
                //_context.Update(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            CreateInitial(cashOutcome.ProductId);
            return(View(cashOutcome));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("ProductId,ProductTypeId,Number,Alias,BankId,CurrencyId,TotalAmount,Balance,OpeningDate,CutDay,DaysToPayCut")] Product product)
        {
            if (ModelState.IsValid)
            {
                product.CreatedDate   = DateTime.Now;
                product.UpdatedDate   = DateTime.Now;
                product.StatusProduct = Models.Enum.StatusProduct.Activo;

                var user = await _userManager.GetUserAsync(User);

                product.UserId = user.Id;

                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BankId"]     = new SelectList(_context.Banks, "BankId", "Description", product.BankId);
            ViewData["CurrencyId"] = new SelectList(_context.Currency, "CurrencyId", "Description", product.CurrencyId);
            return(View(product));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("PayProductId,ProductIdFrom,ProductIdTo,CreditCardCutId,Description,Amount,Tax,PayProductDate")] PayProduct payProduct)
        {
            if (ModelState.IsValid)
            {
                payProduct.ProductFrom = await _context.Product.SingleOrDefaultAsync(p => p.ProductId == payProduct.ProductIdFrom);

                payProduct.ProductTo = await _context.Product.SingleOrDefaultAsync(p => p.ProductId == payProduct.ProductIdTo);

                payProduct.CreditCardCut = await _context.CreditCardCut.SingleOrDefaultAsync(p => p.CreditCardCutId == payProduct.CreditCardCutId);

                if (payProduct.ProductFrom.Balance < (payProduct.Amount + payProduct.Tax))
                {
                    CreateInitial(payProduct.ProductIdFrom, payProduct.ProductIdTo, payProduct.CreditCardCutId);
                    ModelState.AddModelError("", "Balance de Producto origen insuficiente.");
                    return(View(payProduct));
                }
                FunctionsConvert functionsConvert = new FunctionsConvert(_context);
                var _payProduct = functionsConvert.ConvertCurrency(payProduct, 0, 0);

                //restar el balance del producto origen
                payProduct.ProductFrom.Balance = payProduct.ProductFrom.Balance - payProduct.Amount - payProduct.Tax;

                //sumar al balance a la tc destino
                payProduct.ProductTo.Balance = payProduct.ProductTo.Balance + payProduct.Amount;

                //actualizar corte de tarjeta
                payProduct.CreditCardCut.AmountPayment = payProduct.CreditCardCut.AmountPayment + payProduct.Amount;
                payProduct.CreditCardCut.AmountPending = payProduct.CreditCardCut.AmountPending - payProduct.Amount;

                payProduct.CreatedDate      = DateTime.Today;
                payProduct.StatusPayProduct = Models.Enum.StatusPayment.Activo;
                _context.Add(payProduct);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            CreateInitial(payProduct.ProductIdFrom, payProduct.ProductIdTo, payProduct.CreditCardCutId);
            return(View(payProduct));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("PayProductId,ProductIdFrom,ProductIdTo,Description,Amount,Tax,PayProductDate")] PayProduct payProduct)
        {
            if (ModelState.IsValid)
            {
                payProduct.ProductFrom = await _context.Product.SingleOrDefaultAsync(p => p.ProductId == payProduct.ProductIdFrom);

                payProduct.ProductTo = await _context.Product.SingleOrDefaultAsync(p => p.ProductId == payProduct.ProductIdTo);

                if (payProduct.ProductFrom.Balance < (payProduct.Amount + payProduct.Tax))
                {
                    CreateInitial(payProduct.ProductIdFrom, payProduct.ProductIdTo);
                    ModelState.AddModelError("", "Balance de Producto origen insuficiente.");
                    return(View(payProduct));
                }

                FunctionsConvert functionsConvert = new FunctionsConvert(_context);
                var _payProduct = functionsConvert.ConvertCurrency(payProduct, 0, 0);

                //restar el balance del producto origen
                payProduct.ProductFrom.Balance = payProduct.ProductFrom.Balance - _payProduct.Amount - _payProduct.Tax;

                //sumar al balance del prestamo destino, pero convertir antes si hay diferencia de monedas
                payProduct.ProductTo.Balance = payProduct.ProductTo.Balance - payProduct.Amount;

                //ver como trabajar con los intereses y capital del prestamo

                payProduct.StatusPayProduct = Models.Enum.StatusPayment.Activo;
                payProduct.CreatedDate      = DateTime.Today;
                _context.Add(payProduct);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            CreateInitial(payProduct.ProductIdFrom, payProduct.ProductIdTo);
            return(View(payProduct));
        }