Exemplo n.º 1
0
        private void BalanceSurpluses(IPayPeriodBuilder builderWithDeficit)
        {
            List <IPayPeriodBuilder> buildersWithSurpluses = Builders.Where(b => b.Surplus > 0 && b.StartDate < builderWithDeficit.StartDate).ToList();

            foreach (IPayPeriodBuilder builder in buildersWithSurpluses)
            {
                if (builderWithDeficit.Deficit > 0)
                {
                    BalanceSurplus(builder, builderWithDeficit);
                }
            }
        }
Exemplo n.º 2
0
        private void BalanceSurplus(IPayPeriodBuilder builderWithSurplus, IPayPeriodBuilder builderWithDeficit)
        {
            if (builderWithSurplus.Surplus >= builderWithDeficit.Deficit)
            {
                builderWithSurplus.Surplus -= builderWithDeficit.Deficit;
                builderWithDeficit.Deficit  = 0;
                return;
            }

            builderWithDeficit.Deficit -= builderWithSurplus.Surplus;
            builderWithSurplus.Surplus  = 0;
        }
Exemplo n.º 3
0
        private void GetResult(IPayPeriodBuilder builder)
        {
            DateTime date = builder.StartDate;
            decimal  money;

            if (builder.Surplus > 0)
            {
                money = builder.Surplus;
            }
            else
            {
                money = -1 * builder.Deficit;
            }

            Result.Add(new DateDecimal(date, money));
        }