public static List <FinanceCardInfo> GetByPaymentInPeriod(DateTime fromDate, DateTime toDate, List <int> lstBranhces,
                                                                  List <int> lstInsuranceCompanies, List <int> lstInsuranceSubTypes, List <int> lstUsers, List <int> lstMarketingAgents)
        {
            decimal totSaldo = 0;
            List <FinanceCardInfo> retList     = new List <FinanceCardInfo>();
            List <Payment>         lstPayments = Payment.GetInPeriod(fromDate, toDate, lstBranhces, lstInsuranceCompanies, lstInsuranceSubTypes, lstUsers, lstMarketingAgents);

            foreach (Payment payment in lstPayments)
            {
                FinanceCardInfo fciPayment = new FinanceCardInfo();
                fciPayment.PolicyNumber = payment.Rate.PolicyItem.PolicyNumber;
                fciPayment.PolicyItemID = payment.Rate.PolicyItemID;
                fciPayment.DocumentDate = payment.Date;
                fciPayment.PaidDate     = payment.Rate.Date;
                if (lstPayments.Count == 1)
                {
                    fciPayment.Description = "Уплата по полиса " + payment.Rate.PolicyItem.PolicyNumber;
                }
                else
                {
                    fciPayment.Description = "Уплата за " + payment.Rate.Number + "-ва рата по полиса " + payment.Rate.PolicyItem.PolicyNumber;
                }
                fciPayment.DebtValue   = 0;
                fciPayment.DemandValue = payment.Value;
                fciPayment.SaldoValue  = totSaldo + (fciPayment.DebtValue - fciPayment.DemandValue);
                totSaldo = fciPayment.SaldoValue;
                retList.Add(fciPayment);
            }
            return(retList);
        }
        public static List <FinanceCardInfo> GetByRateInPeriod(DateTime fromDate, DateTime toDate, List <int> lstBranhces,
                                                               List <int> lstInsuranceCompanies, List <int> lstInsuranceSubTypes, List <int> lstUsers, List <int> lstMarketingAgents)
        {
            decimal totSaldo = 0;
            List <FinanceCardInfo> retList  = new List <FinanceCardInfo>();
            List <Rate>            lstRates = Rate.GetInPeriod(fromDate, toDate, lstBranhces, lstInsuranceCompanies, lstInsuranceSubTypes, lstUsers, lstMarketingAgents);

            foreach (Rate r in lstRates)
            {
                FinanceCardInfo fciRate = new FinanceCardInfo();
                fciRate.PolicyNumber = r.PolicyItem.PolicyNumber;
                fciRate.PolicyItemID = r.PolicyItemID;
                fciRate.DocumentDate = r.PolicyItem.Policy.ApplicationDate;
                fciRate.PaidDate     = r.Date;
                if (lstRates.Count == 1)
                {
                    fciRate.Description = "Продадена полиса " + r.PolicyItem.PolicyNumber;
                }
                else
                {
                    fciRate.Description = r.Number.ToString() + "-ва рата по полиса " + r.PolicyItem.PolicyNumber;
                }
                fciRate.DebtValue   = r.Value;
                fciRate.DemandValue = 0;
                fciRate.SaldoValue  = totSaldo + (fciRate.DebtValue - fciRate.DemandValue);
                totSaldo            = fciRate.SaldoValue;
                retList.Add(fciRate);
            }
            return(retList);
        }
        public static List <FinanceCardInfo> GetByPolicy(Policy p, decimal totSaldo)
        {
            List <FinanceCardInfo> retList = new List <FinanceCardInfo>();
            List <PolicyItem>      lstPI   = PolicyItem.GetByPolicy(p.ID);

            foreach (PolicyItem pi in lstPI)
            {
                List <Rate>    lstRates   = Rate.GetByPolicyItemID(pi.ID);
                List <Payment> lstPayment = Payment.GetByPolicyItemID(pi.ID);

                foreach (Rate r in lstRates)
                {
                    FinanceCardInfo fciRate = new FinanceCardInfo();
                    fciRate.DocumentDate = pi.Policy.ApplicationDate;
                    fciRate.PaidDate     = r.Date;
                    if (lstRates.Count == 1)
                    {
                        fciRate.Description = "Продадена полиса " + pi.PolicyNumber;
                    }
                    else
                    {
                        fciRate.Description = r.Number.ToString() + "-ва рата по полиса " + pi.PolicyNumber;
                    }
                    fciRate.DebtValue   = r.Value;
                    fciRate.DemandValue = 0;
                    fciRate.SaldoValue  = totSaldo + (fciRate.DebtValue - fciRate.DemandValue);
                    totSaldo            = fciRate.SaldoValue;
                    retList.Add(fciRate);
                }

                foreach (Payment payment in lstPayment)
                {
                    FinanceCardInfo fciPayment = new FinanceCardInfo();
                    fciPayment.DocumentDate = payment.Date;
                    fciPayment.PaidDate     = payment.Rate.Date;
                    if (lstRates.Count == 1)
                    {
                        fciPayment.Description = "Уплата по полиса " + pi.PolicyNumber;
                    }
                    else
                    {
                        fciPayment.Description = "Уплата за " + payment.Rate.Number + "-ва рата по полиса " + pi.PolicyNumber;
                    }
                    fciPayment.DebtValue   = 0;
                    fciPayment.DemandValue = payment.Value;
                    fciPayment.SaldoValue  = totSaldo + (fciPayment.DebtValue - fciPayment.DemandValue);
                    totSaldo = fciPayment.SaldoValue;
                    retList.Add(fciPayment);
                }
            }
            return(retList);
        }