public CalculateArrangementActivityPlanKDPRs CalculateInstalmentPlanCS(KdpInstallmentPlanCalculationRequest request) { var endpointUrl = _options.Value.Url; // http://expapp1:54505/CalculationService BasicHttpBinding binding = new BasicHttpBinding { MaxReceivedMessageSize = 2147483647 }; EndpointAddress endpoint = new EndpointAddress(endpointUrl); ChannelFactory <CalcService> channelFactory = new ChannelFactory <CalcService>(binding, endpoint); CalcService clientProxy = channelFactory.CreateChannel(); var res = clientProxy.CalculateArrangementActivityPlanKDP(new CalculateArrangementActivityPlanKDPRq(request)); return(res); }
private KdpInstallmentPlanCalculationRequest PrepareInstallmentPlanRequest(CalculateInstallmentPlanRequest request, int termUnits = 0, SimpleUnitOfTime termUnitOfTime = SimpleUnitOfTime.M) { KdpInstallmentPlanCalculationRequest calcReq = Mapper.Map <CalculateInstallmentPlanRequest, KdpInstallmentPlanCalculationRequest>(request); if (termUnits != 0) { switch (termUnitOfTime) { case SimpleUnitOfTime.Y: calcReq.NumberOfInstallments = termUnits * 12; break; case SimpleUnitOfTime.D: calcReq.NumberOfInstallments = termUnits / 30; // aproksimiramo break; default: calcReq.NumberOfInstallments = termUnits; break; } } else { calcReq.NumberOfInstallments = 9999; } calcReq.NumberOfInstallmentsSpecified = true; if (termUnits != 0) { switch (termUnitOfTime) { case SimpleUnitOfTime.Y: calcReq.MaturityDate = calcReq.StartDate.AddYears(termUnits); break; case SimpleUnitOfTime.D: calcReq.MaturityDate = calcReq.StartDate.AddDays(termUnits); break; default: calcReq.MaturityDate = calcReq.StartDate.AddMonths(termUnits); break; } } else { calcReq.MaturityDate = calcReq.StartDate.AddYears(100); } calcReq.MaturityDateSpecified = true; // da postavim sve datume koje sam zaboravio :) foreach (var prop in typeof(KdpInstallmentPlanCalculationRequest).GetProperties().Where(p => p.PropertyType == typeof(DateTime))) { prop.SetValue(calcReq, ((DateTime)prop.GetValue(calcReq)).Date); if (((DateTime)prop.GetValue(calcReq)).Date < calcReq.StartDate.Date) { prop.SetValue(calcReq, calcReq.StartDate.Date); } typeof(KdpInstallmentPlanCalculationRequest).GetProperty(prop.Name + "Specified").SetValue(calcReq, true); } calcReq.AdditionalRegularInterestInfo = GetAdditionalRegularInterestInfo(request.Periods, calcReq.StartDate, calcReq.MaturityDate, calcReq.RegularInterestPercentage, calcReq.RegularInterestUnitOfTime); calcReq.AdditionalConditions = calcReq.AdditionalRegularInterestInfo != null && calcReq.AdditionalRegularInterestInfo.Count() > 0; calcReq.AdditionalConditionsSpecified = calcReq.AdditionalRegularInterestInfo != null && calcReq.AdditionalRegularInterestInfo.Count() > 0; calcReq.RouteIdentifier = _options.Value.RouteIdentifier; calcReq.ArrangementType = _options.Value.ArrangementType; calcReq.ClientIdentifier = _options.Value.ClientIdentifier; calcReq.InstallmentPlanCalculationScenario = 2; calcReq.InstallmentPlanCalculationScenarioSpecified = true; return(calcReq); }