Exemplo n.º 1
0
        public async Task <BudgetActualsView> GetActualsView(BudgetRangeView budgetRangeView, string actualsKeyCode, string hoursKeyCode)
        {
            try
            {
                // Udc udcActuals = await GetUdc("GENERALLEDGERTYPE", "AA");
                //Udc udcHours = await GetUdc("GENERALLEDGERTYPE", "HA");



                BudgetActualsView budgetActualsView = applicationViewFactory.MapBudgetRangeToBudgetActuals(budgetRangeView);


                //query actual amounts
                decimal actualAmount = await(from e in _dbContext.GeneralLedger
                                             where e.AccountId == budgetRangeView.AccountId &&
                                             e.Gldate >= budgetRangeView.StartDate &&
                                             e.Gldate <= budgetRangeView.EndDate &&
                                             e.LedgerType == actualsKeyCode
                                             select e.Amount
                                             ).SumAsync();
                budgetActualsView.ActualAmount = actualAmount;
                //query actual hours
                decimal?actualHours = await(from e in _dbContext.GeneralLedger
                                            where e.AccountId == budgetRangeView.AccountId &&
                                            e.Gldate >= budgetRangeView.StartDate &&
                                            e.Gldate <= budgetRangeView.EndDate &&
                                            e.LedgerType == hoursKeyCode
                                            select e.Units
                                            ).SumAsync();
                budgetActualsView.ActualHours = actualHours ?? 0;
                return(budgetActualsView);
            }
            catch (Exception ex) { throw new Exception(GetMyMethodName(), ex); }
        }
Exemplo n.º 2
0
        public async Task <BudgetActualsView> GetBudgetActualsView(BudgetRangeView budgetRangeView)
        {
            Udc udcActuals = await _unitOfWork.udcRepository.GetUdc("GENERALLEDGERTYPE", "AA");

            Udc udcHours = await _unitOfWork.udcRepository.GetUdc("GENERALLEDGERTYPE", "HA");

            BudgetActualsView budgetActualsView = await _unitOfWork.budgetRepository.GetActualsView(budgetRangeView, udcActuals.KeyCode, udcHours.KeyCode);

            return(budgetActualsView);
        }
Exemplo n.º 3
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);
        }