예제 #1
0
        public void ItShouldNameOutputWithConceptTitleWhenNoName()
        {
            var concept = new Concept <int>("({0} * {1}) + ({2} * {3})")
            {
                Title = "Concept"
            };
            var filter = new Filter <int, bool>("{0} > {1}");

            filter.SetParameters(new List <IMonthlyParameter <int> > {
                SetDictionary("0", 10), SetDictionary("1", 1)
            });
            concept.AddFilter(filter);
            var january = SetDictionary("0", 2);

            january.Value[Month.January] = 3;
            concept.SetParameters(new List <IMonthlyParameter <int> > {
                january, SetDictionary("1", 3), SetDictionary("2", 2), SetDictionary("3", 5)
            });


            concept.Run();
            Assert.AreEqual(16, concept.Output1.Value[Month.May]);
            Assert.AreEqual(19, concept.Output1.Value[Month.January]);
            Assert.AreEqual("Concept", concept.Output1.Name);
        }
        public void BonoCashTest()
        {
            var bonoCash = new Global <decimal>
            {
                Name  = "bonoCash",
                Value = new Dictionary <Month, decimal>
                {
                    { Month.October, 0 },
                    { Month.November, 0 },
                    { Month.December, .1M },
                    { Month.January, 0 },
                    { Month.February, 0 },
                    { Month.March, 0 },
                    { Month.April, 0 },
                    { Month.May, 0 },
                    { Month.June, 0 },
                    { Month.July, 0 },
                    { Month.August, 0 },
                    { Month.September, 0 },
                }
            };


            var concept = new Concept <decimal>("{SueldoAnual} * {bonoCash}");

            concept.SetParameters(new List <IMonthlyParameter <decimal> > {
                SetDictionary("SueldoAnual", 13000M), bonoCash
            });

            concept.Run();
            Assert.AreEqual(0M, concept.Output1.Value[Month.October]);
            Assert.AreEqual(1300M, concept.Output1.Value[Month.December]);
            Assert.AreEqual(0, concept.Output1.Value[Month.September]);
            Assert.AreEqual(1300M, concept.Output1.Total);
        }
예제 #3
0
        public void ItShouldCreateOperationFromConcept()
        {
            var concept = new Concept <int>("({0} * {1}) + ({2} * {3})");
            var filter  = new Filter <int, bool>("{0} > {1}");

            filter.SetParameters(new List <IMonthlyParameter <int> > {
                SetDictionary("0", 10), SetDictionary("1", 1)
            });
            concept.AddFilter(filter);
            var january = SetDictionary("0", 2);

            january.Value[Month.January] = 3;
            concept.SetParameters(new List <IMonthlyParameter <int> >
            {
                january, SetDictionary("1", 3), SetDictionary("2", 2), SetDictionary("3", 5)
            });
            var output = SetDictionary("output", 25);

            concept.AddOutputParameter1(output);

            concept.Run();
            Assert.AreEqual(16, concept.Output1.Value[Month.May]);
            Assert.AreEqual(16, output.Value[Month.August]);
            Assert.AreEqual(19, concept.Output1.Value[Month.January]);
            Assert.AreEqual(19, output.Value[Month.January]);
        }
