예제 #1
0
        public ActionResult SaveSaleInvoice(AmountModel model)
        {
            try
            {
                var product = Session["soldproductlist"] as List <SoldItems>;

                var UserInfo = (Dashboard.Models.UserInfo)Session["UserInfo"];

                var sale = productprovider.GenerateSale();
                product.ForEach(x => x.SaleId    = sale.Id);
                product.ForEach(x => x.CreatedOn = DateTime.Now);

                productprovider.SaveSoldItems(product);

                var ledgerForBuyer = BuildSaleLedger(sale.Id, model.InsertionTypeId, UserInfo.UserId, model.AmountIn, model.AmountOut, model.Balance, model.Total, model.AccountHolderId);
                ledgerProvider.SaveLedger(ledgerForBuyer);

                var trademarkaccountholder = productprovider.gettrademarakaccountholder(UserInfo.TrademarkID);

                var ledgerFortradeMark = BuildSaleLedger(sale.Id, model.InsertionTypeId, UserInfo.UserId, model.AmountOut, model.AmountIn, -model.Balance, model.Total, trademarkaccountholder.Id);
                ledgerProvider.SaveLedger(ledgerFortradeMark);
                Session["productlist"] = null;
                return(RedirectToAction("ShowPurchaseInvoice"));
            }

            catch (Exception ex)
            {
                return(View("Views/Product/Error.cshtml", ex.Message));
            }
        }