Beispiel #1
0
        private SubjectPosition ConstructSubject(Dictionary <string, object> KeyValueData)
        {
            object CausesOfLossObject;
            HashSet <SymbolicValue> CausesOfLoss = new HashSet <SymbolicValue>();

            if (KeyValueData.TryGetValue("CausesOfLoss", out CausesOfLossObject))
            {
                CausesOfLoss.UnionWith(ToHashSet(CausesOfLossObject.ToString()));
            }

            object ScheduleObject;
            HashSet <SymbolicValue> ScheduleSymbols = new HashSet <SymbolicValue>();

            if (KeyValueData.TryGetValue("Schedule", out ScheduleObject))
            {
                ScheduleSymbols.UnionWith(ToHashSet(ScheduleObject.ToString()));
            }
            Schedule _Schedule = new Schedule(ScheduleSymbols);

            object ExposureTypesObject;
            HashSet <SymbolicValue> ExposureTypes = new HashSet <SymbolicValue>();

            if (KeyValueData.TryGetValue("ExposureTypes", out ExposureTypesObject))
            {
                ExposureTypes.UnionWith(ToHashSet(ExposureTypesObject.ToString()));
            }

            bool Resolution = false;

            if (KeyValueData.ContainsKey("PerRisk"))
            {
                Resolution = bool.Parse((string)KeyValueData["PerRisk"]);
            }

            if ((CausesOfLoss.Count == 0) && (ScheduleSymbols.Count == 0) && (ExposureTypes.Count == 0))
            {
                SubjectPosition CoverSubjectPosition = new SubjectPosition();
                if (this.ContractSubject is Subject)
                {
                    CoverSubjectPosition = new Subject(this.ContractSubject as Subject);
                    ((Subject)CoverSubjectPosition).PerRisk = Resolution;
                }
                else if (this.ContractSubject is NetPosition)
                {
                    CoverSubjectPosition = new NetPosition(this.ContractSubject as NetPosition);
                }
                else if (this.ContractSubject is SubjectPosition)
                {
                    CoverSubjectPosition = new SubjectPosition(this.ContractSubject as SubjectPosition);
                }

                return(CoverSubjectPosition);
            }


            return(new Subject(UniversalSubject, _Schedule, CausesOfLoss, ExposureTypes, ResolvedSchedule, CoverageIdAttrMap, Resolution));
        }
Beispiel #2
0
        public Contract(Dictionary <string, object> IR,
                        Dictionary <string, HashSet <long> > resolvedSchedule,
                        Dictionary <long, RiskItemCharacteristicIDAttributes> CoverageIdAttrMap)
        {
            this.ResolvedSchedule  = resolvedSchedule;
            this.CoverageIdAttrMap = CoverageIdAttrMap;

            // Construct universal subject position
            HashSet <long> AllRITEIds = new HashSet <long>();

            if (resolvedSchedule != null)
            {
                AllRITEIds = resolvedSchedule.Aggregate(new HashSet <long>(), (a, b) => { a.UnionWith(b.Value); return(a); });
            }

            HashSet <long> AllRiskItemIds = new HashSet <long>();

            if (CoverageIdAttrMap != null)
            {
                AllRiskItemIds = new HashSet <long>(AllRITEIds.Where(x => CoverageIdAttrMap.ContainsKey(x)).Select(x => CoverageIdAttrMap[x].RITExposureId).Distinct());
            }

            UniversalSubject = new UniversalSubjectPosition(AllRITEIds, AllRiskItemIds);

            // Declarations
            Declarations = (Dictionary <string, object>)IR["Declarations"];

            // Claims Adjustment Settings
            if (!Declarations.ContainsKey("Claims Adjustment Options") ||
                Declarations["Claims Adjustment Options"] == null)
            {
                _AreSublimitsNetOfDeductible = false;
                _AreDeductiblesAbsorbable    = false;
            }
            else
            {
                if (!((Declarations["Claims Adjustment Options"] as Dictionary <string, object>).ContainsKey("Claims Adjustment Sublimits")) ||
                    (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Sublimits"] == null)
                {
                    _AreSublimitsNetOfDeductible = false;
                }
                else
                {
                    _AreSublimitsNetOfDeductible = (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Sublimits"].ToString().Equals("Net Of Deductible");
                }

                if (!((Declarations["Claims Adjustment Options"] as Dictionary <string, object>).ContainsKey("Claims Adjustment Deductibles")) ||
                    (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Deductibles"] == null)
                {
                    _AreDeductiblesAbsorbable = false;
                }
                else
                {
                    _AreDeductiblesAbsorbable = (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Deductibles"].ToString().Equals("Absorbable");
                }
            }


            object NameObject;

            if (Declarations.TryGetValue("Name", out NameObject))
            {
                this.Name = NameObject.ToString();
            }

            object CausesOfLossObject;

            Declarations.TryGetValue("CausesOfLoss", out CausesOfLossObject);

            object ScheduleObject;

            Declarations.TryGetValue("Schedule", out ScheduleObject);

            object ExposureTypesObject;

            Declarations.TryGetValue("ExposureTypes", out ExposureTypesObject);

            object GrossPositionObject;

            Declarations.TryGetValue("GrossPosition", out GrossPositionObject);

            object CededPositionObject;

            Declarations.TryGetValue("CededPosition", out CededPositionObject);

            if (GrossPositionObject != null)
            {
                if (CededPositionObject != null)
                {
                    this.ContractSubject = new NetPosition(ToHashSet(GrossPositionObject.ToString()), ToHashSet(CededPositionObject.ToString()));
                }
                else if (CausesOfLossObject != null)
                {
                    this.ContractSubject = new SubjectPosition(ToHashSet(GrossPositionObject.ToString()), ToHashSet(CausesOfLossObject.ToString()));
                }
                else
                {
                    this.ContractSubject = new SubjectPosition(ToHashSet(GrossPositionObject.ToString()));
                }
            }
            else if (CausesOfLossObject != null && ScheduleObject != null && ExposureTypesObject != null)
            {
                this.ContractSubject = new Subject(
                    UniversalSubject, new Schedule(ToHashSet(ScheduleObject.ToString())), ToHashSet(CausesOfLossObject.ToString()), ToHashSet(ExposureTypesObject.ToString()),
                    ResolvedSchedule, CoverageIdAttrMap);
            }

            // Covers

            object[] covers = (object[])IR["Covers"];

            Covers = new List <ICover <Value, Value, Value> >(covers.Length);

            foreach (object cover in covers)
            {
                Dictionary <string, object> coverData = (Dictionary <string, object>)cover;

                Covers.Add(ConstructCover(coverData));
            }

            // Sublimits

            object[] sublimits = (object[])IR["Sublimits"];

            Sublimits = new List <ITerm <Value> >(sublimits.Length);

            foreach (object sublimit in sublimits)
            {
                Sublimits.Add(ConstructSublimit((Dictionary <string, object>)sublimit, AreSublimitsNetOfDeductible()));
            }

            // Deductibles

            object[] deductibles = (object[])IR["Deductibles"];

            Deductibles = new List <ITerm <Value> >(deductibles.Length);

            foreach (object deductible in deductibles)
            {
                Deductibles.Add(ConstructDeductible((Dictionary <string, object>)deductible, AreDeductiblesAbsorbable()));
            }
        }