예제 #4
0
        public void ItShouldReplaceOutputValue()
        {
            var filter = new Filter <int, bool>("{0} > {1}");

            filter.SetParameters(new List <IMonthlyParameter <int> > {
                SetDictionary("0", 10), SetDictionary("1", 1)
            });
            var concept = new Concept <int>();

            concept.AddFilter(filter);
            const string text      = "({0} * {1}) + ({2} * {3})";
            var          operation = new RuleTree <int, int>(text);

            operation.SetParameters(
                new List <IMonthlyParameter <int> > {
                SetDictionary("0", 2), SetDictionary("1", 3), SetDictionary("2", 2), SetDictionary("3", 5)
            });
            concept.AddOperation(operation);
            var output = SetDictionary("output", 25);

            concept.AddOutputParameter1(output);

            concept.Run();
            Assert.AreEqual(16, concept.Output1.Value[Month.May]);
            Assert.AreEqual(16, output.Value[Month.August]);
        }
        private Concept <decimal> GetAndRunSueldoMensualSindicalizado()
        {
            var aumSindicato = new Global <decimal>
            {
                Name  = "aumSindicato",
                Value = new Dictionary <Month, decimal>
                {
                    { Month.October, .14M },
                    { Month.November, .14M },
                    { Month.December, .14M },
                    { Month.January, .20M },
                    { Month.February, .20M },
                    { Month.March, .24M },
                    { Month.April, .24M },
                    { Month.May, .24M },
                    { Month.June, .24M },
                    { Month.July, .24M },
                    { Month.August, .24M },
                    { Month.September, .24M },
                }
            };


            var concept = new Concept <decimal>("({SueldoAnual} / 13) * ({aumSindicato} + 1)")
            {
                Title = "SueldoMensualSindicalizado"
            };

            concept.SetParameters(new List <IMonthlyParameter <decimal> > {
                SetDictionary("SueldoAnual", 13000M), aumSindicato
            });
            concept.Run();
            return(concept);
        }
        //      4001		FTE		1		Comisión		11510		Tiene Com.?		603001		N/A		N/A		Valor Com.		N/A		Dic / Mar / Jun / Oct		 2.000   -       -       500     -       -       500     -       -       500     -       -       500     2.000      Como lo cargamos? Tengo que cargarle 4 comisiones? Una para cada Q por ejemplo?
        public void ConceptoComision()
        {
            var comision = new Global <decimal>
            {
                Name  = "comision",
                Value = new Dictionary <Month, decimal>
                {
                    { Month.October, 0 },
                    { Month.November, 0 },
                    { Month.December, 500M },
                    { Month.January, 0 },
                    { Month.February, 0 },
                    { Month.March, 500M },
                    { Month.April, 0 },
                    { Month.May, 0 },
                    { Month.June, 500M },
                    { Month.July, 0 },
                    { Month.August, 0 },
                    { Month.September, 500M },
                }
            };

            var concept = new Concept <decimal>("{comision} * 1");

            concept.SetParameters(new List <IMonthlyParameter <decimal> > {
                comision
            });

            concept.Run();
            Assert.AreEqual(0M, concept.Output1.Value[Month.October]);
            Assert.AreEqual(500M, concept.Output1.Value[Month.December]);
            Assert.AreEqual(500M, concept.Output1.Value[Month.September]);
            Assert.AreEqual(2000M, concept.Output1.Total);
        }
        private Concept <decimal> GetAndRunSueldoMensualConcept()
        {
            var merit = new Global <decimal>
            {
                Name  = "merit",
                Value = new Dictionary <Month, decimal>
                {
                    { Month.October, 0 },
                    { Month.November, 0 },
                    { Month.December, 0 },
                    { Month.January, .25M },
                    { Month.February, .25M },
                    { Month.March, .25M },
                    { Month.April, .25M },
                    { Month.May, .25M },
                    { Month.June, .25M },
                    { Month.July, .25M },
                    { Month.August, .25M },
                    { Month.September, .25M },
                }
            };


            var concept = new Concept <decimal>("({SueldoAnual} / 13) * ({merit} + 1)")
            {
                Title = "SueldoMensual"
            };

            concept.SetParameters(new List <IMonthlyParameter <decimal> > {
                SetDictionary("SueldoAnual", 13000M), merit
            });

            concept.Run();
            return(concept);
        }
        public void SpecialBonusConceptTest()
        {
            var specialBonus = new Global <decimal>
            {
                Name  = "specialBonus",
                Value = new Dictionary <Month, decimal>
                {
                    { Month.October, 0 },
                    { Month.November, 0 },
                    { Month.December, 0 },
                    { Month.January, 0 },
                    { Month.February, 0 },
                    { Month.March, 0 },
                    { Month.April, 0 },
                    { Month.May, 0 },
                    { Month.June, 30000M },
                    { Month.July, 0 },
                    { Month.August, 0 },
                    { Month.September, 0 },
                }
            };


            var concept = new Concept <decimal>("{specialBonus} * 1");

            concept.SetParameters(new List <IMonthlyParameter <decimal> > {
                specialBonus
            });

            concept.Run();
            Assert.AreEqual(0M, concept.Output1.Value[Month.October]);
            Assert.AreEqual(0, concept.Output1.Value[Month.December]);
            Assert.AreEqual(30000M, concept.Output1.Value[Month.June]);
            Assert.AreEqual(30000M, concept.Output1.Total);
        }
        private Concept <decimal> AddConcepts(Concept <decimal> a, Concept <decimal> b)
        {
            var sumarConcept = new Concept <decimal>("{" + a.Output1.Name + "} + {" + b.Output1.Name + "}")
            {
                Title = "Add"
            };

            sumarConcept.SetParameters(new List <IMonthlyParameter <decimal> > {
                a.Output1, b.Output1
            });
            sumarConcept.Run();
            return(sumarConcept);
        }
