public List <IncomeExpensesVM> CalculateExpenseDetails(AprajitaRetailsContext db, DateTime onDate, bool Weekly)
        {
            List <IncomeExpensesVM> ExpensesDetails = new List <IncomeExpensesVM> ();
            DateTime startDate = onDate.StartOfWeek();
            DateTime endDate   = onDate.EndOfWeek();

            var exp       = db.Expenses.Where(c => c.ExpDate.Date >= startDate.Date && c.ExpDate.Date <= endDate.Date).ToList();
            var tailoradv = db.TailoringStaffAdvancePayments.Include(c => c.Employee).Where(c => c.PaymentDate.Date >= startDate.Date && c.PaymentDate.Date <= endDate.Date).ToList();

            var pettycashexp = db.PettyCashExpenses.Where(c => c.ExpDate.Date >= startDate.Date && c.ExpDate.Date <= endDate.Date).ToList();
            var tailor       = db.TailoringSalaryPayments.Include(c => c.Employee).Where(c => c.PaymentDate.Date >= startDate.Date && c.PaymentDate.Date <= endDate.Date).ToList();

            var cashpay   = db.CashPayments.Include(c => c.Mode).Where(c => c.PaymentDate.Date >= startDate.Date && c.PaymentDate.Date <= endDate.Date).ToList();
            var staff     = db.SalaryPayments.Include(c => c.Employee).Where(c => c.PaymentDate.Date >= startDate.Date && c.PaymentDate.Date <= endDate.Date).ToList();
            var staffavc  = db.StaffAdvancePayments.Include(c => c.Employee).Where(c => c.PaymentDate.Date >= startDate.Date && c.PaymentDate.Date <= endDate.Date).ToList();
            var TotalDues = db.DuesLists.Include(c => c.DailySale).Where(c => !c.IsRecovered && c.DailySale.SaleDate.Date >= startDate.Date && c.RecoveryDate.Value.Date <= endDate.Date).ToList();
            var paym      = db.Payments.Where(c => c.PayDate.Date >= startDate.Date && c.PayDate.Date <= endDate.Date).ToList();

            foreach (var item in paym)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.PayDate,
                    Particulars = item.PaymentPartry,
                    IsNonCash   = (item.PayMode == PaymentModes.Cash ? false : true)
                };
                ExpensesDetails.Add(vmdata);
            }
            foreach (var item in cashpay)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.PaymentDate,
                    Particulars = $"Paid to: {item.PaidTo}\t onAcc: {item.Mode.Transcation}",
                    IsNonCash   = false
                };
                ExpensesDetails.Add(vmdata);
            }
            foreach (var item in pettycashexp)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.ExpDate,
                    Particulars = item.Particulars,
                    IsNonCash   = false// ( item.PayMode == PaymentModes.Cash ? false : true )
                };
                ExpensesDetails.Add(vmdata);
            }
            foreach (var item in exp)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.ExpDate,
                    Particulars = item.Particulars,
                    IsNonCash   = (item.PayMode == PaymentModes.Cash ? false : true)
                };
                ExpensesDetails.Add(vmdata);
            }

            foreach (var item in tailor)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.PaymentDate,
                    Particulars = item.Employee.StaffName + "\t " + item.SalaryMonth,
                    IsNonCash   = (item.PayMode == PayModes.Cash ? false : true)
                };
                ExpensesDetails.Add(vmdata);
            }

            foreach (var item in tailoradv)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.PaymentDate,
                    Particulars = item.Employee.StaffName + "\t " + item.Details,
                    IsNonCash   = (item.PayMode == PayModes.Cash ? false : true)
                };
                ExpensesDetails.Add(vmdata);
            }
            foreach (var item in exp)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.ExpDate,
                    Particulars = item.Particulars,
                    IsNonCash   = (item.PayMode == PaymentModes.Cash ? false : true)
                };
                ExpensesDetails.Add(vmdata);
            }

            foreach (var item in staffavc)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.PaymentDate,
                    Particulars = item.Employee.StaffName + "\t " + item.Details,
                    IsNonCash   = (item.PayMode == PayModes.Cash ? false : true)
                };
                ExpensesDetails.Add(vmdata);
            }
            foreach (var item in TotalDues)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.DailySale.SaleDate,
                    Particulars = "Dues of Inv:" + item.DailySale.InvNo,
                    IsNonCash   = true
                };
                ExpensesDetails.Add(vmdata);
            }

            return(ExpensesDetails);
        }
        public List <IncomeExpensesVM> CalculateIncomeDetails(AprajitaRetailsContext db, DateTime onDate, bool Weekly)
        {
            List <IncomeExpensesVM> IncomeDetails = new List <IncomeExpensesVM> ();

            DateTime startDate = onDate.StartOfWeek();
            DateTime endDate   = onDate.EndOfWeek();
            var      tailor    = db.TailoringStaffAdvanceReceipts.Include(c => c.Employee).Where(c => c.ReceiptDate.Date >= startDate.Date && c.ReceiptDate.Date <= endDate.Date).ToList();
            var      sales     = db.DailySales.Where(c => c.SaleDate.Date >= startDate.Date && c.SaleDate.Date <= endDate.Date).ToList();
            var      cashRec   = db.CashReceipts.Where(c => c.InwardDate.Date >= startDate.Date && c.InwardDate.Date <= endDate.Date).ToList();
            var      staff     = db.StaffAdvanceReceipts.Include(c => c.Employee).Where(c => c.ReceiptDate.Date >= startDate.Date && c.ReceiptDate.Date <= endDate.Date).ToList();
            var      rec       = db.Receipts.Where(c => c.RecieptDate.Date >= startDate.Date && c.RecieptDate.Date <= endDate.Date).ToList();

            var recover = db.DueRecoverds.Include(c => c.DuesList).Include(c => c.DuesList.DailySale).Where(c => c.PaidDate.Date >= startDate.Date && c.PaidDate.Date <= endDate.Date).ToList();

            foreach (var item in sales)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.SaleDate,
                    Particulars = item.InvNo,
                    IsNonCash   = (item.PayMode == PayModes.Cash ? false : true)
                };
                IncomeDetails.Add(vmdata);
            }

            foreach (var item in cashRec)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.InwardDate,
                    Particulars = $"Slip No:{item.SlipNo}\t From: {item.ReceiptFrom}",
                    IsNonCash   = false
                };
                IncomeDetails.Add(vmdata);
            }

            foreach (var item in tailor)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.ReceiptDate,
                    Particulars = item.Employee.StaffName,
                    IsNonCash   = (item.PayMode == PayModes.Cash ? false : true)
                };
                IncomeDetails.Add(vmdata);
            }

            foreach (var item in staff)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.ReceiptDate,
                    Particulars = item.Employee.StaffName,
                    IsNonCash   = (item.PayMode == PayModes.Cash ? false : true)
                };
                IncomeDetails.Add(vmdata);
            }
            foreach (var item in rec)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.Amount,
                    OnDate      = item.RecieptDate,
                    Particulars = $"Slip No:{item.RecieptSlipNo}\t From: {item.ReceiptFrom}",
                    IsNonCash   = (item.PayMode == PaymentModes.Cash ? false : true)
                };
                IncomeDetails.Add(vmdata);
            }
            foreach (var item in recover)
            {
                IncomeExpensesVM vmdata = new IncomeExpensesVM
                {
                    Amount      = item.AmountPaid,
                    OnDate      = item.PaidDate,
                    Particulars = "Dues Recovered :" + item.DuesList.DailySale.InvNo,
                    IsNonCash   = (item.Modes == PaymentModes.Cash ? false : true)
                };
                IncomeDetails.Add(vmdata);
            }

            return(IncomeDetails);
        }