public IList <BalanceSheetReportViewModel> GetBalanceSheetReport(int level, DateTime?DateFrom, DateTime?DateTo) { var lang = this._languageService.CurrentLanguage; //DateFrom = DateFrom.SetTimeToNow(); DateTo = DateTo.SetTimeToMax(); List <BalanceSheetReportViewModel> list = new List <BalanceSheetReportViewModel>(); var accountList = this._AccountChartsRepository.Get(null).Where(x => x.AccountLevel == level).ToList(); foreach (var item in accountList) { var reportRow = new BalanceSheetReportViewModel { Level = level, Code = item.Code, CreditorValue = 0, DebtorValue = 0, DocumentCode = item.Id.ToString(), FullCode = item.FullCode, Name = item.ChildTranslatedAccountCharts.FirstOrDefault(x => x.Language == lang).Name, OpeningCredit = 0, OpeningDebit = 0 }; reportRow = this.GetOpeningBalance(reportRow, item.Id, DateFrom, DateTo, item); reportRow.TotalCreditValue = reportRow.OpeningCredit + reportRow.CreditorValue; reportRow.TotalDebtValue = reportRow.OpeningDebit + reportRow.DebtorValue; list.Add(reportRow); } return(list); }
private void OnNav(string Destination) { switch (Destination) { case "generalledgerParam": GeneralLedgerViewModel = ContainerHelper.Container.Resolve <GeneralLedgerViewModel>(); CurrentViewModel = GeneralLedgerViewModel; break; case "PurchaseReportParam": PurchaseReportViewModel = ContainerHelper.Container.Resolve <PurchaseReportViewModel>(); CurrentViewModel = PurchaseReportViewModel; break; case "SalesReportParam": SalesReportViewModel = ContainerHelper.Container.Resolve <SalesReportViewModel>(); CurrentViewModel = SalesReportViewModel; break; case "IncomeReportParam": IncomeStatementReportViewModel = ContainerHelper.Container.Resolve <IncomeStatementReportViewModel>(); CurrentViewModel = IncomeStatementReportViewModel; break; case "TrialBalanceReportParam": TrialBalanceReportViewModel = ContainerHelper.Container.Resolve <TrialBalanceReportViewModel>(); CurrentViewModel = TrialBalanceReportViewModel; break; case "BalanceSheetReportParam": BalanceSheetReportViewModel = ContainerHelper.Container.Resolve <BalanceSheetReportViewModel>(); CurrentViewModel = BalanceSheetReportViewModel; break; } //if (Isvirgin) //{ // IsReportMayLoaded = false; // await Task.Delay(5000).ContinueWith(a => IsReportMayLoaded = true); //} //Isvirgin = false; }
public BalanceSheetReportControl() { vm = ContainerHelper.Container.Resolve <BalanceSheetReportViewModel>(); DataContext = vm; InitializeComponent(); }
public BalanceSheetReportViewModel GetOpeningBalance(BalanceSheetReportViewModel source, long accountChartId, DateTime?dateFrom, DateTime?dateTo, AccountChart accountChart = null) { if (accountChart == null) { accountChart = this._AccountChartsRepository.Get(accountChartId); } //DateTime? dateBefore = dateFrom.Value.Subtract(new TimeSpan(1, 0, 0, 0)); if (accountChart.IsDebt.HasValue && accountChart.OpeningCredit.HasValue && accountChart.CreationDate <= dateTo) { if (dateFrom.HasValue && accountChart.CreationDate < dateFrom) { source.OpeningCredit += (accountChart.IsDebt.Value == false) ? accountChart.OpeningCredit : 0; source.OpeningDebit += (accountChart.IsDebt.Value == true) ? accountChart.OpeningCredit : 0; } else { source.CreditorValue += (accountChart.IsDebt.Value == false) ? accountChart.OpeningCredit : 0; source.DebtorValue += (accountChart.IsDebt.Value == true) ? accountChart.OpeningCredit : 0; } } if (accountChart.AccountTypeId == (long)AccountTypeEnum.Sub) { var transCollection = this._TransactionsRepository.Get(null).Where(x => x.Journal.PostingStatus == PostingStatus.Approved && x.AccountChartId == accountChartId && x.CreationDate <= dateTo //x.Journal.Date <= dateTo ); if (transCollection.Count() > 0) { foreach (var trans in transCollection) { if (dateFrom.HasValue && trans.CreationDate < dateFrom) { if (trans.IsCreditor == true) { source.OpeningCredit += trans.Amount; } else { source.OpeningDebit += trans.Amount; } } else { if (trans.IsCreditor == true) { source.CreditorValue += trans.Amount; } else { source.DebtorValue += trans.Amount; } } } } } if (accountChart.ChildAccountCharts.Count > 0) { foreach (var item in accountChart.ChildAccountCharts) { source = this.GetOpeningBalance(source, item.Id, dateFrom, dateTo); } } return(source); }