예제 #1
0
        public async Task TestAddUpdatDelete()
        {
            BudgetModule   BudgetMod      = new BudgetModule();
            ChartOfAccount chartOfAccount = await BudgetMod.ChartOfAccount.Query().GetEntityById(42);

            BudgetRange budgetRange = await BudgetMod.BudgetRange.Query().GetEntityById(1);

            BudgetView view = new BudgetView()
            {
                BudgetAmount    = 5216M,
                ActualHours     = 0M,
                ActualAmount    = 768M,
                AccountId       = chartOfAccount.AccountId,
                RangeId         = budgetRange.RangeId,
                ProjectedAmount = 9600,
                ProjectedHours  = 0,
                ActualsAsOfDate = DateTime.Parse("12/9/2019"),

                AccountDescription = chartOfAccount.Description,
                CompanyCode        = chartOfAccount.CompanyCode,
                BusUnit            = chartOfAccount.BusUnit,
                ObjectNumber       = chartOfAccount.ObjectNumber,
                Subsidiary         = chartOfAccount.Subsidiary,
                RangeIsActive      = budgetRange.IsActive,
                RangeStartDate     = budgetRange.StartDate,
                RangeEndDate       = budgetRange.EndDate,
                SupervisorCode     = budgetRange.SupervisorCode
            };
            NextNumber nnNextNumber = await BudgetMod.Budget.Query().GetNextNumber();

            view.BudgetNumber = nnNextNumber.NextNumberValue;

            Budget budget = await BudgetMod.Budget.Query().MapToEntity(view);

            BudgetMod.Budget.AddBudget(budget).Apply();

            Budget newBudget = await BudgetMod.Budget.Query().GetEntityByNumber(view.BudgetNumber);

            Assert.NotNull(newBudget);

            newBudget.BudgetAmount = 100M;

            BudgetMod.Budget.UpdateBudget(newBudget).Apply();

            BudgetView updateView = await BudgetMod.Budget.Query().GetViewById(newBudget.BudgetId);

            if (updateView.BudgetAmount == 100M)
            {
                Assert.True(true);
            }

            BudgetMod.Budget.DeleteBudget(newBudget).Apply();
            Budget lookupBudget = await BudgetMod.Budget.Query().GetEntityById(view.BudgetId);

            Assert.Null(lookupBudget);
        }
예제 #2
0
        public async Task TestPersonalBudgetViews()
        {
            BudgetModule budgetMod = new BudgetModule();

            IList <PersonalBudgetView> list = await budgetMod.Budget.Query().GetPersonalBudgetViews();

            if (list.Count > 0)
            {
                Assert.True(true);
            }
        }
예제 #3
0
        public async Task TestGetBudget()
        {
            long budgetId = 2;

            BudgetModule budgetMod = new BudgetModule();

            BudgetView budgetView = await budgetMod.Budget.Query().GetViewById(budgetId);

            if (budgetView != null)
            {
                Assert.True(true);
            }
        }
예제 #4
0
        public async Task TestCreateBudget()
        {
            BudgetModule budgetMod = new BudgetModule();

            BudgetRangeView budgetRangeView = new BudgetRangeView();

            //personal mortgage
            ChartOfAccount coa = await budgetMod.ChartOfAccount.Query().GetEntity("1000", "1200", "502", "01");

            budgetRangeView.StartDate = DateTime.Parse("1/1/2018");;
            budgetRangeView.EndDate   = DateTime.Parse("12/31/2018");;

            budgetRangeView.Location       = coa.Location;
            budgetRangeView.GenCode        = coa.GenCode;
            budgetRangeView.SubCode        = coa.SubCode;
            budgetRangeView.CompanyCode    = coa.Company.CompanyCode;
            budgetRangeView.BusUnit        = coa.BusUnit;
            budgetRangeView.ObjectNumber   = coa.ObjectNumber;
            budgetRangeView.Subsidiary     = coa.Subsidiary;
            budgetRangeView.AccountId      = coa.AccountId;
            budgetRangeView.SupervisorCode = coa.SupCode;

            BudgetView budgetView = new BudgetView();

            budgetMod.BudgetRange.CreateBudgetRange(budgetRangeView).Apply();

            BudgetRangeView budgetRangeLookupView = await budgetMod.BudgetRange.Query().GetBudgetRange(budgetRangeView.AccountId, budgetRangeView.StartDate, budgetRangeView.EndDate);

            budgetMod.Budget.MapRangeToBudgetView(ref budgetView, budgetRangeLookupView);

            BudgetActualsView budgetActualsView = await budgetMod.Budget.Query().GetBudgetActualsView(budgetRangeLookupView);

            budgetView.BudgetAmount    = 768 * 12;
            budgetView.BudgetHours     = 0;
            budgetView.ProjectedAmount = 800 * 12;
            budgetView.ProjectedHours  = 0;
            budgetView.ActualAmount    = budgetActualsView.ActualAmount;
            budgetView.ActualHours     = budgetActualsView.ActualHours;

            budgetMod.Budget.TransactBudget(budgetView).Apply();

            Assert.True(true);
        }