Example #1
0
        public async Task <BudgetActualsView> GetActualsView(BudgetRangeView budgetRangeView)
        {
            try
            {
                UDC udcActuals = await GetUdc("GENERALLEDGERTYPE", "AA");

                UDC udcHours = await GetUdc("GENERALLEDGERTYPE", "HA");



                BudgetActualsView budgetActualsView = applicationViewFactory.MapBudgetRangeToBudgetActuals(budgetRangeView);


                //query actual amounts
                decimal actualAmount = (from e in _dbContext.GeneralLedgers
                                        where e.AccountId == budgetRangeView.AccountId &&
                                        e.GLDate >= budgetRangeView.StartDate &&
                                        e.GLDate <= budgetRangeView.EndDate &&
                                        e.LedgerType == udcActuals.KeyCode
                                        select e.Amount
                                        ).Sum();
                budgetActualsView.ActualAmount = actualAmount;
                //query actual hours
                decimal?actualHours = (from e in _dbContext.GeneralLedgers
                                       where e.AccountId == budgetRangeView.AccountId &&
                                       e.GLDate >= budgetRangeView.StartDate &&
                                       e.GLDate <= budgetRangeView.EndDate &&
                                       e.LedgerType == udcHours.KeyCode
                                       select e.Units
                                       ).Sum();
                budgetActualsView.ActualHours = actualHours ?? 0;
                return(budgetActualsView);
            }
            catch (Exception ex) { throw new Exception(GetMyMethodName(), ex); }
        }
Example #2
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);
        }