示例#1
0
        public IList <SafeReportViewModel> GetSafeBalanceReport(long SafeId, DateTime?DateFrom, DateTime?DateTo)
        {
            //DateFrom = DateFrom.SetTimeToNow();
            DateTo = DateTo.SetTimeToMax();
            var lang   = this._languageService.CurrentLanguage;
            var userId = this._currentUserService.CurrentUserId;

            List <Transaction> source = new List <Transaction>();

            source.AddRange(this.VirtualPostPaymentMovement(SafeId, DateTo, lang, userId));
            source.AddRange(this.VirtualPostPurchaseInvoice(SafeId, DateTo, lang, userId));
            source.AddRange(this.VirtualPostPurchaseRebate(SafeId, DateTo, lang, userId));
            source.AddRange(this.VirtualPostReceiptsMovement(SafeId, DateTo, lang, userId));
            //source.AddRange(this.VirtualPostSalesInvoice(SafeId, DateTo, lang, userId));
            //source.AddRange(this.VirtualPostSalesRebate(SafeId, DateTo, lang, userId));
            //source.AddRange(this.VirtualPostStoreMovement(SafeId, DateTo, lang, userId));

            //DateTime dateBefore = DateFrom.Value.Subtract(new TimeSpan(1, 0, 0, 0, 0));
            List <SafeReportViewModel> AccountsReport = new List <SafeReportViewModel>();

            AccountsReport = GetSafeReportBeforeDate(SafeId, DateFrom.Value, source).ToList();

            var entityCollection = source.FindAll(x => x.Journal.Date > DateFrom);

            if (entityCollection.Any())
            {
                SafeReportViewModel accountCreditor = new SafeReportViewModel();
                SafeReportViewModel accountDebtor   = new SafeReportViewModel();
                accountCreditor.CreationDate  = DateFrom;
                accountCreditor.MovementType  = this._resourcesService[ResourceKeyEnum.TotalCreditBalanceInPeriod, lang].Value;
                accountCreditor.CreditorValue = 0;
                accountCreditor.DebtorValue   = 0;

                accountDebtor.CreationDate  = DateFrom;
                accountDebtor.MovementType  = this._resourcesService[ResourceKeyEnum.TotalDebtBalanceInPeriod, lang].Value;
                accountDebtor.DebtorValue   = 0;
                accountDebtor.CreditorValue = 0;
                foreach (var item in entityCollection)
                {
                    if (item.Amount < 1)
                    {
                        continue;
                    }
                    else
                    {
                        if (item.IsCreditor)
                        {
                            accountCreditor.CreditorValue += item.Amount;
                        }
                        else
                        {
                            accountDebtor.DebtorValue += item.Amount;
                        }
                    }
                }
                AccountsReport.Add(accountCreditor);
                AccountsReport.Add(accountDebtor);
            }
            return(AccountsReport);
        }
示例#2
0
        public SafeReportViewModel mapToReportModel(Transaction item, Language lang)
        {
            SafeReportViewModel account = new SafeReportViewModel();

            account.Name     = item.AccountChart.ChildTranslatedAccountCharts.FirstOrDefault(x => x.Language == lang).Name;
            account.Code     = item.AccountChart.Code;
            account.FullCode = item.AccountChart.FullCode;

            account.CreationDate = item.Journal.Date;
            //account.CreationDate = item.CreationDate;

            if (lang == Language.English)
            {
                account.Description = item.DescriptionEN;
            }
            else
            {
                account.Description = item.DescriptionAR;
            }

            account.MovementType = this._resourcesService.GetMovementTypeName(item.Journal.MovementType, lang);

            account.DocumentCode = item.Journal.ObjectId.ToString();
            //account.DocumentCode = item.Id.ToString();

            if (item.IsCreditor)
            {
                account.CreditorValue = item.Amount;
                account.DebtorValue   = 0;
            }
            else
            {
                account.CreditorValue = 0;
                account.DebtorValue   = item.Amount;
            }

            return(account);
        }
