protected override void DisplayItem(ReportLineViewModel line, Excel.Range cell) { cell.Offset[0, 0].Value = line.Product.Name; PrintQuantity(cell, 0, 1, line.Quantity, line.UnitMeasure); //cell.Offset[0, 1].Value = Math.Round(line.Quantity, 2) + " " + line.UnitMeasure.Caption; }
//public List<ReportLineViewModel> GetSalesDataWithCost(DateTime fromDate, DateTime toDate) //{ // return GetSalesData(fromDate, toDate, true); //} private List <ReportLineViewModel> GetSalesData(IUnitOfWork unitOfWork, DateTime fromDate, DateTime toDate, bool loadCost) { List <ReportLineViewModel> allSales = new List <ReportLineViewModel>(); //List<SaleLineItemReportViewModel> allSalesTotalized = new List<SaleLineItemReportViewModel>(); DateTime startDate = fromDate.Date; DateTime endDate = toDate.Date.AddDays(1); //get data var query = from sale in unitOfWork.OrderRepository.Get(s => s.Date >= startDate && s.Date < endDate) //where sale.Date >= startDate && sale.Date < endDate select sale; //group li by li.Product; //UnitMeasure unitUM = context.UnitMeasures.Single(x => x.Name == "U"); foreach (var sale in query) { ReportLineViewModel copy = new ReportLineViewModel(sale, loadCost); allSales.Add(copy); }//foreach return(allSales); }
private void MakeSum(IEnumerable <ReportLineViewModel> group, ReportLineViewModel lic) { //qtty in base unit of measure double qttySum = group.Sum(x => x.Quantity * x.UnitMeasure.ToBaseConversion); //UMFamily umFamily = appvm.ProductsOC.Single(x => x.Id == lic.Product.Id).UMFamily; var invSVC = ServiceContainer.GetService <IInventoryService>(); //quantity UnitMeasure bestUM = invSVC.GetBestUM(lic.Product.UMFamily, qttySum); lic.UnitMeasure = bestUM; lic.Quantity = qttySum / bestUM.ToBaseConversion; //basic quantity double ep = lic.Product.EdiblePart; UnitMeasure realUM = invSVC.GetBestUM(lic.Product.UMFamily, qttySum / ep); lic.RealUnitMeasure = realUM; lic.RealQuantity = qttySum / ep / realUM.ToBaseConversion; //cost lic.Cost = group.Sum(x => x.Cost); lic.RealCost = lic.Cost / (decimal)ep; }
protected override List <ReportLineViewModel> Transform(List <ReportLineViewModel> filtered, CustomizeReportOptions cro) { List <ReportLineViewModel> result = new List <ReportLineViewModel>(); var query = from item in filtered //orderby item.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)item.DayOfWeek group item by item.DayOfWeek; foreach (var dowGroup in query) { ReportLineViewModel lic = new ReportLineViewModel(); lic.DayOfWeek = dowGroup.Key; //MakeSum(dowGroup, lic); int days = dowGroup.GroupBy(x => x.Date).Count(); lic.Amount = dowGroup.Sum(x => x.Amount) / days; lic.Clients = dowGroup.Sum(x => x.Clients) / days; result.Add(lic); } return(result); }
protected override List <ReportLineViewModel> Transform(List <ReportLineViewModel> filtered, CustomizeReportOptions cro) { List <ReportLineViewModel> result = new List <ReportLineViewModel>(); var query = from sale in filtered group sale by sale.SalesPerson; foreach (var salesPersonGroup in query) { ReportLineViewModel line = new ReportLineViewModel(); if (salesPersonGroup.Key == null) { //NO SALESPERSON line.SalesPersonName = "Sin Dependiente"; } else { line.SalesPerson = salesPersonGroup.Key; line.SalesPersonName = salesPersonGroup.Key.Name; } MakeSum(salesPersonGroup, line); result.Add(line); } return(result); }
public ReportLineViewModel Create(ReportLineViewModel pt, string UserName) { ReportLine obj = Mapper.Map <ReportLine>(pt); obj.CreatedDate = DateTime.Now; obj.ModifiedDate = DateTime.Now; obj.CreatedBy = UserName; obj.ModifiedBy = UserName; obj.ObjectState = Model.ObjectState.Added; Create(obj); _unitOfWork.Save(); pt.ReportLineId = obj.ReportLineId; _logger.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = _DocumentTypeService.Find(TransactionDoctypeConstants.Report).DocumentTypeId, DocId = pt.ReportHeaderId, DocLineId = pt.ReportLineId, ActivityType = (int)ActivityTypeContants.Added, })); return(pt); }
public void Delete(ReportLineViewModel pt, string UserName) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); var obj = Find(pt.ReportLineId); LogList.Add(new LogTypeViewModel { ExObj = obj, }); Delete(obj); XElement Modifications = _modificationCheck.CheckChanges(LogList); _unitOfWork.Save(); _logger.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = _DocumentTypeService.Find(TransactionDoctypeConstants.Report).DocumentTypeId, DocId = pt.ReportHeaderId, DocLineId = pt.ReportLineId, ActivityType = (int)ActivityTypeContants.Deleted, xEModifications = Modifications, })); }
public void Update(ReportLineViewModel pt, string UserName) { var obj = Find(pt.ReportLineId); obj.FieldName = pt.FieldName; obj.DataType = pt.DataType; obj.Type = pt.Type; obj.ServiceFuncGet = pt.ServiceFuncGet; obj.ServiceFuncSet = pt.ServiceFuncSet; obj.CacheKey = pt.CacheKey; obj.Serial = pt.Serial; obj.IsVisible = pt.IsVisible; obj.ModifiedDate = DateTime.Now; obj.ModifiedBy = UserName; obj.ObjectState = Model.ObjectState.Modified; Update(obj); _unitOfWork.Save(); _logger.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = _DocumentTypeService.Find(TransactionDoctypeConstants.Report).DocumentTypeId, DocId = pt.ReportHeaderId, DocLineId = pt.ReportLineId, ActivityType = (int)ActivityTypeContants.Modified, })); }
private void AddToCategoryBranch(ReportLineViewModel lic, Category targetCategory, List <ReportLineViewModel> tempList, bool isRecursiveCall) { ReportLineViewModel targetLine = tempList.FirstOrDefault(x => x.Category == targetCategory); //Category targetCategory = appvm.CategoriesOC.Single(x => x.Id == targetCategoryId); if (targetLine == null) { targetLine = new ReportLineViewModel(); targetLine.Category = targetCategory; var invSvc = ServiceContainer.GetService <IInventoryService>(); targetLine.CategoryName = invSvc.GetFullCategoryName(targetCategory); tempList.Add(targetLine); } targetLine.Amount += lic.Amount; if (!isRecursiveCall) { targetLine.ChildrenProductsTotalSale += lic.Amount; } targetLine.Cost += lic.Cost; if (targetCategory.ParentCategory != null) { AddToCategoryBranch(lic, targetCategory.ParentCategory, tempList, true); } //else targetLine.IsRootCategory = true; }
protected override List <ReportLineViewModel> Transform(List <ReportLineViewModel> filtered, CustomizeReportOptions cro) { var groupsByCategory = from item in filtered orderby item.CategoryName group item by item.Category; List <ReportLineViewModel> result = new List <ReportLineViewModel>(); foreach (var group in groupsByCategory) { ReportLineViewModel line = new ReportLineViewModel(); MakeSum(group, line); if (group.Key == null) { //UNCATEGORIZED line.CategoryName = "Sin Categoría"; //noCategoryLine.IsRootCategory = true; line.ChildrenProductsTotalSale = line.Amount; result.Add(line); } else { AddToCategoryBranch(line, group.Key, result, false); //lineitems_showing.Add(lic); } } return(result); }
// GET: /ProductMaster/Create public ActionResult _Create(int id) { ReportLineViewModel line = new ReportLineViewModel(); line.ReportHeaderId = id; return(PartialView("_Create", line)); }
private void MakeSum(IEnumerable <ReportLineViewModel> group, ReportLineViewModel lic) { lic.Quantity = group.Sum(x => x.Quantity); lic.UnitMeasure = group.First().UnitMeasure; lic.Cost = group.Sum(x => x.Cost); lic.Amount = group.Sum(x => x.Amount); }
protected override List <ReportLineViewModel> Transform(List <ReportLineViewModel> filtered, CustomizeReportOptions cro) { var groupsByProduct = from item in filtered group item by item.Product; List <ReportLineViewModel> transformed = new List <ReportLineViewModel>(); double totalQtty = filtered.Sum(x => x.Quantity); foreach (var group in groupsByProduct) { ReportLineViewModel lic = new ReportLineViewModel(); lic.Product = group.Key; lic.Preference = group.Sum(x => x.Quantity) / totalQtty; MakeSum(group, lic); transformed.Add(lic); //salesByItemLines.Add(sbiLine); } double avePref = 0; decimal aveProfitMargin = 0; if (transformed.Count() == 0) { avePref = 0; aveProfitMargin = 0; } else { avePref = transformed.Average(x => x.Preference); aveProfitMargin = transformed.Average(x => x.ProfitMargin); } foreach (var item in transformed) { if (item.Preference >= avePref && item.ProfitMargin >= aveProfitMargin) { item.ProductClass = ProductClass.A; } else if (item.Preference >= avePref && item.ProfitMargin < aveProfitMargin) { item.ProductClass = ProductClass.B; } else if (item.Preference < avePref && item.ProfitMargin >= aveProfitMargin) { item.ProductClass = ProductClass.C; } else //if (item.Preference < avePref && item.ProfitMargin < aveProfitMargin) { item.ProductClass = ProductClass.D; } } return(transformed); }
// GET: /ProductMaster/Edit/5 public ActionResult _ModifyLine(int id) { ReportLineViewModel pt = _ReportLineService.GetReportLineViewModel(id); if (pt == null) { return(HttpNotFound()); } return(PartialView("_Create", pt)); }
protected override void DisplayItem(ReportLineViewModel line, Excel.Range cell) { cell.Offset[0, 0].Value = line.Product.Name; PrintQuantity(cell, 0, 1, line.Quantity, line.UnitMeasure); PrintQuantity(cell, 0, 2, line.RealQuantity, line.RealUnitMeasure); PrintMoney(cell, 0, 3, line.Cost); PrintMoney(cell, 0, 4, line.RealCost); }
protected override void DisplayItem(ReportLineViewModel line, Excel.Range cell) { cell.Offset[0, 0].Value = line.DiaEnEspanol.ToString(); PrintMoney(cell, 0, 1, line.Amount); cell.Offset[0, 2].Value = line.Clients; PrintMoney(cell, 0, 3, line.SalesByClient); }
private void MakeSum(IEnumerable <ReportLineViewModel> group, ReportLineViewModel lic) { //qtty in base unit of measure double tempQuantity = group.Sum(x => x.Quantity * x.UnitMeasure.ToBaseConversion); //UMFamily umFamily = appvm.ProductsOC.Single(x => x.Id == lic.Product.Id).UMFamily; var invSVC = ServiceContainer.GetService <IInventoryService>(); UnitMeasure bestUM = invSVC.GetBestUM(lic.Product.UMFamily, tempQuantity); lic.UnitMeasure = bestUM; lic.Quantity = tempQuantity / bestUM.ToBaseConversion; }
protected override void DisplayItem(ReportLineViewModel line, Excel.Range cell) { cell.Offset[0, 0].Value = line.CategoryName; PrintMoney(cell, 0, 1, line.Amount); PrintMoney(cell, 0, 2, line.Cost); PrintMoney(cell, 0, 4, line.Profit); cell.Offset[0, 3].Value = line.CostToPriceRatio; cell.Offset[0, 3].Style = "Percent"; }
protected override void DisplayItem(ReportLineViewModel line, Excel.Range cell) { cell.Offset[0, 0].Value = line.Product.Name; cell.Offset[0, 1].NumberFormat = "0.00%"; cell.Offset[0, 1].Value = line.Preference; //cell.Offset[0, 1].Style = "Percent"; cell.Offset[0, 2].Value = line.ProfitMargin; cell.Offset[0, 2].Style = "Percent"; cell.Offset[0, 3].Value = line.ProductClass.ToString(); }
public ActionResult DeletePost(ReportLineViewModel pt) { try { _ReportLineService.Delete(pt, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("_Create", pt)); } return(Json(new { success = true })); }
protected override void DisplayItem(ReportLineViewModel line, Excel.Range cell) { cell.Offset[0, 0].Value = line.Date.ToString("d"); cell.Offset[0, 1].Value = line.ShiftName; cell.Offset[0, 2].Value = line.InvoiceNumber; cell.Offset[0, 3].Value = line.DateCreated.ToString("t"); cell.Offset[0, 4].Value = line.DatePrinted == null ? "-" : line.DatePrinted.Value.ToString("t"); cell.Offset[0, 5].Value = line.DateClosed == null ? "-" : line.DateClosed.Value.ToString("t"); cell.Offset[0, 6].Value = line.ServiceTime + " mins"; }
private void AddIngredients(Product recipeProduct, double qtty, UnitMeasure um, List <ReportLineViewModel> allSalesLines, DateTime date, Shift shift, Employee salesPerson) { double proportion = qtty * um.ToBaseConversion / recipeProduct.RecipeQuantity / recipeProduct.RecipeUnitMeasure.ToBaseConversion; foreach (var ingredient in recipeProduct.Ingredients) { Product ing_prod = ingredient.IngredientProduct; double ing_qtty = proportion * ingredient.Quantity; UnitMeasure ing_um = ingredient.UnitMeasure; ReportLineViewModel ing_op = new ReportLineViewModel(ing_prod, ing_qtty, ing_um, 0, date, shift, salesPerson); //ing_op.Product = ingredient.IngredientProduct; //ing_op.Quantity = proportion * ingredient.Quantity; //ing_op.UnitMeasure = ingredient.UnitMeasure; //TAGS //foreach (var tag in ing_op.Product.Tags) //{ // ing_op.TagIds.Add(tag.Id); //} //if (salesPerson != null) //{ // ing_op.SalesPerson = salesPerson; // ing_op.SalesPersonId = salesPerson.Id; //} //if (shift != null) //{ // ing_op.Shift = shift; // ing_op.ShiftId = shift.Id; //} allSalesLines.Add(ing_op); //add ingredients recursively if (IsRecipe(ingredient.IngredientProduct)) { AddIngredients(ing_op.Product, ing_op.Quantity, ing_op.UnitMeasure, allSalesLines, date, shift, salesPerson); } } }
protected override List <ReportLineViewModel> Transform(List <ReportLineViewModel> filtered, CustomizeReportOptions cro) { var groupsByProduct = from item in filtered group item by item.Product; List <ReportLineViewModel> transformed = new List <ReportLineViewModel>(); foreach (var group in groupsByProduct) { ReportLineViewModel lic = new ReportLineViewModel(); lic.Product = group.Key; lic.ProductId = group.Key.Id; MakeSum(group, lic); transformed.Add(lic); } return(transformed); }
public ActionResult _CreatePost(ReportLineViewModel pt) { if (ModelState.IsValid) { if (pt.ReportLineId <= 0) { try { _ReportLineService.Create(pt, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", pt)); } return(RedirectToAction("_Create", new { id = pt.ReportHeaderId })); } else { try { _ReportLineService.Update(pt, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", pt)); } return(Json(new { success = true })); } } return(PartialView("_Create", pt)); }
public List <ReportLineViewModel> GetSalesByItemData(IUnitOfWork unitOfWork, DateTime fromDate, DateTime toDate, bool includeIngredients) { List <ReportLineViewModel> allSalesLines = new List <ReportLineViewModel>(); //List<SaleLineItemReportViewModel> allSalesTotalized = new List<SaleLineItemReportViewModel>(); DateTime startDate = fromDate.Date; DateTime endDate = toDate.Date.AddDays(1); //get data var query = from li in unitOfWork.LineItemRepository.Get(x => x.Order.Date >= startDate && x.Order.Date < endDate) //where li.Order.Date >= startDate && li.Order.Date < endDate select li; //group li by li.Product; //UnitMeasure unitUM = context.UnitMeasures.Single(x => x.Name == "U"); foreach (var li in query) { ReportLineViewModel copy = new ReportLineViewModel(li); //copy.Product = li.Product; //copy.Quantity = li.Quantity; ////unit of measure will be "each"(U) //copy.UnitMeasure = unitUM; allSalesLines.Add(copy); //add ingredients if (includeIngredients && IsRecipe(copy.Product)) { AddIngredients(copy.Product, copy.Quantity, copy.UnitMeasure, allSalesLines, li.Sale.Date, li.Sale.Shift, li.Sale.Employee); } }//foreach return(allSalesLines); }
// GET: Report/ReportLines/5 public IActionResult ReportLines(int id) { var report = _reportRepository.Select(id); var project = _projectRepository.Select(report.ProjectId); var reportLineViewModel = new ReportLineViewModel { ProjectName = project.ProjectName, OssIndexs = new List <OssIndexViewModel>() }; foreach (var reportLine in _reportLinesRepository.SelectListByReportId(report.Id)) { var ossIndex = _ossIndexRepository.Select(reportLine.OssIndexId); var component = _componentRepository.Select(ossIndex.ComponentId); var score = _scoreService.GetScoreByOssIndexId(reportLine.OssIndexId); Enum.TryParse(ossIndex.HttpStatus.ToString(), out HttpStatusCode httpStatusCode); reportLineViewModel.OssIndexs.Add(new OssIndexViewModel() { Id = reportLine.OssIndexId, ComponentName = component.Name, Score = score, ScoreFieldClass = _scoreClassService.SetScoreFieldClass(score), Status = httpStatusCode.ToString() }); } HttpContext.Session.SetString(SessionConstants.ProjectName, project.ProjectName); HttpContext.Session.SetInt32(SessionConstants.ProjectId, project.Id); HttpContext.Session.SetInt32(SessionConstants.ReportId, id); SetTopNavSelected(); ViewData["Breadcrumbs"] = _breadcrumbService.GetReportLines(project.ProjectName, project.Id); return(View(reportLineViewModel)); }
protected override bool OfflineFilter(ReportLineViewModel li) { return(true); }
protected override bool OfflineFilter(ReportLineViewModel li) { return(li.Product.ProductType == ProductType.RawMaterials || li.Product.ProductType == ProductType.CompraVenta); }
protected override bool OfflineFilter(ReportLineViewModel li) { return(true); //return li.ProductType == ProductType.FinishedGoods || li.ProductType == ProductType.CompraVenta; }
protected override void DisplayItem(ReportLineViewModel line, Microsoft.Office.Interop.Excel.Range cell) { cell.Offset[0, 0].Value = line.Product.Name; PrintQuantity(cell, 0, 1, line.Quantity, line.UnitMeasure); }