public ValuationResult GetValuationSheetDetailsByAdjId(Guid AdjudicationId)
        {
            ValuationRequest  Request = new ValuationRequest();
            ValuationSheetRow row     = (ValuationSheetRow)IgrssAdapters.ValuationSheetAdapter.GetValuationSheetDetailsByAdjId(AdjudicationId).Rows[0];

            Request.AdjudicationId        = AdjudicationId;
            Request.ValuationId           = row.ValuationFormId;
            Request.IsConstructedProperty = row.IsConstructedProperty;
            Request.EstimatedPrice        = Convert.ToDecimal(row.EstimatedPrice);
            Request.TalukaCode            = row.TalukaCode;
            Request.VillageCode           = row.VillageCode;
            Request.DistrictCode          = row.DistrictCode;
            Request.SchemeNo   = row.SchemeNo;
            Request.AreaOfPlot = row.AreaOfPlot;
            Request.SchemeType = row.SchemeType;
            Request.TypeOfLand = row.TypeOfLand;
            Request.InternalElectrificationRate = row.InternalElectrificationRate;
            Request.DevelopmentRate             = row.DevelopmentRate;
            Request.OtherFeeRate         = row.OtherFeeRate;
            Request.SpecialDeductionRate = row.SpecialDeductionRate;
            Request.YearOfConstruction   = row.YearOfConstruction;

            StampDutyCalculator calc   = new StampDutyCalculator();
            ValuationResult     Result = calc.GetStampDutyCalculation(Request);

            return(Result);
        }
        public bool UpdateValuationRequestDetails(ValuationRequest Request)
        {
            try
            {
                IgrssAdapters.ValuationSheetAdapter.AddNewValuationRequest(Request.AdjudicationId, Request.ValuationId,
                                                                           Request.DistrictCode, Request.TalukaCode, Request.VillageCode, Request.SchemeType, Request.EstimatedPrice, Request.IsConstructedProperty,
                                                                           Request.SchemeNo,
                                                                           Request.PlotNo,
                                                                           Request.AreaOfPlot, Request.TypeOfLand, Convert.ToDecimal("12.00"),
                                                                           Request.DevelopmentRate, Request.OtherFeeRate, Request.YearOfConstruction, Request.SpecialDeductionRate, Request.LiftExpense);
            }
            catch (Exception ex)
            {
                throw;
            }

            return(true);
        }
        public ValuationRequest GetValuationFormDetails(Guid AdjudicationId)
        {
            ValuationRequest RetRequest = new ValuationRequest();
            ValuationFormRow row        = (ValuationFormRow) new AdjudicationRequest().GetValuationFormRowByAdjudicationId(AdjudicationId).Rows[0];

            RetRequest.AdjudicationId     = AdjudicationId;
            RetRequest.ValuationId        = row.ValuationFormId;
            RetRequest.TalukaCode         = 1;
            RetRequest.VillageCode        = 1;
            RetRequest.DistrictCode       = 1;
            RetRequest.SchemeNo           = row.TPSchemeNo;
            RetRequest.SchemeType         = "TP Scheme";
            RetRequest.PlotNo             = row.FinalPlotNo;
            RetRequest.AreaOfPlot         = row.AreaOfPlot;
            RetRequest.AreaOfConstruction = row.AreaOfConstruction;
            RetRequest.TypeOfLand         = "APrate";
            RetRequest.YearOfConstruction = row.YearOfConstruction;
            return(RetRequest);
        }
    public ValuationResult GetStampDutyCalculation(ValuationRequest Request)
    {
        ValuationResult Result = new ValuationResult();

        Result.TalukaCode   = Request.TalukaCode;
        Result.DistrictCode = Request.DistrictCode;
        Result.VillageCode  = Request.VillageCode;
        #region Calculate Value of Land
        Result.AdjudicationId = Request.AdjudicationId;
        Result.ValuationId    = Request.ValuationId;
        Result.ValuationDate  = DateTime.Now;

        Result.SchemeNo   = Request.SchemeNo;
        Result.PlotNo     = Request.PlotNo;
        Result.AreaOfPlot = Request.AreaOfPlot;
        Result.LandRate   = GetLandRate(Request.TypeOfLand,
                                        Request.DistrictCode,
                                        Request.TalukaCode,
                                        Request.VillageCode,
                                        Request.SchemeNo,
                                        Request.SchemeType);
        Result.ValueOfLand = Result.AreaOfPlot * Result.LandRate;

        #endregion

        Result.IsConstructedProperty = Request.IsConstructedProperty;

        #region Calculate Value of Construction

        if (Result.IsConstructedProperty)
        {
            Result.AreaOfConstruction = Request.AreaOfConstruction;
            Result.TypeOfLand         = Request.TypeOfLand;

            Result.EstimatedPrice = Request.EstimatedPrice;

            Result.InternalElectrificationExpense = (Result.EstimatedPrice
                                                     * Request.InternalElectrificationRate)
                                                    / 100;
            Result.DevelopmentExpense = (Result.EstimatedPrice
                                         * Request.DevelopmentRate)
                                        / 100;
            Result.OtherFees = (Result.EstimatedPrice
                                * Request.OtherFeeRate)
                               / 100;
            Result.LiftExpense = Request.LiftExpense;

            Result.ValuationOfConstruction = Result.InternalElectrificationExpense
                                             + Result.DevelopmentExpense
                                             + Result.OtherFees
                                             + Result.LiftExpense;

            Result.EstimatedPriceOfConstruction = Result.EstimatedPrice
                                                  + Result.ValuationOfConstruction;

            Result.YearOfConstruction = Request.YearOfConstruction;
            Result.LifeOfConstruction = DateTime.Now.Year - Result.YearOfConstruction;

            Result.Depreciation = (Convert.ToDecimal(0.9) * Result.EstimatedPriceOfConstruction)
                                  / Result.LifeOfConstruction;

            Result.NetPrice = Result.EstimatedPriceOfConstruction
                              - Result.Depreciation;

            Result.SpecialDeduction = Result.NetPrice * (Request.SpecialDeductionRate / 100);

            Result.ValueOfConstruction = Result.NetPrice - Result.SpecialDeduction;
        }
        else
        {
            Result.ValueOfConstruction = 0.00M;
        }

        #endregion

        Result.ValuationOfConstruction = Result.ValueOfConstruction + Result.ValueOfLand;

        Result.StampDutyRate = GetStampDutyRate();

        Result.StampDuty = Result.StampDutyRate * Result.ValuationOfConstruction;

        Result.Remarks = "Valuation Complete";

        return(Result);
    }
        /// <summary>
        /// GetValuation: Perform valuation for a list of portfolios and/or portfolio groups Perform valuation on specified list of portfolio and/or portfolio groups for a set of dates.
        /// </summary>
        /// <exception cref="Lusid.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="valuationRequest">The request specifying the set of portfolios and dates on which to calculate a set of valuation metrics (optional)</param>
        /// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
        /// <returns>Task of ApiResponse (ListAggregationResponse)</returns>
        public async System.Threading.Tasks.Task <Lusid.Sdk.Client.ApiResponse <ListAggregationResponse> > GetValuationWithHttpInfoAsync(ValuationRequest valuationRequest = default(ValuationRequest), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            Lusid.Sdk.Client.RequestOptions localVarRequestOptions = new Lusid.Sdk.Client.RequestOptions();

            String[] _contentTypes = new String[] {
                "application/json-patch+json",
                "application/json",
                "text/json",
                "application/_*+json"
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "text/plain",
                "application/json",
                "text/json"
            };


            var localVarContentType = Lusid.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes);

            if (localVarContentType != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = Lusid.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts);

            if (localVarAccept != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            localVarRequestOptions.Data = valuationRequest;

            // authentication (oauth2) required
            // oauth required
            if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
            }

            //  set the LUSID header
            localVarRequestOptions.HeaderParameters.Add("X-LUSID-Sdk-Language", "C#");
            localVarRequestOptions.HeaderParameters.Add("X-LUSID-Sdk-Version", "0.11.4385");

            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.PostAsync <ListAggregationResponse>("/api/aggregation/$valuation", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetValuation", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
        /// <summary>
        /// GetValuation: Perform valuation for a list of portfolios and/or portfolio groups Perform valuation on specified list of portfolio and/or portfolio groups for a set of dates.
        /// </summary>
        /// <exception cref="Lusid.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="valuationRequest">The request specifying the set of portfolios and dates on which to calculate a set of valuation metrics (optional)</param>
        /// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
        /// <returns>Task of ListAggregationResponse</returns>
        public async System.Threading.Tasks.Task <ListAggregationResponse> GetValuationAsync(ValuationRequest valuationRequest = default(ValuationRequest), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            Lusid.Sdk.Client.ApiResponse <ListAggregationResponse> localVarResponse = await GetValuationWithHttpInfoAsync(valuationRequest, cancellationToken).ConfigureAwait(false);

            return(localVarResponse.Data);
        }
 /// <summary>
 /// GetValuation: Perform valuation for a list of portfolios and/or portfolio groups Perform valuation on specified list of portfolio and/or portfolio groups for a set of dates.
 /// </summary>
 /// <exception cref="Lusid.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="valuationRequest">The request specifying the set of portfolios and dates on which to calculate a set of valuation metrics (optional)</param>
 /// <returns>ListAggregationResponse</returns>
 public ListAggregationResponse GetValuation(ValuationRequest valuationRequest = default(ValuationRequest))
 {
     Lusid.Sdk.Client.ApiResponse <ListAggregationResponse> localVarResponse = GetValuationWithHttpInfo(valuationRequest);
     return(localVarResponse.Data);
 }
    public ValuationResult GetStampDutyCalculation(ValuationRequest Request)
    {
        ValuationResult Result = new ValuationResult();

        Result.TalukaCode = Request.TalukaCode;
        Result.DistrictCode = Request.DistrictCode;
        Result.VillageCode = Request.VillageCode;
        #region Calculate Value of Land
        Result.AdjudicationId = Request.AdjudicationId;
        Result.ValuationId = Request.ValuationId;
        Result.ValuationDate = DateTime.Now;

        Result.SchemeNo = Request.SchemeNo;
        Result.PlotNo = Request.PlotNo;
        Result.AreaOfPlot = Request.AreaOfPlot;
        Result.LandRate = GetLandRate(Request.TypeOfLand,
                                                Request.DistrictCode,
                                                Request.TalukaCode,
                                                Request.VillageCode,
                                                Request.SchemeNo,
                                                Request.SchemeType);
        Result.ValueOfLand = Result.AreaOfPlot * Result.LandRate;

        #endregion

        Result.IsConstructedProperty = Request.IsConstructedProperty;

        #region Calculate Value of Construction

        if (Result.IsConstructedProperty)
        {
            Result.AreaOfConstruction = Request.AreaOfConstruction;
            Result.TypeOfLand = Request.TypeOfLand;

            Result.EstimatedPrice = Request.EstimatedPrice;

            Result.InternalElectrificationExpense = (Result.EstimatedPrice
                                                    * Request.InternalElectrificationRate)
                                                    / 100;
            Result.DevelopmentExpense = (Result.EstimatedPrice
                                        * Request.DevelopmentRate)
                                        / 100;
            Result.OtherFees = (Result.EstimatedPrice
                                * Request.OtherFeeRate)
                                / 100;
            Result.LiftExpense = Request.LiftExpense;

            Result.ValuationOfConstruction = Result.InternalElectrificationExpense
                                            + Result.DevelopmentExpense
                                            + Result.OtherFees
                                            + Result.LiftExpense;

            Result.EstimatedPriceOfConstruction = Result.EstimatedPrice
                                                    + Result.ValuationOfConstruction;

            Result.YearOfConstruction = Request.YearOfConstruction;
            Result.LifeOfConstruction = DateTime.Now.Year - Result.YearOfConstruction;

            Result.Depreciation = (Convert.ToDecimal(0.9) * Result.EstimatedPriceOfConstruction)
                                    / Result.LifeOfConstruction;

            Result.NetPrice = Result.EstimatedPriceOfConstruction
                                - Result.Depreciation;

            Result.SpecialDeduction = Result.NetPrice * (Request.SpecialDeductionRate / 100);

            Result.ValueOfConstruction = Result.NetPrice - Result.SpecialDeduction;

        }
        else
            Result.ValueOfConstruction = 0.00M;

        #endregion

        Result.ValuationOfConstruction = Result.ValueOfConstruction + Result.ValueOfLand;

        Result.StampDutyRate = GetStampDutyRate();

        Result.StampDuty = Result.StampDutyRate * Result.ValuationOfConstruction;

        Result.Remarks = "Valuation Complete";

        return Result;
    }
 public async Task <HttpResponseMessage> Post(ValuationRequest model)
 {
     Debugger.Break();
     //look at the wonderful model!
     return(await Task.FromResult(Request.CreateResponse(HttpStatusCode.OK)));
 }