示例#3
0
        public IList <SafeReportViewModel> GetSafeReportBeforeDate(long SafeId, DateTime DateFrom, List <Transaction> source)
        {
            var lang = this._languageService.CurrentLanguage;
            //DateFrom = DateFrom.SetTimeToNow();

            List <SafeReportViewModel> AccountsReport = new List <SafeReportViewModel>();
            var currentSafe = this._safesRepository.Get(SafeId);

            //var currentAccount = currentSafe.AccountChart;

            #region OpeningBalance
            SafeReportViewModel account = new SafeReportViewModel();
            account.Name         = currentSafe.ChildTranslatedSafes.FirstOrDefault(x => x.Language == lang).Name;
            account.Code         = currentSafe.Code; //currentAccount.Code;
            account.FullCode     = currentSafe.Code; //currentAccount.FullCode;
            account.CreationDate = currentSafe.CreationDate;
            account.Description  = "";
            account.MovementType = this._resourcesService[ResourceKeyEnum.OpeningBalance, lang].Value;
            account.DocumentCode = currentSafe.Code;
            if (currentSafe.IsDebt != null)
            {
                if (currentSafe.IsDebt == true)
                {
                    account.CreditorValue = currentSafe.OpeningCredit;
                    account.DebtorValue   = 0;
                }
                else
                {
                    account.CreditorValue = 0;
                    account.DebtorValue   = currentSafe.OpeningCredit;
                }
            }
            else
            {
                account.CreditorValue = 0;
                account.DebtorValue   = 0;
            }
            account.SafeName = currentSafe.ChildTranslatedSafes.FirstOrDefault(x => x.Language == lang).Name;
            AccountsReport.Add(account);


            //SafeReportViewModel account = new SafeReportViewModel();
            //account.Name = currentAccount.ChildTranslatedAccountCharts.First().Name;
            //account.Code = currentSafe.Code; //currentAccount.Code;
            //account.FullCode = currentSafe.Code; //currentAccount.FullCode;
            //account.CreationDate = currentAccount.CreationDate;
            //account.Description = "";
            //account.MovementType = this._resourcesService[ResourceKeyEnum.OpeningBalance, lang].Value;
            //account.DocumentCode = currentAccount.Code;
            //if (currentAccount.IsDebt != null)
            //{
            //    if (currentAccount.IsDebt == true)
            //    {
            //        account.CreditorValue = currentAccount.OpeningCredit;
            //        account.DebtorValue = 0;
            //    }
            //    else
            //    {
            //        account.CreditorValue = 0;
            //       account.DebtorValue = currentAccount.OpeningCredit;
            //    }
            //}
            //else
            //{
            //    account.CreditorValue = 0;
            //    account.DebtorValue = 0;
            //}
            //account.SafeName = currentSafe.Name;
            //AccountsReport.Add(account);
            #endregion

            var entityCollection = source.FindAll(x => x.Journal.Date <= DateFrom);
            if (entityCollection.Any())
            {
                SafeReportViewModel accountCreditor = new SafeReportViewModel();
                SafeReportViewModel accountDebtor   = new SafeReportViewModel();
                accountCreditor.CreationDate  = DateFrom.AddDays(-1);
                accountCreditor.MovementType  = this._resourcesService[ResourceKeyEnum.TotalCreditBalanceBeforePeriod, lang].Value;
                accountCreditor.CreditorValue = 0;
                accountCreditor.DebtorValue   = 0;

                accountDebtor.CreationDate  = DateFrom.AddDays(-1);
                accountDebtor.MovementType  = this._resourcesService[ResourceKeyEnum.TotalDebtBalanceBeforePeriod, lang].Value;
                accountDebtor.DebtorValue   = 0;
                accountDebtor.CreditorValue = 0;
                foreach (var item in entityCollection)
                {
                    if (item.Amount < 1)
                    {
                        continue;
                    }
                    else
                    {
                        if (item.IsCreditor)
                        {
                            accountCreditor.CreditorValue += item.Amount;
                        }
                        else
                        {
                            accountDebtor.DebtorValue += item.Amount;
                        }
                    }
                }
                AccountsReport.Add(accountCreditor);
                AccountsReport.Add(accountDebtor);
            }
            //foreach (var item in entityCollection)
            //{
            //    if (item.Amount < 1)
            //        continue;
            //    else
            //        AccountsReport.Add(mapToReportModel(item, lang));
            //}
            return(AccountsReport);
        }