コード例 #1
0
        public void ToFraction_Return_Exception()
        {
            dynamic number = "10";
            var     result = Percentage.ToFraction(number);

            Assert.Equal(0, result);
        }
コード例 #2
0
        public void ToFraction_Return_Success()
        {
            dynamic number = 10;
            var     result = Percentage.ToFraction(number);

            Assert.Equal(0.1, result);
        }
        public CostCalculationRetail MapToModel(CostCalculationRetailViewModel viewModel)
        {
            CostCalculationRetail model = new CostCalculationRetail();

            PropertyCopier <CostCalculationRetailViewModel, CostCalculationRetail> .Copy(viewModel, model);

            model.StyleId              = viewModel.Style._id;
            model.StyleName            = viewModel.Style.name;
            model.SeasonId             = viewModel.Season._id;
            model.SeasonCode           = viewModel.Season.code;
            model.SeasonName           = viewModel.Season.name;
            model.CounterId            = viewModel.Counter._id;
            model.CounterName          = viewModel.Counter.name;
            model.BuyerId              = viewModel.Buyer.Id;
            model.BuyerName            = viewModel.Buyer.Name;
            model.SizeRangeId          = viewModel.SizeRange.Id;
            model.SizeRangeName        = viewModel.SizeRange.Name;
            model.FabricAllowance      = Percentage.ToFraction(viewModel.FabricAllowance);
            model.AccessoriesAllowance = Percentage.ToFraction(viewModel.AccessoriesAllowance);
            model.EfficiencyId         = viewModel.Efficiency.Id;
            model.EfficiencyValue      = viewModel.Efficiency.Value != null ? (double)viewModel.Efficiency.Value : 0;
            model.Risk = Percentage.ToFraction(viewModel.Risk);

            model.OLId               = viewModel.OL.Id;
            model.OLRate             = viewModel.OL.Value != null ? (double)viewModel.OL.Value : 0;
            model.OLCalculatedRate   = viewModel.OL.CalculatedValue != null ? (double)viewModel.OL.CalculatedValue : 0;
            model.OTL1Id             = viewModel.OTL1.Id;
            model.OTL1Rate           = viewModel.OTL1.Value != null ? (double)viewModel.OTL1.Value : 0;
            model.OTL1CalculatedRate = viewModel.OTL1.CalculatedValue != null ? (double)viewModel.OTL1.CalculatedValue : 0;
            model.OTL2Id             = viewModel.OTL2.Id;
            model.OTL2Rate           = viewModel.OTL2.Value != null ? (double)viewModel.OTL2.Value : 0;
            model.OTL2CalculatedRate = viewModel.OTL2.CalculatedValue != null ? (double)viewModel.OTL2.CalculatedValue : 0;
            model.OTL3Id             = viewModel.OTL3.Id;
            model.OTL3Rate           = viewModel.OTL3.Value != null ? (double)viewModel.OTL3.Value : 0;
            model.OTL3CalculatedRate = viewModel.OTL3.CalculatedValue != null ? (double)viewModel.OTL3.CalculatedValue : 0;

            model.CostCalculationRetail_Materials = new List <CostCalculationRetail_Material>();

            foreach (CostCalculationRetail_MaterialViewModel costCalculationRetail_MaterialVM in viewModel.CostCalculationRetail_Materials)
            {
                CostCalculationRetail_Material costCalculationRetail_Material = new CostCalculationRetail_Material();
                PropertyCopier <CostCalculationRetail_MaterialViewModel, CostCalculationRetail_Material> .Copy(costCalculationRetail_MaterialVM, costCalculationRetail_Material);

                costCalculationRetail_Material.CategoryId      = costCalculationRetail_MaterialVM.Category.Id;
                costCalculationRetail_Material.CategoryName    = costCalculationRetail_MaterialVM.Category.SubCategory != null ? costCalculationRetail_MaterialVM.Category.Name + " - " + costCalculationRetail_MaterialVM.Category.SubCategory : costCalculationRetail_MaterialVM.Category.Name;
                costCalculationRetail_Material.MaterialId      = costCalculationRetail_MaterialVM.Material.Id;
                costCalculationRetail_Material.MaterialName    = costCalculationRetail_MaterialVM.Material.Name;
                costCalculationRetail_Material.UOMQuantityId   = costCalculationRetail_MaterialVM.UOMQuantity.Id;
                costCalculationRetail_Material.UOMQuantityName = costCalculationRetail_MaterialVM.UOMQuantity.Name;
                costCalculationRetail_Material.UOMPriceId      = costCalculationRetail_MaterialVM.UOMPrice.Id;
                costCalculationRetail_Material.UOMPriceName    = costCalculationRetail_MaterialVM.UOMPrice.Name;

                model.CostCalculationRetail_Materials.Add(costCalculationRetail_Material);
            }

            return(model);
        }
        public CostCalculationGarment MapToModel(CostCalculationGarmentViewModel viewModel)
        {
            CostCalculationGarment model = new CostCalculationGarment();

            PropertyCopier <CostCalculationGarmentViewModel, CostCalculationGarment> .Copy(viewModel, model);

            model.Convection = viewModel.Convection;

            model.FabricAllowance      = Percentage.ToFraction(viewModel.FabricAllowance);
            model.AccessoriesAllowance = Percentage.ToFraction(viewModel.AccessoriesAllowance);

            model.SizeRange = viewModel.SizeRange;

            model.BuyerId   = viewModel.Buyer._id;
            model.BuyerName = viewModel.Buyer.name;

            model.EfficiencyId    = viewModel.Efficiency.Id;
            model.EfficiencyValue = Percentage.ToFraction(viewModel.Efficiency.Value);

            model.UOMID   = viewModel.UOM._id;
            model.UOMCode = viewModel.UOM.code;
            model.UOMUnit = viewModel.UOM.unit;

            model.WageId   = viewModel.Wage.Id;
            model.WageRate = viewModel.Wage.Value != null ? (double)viewModel.Wage.Value : 0;

            model.ComodityID           = viewModel.Commodity._id;
            model.Commodity            = viewModel.Commodity.name;
            model.CommodityDescription = viewModel.CommodityDescription;

            model.THRId   = viewModel.THR.Id;
            model.THRRate = viewModel.THR.Value != null ? (double)viewModel.THR.Value : 0;

            model.RateId    = viewModel.Rate.Id;
            model.RateValue = viewModel.Rate.Value != null ? (double)viewModel.Rate.Value : 0;

            model.CostCalculationGarment_Materials = new List <CostCalculationGarment_Material>();

            foreach (CostCalculationGarment_MaterialViewModel CostCalculationGarment_MaterialVM in viewModel.CostCalculationGarment_Materials)
            {
                CostCalculationGarment_Material CostCalculationGarment_Material = new CostCalculationGarment_Material();
                PropertyCopier <CostCalculationGarment_MaterialViewModel, CostCalculationGarment_Material> .Copy(CostCalculationGarment_MaterialVM, CostCalculationGarment_Material);

                CostCalculationGarment_Material.Convection         = model.Convection;
                CostCalculationGarment_Material.ProductId          = CostCalculationGarment_MaterialVM.Product._id;
                CostCalculationGarment_Material.ProductCode        = CostCalculationGarment_MaterialVM.Product.code;
                CostCalculationGarment_Material.Construction       = CostCalculationGarment_MaterialVM.Product.construction;
                CostCalculationGarment_Material.Yarn               = CostCalculationGarment_MaterialVM.Product.yarn;
                CostCalculationGarment_Material.Width              = CostCalculationGarment_MaterialVM.Product.width;
                CostCalculationGarment_Material.Composition        = CostCalculationGarment_MaterialVM.Product.composition;
                CostCalculationGarment_Material.CategoryId         = CostCalculationGarment_MaterialVM.Category._id;
                CostCalculationGarment_Material.CategoryName       = CostCalculationGarment_MaterialVM.Category.SubCategory != null ? CostCalculationGarment_MaterialVM.Category.name + " - " + CostCalculationGarment_MaterialVM.Category.SubCategory : CostCalculationGarment_MaterialVM.Category.name;
                CostCalculationGarment_Material.UOMQuantityId      = CostCalculationGarment_MaterialVM.UOMQuantity._id;
                CostCalculationGarment_Material.UOMQuantityName    = CostCalculationGarment_MaterialVM.UOMQuantity.unit;
                CostCalculationGarment_Material.UOMPriceId         = CostCalculationGarment_MaterialVM.UOMPrice._id;
                CostCalculationGarment_Material.UOMPriceName       = CostCalculationGarment_MaterialVM.UOMPrice.unit;
                CostCalculationGarment_Material.ShippingFeePortion = Percentage.ToFraction(CostCalculationGarment_MaterialVM.ShippingFeePortion);

                model.CostCalculationGarment_Materials.Add(CostCalculationGarment_Material);
            }

            model.CommissionPortion = Percentage.ToFraction(viewModel.CommissionPortion);
            model.Risk = Percentage.ToFraction(viewModel.Risk);

            model.OTL1Id             = viewModel.OTL1.Id;
            model.OTL1Rate           = viewModel.OTL1.Value != null ? (double)viewModel.OTL1.Value : 0;
            model.OTL1CalculatedRate = viewModel.OTL1.CalculatedValue != null ? (double)viewModel.OTL1.CalculatedValue : 0;

            model.OTL2Id             = viewModel.OTL2.Id;
            model.OTL2Rate           = viewModel.OTL2.Value != null ? (double)viewModel.OTL2.Value : 0;
            model.OTL2CalculatedRate = viewModel.OTL2.CalculatedValue != null ? (double)viewModel.OTL2.CalculatedValue : 0;

            model.NETFOBP = Percentage.ToFraction(viewModel.NETFOBP);

            return(model);
        }
        public CostCalculationGarment MapToModel(CostCalculationGarmentViewModel viewModel)
        {
            CostCalculationGarment model = new CostCalculationGarment();

            PropertyCopier <CostCalculationGarmentViewModel, CostCalculationGarment> .Copy(viewModel, model);

            model.LineId   = viewModel.Line.Id;
            model.LineCode = viewModel.Line.Code;
            model.LineName = viewModel.Line.Name;

            model.FabricAllowance      = Percentage.ToFraction(viewModel.FabricAllowance);
            model.AccessoriesAllowance = Percentage.ToFraction(viewModel.AccessoriesAllowance);

            model.SizeRangeId   = viewModel.SizeRange.Id;
            model.SizeRangeName = viewModel.SizeRange.Name;

            model.BuyerId   = viewModel.Buyer.Id;
            model.BuyerName = viewModel.Buyer.Name;

            model.EfficiencyId    = viewModel.Efficiency.Id;
            model.EfficiencyValue = Percentage.ToFraction(viewModel.Efficiency.Value);

            model.WageId   = viewModel.Wage.Id;
            model.WageRate = viewModel.Wage.Value != null ? (double)viewModel.Wage.Value : 0;

            model.THRId   = viewModel.THR.Id;
            model.THRRate = viewModel.THR.Value != null ? (double)viewModel.THR.Value : 0;

            model.RateId    = viewModel.Rate.Id;
            model.RateValue = viewModel.Rate.Value != null ? (double)viewModel.Rate.Value : 0;

            model.CostCalculationGarment_Materials = new List <CostCalculationGarment_Material>();

            foreach (CostCalculationGarment_MaterialViewModel CostCalculationGarment_MaterialVM in viewModel.CostCalculationGarment_Materials)
            {
                CostCalculationGarment_Material CostCalculationGarment_Material = new CostCalculationGarment_Material();
                PropertyCopier <CostCalculationGarment_MaterialViewModel, CostCalculationGarment_Material> .Copy(CostCalculationGarment_MaterialVM, CostCalculationGarment_Material);

                CostCalculationGarment_Material.CategoryId         = CostCalculationGarment_MaterialVM.Category.Id;
                CostCalculationGarment_Material.CategoryName       = CostCalculationGarment_MaterialVM.Category.SubCategory != null ? CostCalculationGarment_MaterialVM.Category.Name + " - " + CostCalculationGarment_MaterialVM.Category.SubCategory : CostCalculationGarment_MaterialVM.Category.Name;
                CostCalculationGarment_Material.MaterialId         = CostCalculationGarment_MaterialVM.Material.Id;
                CostCalculationGarment_Material.MaterialName       = CostCalculationGarment_MaterialVM.Material.Name;
                CostCalculationGarment_Material.UOMQuantityId      = CostCalculationGarment_MaterialVM.UOMQuantity.Id;
                CostCalculationGarment_Material.UOMQuantityName    = CostCalculationGarment_MaterialVM.UOMQuantity.Name;
                CostCalculationGarment_Material.UOMPriceId         = CostCalculationGarment_MaterialVM.UOMPrice.Id;
                CostCalculationGarment_Material.UOMPriceName       = CostCalculationGarment_MaterialVM.UOMPrice.Name;
                CostCalculationGarment_Material.ShippingFeePortion = Percentage.ToFraction(CostCalculationGarment_MaterialVM.ShippingFeePortion);

                model.CostCalculationGarment_Materials.Add(CostCalculationGarment_Material);
            }

            model.CommissionPortion = Percentage.ToFraction(viewModel.CommissionPortion);
            model.Risk = Percentage.ToFraction(viewModel.Risk);

            model.OTL1Id             = viewModel.OTL1.Id;
            model.OTL1Rate           = viewModel.OTL1.Value != null ? (double)viewModel.OTL1.Value : 0;
            model.OTL1CalculatedRate = viewModel.OTL1.CalculatedValue != null ? (double)viewModel.OTL1.CalculatedValue : 0;

            model.OTL2Id             = viewModel.OTL2.Id;
            model.OTL2Rate           = viewModel.OTL2.Value != null ? (double)viewModel.OTL2.Value : 0;
            model.OTL2CalculatedRate = viewModel.OTL2.CalculatedValue != null ? (double)viewModel.OTL2.CalculatedValue : 0;

            model.NETFOBP = Percentage.ToFraction(viewModel.NETFOBP);

            return(model);
        }