Exemple #1
0
        public async Task <CreateProcessStatus> TransactBudget(BudgetView budgetView)
        {
            try
            {
                Budget budgetLookup = await(from e in _dbContext.Budgets
                                            where e.AccountId == budgetView.AccountId &&
                                            e.RangeId == budgetView.RangeId
                                            select e
                                            ).FirstOrDefaultAsync <Budget>();
                if (budgetLookup == null)
                {
                    Budget newBudget = new Budget();
                    applicationViewFactory.MapBudgetEntity(ref newBudget, budgetView);
                    AddObject(newBudget);
                    return(CreateProcessStatus.Insert);
                }
                else

                {
                    budgetView.BudgetId = budgetLookup.BudgetId;
                    applicationViewFactory.MapBudgetEntity(ref budgetLookup, budgetView);
                    UpdateObject(budgetLookup);
                    return(CreateProcessStatus.Update);
                }
            }
            catch (Exception ex) { throw new Exception(GetMyMethodName(), ex); }
        }
Exemple #2
0
        public async Task <BudgetView> GetBudgetView(long budgetId)
        {
            Budget budget = await(from e in _dbContext.Budgets
                                  where e.BudgetId == budgetId
                                  select e).FirstOrDefaultAsync <Budget>();

            BudgetView budgetView = null;

            if (budget != null)
            {
                budgetView = applicationViewFactory.MapBudgetView(budget);
            }
            return(budgetView);
        }
Exemple #3
0
        public void TestGetBudget()
        {
            long budgetId = 2;

            UnitOfWork unitOfWork = new UnitOfWork();

            BudgetModule budgetMod = new BudgetModule();

            BudgetView budgetView = budgetMod.Budget.Query().GetBudgetView(budgetId);

            if (budgetView != null)
            {
                Assert.True(true);
            }
        }
Exemple #4
0
        public async Task TestCreateBudget()
        {
            UnitOfWork unitOfWork = new UnitOfWork();

            BudgetModule budgetMod = new BudgetModule();

            BudgetRangeView budgetRangeView = new BudgetRangeView();

            //personal mortgage
            ChartOfAccts coa = await unitOfWork.chartOfAccountRepository.GetChartofAccount("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.BusinessUnit   = 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 = budgetMod.BudgetRange.Query().GetBudgetRange(budgetRangeView.AccountId, budgetRangeView.StartDate, budgetRangeView.EndDate);

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

            BudgetActualsView budgetActualsView = 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);
        }
Exemple #5
0
 public void MapRangeToBudgetView(ref BudgetView budgetView, BudgetRangeView budgetRangeView)
 {
     applicationViewFactory.MapRangeToBudgetViewEntity(ref budgetView, budgetRangeView);
 }