Esempio n. 1
0
        public static void InsertItems(RollBackDistribution rbd, List <RollBackDistributionInfo> previousMonths, List <RollBackDistributionInfo> currentMonths)
        {
            decimal totalValue     = 0;
            decimal brokerageValue = 0;

            foreach (RollBackDistributionInfo rbdi in previousMonths)
            {
                if (rbdi.IsForRollBack)
                {
                    PolicyItem pi = PolicyItem.Get(rbdi.ID);
                    if (!pi.Policy.Discard)
                    {
                        totalValue     += rbdi.PremiumValue;
                        brokerageValue += rbdi.BrokerageValue;
                    }
                    RollBackDistributionItem rbdItem = new RollBackDistributionItem();
                    rbdItem.PolicyItemID           = rbdi.ID;
                    rbdItem.RollBackDistributionID = rbd.ID;
                    pi.IsRollBacked = true;
                    rbdItem.Insert();
                }
            }
            foreach (RollBackDistributionInfo rbdi in currentMonths)
            {
                if (rbdi.IsForRollBack)
                {
                    PolicyItem pi = PolicyItem.Get(rbdi.ID);
                    if (!pi.Policy.Discard)
                    {
                        totalValue     += rbdi.PremiumValue;
                        brokerageValue += rbdi.BrokerageValue;
                    }
                    RollBackDistributionItem rbdItem = new RollBackDistributionItem();
                    rbdItem.PolicyItemID           = rbdi.ID;
                    rbdItem.RollBackDistributionID = rbd.ID;
                    pi.IsRollBacked = true;
                    rbdItem.Insert();
                }
            }
            RollBackDistribution.UpdateValues(totalValue, brokerageValue, rbd.ID);
        }
Esempio n. 2
0
        public static void GetForRollBack(RollBackDistribution rbd, List <Policy> policyList)
        {
            List <RollBackDistributionItem> rbdiList = new List <RollBackDistributionItem>();
            decimal totalValue     = 0;
            decimal brokerageValue = 0;

            // List<Policy> policyList = Policy.GetByCompanyAndPeriod(rbd.InsuranceCompanyID, rbd.StartDate, rbd.EndDate);
            foreach (Policy p in policyList)
            {
                foreach (PolicyItem pi in p.PolicyItems)
                {
                    totalValue     += pi.PremiumValue;
                    brokerageValue += pi.BrokerageValue;
                    RollBackDistributionItem rdbi = new RollBackDistributionItem();
                    rdbi.PolicyItemID           = pi.ID;
                    rdbi.RollBackDistributionID = rbd.ID;
                    pi.IsRollBacked             = true;
                    rdbi.Insert();
                }
            }

            RollBackDistribution.UpdateValues(totalValue, brokerageValue, rbd.ID);
        }