예제 #10
0
        public void ItShouldGet16OnComplexOperation()
        {
            var filter = new Filter <int, bool>("{0} > {1}");

            filter.SetParameters(new List <IMonthlyParameter <int> > {
                SetDictionary("0", 10), SetDictionary("1", 1)
            });
            var concept = new Concept <int>("({0} * {1}) + ({2} * {3})");

            concept.AddFilter(filter);
            concept.SetParameters(
                new List <IMonthlyParameter <int> > {
                SetDictionary("0", 2), SetDictionary("1", 3), SetDictionary("2", 2), SetDictionary("3", 5)
            });
            concept.Run();
            Assert.AreEqual(16, concept.Output1.Value[Month.May]);
        }
예제 #11
0
        public void ItShouldGet15OnOutput()
        {
            var filter = new Filter <int, bool>("{0} > {1}")
            {
                Parameter1 = SetDictionary("0", 10),
                Parameter2 = SetDictionary("1", 1)
            };
            var concept = new Concept <int>();

            concept.AddFilter(filter);
            var operation = new Mock <IRule <int, int> >();

            operation.Setup(x => x.GetResult()).Returns(SetDictionary("0", 15));
            concept.AddOperation(operation.Object);
            concept.Run();
            Assert.AreEqual(15, concept.Output1.Value[Month.March]);
        }
        public void AguinaldoTest()
        {
            var sueldoMensual = GetAndRunSueldoMensualConcept();
            var sueldoMensualSindicalizado = GetAndRunSueldoMensualSindicalizado();

            var sumarConcept = AddConcepts(sueldoMensual, sueldoMensualSindicalizado);

            var concept = new Concept <decimal>("{Add} / 12");

            concept.SetParameters(new List <IMonthlyParameter <decimal> > {
                sumarConcept.Output1
            });
            concept.Run();

            Assert.AreEqual(178M, Math.Truncate(concept.Output1.Value[Month.October]));
            Assert.AreEqual(178M, Math.Truncate(concept.Output1.Value[Month.November]));
            Assert.AreEqual(204M, Math.Truncate(concept.Output1.Value[Month.January]));
            Assert.AreEqual(207M, Math.Truncate(concept.Output1.Value[Month.September]));
            Assert.AreEqual(2395M, Math.Truncate(concept.Output1.Total));
        }
        public void PlusVacacionalTest()
        {
            var sueldoMensual = GetAndRunSueldoMensualConcept();
            var sueldoMensualSindicalizado = GetAndRunSueldoMensualSindicalizado();

            var sumarConcept = AddConcepts(sueldoMensual, sueldoMensualSindicalizado);


            var iConcept = new Concept <decimal>("( {Add} / 25 ) * ( 14 * 1 )")
            {
                Title = "I"
            };

            iConcept.SetParameters(new List <IMonthlyParameter <decimal> > {
                sumarConcept.Output1
            });
            iConcept.Run();


            var jConcept = new Concept <decimal>("( {Add} / 30 ) * ( 14 * 1 )")
            {
                Title = "J"
            };

            jConcept.SetParameters(new List <IMonthlyParameter <decimal> > {
                sumarConcept.Output1
            });
            jConcept.Run();

            var plusVacional = new Concept <decimal>("{I} - {J}");

            plusVacional.SetParameters(new List <IMonthlyParameter <decimal> > {
                iConcept.Output1, jConcept.Output1
            });
            plusVacional.Run();

            Assert.AreEqual(200M, Math.Round(plusVacional.Output1.Value[Month.October], MidpointRounding.ToEven));
            Assert.AreEqual(229M, Math.Round(plusVacional.Output1.Value[Month.January]));
            Assert.AreEqual(232M, Math.Round(plusVacional.Output1.Value[Month.September]));
            Assert.AreEqual(2683M, Math.Round(plusVacional.Output1.Total));
        }
예제 #14
0
        public void ItShouldAddValueToOutputParameter()
        {
            var filter = new Filter <int, bool>("{0} > {1}");

            filter.SetParameters(new List <IMonthlyParameter <int> > {
                SetDictionary("0", 10), SetDictionary("1", 1)
            });
            var concept = new Concept <int>("({0} * {1}) + ({2} * {3})");

            concept.AddFilter(filter);
            concept.SetParameters(
                new List <IMonthlyParameter <int> > {
                SetDictionary("0", 2), SetDictionary("1", 3), SetDictionary("2", 2), SetDictionary("3", 5)
            });
            var output = SetDictionary("output", 10);

            output.IsAccumulator = true;
            concept.AddOutputParameter1(output);

            concept.Run();
            Assert.AreEqual(26, concept.Output1.Value[Month.June]);
            Assert.AreEqual(26, output.Value[Month.February]);
        }