Exemple #1
0
        public static List <AccountSummary> GetAccSummaryByParentAccId(string parentAccId,
                                                                       bool isCreditAccount = false, DateTime?fromDate = null, DateTime?toDate = null)
        {
            List <AccountSummary>     accSummary = new List <AccountSummary>();
            ReportsAccountingEntities db         = new ReportsAccountingEntities();
            var spResult = db.GetAccountSummaryByParentAccId(parentAccId, fromDate, toDate).ToList();

            Mapper.CreateMap <GetAccountSummaryByParentAccId_Result, AccountSummary>();
            Mapper.Map(spResult, accSummary);

            foreach (var item in accSummary)
            {
                if (isCreditAccount)
                {
                    item.DiffAmount = item.CreditAmount - item.DebitAmout;
                }
                else
                {
                    item.DiffAmount = item.DebitAmout - item.CreditAmount;
                }
            }


            return(accSummary.OrderByDescending(x => x.DiffAmount).ToList());
        }
Exemple #2
0
        public static List <AccRpt_TopViewBalance2_Result> GetTopViewBalanceRpt(DateTime?fromDate = null,
                                                                                DateTime?toDate   = null)
        {
            ReportsAccountingEntities db = new ReportsAccountingEntities();
            var result = db.AccRpt_TopViewBalance2(fromDate, toDate).ToList();

            return(result);
        }
Exemple #3
0
        public static JObject GetAccTransByAccId(string accId, string fromDate = null, string toDate = null)
        {
            List <AccountSummary>     accSummary = new List <AccountSummary>();
            ReportsAccountingEntities db         = new ReportsAccountingEntities();
            var spResult = db.GetAccountDetailsByAccId(accId, fromDate == "" ? null : fromDate, toDate == "" ? null : toDate).ToList();

            JTokenWriter pJTokenWriter = new JTokenWriter();
            JObject      ordersJson    = new JObject();

            pJTokenWriter.WriteStartObject();
            pJTokenWriter.WritePropertyName("data");
            pJTokenWriter.WriteStartArray();
            foreach (var item in spResult)
            {
                pJTokenWriter.WriteStartObject();
                pJTokenWriter.WritePropertyName("AccountId");
                pJTokenWriter.WriteValue(item.AccountId);

                pJTokenWriter.WritePropertyName("CreateDate");
                pJTokenWriter.WriteValue(item.CreateDate.ToString("dd/MM/yyyy"));

                pJTokenWriter.WritePropertyName("CreateBy");
                pJTokenWriter.WriteValue(item.UserName);

                pJTokenWriter.WritePropertyName("DebitAmount");
                pJTokenWriter.WriteValue(item.DebitAmount);

                pJTokenWriter.WritePropertyName("CreditAmount");
                pJTokenWriter.WriteValue(item.CreditAmount);

                pJTokenWriter.WritePropertyName("CurrencySign");
                pJTokenWriter.WriteValue(item.CurrencySign);

                pJTokenWriter.WritePropertyName("TransactionName");
                pJTokenWriter.WriteValue(item.TransactionName);

                pJTokenWriter.WritePropertyName("TransactionNameAr");
                pJTokenWriter.WriteValue(item.TransactionNameAr);

                pJTokenWriter.WritePropertyName("ReceiptNotes");
                //pJTokenWriter.WriteValue(item.ReceiptNotes);
                pJTokenWriter.WriteValue("");

                pJTokenWriter.WriteEndObject();
            }

            pJTokenWriter.WriteEndArray();
            pJTokenWriter.WriteEndObject();
            ordersJson = (JObject)pJTokenWriter.Token;
            return(ordersJson);
        }
Exemple #4
0
        /// <summary>
        /// Get Account Summary contains totals grouped by currency for specific account number
        /// Used to fill summary table at page top
        /// </summary>
        /// <param name="accId"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <returns></returns>
        public static AccountSummary GetAccSummaryByAccId(string accId, string fromDate = null, string toDate = null)
        {
            ReportsAccountingEntities db         = new ReportsAccountingEntities();
            AccountSummary            accSummary = new AccountSummary();
            var spResult = db.GetAccountDetailsByAccId(accId, fromDate == "" ? null : fromDate, toDate == "" ? null : toDate).ToList();

            if (spResult.Count > 0)
            {
                accSummary.AccountNameEn = spResult.FirstOrDefault().AccountNameEn;
                accSummary.AccountNameAr = spResult.FirstOrDefault().AccountNameAr;
                accSummary.DiffAmount    = accSummary.DebitAmout - accSummary.CreditAmount;

                var grouped = spResult.GroupBy(x => x.CurrencySign)
                              .Select(x => new
                {
                    Currency  = x.Key,
                    DebitSum  = x.Sum(y => y.DebitAmount),
                    CreditSum = x.Sum(y => y.CreditAmount)
                }).ToList();

                List <AccountSummaryTotal> sumByCurrency = new List <AccountSummaryTotal>();
                AccountSummaryTotal        accountSummaryTotal;
                decimal diffAmount;
                foreach (var item in grouped)
                {
                    accountSummaryTotal = new AccountSummaryTotal();
                    accountSummaryTotal.CurrencySign = item.Currency;
                    diffAmount = item.DebitSum - item.CreditSum;
                    if (diffAmount > 0)
                    {
                        accountSummaryTotal.DebitAmout = diffAmount;
                    }
                    else
                    {
                        accountSummaryTotal.CreditAmount = diffAmount * -1;
                    }

                    sumByCurrency.Add(accountSummaryTotal);
                }

                accSummary.TotalByCurrency = sumByCurrency;
            }

            return(accSummary);
        }