PageRenderTime 44ms CodeModel.GetById 3ms app.highlight 31ms RepoModel.GetById 1ms app.codeStats 1ms

/Apttus.SNowPS/Apttus.SNowPS.Repository/Products/ProdQuoteRepository.cs

https://bitbucket.org/Apttus_karanmonga/ase-d11
C# | 1411 lines | 971 code | 178 blank | 262 comment | 259 complexity | a2d4d3ab98388a4c4e3c9f6bcd0a1e53 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1/****************************************************************************************
  2@Name: QuoteRepository.cs
  3@Author: Asha Tank
  4@CreateDate: 11 Oct 2017
  5@Description: Quote header related process
  6@UsedBy: This will be used by ProdQuoteRepository controller
  7@ModifiedBy: 
  8@ModifiedDate: 
  9@ChangeDescription: 
 10*****************************************************************************************/
 11using Apttus.DataAccess.Common.Enums;
 12using Apttus.DataAccess.Common.Model;
 13using Apttus.SNowPS.Common;
 14using Apttus.SNowPS.Model;
 15using Newtonsoft.Json;
 16using Newtonsoft.Json.Linq;
 17using System;
 18using System.Collections.Generic;
 19using System.Linq;
 20using System.Net.Http;
 21using System.Xml.Linq;
 22using System.IO;
 23using System.Reflection;
 24
 25namespace Apttus.SNowPS.Respository
 26{
 27    public class ProdQuoteRepository
 28    {
 29        /// <summary>
 30        /// Calculate financial fields of quote header for paased quote id 
 31        /// </summary>
 32        /// <param name="QuoteId"></param>
 33        /// <param name="accessToken"></param>
 34        /// <returns></returns>
 35        public HttpResponseMessage GetQuoteDetail(string QuoteId, string accessToken)
 36        {
 37            var errors = new List<Model.ErrorInfo>();
 38            try
 39            {
 40                //Build AQL Query to fetch Quote,Quote Line Items & Product details
 41                var query = new Query(Constants.OBJ_QUOTE);
 42                query.AddColumns(Constants.OBJ_FIELDQUOTELINEITEM.Split(Constants.CHAR_COMMA));
 43                Expression exp = new Expression(ExpressionOperator.AND);
 44                exp.AddCondition(new Condition(Constants.FIELD_ID, FilterOperator.Equal, QuoteId));
 45
 46                query.SetCriteria(exp);
 47
 48                Join quoteLineItem = new Join(Constants.OBJ_QUOTE, Constants.OBJ_CPQ_QUOTELINEITEM, Constants.FIELD_ID, Constants.FIELD_QUOTEID, JoinType.LEFT);
 49                quoteLineItem.EntityAlias = Constants.OBJ_CPQ_QUOTELINEITEM;
 50                query.AddJoin(quoteLineItem);
 51
 52                Join lineItem = new Join(Constants.OBJ_CPQ_QUOTELINEITEM, Constants.OBJ_LINEITEM, Constants.FIELD_DERIVEDFROMId, Constants.FIELD_ID, JoinType.LEFT);
 53                lineItem.EntityAlias = Constants.OBJ_LINEITEM;
 54                query.AddJoin(lineItem);
 55
 56                Join product = new Join(Constants.OBJ_CPQ_QUOTELINEITEM, Constants.OBJ_PRODUCT, Constants.FIELD_PRODUCTID, Constants.FIELD_ID, JoinType.LEFT);
 57                product.EntityAlias = Constants.OBJ_PRODUCT;
 58                query.AddJoin(product);
 59
 60                var jsonQuery = query.Serialize();
 61                //
 62
 63                var reqConfig = new RequestConfigModel();
 64                reqConfig.accessToken = accessToken;
 65                reqConfig.searchType = SearchType.AQL;
 66                reqConfig.objectName = Constants.OBJ_QUOTE;
 67
 68                var response = Utilities.Search(jsonQuery, reqConfig);
 69                ResultQuoteHeaderModel resultQuoteHeaderModel = new ResultQuoteHeaderModel();
 70                if (response != null && response.IsSuccessStatusCode)
 71                {
 72                    var responseString = JObject.Parse(response.Content.ReadAsStringAsync().Result).SelectToken(Constants.NODE_SERIALIZEDRESULTENTITIES).ToString();
 73                    List<QuoteQuoteLineDetails> QuoteLineList = new List<QuoteQuoteLineDetails>();
 74                    QuoteLineList = JsonConvert.DeserializeObject<List<QuoteQuoteLineDetails>>(responseString);
 75
 76                    if (QuoteLineList != null && QuoteLineList.Count > 0)
 77                    {
 78                        DailyExcnageRate objDailyExcnageRate = new DailyExcnageRate();
 79                        objDailyExcnageRate = GetExchangeRateDetails(QuoteLineList.FirstOrDefault().cpq_lineitem.CurrencyId, accessToken);
 80
 81                        decimal EstimatedTotal = 0;
 82                        decimal ProfesionalServiceTotal = 0;
 83
 84                        //Calculate quote fields 
 85                        for (int i = 0; i < QuoteLineList.Count; i++)
 86                        {
 87                            switch (QuoteLineList[i].crm_Product.ContributesTo.Value)
 88                            {
 89                                case Constants.TOTALPSREVENUE:
 90                                    resultQuoteHeaderModel.ext_EducationalServicesandKnowledgeandOther = resultQuoteHeaderModel.ext_EducationalServicesandKnowledgeandOther + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
 91                                    resultQuoteHeaderModel.ext_TotalServicesRevenue = resultQuoteHeaderModel.ext_TotalServicesRevenue + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
 92                                    resultQuoteHeaderModel.ext_TotalPSRevenue = resultQuoteHeaderModel.ext_TotalPSRevenue + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
 93                                    break;
 94                                case Constants.SUBSCRIPTIONANDLICENSEREVENUE:
 95                                    resultQuoteHeaderModel.ext_TotalLicenseValue = resultQuoteHeaderModel.ext_TotalLicenseValue + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
 96                                    resultQuoteHeaderModel.ext_TotalSubscriptionACV = resultQuoteHeaderModel.ext_TotalSubscriptionACV + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.AnnualContractValue);
 97                                    break;
 98                                case Constants.LICENSEREVENUE:
 99                                    resultQuoteHeaderModel.ext_TotalLicenseValue = resultQuoteHeaderModel.ext_TotalLicenseValue + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
100                                    break;
101                                case Constants.TRAININGREVENUE:
102                                    resultQuoteHeaderModel.ext_TotalServicesRevenue = resultQuoteHeaderModel.ext_TotalServicesRevenue + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
103                                    resultQuoteHeaderModel.ext_TotalTrainingRevenue = resultQuoteHeaderModel.ext_TotalTrainingRevenue + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
104                                    break;
105                                case Constants.OTHERREVENUE:
106                                    resultQuoteHeaderModel.ext_TotalOtherRevenue = resultQuoteHeaderModel.ext_TotalOtherRevenue + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
107                                    break;
108
109                            }
110                            if (QuoteLineList[i].crm_Product.Family != null && QuoteLineList[i].crm_Product.Family.Value == "Professional Services")
111                            {
112                                ProfesionalServiceTotal = ProfesionalServiceTotal + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
113                            }
114                            resultQuoteHeaderModel.ext_TotalAnnualListPrice = resultQuoteHeaderModel.ext_TotalAnnualListPrice + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.AnnualContractValue);
115                            EstimatedTotal = EstimatedTotal + Convert.ToDecimal(QuoteLineList[i].cpq_QuoteLineItem.EstimatedTotal);
116                        }
117                        resultQuoteHeaderModel.ext_PreTaxTotals = Convert.ToDecimal(resultQuoteHeaderModel.ext_TotalLicenseValue + resultQuoteHeaderModel.ext_TotalServicesRevenue + resultQuoteHeaderModel.ext_TotalOtherRevenue);
118                        if (ProfesionalServiceTotal != 0)
119                        {
120                            resultQuoteHeaderModel.ext_EstimatedTravelExpenseFees = (ProfesionalServiceTotal * 10) / 100;
121                        }
122                        resultQuoteHeaderModel.ext_EstimatedTotal = EstimatedTotal + resultQuoteHeaderModel.ext_EstimatedTravelExpenseFees;
123                        resultQuoteHeaderModel.Id = QuoteLineList.FirstOrDefault().Id;
124
125                        //Calculation of USD fields
126                        resultQuoteHeaderModel.ext_USDTotalAnnualListPrice = Convert.ToDecimal(objDailyExcnageRate.ext_Rate * resultQuoteHeaderModel.ext_TotalAnnualListPrice);
127                        resultQuoteHeaderModel.ext_USDTotalLicenseValue = Convert.ToDecimal(objDailyExcnageRate.ext_Rate * resultQuoteHeaderModel.ext_TotalLicenseValue);
128                        resultQuoteHeaderModel.ext_USDTotalOtherRevenue = Convert.ToDecimal(objDailyExcnageRate.ext_Rate * resultQuoteHeaderModel.ext_TotalOtherRevenue);
129                        resultQuoteHeaderModel.ext_USDTotalPSRevenue = Convert.ToDecimal(objDailyExcnageRate.ext_Rate * resultQuoteHeaderModel.ext_TotalPSRevenue);
130                        resultQuoteHeaderModel.ext_USDTotalServicesRevenue = Convert.ToDecimal(objDailyExcnageRate.ext_Rate * resultQuoteHeaderModel.ext_TotalServicesRevenue);
131                        resultQuoteHeaderModel.ext_USDTotalSubscriptionACV = Convert.ToDecimal(objDailyExcnageRate.ext_Rate * resultQuoteHeaderModel.ext_TotalSubscriptionACV);
132                        resultQuoteHeaderModel.ext_USDTotalTrainingRevenue = Convert.ToDecimal(objDailyExcnageRate.ext_Rate * resultQuoteHeaderModel.ext_TotalTrainingRevenue);
133                        //Calculation of USD fields end
134                    }
135
136                    //return response
137                    List<ResultQuoteHeaderModel> quoteHeaderList = new List<ResultQuoteHeaderModel>();
138                    quoteHeaderList.Add(resultQuoteHeaderModel);
139
140                    var responseResult = UpdateQuoteHeader(quoteHeaderList, accessToken);
141                    return responseResult;
142                }
143                else
144                {
145                    HttpResponseMessage jsonResponse = new HttpResponseMessage();
146                    Model.ErrorInfo errorInfo = new Model.ErrorInfo();
147                    errorInfo.Message = "Error";
148                    var dict = new Dictionary<string, object>
149                    {
150                        {"Message", "Fail to update records"}
151                    };
152                    errorInfo.Record = dict;
153                    errors.Add(errorInfo);
154                    Utilities.CreateResponse(jsonResponse, errors);
155                    return jsonResponse;
156                }
157            }
158            catch (Exception ex)
159            {
160                var resp = new HttpResponseMessage
161                {
162                    Content = new StringContent("Message :" + ex.Message + " " + "StackStrace :" + ex.StackTrace, System.Text.Encoding.UTF8, "application/json"),
163                    StatusCode = System.Net.HttpStatusCode.BadRequest
164                };
165                return resp;
166            }
167        }
168        /// <summary>
169        /// Get Currency exchange rate based on currency code
170        /// </summary>
171        /// <param name="currencyCode"></param>
172        /// <returns></returns>
173        public DailyExcnageRate GetExchangeRateDetails(string currencyId, string accessToken)
174        {
175            //currencyCode = "USD";
176            DailyExcnageRate ExchangeRates = new DailyExcnageRate();
177            accessToken = accessToken != null ? accessToken : Utilities.GetAuthToken();
178
179            var reqExchangeRateLineItem = Utilities.GetRequestConfiguration(Constants.OBJ_DAILYEXCHANGERATE, Constants.FIELD_CURRENCYCODE, Constants.FIELD_CURRENCYCODE);
180            var dictContent = new List<Dictionary<string, object>> { new Dictionary<string, object>() { { "ext_CurrencyCode", currencyId } } };
181            var resExchangeRate = Utilities.Search(dictContent, reqExchangeRateLineItem);
182
183            if (resExchangeRate != null && resExchangeRate.IsSuccessStatusCode)
184            {
185                var responseString = JObject.Parse(resExchangeRate.Content.ReadAsStringAsync().Result).SelectToken("SerializedResultEntities").ToString();
186                List<DailyExcnageRate> ListExchgRates = JsonConvert.DeserializeObject<List<DailyExcnageRate>>(responseString);
187                // Getting last Created/Modified currency rate
188                ExchangeRates = ListExchgRates.OrderByDescending(x => x.ModifiedOn).FirstOrDefault();
189            }
190            return ExchangeRates;
191        }
192
193        /// <summary>
194        /// Update Quote Line Items
195        /// </summary>
196        /// <param name="lineItems"></param>
197        /// <param name="accessToken"></param>
198        /// <returns></returns>
199        public HttpResponseMessage UpdateQuoteHeader(List<ResultQuoteHeaderModel> quoteHeaderList, string accessToken)
200        {
201            var reqConfig = new RequestConfigModel();
202            reqConfig.accessToken = accessToken;
203            reqConfig.objectName = Constants.OBJ_QUOTE;
204
205            var lstQuoteToUpdate = new List<dynamic>();
206            foreach (var lstQuoteItems in quoteHeaderList)
207            {
208                lstQuoteToUpdate.Add(new
209                {
210                    Id = lstQuoteItems.Id,
211                    ext_EducationalServicesandKnowledgeandOther = lstQuoteItems.ext_EducationalServicesandKnowledgeandOther,
212                    ext_TotalServicesRevenue = lstQuoteItems.ext_TotalServicesRevenue,
213                    ext_TotalPSRevenue = lstQuoteItems.ext_TotalPSRevenue,
214                    ext_TotalSubscriptionACV = lstQuoteItems.ext_TotalSubscriptionACV,
215                    ext_TotalLicenseValue = lstQuoteItems.ext_TotalLicenseValue,
216                    ext_TotalTrainingRevenue = lstQuoteItems.ext_TotalTrainingRevenue,
217                    ext_TotalOtherRevenue = lstQuoteItems.ext_TotalOtherRevenue,
218                    ext_TotalAnnualListPrice = lstQuoteItems.ext_TotalAnnualListPrice,
219                    ext_PreTaxTotals = lstQuoteItems.ext_PreTaxTotals,
220                    ext_EstimatedTravelExpenseFees = lstQuoteItems.ext_EstimatedTravelExpenseFees,
221                    ext_EstimatedTotal = lstQuoteItems.ext_EstimatedTotal,
222                    ext_USDTotalAnnualListPrice = lstQuoteItems.ext_USDTotalAnnualListPrice,
223                    ext_USDTotalLicenseValue = lstQuoteItems.ext_USDTotalLicenseValue,
224                    ext_USDTotalOtherRevenue = lstQuoteItems.ext_USDTotalOtherRevenue,
225                    ext_USDTotalPSRevenue = lstQuoteItems.ext_USDTotalPSRevenue,
226                    ext_USDTotalServicesRevenue = lstQuoteItems.ext_USDTotalServicesRevenue,
227                    ext_USDTotalSubscriptionACV = lstQuoteItems.ext_USDTotalSubscriptionACV,
228                    ext_USDTotalTrainingRevenue = lstQuoteItems.ext_USDTotalTrainingRevenue
229                });
230            }
231
232            var responseString = Utilities.Update(lstQuoteToUpdate, reqConfig);
233            return responseString;
234        }
235
236
237        #region Commented Code
238        ///// <summary>
239        ///// Calculate financial fields of Quote line items for given QuoteId
240        ///// </summary>
241        ///// <param name="QuoteId"></param>
242        ///// <param name="accessToken"></param>
243        ///// <returns></returns>
244        //public HttpResponseMessage UpdateQuoteLineItemFields(string QuoteId, string accessToken)
245        //{
246        //    var errors = new List<Model.ErrorInfo>(); 
247        //    try
248        //    {
249        //        //Build AQL Query to fetch Quote,Quote Line Items & Product details
250        //        var query = new Query(Constants.OBJ_QUOTE);
251        //        query.AddColumns(Constants.OBJ_FIELDQUOTELINEITEMFINANCIAL.Split(Constants.CHAR_COMMA));
252        //        Expression exp = new Expression(ExpressionOperator.AND);
253        //        exp.AddCondition(new Condition(Constants.FIELD_ID, FilterOperator.Equal, QuoteId));
254
255        //        query.SetCriteria(exp);
256
257        //        Join quoteLineItem = new Join(Constants.OBJ_QUOTE, Constants.OBJ_CPQ_QUOTELINEITEM, Constants.FIELD_ID, Constants.FIELD_QUOTEID, JoinType.LEFT);
258        //        quoteLineItem.EntityAlias = Constants.OBJ_CPQ_QUOTELINEITEM;
259        //        query.AddJoin(quoteLineItem);
260
261        //        Join lineItem = new Join(Constants.OBJ_CPQ_QUOTELINEITEM, Constants.OBJ_LINEITEM, Constants.FIELD_DERIVEDFROMId, Constants.FIELD_ID, JoinType.LEFT);
262        //        lineItem.EntityAlias = Constants.OBJ_LINEITEM;
263        //        query.AddJoin(lineItem);
264
265        //        Join product = new Join(Constants.OBJ_CPQ_QUOTELINEITEM, Constants.OBJ_PRODUCT, Constants.FIELD_PRODUCTID, Constants.FIELD_ID, JoinType.LEFT);
266        //        product.EntityAlias = Constants.OBJ_PRODUCT;
267        //        query.AddJoin(product);
268
269        //        var jsonQuery = query.Serialize();
270
271        //        var reqConfig = new RequestConfigModel();
272        //        reqConfig.accessToken = accessToken;
273        //        reqConfig.searchType = SearchType.AQL;
274        //        reqConfig.objectName = Constants.OBJ_QUOTE;
275
276        //        var response = Utilities.Search(jsonQuery, reqConfig);
277        //        ResultUSDQuoteHeaderLineItemFields resultQuoteHeaderAndLIneItems = new ResultUSDQuoteHeaderLineItemFields();
278        //        ResultQuoteHeaderModel resultQuoteHeaderModel = new ResultQuoteHeaderModel();
279        //        List<ResultQuoteLineItem> lstResultQuoteLineItem = new List<ResultQuoteLineItem>();
280
281        //        if (response != null && response.IsSuccessStatusCode)
282        //        {
283        //            var responseString = JObject.Parse(response.Content.ReadAsStringAsync().Result).SelectToken(Constants.NODE_SERIALIZEDRESULTENTITIES).ToString();
284        //            List<QuoteQuoteLineDetails> QuoteLineList = new List<QuoteQuoteLineDetails>();
285
286        //            QuoteLineList = JsonConvert.DeserializeObject<List<QuoteQuoteLineDetails>>(responseString);
287
288        //            if (QuoteLineList != null && QuoteLineList.Count > 0)
289        //            {
290
291        //                LineItemRepository lineItemRepo = new LineItemRepository();
292        //                //Calculate quote line item USD fields 
293        //                for (int i = 0; i < QuoteLineList.Count; i++)
294        //                {
295        //                    ResultQuoteLineItem objResultQuoteLineItem = new ResultQuoteLineItem();
296
297        //                    objResultQuoteLineItem.Id = QuoteLineList[i].cpq_QuoteLineItem.Id;
298
299        //                    //get daily currenct exchange rates based on currency code
300        //                    DailyExcnageRate objDailyExcnageRate = lineItemRepo.GetExchangeRateDetails(QuoteLineList[i].cpq_lineitem.CurrencyId, accessToken);
301
302        //                    //USD fields
303        //                    if (objDailyExcnageRate != null)
304        //                    {
305        //                        objResultQuoteLineItem.ext_USDAdjustment = objDailyExcnageRate.ext_Rate * QuoteLineList[i].cpq_QuoteLineItem.Ext_AdjustmentAmount;
306        //                        objResultQuoteLineItem.ext_USDBasePrice = objDailyExcnageRate.ext_Rate * QuoteLineList[i].cpq_QuoteLineItem.BasePrice;
307        //                        objResultQuoteLineItem.ext_USDTotalValue = objDailyExcnageRate.ext_Rate * (QuoteLineList[i].cpq_QuoteLineItem.NetPrice);
308        //                        objResultQuoteLineItem.ext_USDListPrice = objDailyExcnageRate.ext_Rate * (QuoteLineList[i].cpq_QuoteLineItem.ListPrice);
309        //                        objResultQuoteLineItem.ext_USDSalesPrice = objDailyExcnageRate.ext_Rate * (QuoteLineList[i].cpq_QuoteLineItem.NetUnitPrice);
310        //                        objResultQuoteLineItem.ext_USDAnnualContractValue = objDailyExcnageRate.ext_Rate * QuoteLineList[i].cpq_QuoteLineItem.AnnualContractValue;
311        //                        objResultQuoteLineItem.ext_USDAnnualListPrice = objDailyExcnageRate.ext_Rate * QuoteLineList[i].cpq_QuoteLineItem.AnnualListPrice;
312        //                    }
313        //                    lstResultQuoteLineItem.Add(objResultQuoteLineItem);
314        //                }
315        //            }
316        //            resultQuoteHeaderAndLIneItems.ListQuoteLineItemFinFields = lstResultQuoteLineItem;
317        //            var responseResult = UpdateQuoteLineItems(lstResultQuoteLineItem, accessToken);
318        //            return responseResult;
319        //        }
320        //        else
321        //        {
322        //            HttpResponseMessage jsonResponse = new HttpResponseMessage();
323        //            Model.ErrorInfo errorInfo = new Model.ErrorInfo();
324        //            errorInfo.Message = "Error";
325        //            var dict = new Dictionary<string, object>
326        //            {
327        //                {"Message", "Fail to update records"}
328        //            };
329        //            errorInfo.Record = dict;
330        //            errors.Add(errorInfo);
331        //            Utilities.CreateResponse(jsonResponse, errors);
332        //            return jsonResponse;
333        //        }
334        //        //return response
335
336        //    }
337        //    catch (Exception ex)
338        //    {
339        //        var resp = new HttpResponseMessage
340        //        {
341        //            Content = new StringContent("Message :" + ex.Message + " " + "StackStrace :" + ex.StackTrace, System.Text.Encoding.UTF8, "application/json"),
342        //            StatusCode = System.Net.HttpStatusCode.BadRequest
343        //        };
344        //        return resp;
345        //    }
346        //}
347        #endregion
348
349        /// <summary>
350        /// Calculate financial fields of Quote line items for given QuoteId
351        /// </summary>
352        /// <param name="QuoteId"></param>
353        /// <param name="accessToken"></param>
354        /// <returns></returns>
355        public HttpResponseMessage UpdateQuoteLineItemFields(string QuoteId, string accessToken)
356        {
357            var errors = new List<Model.ErrorInfo>();
358            try
359            {
360                //Build AQL Query to fetch Quote,Quote Line Items & Product details
361                var query = new Query(Constants.OBJ_QUOTE);
362                query.AddColumns(Constants.OBJ_FIELDQUOTELINEITEMFINANCIAL.Split(Constants.CHAR_COMMA));
363                Expression exp = new Expression(ExpressionOperator.AND);
364                exp.AddCondition(new Condition(Constants.FIELD_ID, FilterOperator.Equal, QuoteId));
365
366                query.SetCriteria(exp);
367
368                Join quoteLineItem = new Join(Constants.OBJ_QUOTE, Constants.OBJ_CPQ_QUOTELINEITEM, Constants.FIELD_ID, Constants.FIELD_QUOTEID, JoinType.LEFT);
369                quoteLineItem.EntityAlias = Constants.OBJ_CPQ_QUOTELINEITEM;
370                query.AddJoin(quoteLineItem);
371
372                Join lineItem = new Join(Constants.OBJ_CPQ_QUOTELINEITEM, Constants.OBJ_LINEITEM, Constants.FIELD_DERIVEDFROMId, Constants.FIELD_ID, JoinType.LEFT);
373                lineItem.EntityAlias = Constants.OBJ_LINEITEM;
374                query.AddJoin(lineItem);
375
376                Join product = new Join(Constants.OBJ_CPQ_QUOTELINEITEM, Constants.OBJ_PRODUCT, Constants.FIELD_PRODUCTID, Constants.FIELD_ID, JoinType.LEFT);
377                product.EntityAlias = Constants.OBJ_PRODUCT;
378                query.AddJoin(product);
379
380                var jsonQuery = query.Serialize();
381
382                var reqConfig = new RequestConfigModel();
383                reqConfig.accessToken = accessToken;
384                reqConfig.searchType = SearchType.AQL;
385                reqConfig.objectName = Constants.OBJ_QUOTE;
386
387                var response = Utilities.Search(jsonQuery, reqConfig);
388                ResultUSDQuoteHeaderLineItemFields resultQuoteHeaderAndLIneItems = new ResultUSDQuoteHeaderLineItemFields();
389                ResultQuoteHeaderModel resultQuoteHeaderModel = new ResultQuoteHeaderModel();
390                List<ResultQuoteLineItem> lstResultQuoteLineItem = new List<ResultQuoteLineItem>();
391
392                if (response != null && response.IsSuccessStatusCode)
393                {
394                    var responseString = JObject.Parse(response.Content.ReadAsStringAsync().Result).SelectToken(Constants.NODE_SERIALIZEDRESULTENTITIES).ToString();
395                    List<QuoteQuoteLineDetails> QuoteLineList = new List<QuoteQuoteLineDetails>();
396
397                    QuoteLineList = JsonConvert.DeserializeObject<List<QuoteQuoteLineDetails>>(responseString);
398
399                    if (QuoteLineList != null && QuoteLineList.Count > 0)
400                    {
401
402                        LineItemRepository lineItemRepo = new LineItemRepository();
403                        //Calculate quote line item USD fields 
404                        for (int i = 0; i < QuoteLineList.Count; i++)
405                        {
406                            ResultQuoteLineItem objResultQuoteLineItem = new ResultQuoteLineItem();
407
408                            objResultQuoteLineItem.Id = QuoteLineList[i].cpq_QuoteLineItem.Id;
409                            objResultQuoteLineItem.ext_ListPriceWithAdjustments = QuoteLineList[i].cpq_QuoteLineItem.BasePrice.ConvertToDecimal();
410
411                            if (QuoteLineList[i].cpq_QuoteLineItem.ListPrice != 0)
412                            {
413                                objResultQuoteLineItem.ext_AdjustmentAmount = (QuoteLineList[i].cpq_QuoteLineItem.ListPrice.ConvertToDecimal() * QuoteLineList[i].cpq_QuoteLineItem.Quantity2.ConvertToDecimal() * QuoteLineList[i].cpq_QuoteLineItem.Term.ConvertToDecimal()) - QuoteLineList[i].cpq_QuoteLineItem.NetPrice.ConvertToDecimal();
414                                objResultQuoteLineItem.ext_AdjustmentDiscountPercent = objResultQuoteLineItem.ext_AdjustmentAmount * 100 / (QuoteLineList[i].cpq_QuoteLineItem.ListPrice.ConvertToDecimal() * QuoteLineList[i].cpq_QuoteLineItem.Quantity2.ConvertToDecimal() * QuoteLineList[i].cpq_QuoteLineItem.Term.ConvertToDecimal());
415                            }
416
417
418                            if (QuoteLineList[i].crm_Product.Family != null && QuoteLineList[i].crm_Product.Family.Value.ConvertToStringNull() != null && QuoteLineList[i].cpq_QuoteLineItem.ProductId.Ext_Family.Value.ToString() != Constants.STR_SUBSCRIPTION)
419                            {
420                                objResultQuoteLineItem.ext_AnnualContractValue = 0;
421                                objResultQuoteLineItem.ext_AnnualListPrice = 0;
422                            }
423                            else
424                            {
425                                if (QuoteLineList[i].cpq_QuoteLineItem.SellingFrequency != null && QuoteLineList[i].cpq_QuoteLineItem.SellingFrequency.ConvertToStringNull() != null && QuoteLineList[i].cpq_QuoteLineItem.SellingFrequency.Value.ToString() == Constants.STR_YEARLY)
426                                {
427                                    objResultQuoteLineItem.ext_AnnualContractValue = QuoteLineList[i].cpq_QuoteLineItem.NetUnitPrice.ConvertToDecimal() * QuoteLineList[i].cpq_QuoteLineItem.Quantity2;
428                                    objResultQuoteLineItem.ext_AnnualListPrice = QuoteLineList[i].cpq_QuoteLineItem.ListPrice.ConvertToDecimal() * QuoteLineList[i].cpq_QuoteLineItem.Quantity2;
429                                }
430                                else
431                                {
432                                    objResultQuoteLineItem.ext_AnnualContractValue = QuoteLineList[i].cpq_QuoteLineItem.NetUnitPrice.ConvertToDecimal() * 12 * QuoteLineList[i].cpq_QuoteLineItem.Quantity2;
433                                    objResultQuoteLineItem.ext_AnnualListPrice = QuoteLineList[i].cpq_QuoteLineItem.ListPrice.ConvertToDecimal() * 12 * QuoteLineList[i].cpq_QuoteLineItem.Quantity2;
434                                }
435                            }
436
437
438                            objResultQuoteLineItem.ext_EstimatedTax = QuoteLineList[i].cpq_QuoteLineItem.ext_EstimatedTax.ConvertToDecimal();
439
440                            //Estimated Total: Total Value + EstimatedTax 
441                            objResultQuoteLineItem.ext_EstimatedTotal = QuoteLineList[i].cpq_QuoteLineItem.NetPrice.ConvertToDecimal() + objResultQuoteLineItem.ext_EstimatedTax.ConvertToDecimal();
442
443                            //Sales Price
444                            objResultQuoteLineItem.ext_SalesPrice = QuoteLineList[i].cpq_QuoteLineItem.NetUnitPrice.ConvertToDecimal();
445
446                            //get daily currenct exchange rates based on currency code
447                            DailyExcnageRate objDailyExcnageRate = lineItemRepo.GetExchangeRateDetails(QuoteLineList[i].cpq_lineitem.CurrencyId, accessToken);
448
449                            //USD fields
450                            if (objDailyExcnageRate != null)
451                            {
452                                objResultQuoteLineItem.ext_USDAdjustment = objDailyExcnageRate.ext_Rate * QuoteLineList[i].cpq_QuoteLineItem.Ext_AdjustmentAmount.ConvertToDecimal();
453                                objResultQuoteLineItem.ext_USDBasePrice = objDailyExcnageRate.ext_Rate * QuoteLineList[i].cpq_QuoteLineItem.BasePrice.ConvertToDecimal();
454                                objResultQuoteLineItem.ext_USDTotalValue = objDailyExcnageRate.ext_Rate * (QuoteLineList[i].cpq_QuoteLineItem.NetPrice.ConvertToDecimal());
455                                objResultQuoteLineItem.ext_USDListPrice = objDailyExcnageRate.ext_Rate * (QuoteLineList[i].cpq_QuoteLineItem.ListPrice.ConvertToDecimal());
456                                objResultQuoteLineItem.ext_USDSalesPrice = objDailyExcnageRate.ext_Rate * (QuoteLineList[i].cpq_QuoteLineItem.NetUnitPrice.ConvertToDecimal());
457                                objResultQuoteLineItem.ext_USDAnnualContractValue = objDailyExcnageRate.ext_Rate * QuoteLineList[i].cpq_QuoteLineItem.AnnualContractValue.ConvertToDecimal();
458                                objResultQuoteLineItem.ext_USDAnnualListPrice = objDailyExcnageRate.ext_Rate * QuoteLineList[i].cpq_QuoteLineItem.AnnualListPrice.ConvertToDecimal();
459                            }
460                            lstResultQuoteLineItem.Add(objResultQuoteLineItem);
461                        }
462                    }
463                    resultQuoteHeaderAndLIneItems.ListQuoteLineItemFinFields = lstResultQuoteLineItem;
464                    var responseResult = UpdateQuoteLineItems(lstResultQuoteLineItem, accessToken);
465                    return responseResult;
466                }
467                else
468                {
469                    HttpResponseMessage jsonResponse = new HttpResponseMessage();
470                    Model.ErrorInfo errorInfo = new Model.ErrorInfo();
471                    errorInfo.Message = "Error";
472                    var dict = new Dictionary<string, object>
473                    {
474                        {"Message", "Fail to update records"}
475                    };
476                    errorInfo.Record = dict;
477                    errors.Add(errorInfo);
478                    Utilities.CreateResponse(jsonResponse, errors);
479                    return jsonResponse;
480                }
481                //return response
482
483            }
484            catch (Exception ex)
485            {
486                var resp = new HttpResponseMessage
487                {
488                    Content = new StringContent("Message :" + ex.Message + " " + "StackStrace :" + ex.StackTrace, System.Text.Encoding.UTF8, "application/json"),
489                    StatusCode = System.Net.HttpStatusCode.BadRequest
490                };
491                return resp;
492            }
493        }
494
495        /// <summary>
496        /// Update calculated Quote line items details
497        /// </summary>
498        /// <param name="lineItems">list of fileds to be update</param>
499        /// <returns></returns>
500        public HttpResponseMessage UpdateQuoteLineItems(List<ResultQuoteLineItem> quoteLineItems, string accessToken)
501        {
502            var reqConfig = new RequestConfigModel();
503            reqConfig.accessToken = accessToken;
504            reqConfig.objectName = Constants.OBJ_CPQ_QUOTELINEITEM;
505
506            var lstLineItemsToUpdate = new List<dynamic>();
507            foreach (var lstLineItems in quoteLineItems)
508            {
509                lstLineItemsToUpdate.Add(new
510                {
511                    Id = lstLineItems.Id,
512                    ext_ListPriceWithAdjustments = lstLineItems.ext_ListPriceWithAdjustments,
513                    ext_AdjustmentAmount = lstLineItems.ext_AdjustmentAmount,
514                    ext_AdjustmentDiscountPercent = lstLineItems.ext_AdjustmentDiscountPercent,
515                    ext_EstimatedTax = lstLineItems.ext_EstimatedTax,
516                    ext_AnnualContractValue = lstLineItems.ext_AnnualContractValue,
517                    ext_AnnualListPrice = lstLineItems.ext_AnnualListPrice,
518                    ext_EstimatedTotal = lstLineItems.ext_EstimatedTotal,
519                    ext_SalesPrice = lstLineItems.ext_SalesPrice,
520                    ext_USDAdjustment = lstLineItems.ext_USDAdjustment,
521                    ext_USDBasePrice = lstLineItems.ext_USDBasePrice,
522                    ext_USDTotalValue = lstLineItems.ext_USDTotalValue,
523                    ext_USDListPrice = lstLineItems.ext_USDListPrice,
524                    ext_USDSalesPrice = lstLineItems.ext_USDSalesPrice,
525                    ext_USDAnnualContractValue = lstLineItems.ext_USDAnnualContractValue,
526                    ext_USDAnnualListPrice = lstLineItems.ext_USDAnnualListPrice,
527                });
528            }
529
530            var responseString = Utilities.Update(lstLineItemsToUpdate, reqConfig);
531            return responseString;
532        }
533        /// <summary>
534        /// Default quote details based on rule conditions
535        /// </summary>
536        /// <param name="QuoteId"></param>
537        /// <param name="accessToken"></param>
538        /// <returns></returns>
539        public HttpResponseMessage DefaultQuoteDetails(string QuoteId, string accessToken)
540        {
541            try
542            {
543                //Build AQL Query to fetch Quote's opprtunityID
544                var updateResult = new HttpResponseMessage();
545                var query = new Query(Constants.OBJ_QUOTE);
546                query.AddColumns(Constants.OBJ_QUOTEVALIDATE_DEFAULT_SELECTFIELD.Split(Constants.CHAR_COMMA));
547                Expression exp = new Expression(ExpressionOperator.AND);
548                exp.AddCondition(new Condition(Constants.FIELD_ID, FilterOperator.Equal, QuoteId));
549
550                Join account = new Join(Constants.OBJ_QUOTE, Constants.OBJ_ACCOUNT, Constants.FIELD_ACCOUNTID, Constants.FIELD_ID, JoinType.LEFT);
551                account.EntityAlias = Constants.OBJ_ACCOUNT;
552                query.AddJoin(account);
553
554                query.SetCriteria(exp);
555
556                var jsonQuery = query.Serialize();
557
558
559                var reqConfig = new RequestConfigModel();
560                reqConfig.accessToken = accessToken;
561                reqConfig.searchType = SearchType.AQL;
562                reqConfig.objectName = Constants.OBJ_QUOTE;
563
564                var response = Utilities.Search(jsonQuery, reqConfig);
565                ValidateDefaultQuoteResult objValidateDefaultQuoteResult = new ValidateDefaultQuoteResult();
566                List<Dictionary<string, object>> ListQuoteFieldToUpdate = new List<Dictionary<string, object>>();
567
568                if (response != null && response.IsSuccessStatusCode)
569                {
570                    var responseString = JObject.Parse(response.Content.ReadAsStringAsync().Result).SelectToken(Constants.NODE_SERIALIZEDRESULTENTITIES).ToString();
571                    List<QuoteValidate> objQuoteOppoDetails = new List<QuoteValidate>();
572
573                    objQuoteOppoDetails = JsonConvert.DeserializeObject<List<QuoteValidate>>(responseString);
574
575                    if (objQuoteOppoDetails != null && objQuoteOppoDetails.Count > 0)
576                    {
577                        #region "Set default data center based on Country"
578                        if (objQuoteOppoDetails.FirstOrDefault().crm_Account != null && objQuoteOppoDetails.FirstOrDefault().crm_Account.ext_Country != null)
579                        {
580                            #region get country and data center mapping data from xml file
581                            Dictionary<string, string> countryDCDict = new Dictionary<string, string>();
582                            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"XMLFiles\DataCenterCountryMapping.xml");
583
584                            XDocument XDoc = XDocument.Load(path);
585                            try
586                            {
587                                countryDCDict = XDoc.Descendants("Country").ToDictionary(d => (string)d.Attribute("Name"), d => (string)d);
588
589                                if (countryDCDict.ContainsKey(objQuoteOppoDetails.FirstOrDefault().crm_Account.ext_Country))
590                                {
591                                    objValidateDefaultQuoteResult.ext_datacenter = countryDCDict[objQuoteOppoDetails.FirstOrDefault().crm_Account.ext_Country];
592                                }
593                                else
594                                {  //setting default data center to United States
595                                    objValidateDefaultQuoteResult.ext_datacenter = countryDCDict[Constants.STR_UNITEDSTATES];
596                                }
597
598                            }
599                            catch (Exception ex)
600                            {
601                                objValidateDefaultQuoteResult.ErrorMessage = "DataCenterCountryMapping :" + ex.Message;
602                            }
603                            #endregion
604                        }
605                        #endregion
606
607                        #region "Set Selling entity"
608                        if (objQuoteOppoDetails.FirstOrDefault().crm_Account != null && objQuoteOppoDetails.FirstOrDefault().crm_Account.ext_Country != null)
609                        {
610
611                            #region get country and selling entity mapping data from xml file
612                            Dictionary<string, string> countryDCDict = new Dictionary<string, string>();
613                            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"XMLFiles\CountryandSellingEntityMapping.xml");
614
615                            XDocument XDoc = XDocument.Load(path);
616                            try
617                            {
618                                countryDCDict = XDoc.Descendants("Country").ToDictionary(d => (string)d.Attribute("Name"), d => (string)d);
619
620                                if (countryDCDict.ContainsKey(objQuoteOppoDetails.FirstOrDefault().crm_Account.ext_Country))
621                                {
622                                    objValidateDefaultQuoteResult.ext_SellingEntity = countryDCDict[objQuoteOppoDetails.FirstOrDefault().crm_Account.ext_Country];
623                                }
624                                else
625                                {
626                                    objValidateDefaultQuoteResult.ext_SellingEntity = countryDCDict[Constants.STR_NEDERLAND];
627                                }
628                            }
629                            catch (Exception ex)
630                            {
631                                objValidateDefaultQuoteResult.ErrorMessage += " CountryandSellingEntityMapping :" + ex.Message;
632                            }
633                            #endregion
634                        }
635                        #endregion
636
637                        #region "Set PriceList based on currency and vice versa"
638
639                        //Build AQL Query to fetch pricelist details 
640                        var priceListId = objQuoteOppoDetails.FirstOrDefault().PriceListId != null ? objQuoteOppoDetails.FirstOrDefault().PriceListId.Id : null;
641
642                        if (!string.IsNullOrEmpty(priceListId))
643                        {
644                            var queryPricelist = new Query(Constants.OBJ_PRICELIST);
645                            queryPricelist.AddColumns(Constants.OBJ_PRICELIST_SELECTFIELD.Split(Constants.CHAR_COMMA));
646                            Expression expPriceList = new Expression(ExpressionOperator.AND);
647                            expPriceList.AddCondition(new Condition(Constants.FIELD_ID, FilterOperator.Equal, priceListId));
648
649                            queryPricelist.SetCriteria(expPriceList);
650
651                            jsonQuery = queryPricelist.Serialize();
652
653                            reqConfig = new RequestConfigModel();
654                            reqConfig.accessToken = accessToken;
655                            reqConfig.searchType = SearchType.AQL;
656                            reqConfig.objectName = Constants.OBJ_PRICELIST;
657
658                            var responsePricelistDetail = Utilities.Search(jsonQuery, reqConfig);
659                            if (responsePricelistDetail != null && responsePricelistDetail.IsSuccessStatusCode)
660                            {
661                                var responsePriceListString = JObject.Parse(responsePricelistDetail.Content.ReadAsStringAsync().Result).SelectToken(Constants.NODE_SERIALIZEDRESULTENTITIES).ToString();
662                                List<QQuoteLineItem> objPriceListResult = new List<QQuoteLineItem>();
663                                objPriceListResult = JsonConvert.DeserializeObject<List<QQuoteLineItem>>(responsePriceListString);
664
665                                if (objPriceListResult != null && objPriceListResult.Count > 0)
666                                {
667                                    if (!string.IsNullOrEmpty(objPriceListResult.FirstOrDefault().CurrencyId))
668                                    {
669                                        objValidateDefaultQuoteResult.BaseCurrency = objPriceListResult.FirstOrDefault().CurrencyId;
670                                    }
671                                }
672
673                            }
674                        }
675                        // PricelistId will be null when Quote is created outside Apttus
676                        if (!string.IsNullOrEmpty(objQuoteOppoDetails.FirstOrDefault().ext_BaseCurrency) && string.IsNullOrEmpty(priceListId))
677                        {
678                            if (objQuoteOppoDetails.FirstOrDefault().ext_Type.Value.ToLower() == Constants.SERVICES || objQuoteOppoDetails.FirstOrDefault().ext_Type.Value.ToLower() == Constants.STR_TRAINING.ToLower())
679                            {
680                                #region get Currency and Pricelist mapping data from xml file for Services
681
682                                Dictionary<string, string> currencyDCDict = new Dictionary<string, string>();
683                                string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"XMLFiles\CurrencyandPriceListMappingServices.xml");
684
685                                XDocument XDoc = XDocument.Load(path);
686                                try
687                                {
688                                    currencyDCDict = XDoc.Descendants("Currency").ToDictionary(d => (string)d.Attribute("Name"), d => (string)d);
689                                    if (currencyDCDict.ContainsKey(objQuoteOppoDetails.FirstOrDefault().ext_BaseCurrency))
690                                    {
691                                        objValidateDefaultQuoteResult.PriceListName = currencyDCDict[objQuoteOppoDetails.FirstOrDefault().ext_BaseCurrency];
692                                        if (objQuoteOppoDetails.FirstOrDefault().ext_BaseCurrency == Constants.STR_USD)
693                                        {
694                                            if (objQuoteOppoDetails.FirstOrDefault().crm_Account.ext_Country == Constants.STR_AUSTRALIA)
695                                            {
696                                                objValidateDefaultQuoteResult.PriceListName = "Australian (USD) Services";
697                                            }
698                                            else if (objQuoteOppoDetails.FirstOrDefault().crm_Account.ext_Country == Constants.STR_JAPAN)
699                                            {
700                                                objValidateDefaultQuoteResult.PriceListName = "Japan (USD) Subscription";
701                                            }
702                                        }
703                                    }
704                                    else
705                                    {
706                                        objValidateDefaultQuoteResult.PriceListName = currencyDCDict[Constants.STR_USD];
707                                    }
708                                }
709                                catch (Exception ex)
710                                {
711                                    objValidateDefaultQuoteResult.ErrorMessage += " CurrencyandPriceListMappingServices :" + ex.Message;
712                                }
713                                #endregion
714                            }
715                            else// Remaining types will be for Subscription
716                            {
717                                #region get Currency and Pricelist mapping data from xml file for Subscription
718                                Dictionary<string, string> currencyDCDict = new Dictionary<string, string>();
719                                string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"XMLFiles\CurrencyandPriceListMapping.xml");
720
721                                XDocument XDoc = XDocument.Load(path);
722                                try
723                                {
724                                    currencyDCDict = XDoc.Descendants("Currency").ToDictionary(d => (string)d.Attribute("Name"), d => (string)d);
725
726                                    if (currencyDCDict.ContainsKey(objQuoteOppoDetails.FirstOrDefault().ext_BaseCurrency))
727                                    {
728                                        objValidateDefaultQuoteResult.PriceListName = currencyDCDict[objQuoteOppoDetails.FirstOrDefault().ext_BaseCurrency];
729                                    }
730                                    else
731                                    {
732                                        objValidateDefaultQuoteResult.PriceListName = currencyDCDict[Constants.STR_USD];
733                                    }
734                                }
735                                catch (Exception ex)
736                                {
737                                    objValidateDefaultQuoteResult.ErrorMessage += " CurrencyandPriceListMapping :" + ex.Message;
738                                }
739                                #endregion
740                            }
741                        }
742                        #endregion
743
744                        //Update Quote fileds to default values
745                        ListQuoteFieldToUpdate = new List<Dictionary<string, object>>();
746                        Dictionary<string, object> QuoteFieldToUpdate = new Dictionary<string, object>();
747                        QuoteFieldToUpdate.Add("Id", QuoteId);
748                        if (!string.IsNullOrEmpty(objValidateDefaultQuoteResult.ext_datacenter))
749                        {
750                            QuoteFieldToUpdate.Add("ext_datacenter", objValidateDefaultQuoteResult.ext_datacenter);
751                        }
752                        if (!string.IsNullOrEmpty(objValidateDefaultQuoteResult.ext_SellingEntity))
753                        {
754
755                            //Build AQL Query to fetch Account details 
756                            var queryQuote = new Query(Constants.OBJ_ACCOUNT);
757                            queryQuote.AddColumns(Constants.OBJ_ACCOUNT_SELECTFIELD.Split(Constants.CHAR_COMMA));
758                            Expression expQuote = new Expression(ExpressionOperator.AND);
759                            expQuote.AddCondition(new Condition(Constants.FIELD_NAME, FilterOperator.Equal, objValidateDefaultQuoteResult.ext_SellingEntity));
760
761                            queryQuote.SetCriteria(expQuote);
762
763                            jsonQuery = queryQuote.Serialize();
764
765                            reqConfig = new RequestConfigModel();
766                            reqConfig.accessToken = accessToken;
767                            reqConfig.searchType = SearchType.AQL;
768                            reqConfig.objectName = Constants.OBJ_ACCOUNT;
769
770                            var responseAccountDetail = Utilities.Search(jsonQuery, reqConfig);
771                            if (responseAccountDetail != null && responseAccountDetail.IsSuccessStatusCode)
772                            {
773                                var responseAccountString = JObject.Parse(responseAccountDetail.Content.ReadAsStringAsync().Result).SelectToken(Constants.NODE_SERIALIZEDRESULTENTITIES).ToString();
774                                List<AccountCountry> objAccountResult = new List<AccountCountry>();
775                                objAccountResult = JsonConvert.DeserializeObject<List<AccountCountry>>(responseAccountString);
776
777                                if (objAccountResult != null && objAccountResult.Count > 0)
778                                {
779                                    Dictionary<string, object> dictAccount = new Dictionary<string, object>();
780                                    dictAccount.Add("Id", objAccountResult.FirstOrDefault().Id);
781                                    dictAccount.Add("Name", objAccountResult.FirstOrDefault().Name);
782
783                                    QuoteFieldToUpdate.Add("ext_SellingEntity", dictAccount);
784                                }
785                            }
786
787
788                        }
789                        if (!string.IsNullOrEmpty(objValidateDefaultQuoteResult.PriceListName))
790                        {
791
792                            //Build AQL Query to fetch Account details 
793                            var queryPriceList = new Query(Constants.OBJ_PRICELIST);
794                            queryPriceList.AddColumns(Constants.OBJ_PRICELIST_SELECTFIELD.Split(Constants.CHAR_COMMA));
795                            Expression expPriceLIst = new Expression(ExpressionOperator.AND);
796                            expP

Large files files are truncated, but you can click here to view the full file