Ejemplo n.º 1
0
        public object BillPayment(BranchesBillDateRangeViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Response.RenderError(ModelState));
                }
                List <BranchIdList> _items = new List <BranchIdList>();
                foreach (var branch in model.BranchIdList)
                {
                    BranchIdList _b = new BranchIdList
                    {
                        BranchId = branch
                    };
                    _items.Add(_b);
                }
                ReqReconcile _line = new ReqReconcile
                {
                    DateFrom = DateTime.ParseExact(model.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US")).ToString("yyyyMMdd"),
                    DateTo   = DateTime.ParseExact(model.DateTo, "dd/MM/yyyy", new CultureInfo("en-US")).ToString("yyyyMMdd"),
                    //DateTo = DateTime.Parse(model.DateTo, new CultureInfo("en-US")).ToString("yyyyMMdd"),
                    BranchIdList = _items
                };

                string       json      = JsonConvert.SerializeObject(_line);
                SqlParameter jsonInput = new SqlParameter()
                {
                    ParameterName = "@jsonreq",
                    SqlDbType     = SqlDbType.NVarChar,
                    SqlValue      = json,
                    Size          = int.MaxValue
                };

                SqlParameter jsonOutput = new SqlParameter()
                {
                    ParameterName = "@jsonOutput",
                    SqlDbType     = SqlDbType.NVarChar,
                    Direction     = ParameterDirection.Output,
                    Size          = int.MaxValue
                };

                List <DailyRevenueReconcileBillPayment> dailyRevenueReconcile = DB.DailyRevenueReconcileBillPayment
                                                                                .FromSql(
                    "EXEC sp_PDC_Report_DailyRevenueReconcileBillPayment_Get {0}, {1}, {2}, {3}, {4}"
                    ).ToList();
                DB.Database.ExecuteSqlCommand(" sp_PDC_Reconcile_Report_DailyRevenue_Bill_Payment_Verify_Summary @jsonreq, @jsonOutput OUTPUT ", jsonInput, jsonOutput);
                //JObject dd = JObject.Parse("[" + jsonOutput.Value.ToString() + "]");
                List <SumMatching> RevenueData = JsonConvert.DeserializeObject <List <SumMatching> >("[" + jsonOutput.Value.ToString() + "]");
                //0 Unmatch, 1 Match, 2 Not found data


                Response.Success = true;
                Response.Result  = RevenueData;

                //Response.ResultInfo = new
                //{
                //    page = model.Page,
                //    perPage = model.PerPage,
                //    count = _line
                //};

                DB.Dispose();

                return(Response.Render());
            }
            catch (Exception ex)
            {
                return(Response.RenderError(ModelState));
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult branchStockStatusFilter(InputBranchStockStatusReportModel inputmodel)
        {
            List <string> BranchIdList;   // = new List<string>();
            List <string> ProductSKUList; // = new List<string>();
            List <string> StyleSKUList;   // = new List<string>();

            var moddel = getProcessingData(inputmodel, out BranchIdList, out ProductSKUList, out StyleSKUList);

            Dictionary <int, int>          branchlist = new Dictionary <int, int>();
            List <BranchStockStatusReport> result     = new List <BranchStockStatusReport>();
            var ProductList = db.Products.Where(x => x.IsActive == true && x.StockInventories.Any(y => y.IsActive ?? false) == true && x.StockBranchInventories.Any(y => y.IsActive ?? false) == true)

                              .Include(i => i.Color)
                              .Include(i => i.Template1)
                              .Include(i => i.StockInventories)
                              .Include(i => i.StockBranchInventories)
                              .Include(i => i.StockBranchInventories.Select(y => y.Branch))
                              //.ToList()
            ;
            var ptemp = ProductList.ToList();

            if (ProductSKUList.Count > 0)
            {
                ProductList = ProductList.Where(x => ProductSKUList.Contains(x.ProductSKU));
                ptemp       = ProductList.ToList();
            }
            if (StyleSKUList.Count > 0)
            {
                ProductList = ProductList.Where(x => StyleSKUList.Contains(x.StyleSKU));
                ptemp       = ProductList.ToList();
            }

            var products         = ProductList.ToList();
            var branchSearchlist = db.Branches.Where(x => x.IsActive == true);
            var btemp            = branchSearchlist.ToList();

            if (BranchIdList.Count > 0)
            {
                branchSearchlist = branchSearchlist.Where(x => BranchIdList.Contains(x.BranchCode));
                btemp            = branchSearchlist.ToList();
            }


            var branches = branchSearchlist.OrderBy(o => o.Id).ToList();

            branches.ForEach(x => branchlist.Add(x.Id, 0));

            var modellist = products.Where(x => x.StockBranchInventories != null && x.StockBranchInventories.Count > 0).ToList();

            foreach (var item in modellist)
            {
                Dictionary <int, int>   branch = new Dictionary <int, int>();
                BranchStockStatusReport model  = new BranchStockStatusReport();
                var Branches = item.StockBranchInventories.Where(x => x.Branch.IsActive == true).Select(s => s.Branch).ToList();

                model.Product       = item.ProductSKU + " " + item.StyleSKU + " " + item.ShortDescription;
                model.Color         = item.Color?.Code + " " + item.Color?.ColorShort;
                model.CostPrice     = item.CostPrice ?? 0;
                model.OriginalPrice = item.ActualSellingPrice ?? 0;
                var sumQunatity  = SumQuantityInventory(item.StockBranchInventories.ToList(), out branch);
                var sumQuantity2 = SumQuantityInventory(item.StockInventories.ToList());
                model.TotalQuantiy      = sumQunatity + sumQuantity2;
                model.WarehoustQuantity = sumQuantity2;
                model.MarkdownTemplate  = item.Template1?.Name;
                model.BranchId          = new Dictionary <int, int>();
                foreach (var bran in branchlist)
                {
                    if (branch.ContainsKey(bran.Key))
                    {
                        var value = branch[bran.Key];
                        model.BranchId.Add(bran.Key, value);
                    }
                    else
                    {
                        model.BranchId.Add(bran.Key, bran.Value);
                    }
                }

                // model.TotalQuantiy = "";
                result.Add(model);
            }
            return(Ok(result));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> DiscountReport(ReqDiscount ReqDiscount, string FileType)
        {
            try
            {
                string[] lines = ReqDiscount.BranchList.Split(",");

                Pagination pagination = new Pagination(HttpContext);


                string filetype = (FileType ?? "").ToLower();

                DateTime DateTo   = DateTime.ParseExact(ReqDiscount.DateTo, "dd/MM/yyyy", new CultureInfo("en-US"));
                DateTime DateFrom = DateTime.ParseExact(ReqDiscount.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US"));
                if (filetype.Equals("excel"))
                {
                    return(ExportExcelDiscountReport(ReqDiscount, DateTo, DateFrom));
                }
                List <BranchIdList> _items = new List <BranchIdList>();
                foreach (var branch in lines)
                {
                    BranchIdList _b = new BranchIdList
                    {
                        BranchId = branch.ToString()
                    };
                    _items.Add(_b);
                }
                List <DiscountTypeList> _Dis = new List <DiscountTypeList>();
                foreach (var DiscountType in ReqDiscount.DiscountTypeList)
                {
                    DiscountTypeList _d = new DiscountTypeList
                    {
                        DiscountType = DiscountType.ToString()
                    };
                    _Dis.Add(_d);
                }

                ReqDiscountType DiscountTypeList = new ReqDiscountType
                {
                    DateFrom         = DateFrom.ToString("yyyyMMdd"),
                    DateTo           = DateTo.ToString("yyyyMMdd"),
                    BranchIdList     = _items,
                    DiscountTypeList = _Dis
                };

                string       json      = JsonConvert.SerializeObject(DiscountTypeList);
                SqlParameter jsonInput = new SqlParameter()
                {
                    ParameterName = "@jsonreq",
                    SqlDbType     = SqlDbType.NVarChar,
                    SqlValue      = json,
                    Size          = int.MaxValue
                };

                SqlParameter jsonOutput = new SqlParameter()
                {
                    ParameterName = "@jsonOutput",
                    SqlDbType     = SqlDbType.NVarChar,
                    Direction     = ParameterDirection.Output,
                    Size          = int.MaxValue
                };



                DB.Database.ExecuteSqlCommand(" sp_PDC_Discount_Report_Detail @jsonreq, @jsonOutput OUTPUT ", jsonInput, jsonOutput);
                var data = jsonOutput.Value.ToString();
                if (data == "" || data == null)
                {
                    Response.Success    = false;
                    Response.Result     = DiscountTypeList;
                    Response.ResultInfo = new
                    {
                        page       = pagination.Page,
                        perPage    = pagination.PerPage,
                        count      = 0,
                        totalCount = 0
                    };
                    return(Json(Response.Render()));
                }
                //JObject dd = JObject.Parse("[" + jsonOutput.Value.ToString() + "]");
                ResResultDiscount Discount = JsonConvert.DeserializeObject <ResResultDiscount>(jsonOutput.Value.ToString());

                //GlobalVal._listDiscount = Discount;

                List <DiscountModel> disc = new List <DiscountModel>();
                foreach (var item in Discount.Result)
                {
                    DiscountModel dc = new DiscountModel
                    {
                        BranchType     = item.BranchType,
                        ERPID          = item.ERPID,
                        BranchId       = item.BranchId,
                        ReceiptNo      = item.ReceiptNo,
                        ReceiptDate    = item.ReceiptDate,
                        MemberId       = item.MemberId,
                        SenderName     = item.SenderName,
                        SenderMobile   = item.SenderMobile,
                        DiscountCode   = item.DiscountCode,
                        DiscountType   = item.DiscountType,
                        Surcharge      = item.Surcharge,
                        DiscountAmount = item.DiscountAmount
                    };
                    disc.Add(dc);
                }

                GlobalVal._listDiscount = disc;

                int totalCount = Discount.Result.Count();

                var _discount = Discount.Result.Skip(pagination.From()).Take(pagination.To()).ToList();

                Response.Success    = true;
                Response.Result     = disc;
                Response.ResultInfo = new
                {
                    page       = pagination.Page,
                    perPage    = pagination.PerPage,
                    count      = _discount.Count(),
                    totalCount = totalCount
                };

                DB.Dispose();

                return(Json(Response.Render()));
            }
            catch (Exception ex)
            {
                var mss = ex.Message.ToString();
                return(null);
            }
        }