Пример #1
0
        public static AnimalLabel ToAnimalLabel(this AnimalLabelsViewModel animalLabelViewModel)
        {
            var animalLabel = new AnimalLabel()
            {
                Name      = animalLabelViewModel.Name,
                Id        = animalLabelViewModel.Id,
                IsOrganic = animalLabelViewModel.IsOrganic,
                SpeciesId = animalLabelViewModel.Species.Id
            };

            return(animalLabel);
        }
Пример #2
0
        public void ProduceCustomBagLabels(List <OrderDetail> orderDetails, double poundWeight, OmsLabelType labelType, DateTime?processDate, QualityGrade qualityGrade, AnimalLabelsViewModel animalLabel = null, CaseSize customCaseSize = null)
        {
            if (!orderDetails.Any())
            {
                return;
            }
            var model = GetLabelLayoutViewModel(poundWeight, orderDetails.First(), labelType, false, qualityGrade, animalLabel, customCaseSize);

            foreach (var orderDetail in orderDetails)
            {
                ProduceLabel(labelType, model, orderDetail, true, processDate);
            }
        }
Пример #3
0
        public void ProduceLabel(int orderDetailId, double poundWeight, OmsLabelType labelType, int quantity = 1, DateTime?processDate = null, QualityGrade qualityGrade = null, AnimalLabelsViewModel animalLabel = null, CaseSize customCaseSize = null)
        {
            var context = new OmsContext();

            _orderDetailRepository = new OrderDetailRepository(context);
            var orderDetail = _orderDetailRepository.GetLabelInfo(orderDetailId);
            var model       = GetLabelLayoutViewModel(poundWeight, orderDetail, labelType, false, qualityGrade, animalLabel, customCaseSize);

            for (var i = 0; i < quantity; i++)
            {
                ProduceLabel(labelType, model, orderDetail, false, processDate);
            }
            context.Dispose();
        }
Пример #4
0
        private LabelOutputViewModel GetLabelLayoutViewModel(double poundWeight, OrderDetail orderDetail, OmsLabelType labelType, bool needSetSerialNumber = true, QualityGrade qualityGrade = null, AnimalLabelsViewModel animalLabel = null, CaseSize customCaseSize = null)
        {
            var model = new LabelOutputViewModel();


            model.PoundWeight    = GetNetPoundWeight(poundWeight, labelType, orderDetail);
            model.KilogramWeight = GetCorrectKilogramWeight(model.PoundWeight);

            var order    = orderDetail.Order;
            var product  = orderDetail.Product;
            var customer = order.Customer;

            var productData = GetCustomerProductData(product, order);

            model.CustomerStateCode = orderDetail.CustomerLocation.StateCode;
            model.CustomerAddress1  = orderDetail.CustomerLocation.Address1;
            model.CustomerAddress2  = orderDetail.CustomerLocation.Address2;
            model.CustomerCity      = orderDetail.CustomerLocation.City;
            model.CustomerEmail     = orderDetail.CustomerLocation.Email;
            model.CustomerFax       = orderDetail.CustomerLocation.Fax;
            model.CustomerZipCode   = orderDetail.CustomerLocation.ZipCode;
            model.CustomerPhone     = orderDetail.CustomerLocation.Phone;
            model.CustomerName      = orderDetail.CustomerLocation.Name;
            model.OrderDetailId     = orderDetail.Id;
            model.Type                      = labelType;
            model.ItemCode                  = product.Upc;
            model.LotNumber                 = GetLotNumber(order.Id);
            model.Description               = product.EnglishDescription;
            model.ProcessDate               = order.ProcessDate ?? DateTime.Today;
            model.SlaughterDate             = order.SlaughterDate ?? DateTime.Today;
            model.BestBeforeDate            = order.BestBeforeDate ?? DateTime.Today.AddDays(45);
            model.SpeciesBugPath            = GetSpeciesBugPath(product);
            model.LogoPath                  = GetLogoPath(customer);
            model.BornInRegionName          = order.BornRegion.With(x => x.Name);
            model.RaisedInRegionName        = order.RaisedRegion.With(x => x.Name);
            model.ProductOfRegionName       = order.ProductOfRegion.With(x => x.Name);
            model.SlaughteredInRegionName   = order.SlaughteredRegion.With(x => x.Name);
            model.DistributedBy             = customer.DistributedBy;
            model.LabelFile                 = SetLabelFile(labelType, customer, false);
            model.GermanDescription         = product.GermanDescription;
            model.FrenchDescription         = product.FrenchDescription;
            model.ItalianDescription        = product.ItalianDescription;
            model.SwedishDescription        = product.SwedishDescription;
            model.Organic                   = GetOrganicPath(animalLabel != null && animalLabel.IsOrganic);
            model.SerialNumber              = (needSetSerialNumber) ? GetSerialNumber() : null;
            model.JulianProductionDate      = DateTime.Now.DayOfYear.ToString(CultureInfo.InvariantCulture).PadLeft(3, '0');
            model.VarCustomerJobValue       = order.AdditionalInfoOnLabel;
            model.AnimalName                = animalLabel != null ? animalLabel.Name : "";
            model.Species                   = (animalLabel != null && animalLabel.Species != null) ? animalLabel.Species.Name : "";
            model.NutritionDescription      = product.NutritionDescription;
            model.NutritionServingSize      = product.NutritionServingSize;
            model.NutritionServingContainer = product.NutritionServingContainer;
            model.NutritionCalories         = product.NutritionCalories;
            model.NutritionCaloriesFat      = product.NutritionCaloriesFat;
            model.NutritionTotalFat         = product.NutritionTotalFat;
            model.NutritionSatFat           = product.NutritionSatFat;
            model.NutritionTransFat         = product.NutritionTransFat;
            model.NutritionPolyFat          = product.NutritionPolyFat;
            model.NutritionMonoFat          = product.NutritionMonoFat;
            model.NutritionCholesterol      = product.NutritionCholesterol;
            model.NutritionSodium           = product.NutritionSodium;
            model.NutritionCarbs            = product.NutritionCarbs;
            model.NutritionProtein          = product.NutritionProtein;
            model.NutritionVitA             = product.NutritionVitA;
            model.NutritionVitC             = product.NutritionVitC;
            model.NutritionCalcium          = product.NutritionCalcium;
            model.NutritionIron             = product.NutritionIron;

            model.PackedFor     = customer.Name;
            model.Refrigeration = order.Refrigeration.Return(x => x.Name);
            model.Trim          = product.TrimCut.Return(x => x.Name);
            model.GradeName     = qualityGrade != null? qualityGrade.Name: "";

            model.CustomerProductCode = productData == null || productData.ProductCode == null
                ? product.Code
                : productData.ProductCode;
            model.PricePerPound = productData == null || productData.PricePerPound == null
                ? product.PricePerPound
                : productData.PricePerPound;
            model.Price = model.PricePerPound != null
                ? model.PricePerPound.Value *Convert.ToDecimal(model.PoundWeight)
                : (decimal?)null;

            model.Gtin = productData == null || productData.Gtin == null
                ? product.Gtin
                : productData.Gtin.Value;
            model.VarCustomerProductValue = productData == null || productData.ProductDescription == null
                ? null
                : productData.ProductDescription;

            model.Customer    = customer.Name;
            model.CustomerPO  = order.POCustomer;
            model.Printer     = SettingsManager.Current.Printer;
            model.WeighedDate = DateTime.Now;

            // todo (alexm): should be checked
            model.TareWeight = labelType == OmsLabelType.Box? GetBoxTareWeight(customCaseSize, orderDetail) : GetBagTareWeight(customCaseSize, orderDetail);

            return(model);
        }
