예제 #1
0
        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);
        }