Example #1
0
            public List <Models.MViewModels.MViewPaymentHistory> GetPaymentHistory(int OrderId)
            {
                List <Models.MViewModels.MViewPaymentHistory> PaymentHistory = new List <Models.MViewModels.MViewPaymentHistory>();
                List <Models.MPayments>   Payments     = new List <Models.MPayments>();
                List <Models.PaymentLine> PaymentsLine = new List <Models.PaymentLine>()
                , tempPaymentsLine = new List <Models.PaymentLine>();

                Classes.CPayment       cp  = new CPayment();
                Classes.CPaymentLine   cpl = new CPaymentLine();
                Classes.CBankOfAccount cb  = new CBankOfAccount();
                Classes.CCashAccount   cca = new CCashAccount();
                Payments     = cp.GetAll();
                Payments     = Payments.Where(o => o.OrderId == OrderId).ToList();
                PaymentsLine = cpl.GetAll();
                for (int i = 0; i < Payments.Count; i++)
                {
                    tempPaymentsLine.Clear();
                    tempPaymentsLine = PaymentsLine.Where(o => o.PaymentId == Payments[i].id).ToList();
                    float CummulativePayment = 0;
                    for (int j = 0; j < tempPaymentsLine.Count; j++)
                    {
                        Models.MViewModels.MViewPaymentHistory ph = new Models.MViewModels.MViewPaymentHistory();
                        string AccountName = string.Empty;
                        if (tempPaymentsLine[j].ModeOfPayment == Common.Constants.ModeOfPayment.Cheque.ToString())
                        {
                            AccountName = cb.GetAccountNumberAccountTileById(tempPaymentsLine[j].BankId);
                        }
                        if (tempPaymentsLine[j].ModeOfPayment == Common.Constants.ModeOfPayment.Cash.ToString())
                        {
                            AccountName = cca.GetAccountNameById(tempPaymentsLine[j].BankId);
                        }
                        ph.AccountName        = AccountName;
                        ph.ChequeNumber       = tempPaymentsLine[j].Cheque;
                        ph.Date               = tempPaymentsLine[j].Date;
                        ph.ModeOfPayment      = tempPaymentsLine[j].ModeOfPayment;
                        ph.PaidAmount         = tempPaymentsLine[j].PaidAmount;
                        CummulativePayment   += Convert.ToSingle(tempPaymentsLine[j].PaidAmount);
                        ph.CummulativePayment = CummulativePayment.ToString();
                        PaymentHistory.Add(ph);
                    }
                }
                return(PaymentHistory);
            }
Example #2
0
            public List <Models.MViewModels.MViewCashAccountBalanceSheet> GetAll(string AccountType)
            {
                List <Models.MViewModels.MViewCashAccountBalanceSheet> Get = new List <Models.MViewModels.MViewCashAccountBalanceSheet>();

                Models.MViewModels.MViewCashAccountBalanceSheet mvt = new Models.MViewModels.MViewCashAccountBalanceSheet();
                List <Models.MCashTransactions> CashTransactions    = new List <Models.MCashTransactions>();
                List <Models.MCashAccount>      CashAccounts        = new List <Models.MCashAccount>();

                Classes.CCashTransaction cct = new CCashTransaction();
                Classes.CCashAccount     cca = new CCashAccount();
                Classes.CUsers           cu  = new CUsers();
                CashAccounts     = cca.GetAll();
                CashTransactions = cct.GetAll();
                Get.Clear();
                switch (AccountType)
                {
                case "Personal":
                {
                    var joined = from ct in CashTransactions
                                 join ca in CashAccounts
                                 on ct.CashAccountId equals ca.id
                                 where ca.AccountType == Common.Constants.CashAccountTypes.Personal.ToString()
                                 select ct;

                    foreach (var item in joined)
                    {
                        mvt = new Models.MViewModels.MViewCashAccountBalanceSheet();
                        string AccountName = cca.GetAccountNameById(item.CashAccountId);
                        string UserName    = cu.GetUserNameById(Convert.ToInt32(item.UserId));
                        mvt.AccountId     = AccountName;
                        mvt.Balance       = item.Total;
                        mvt.Credit        = item.Credit;
                        mvt.Debit         = item.Debit;
                        mvt.Description   = item.Description;
                        mvt.TransactionBy = UserName;
                        mvt.Date          = item.eDate;
                        Get.Add(mvt);
                    }
                    break;
                }

                case "Vendor":
                {
                    var joined = from ct in CashTransactions
                                 join ca in CashAccounts
                                 on ct.CashAccountId equals ca.id
                                 where ca.AccountType == Common.Constants.CashAccountTypes.Vendor.ToString()
                                 select ct;

                    foreach (var item in joined)
                    {
                        mvt = new Models.MViewModels.MViewCashAccountBalanceSheet();
                        string AccountName = cca.GetAccountNameById(item.CashAccountId);
                        string UserName    = cu.GetUserNameById(Convert.ToInt32(item.UserId));
                        mvt.AccountId     = AccountName;
                        mvt.Balance       = item.Total;
                        mvt.Credit        = item.Credit;
                        mvt.Debit         = item.Debit;
                        mvt.Description   = item.Description;
                        mvt.TransactionBy = UserName;
                        mvt.Date          = item.eDate;
                        Get.Add(mvt);
                    }
                    break;
                }

                case "Client":
                {
                    var joined = from ct in CashTransactions

                                 join ca in CashAccounts
                                 on ct.CashAccountId equals ca.id
                                 where ca.AccountType == Common.Constants.CashAccountTypes.Client.ToString()
                                 select ct;

                    foreach (var item in joined)
                    {
                        mvt = new Models.MViewModels.MViewCashAccountBalanceSheet();
                        string AccountName = cca.GetAccountNameById(item.CashAccountId);
                        string UserName    = cu.GetUserNameById(Convert.ToInt32(item.UserId));
                        mvt.AccountId     = AccountName;
                        mvt.Balance       = item.Total;
                        mvt.Credit        = item.Credit;
                        mvt.Debit         = item.Debit;
                        mvt.Description   = item.Description;
                        mvt.TransactionBy = UserName;
                        mvt.Date          = item.eDate;
                        Get.Add(mvt);
                    }
                    break;
                }

                default:
                    break;
                }


                return(Get);
            }