Пример #5
0
        private PartialViewResult GetAnimalGridPartial(TrackAnimal trackAnimal, ColdWeightEntryDetailItem item)
        {
            ViewBag.CustomerLocations = GetCustomerLocationsByOrderId(item.OrderId);
            var animalLabels = new List <AnimalLabelsViewModel>();
            var labels       = _animalLabelRepository.FindAll(x => x.SpeciesId == item.AnimalLabel.Species.Id).ToList();

            foreach (var animalLabel in labels)
            {
                var label = new AnimalLabelsViewModel()
                {
                    Id      = animalLabel.Id,
                    Name    = animalLabel.Name,
                    Species = new SpeciesViewModel()
                    {
                        Name = animalLabel.Species.Name,
                        Id   = animalLabel.SpeciesId
                    }
                };
                animalLabels.Add(label);
            }
            if (animalLabels.Any())
            {
                item.AnimalLabel = animalLabels.FirstOrDefault();
            }
            ViewBag.AnimalLabels = animalLabels;
            var grades = _lookupService.GetQualityGrades().Select(x => new QualityGrade()
            {
                Id        = x.Id,
                Name      = x.Name,
                SortOrder = x.SortOrder
            });

            if (grades.Any())
            {
                ViewBag.QualityGrades = grades;
            }

            ViewBag.TrackAnimalByList = Enum
                                        .GetValues(typeof(TrackAnimal))
                                        .Cast <int>()
                                        .Select(i => new SelectListItem
            {
                Value = i.ToString(),
                Text  = Enum.GetName(typeof(TrackAnimal), i).GetTrackAnimailEnumDescription(i),
            }
                                                )
                                        .ToList();
            switch (trackAnimal)
            {
            case (TrackAnimal.Whole):
                return(PartialView("_AnimalTrackingGrid", item));

            case (TrackAnimal.Quarter):
                return(PartialView("_AnimalTrackingGridQuarters", item));

            case (TrackAnimal.Half):
                return(PartialView("_AnimalTrackingGridHalves", item));

            case (TrackAnimal.HalfAndTwoQuaters):
                return(PartialView("_AnimalTrakingGridHalfAndTwoQuaters", item));

            case (TrackAnimal.ThreeQuatersAndQuater):
                return(PartialView("_AnimalTrakingGridThreeQuatersAndQuater", item));

            default:
                return(new PartialViewResult());
            }
        }