private async Task <OwnerDto[]> CreateOwners(BaseValueSegmentTransactionDto bvsTransaction,
                                                     List <GrmEventInformationDto> grmEventInformationDtos,
                                                     List <LegalPartyDocumentDto> legalPartyRoleDocuments,
                                                     DateTime assessmentEventDate, int assessmentEventType)
        {
            var ownerDtos = new List <OwnerDto>();

            // now build segments and base value segment per owner
            foreach (var bvsOwner in bvsTransaction.BaseValueSegmentOwners)
            {
                // now build assessment event dto
                var owner = bvsOwner.ToOwner();

                grmEventInformationDtos.PopulateEvent(owner, bvsOwner.GRMEventId);
                legalPartyRoleDocuments.PopulateOwner(owner, bvsOwner);

                // the legal party role document may not tie back
                if (string.IsNullOrEmpty(owner.BeneficialInterest))
                {
                    var legalPartyRole = (await _legalPartyDomain.GetLegalPartyRole(bvsOwner.LegalPartyRoleId, assessmentEventDate));

                    owner.BeneficialInterest = legalPartyRole.LegalParty.DisplayName;
                }

                owner.IsOverride = bvsOwner.IsOverride;
                ownerDtos.Add(owner);

                // cast so we can add our base value segments
                var ownerEvents = new List <OwnerValueDto>();

                foreach (var ownerValue in bvsOwner.BaseValueSegmentOwnerValueValues)
                {
                    // get the values associated with the owner value
                    var valueHeaderDtos = bvsTransaction.BaseValueSegmentValueHeaders.Where(v => ownerValue.BaseValueSegmentValueHeaderId == v.Id);

                    foreach (var valueHeaderDto in valueHeaderDtos)
                    {
                        // now build new assessment dto
                        var ownerValueDto = new OwnerValueDto
                        {
                            ValueHeaderId = ownerValue.BaseValueSegmentValueHeaderId,       // NEW HOW TO SELECT ITEM IN COMBO
                            OwnerId       = bvsOwner.Id.Value,
                            // ReSharper disable once PossibleInvalidOperationException
                            OwnerValueId = ownerValue.Id.Value,

                            //GrmEventId = valueHeaderDto.GRMEventId, //OLD HOW TO SELECT ITEM IN COMBO
                            BaseYear  = valueHeaderDto.BaseYear,
                            BaseValue = decimal.Truncate(ownerValue.BaseValue)
                        };

                        grmEventInformationDtos.PopulateEvent(ownerValueDto, valueHeaderDto.GRMEventId);

                        var fbyvDetail = _baseValueSegmentRepository.GetFactorBaseYearValueDetail(assessmentEventDate,
                                                                                                  valueHeaderDto.BaseYear, ownerValue.BaseValue, assessmentEventType);

                        ownerValueDto.Fbyv       = fbyvDetail.Result.Fbyv;
                        ownerValueDto.IsOverride = valueHeaderDto.BaseValueSegmentValues.Any(x => x.IsOverride == true);
                        ownerEvents.Add(ownerValueDto);
                    }
                }

                owner.OwnerValues = ownerEvents.ToArray();
            }

            //Add default sorting
            ownerDtos = ownerDtos.OrderBy(x => x.BeneficialInterest)
                        .ThenBy(x => x.EventDate).ToList();

            return(ownerDtos.ToArray());
        }
コード例 #2
0
        private ComponentDto[] CreateComponents(BaseValueSegmentTransactionDto bvsTransaction,
                                                List <GrmEventInformationDto> grmEventInformationDtos,
                                                DateTime baseValueSegmentAsOfDate,
                                                int baseValueSegmentRevObjId,
                                                DateTime assessmentEventDate,
                                                int assessmentEventType)
        {
            var componentDtos = new List <ComponentDto>();

            // now build segments and base value segment per subComponents
            foreach (var bvsValueHeader in bvsTransaction.BaseValueSegmentValueHeaders)
            {
                // per meeting  with bob do not error out if grm even information is missing, return unknown
                var grmEventInformationDto = grmEventInformationDtos.FirstOrDefault(grm => grm.GrmEventId == bvsValueHeader.GRMEventId);
                if (grmEventInformationDto == null)
                {
                    continue;
                }

                grmEventInformationDto.RevenueObjectId = baseValueSegmentRevObjId;

                var eventName     = grmEventInformationDto.Description;
                var eventType     = grmEventInformationDto.EventType;
                var eventDate     = string.Format("{0:d}", grmEventInformationDto.EventDate);
                var effectiveDate = string.Format("{0:d}", grmEventInformationDto.EffectiveDate);

                var subComponentDetailDtos = _baseValueSegmentRepository.GetSubComponentDetails(baseValueSegmentRevObjId, baseValueSegmentAsOfDate).Result.ToList();

                // Build Component dto
                var component = new ComponentDto
                {
                    EventName     = eventName,
                    EventType     = eventType,
                    EventDate     = eventDate,
                    EffectiveDate = effectiveDate,
                    EventId       = bvsValueHeader.GRMEventId,
                    BaseYear      = bvsValueHeader.BaseYear,
                    FbyvAsOfYear  = (grmEventInformationDto.EventDate.Month < 7) ? grmEventInformationDto.EventDate.Year : grmEventInformationDto.EventDate.Year + 1,
                    ValueHeaderId = bvsValueHeader.Id
                };

                // Build Component Details
                var componentDetails = new List <ComponentDetailDto>();
                foreach (var value in bvsValueHeader.BaseValueSegmentValues)
                {
                    var subComponentDetail = subComponentDetailDtos.FirstOrDefault(x => x.SubComponentId == value.SubComponent);

                    int    componentId      = -1;
                    int    subComponentId   = -1;
                    string componentName    = Constants.ComponentUnknownName;
                    string subComponentName = Constants.SubComponentUnknownName;

                    if (subComponentDetail != null)
                    {
                        componentId      = subComponentDetail.ComponentTypeId;
                        subComponentId   = subComponentDetail.SubComponentId;
                        componentName    = subComponentDetail.Component;
                        subComponentName = subComponentDetail.SubComponent;
                    }


                    // build new component detail dto
                    var componentDetail = new ComponentDetailDto
                    {
                        ComponentId    = componentId,
                        Component      = componentName,
                        SubComponentId = subComponentId,
                        SubComponent   = subComponentName,
                        BaseValue      = decimal.Truncate(value.ValueAmount),
                        // ReSharper disable once PossibleInvalidOperationException
                        ValueId = value.Id.Value
                    };
                    var fbyvDetail = _baseValueSegmentRepository.GetFactorBaseYearValueDetail(assessmentEventDate,
                                                                                              bvsValueHeader.BaseYear, value.ValueAmount, assessmentEventType);

                    componentDetail.Fbyv       = fbyvDetail.Result.Fbyv;
                    componentDetail.IsOverride = value.IsOverride;
                    componentDetails.Add(componentDetail);
                }

                component.IsOverride       = bvsValueHeader.BaseValueSegmentValues.All(x => x.IsOverride == true);
                component.ComponentDetails = componentDetails;
                componentDtos.Add(component);
            }

            //Add default sorting
            componentDtos = componentDtos.OrderBy(x => x.BaseYear)
                            .ThenBy(x => x.EffectiveDate).ToList();

            return(componentDtos.ToArray());
        }