예제 #1
0
        /// <summary>
        /// Adds a TaxCode under the specified realm. The realm must be set in the context.
        /// </summary>
        /// <param name="taxCode">TaxCode to Add.</param>
        public void AddTaxCodeAsync(Intuit.Ipp.Data.TaxService taxCode)
        {
            Console.Write("AddAsync started \n");
            this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Add Asynchronously.");
            GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService> callCompletedEventArgs = new GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService>();

            Console.Write("callCompletedEventArgs instantiated \n");

            if (!GlobalTaxServiceHelper.IsTypeNull(taxCode))
            {
                IdsException exception = new IdsException(Resources.ParameterNotNullMessage, new ArgumentNullException(Resources.EntityString));
                Console.Write("IdsException instantiated \n");
                this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Error, string.Format(CultureInfo.InvariantCulture, Resources.ExceptionGeneratedMessage, exception.ToString()));
                callCompletedEventArgs.Error = exception;
                this.OnAddTaxCodeAsyncCompleted(this, callCompletedEventArgs);
            }
            else
            {
                try
                {
                    GlobalAsyncTaxService asyncService = new GlobalAsyncTaxService(this.serviceContext);
                    asyncService.OnAddTaxCodeAsyncCompleted += new GlobalTaxServiceCallback <Intuit.Ipp.Data.TaxService> .GlobalTaxServiceCallCompletedEventHandler(this.AddTaxCodeAsyncCompleted);

                    asyncService.AddTaxCodeAsync(taxCode as Intuit.Ipp.Data.TaxService);
                }
                catch (SystemException systemException)
                {
                    this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(TraceLevel.Error, systemException.Message);
                    IdsException idsException = new IdsException(systemException.Message);
                    callCompletedEventArgs.Error = idsException;
                    this.OnAddTaxCodeAsyncCompleted(this, callCompletedEventArgs);
                }
            }
        }
        /// <summary>
        /// Checks whether the entity passed has a type or not.
        /// </summary>
        /// <param name="entity">CDM Entity.</param>
        /// <returns>True if the type exists or else false.</returns>
        internal static bool IsTypeNull(Intuit.Ipp.Data.TaxService taxCodeName)
        {
            if (taxCodeName == null || taxCodeName.GetType() == null || string.IsNullOrWhiteSpace(taxCodeName.GetType().Name))
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Adds a TaxCode under the specified realm. The realm must be set in the context.
        /// </summary>
        /// <param name="taxCode">TaxCode to Add.</param>
        /// <returns>Returns an updated version of the entity with updated identifier.</returns>
        public Intuit.Ipp.Data.TaxService AddTaxCode(Intuit.Ipp.Data.TaxService taxCode)
        {
            this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method AddTaxCode for TaxService.");


            // Validate parameter
            if (!GlobalTaxServiceHelper.IsTypeNull(taxCode))
            {
                IdsException exception = new IdsException(Resources.ParameterNotNullMessage, new ArgumentNullException(Resources.EntityString));
                this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Error, string.Format(CultureInfo.InvariantCulture, Resources.ExceptionGeneratedMessage, exception.ToString()));
                IdsExceptionManager.HandleException(exception);
            }


            string resourceString = taxCode.GetType().Name.ToLower(CultureInfo.InvariantCulture);


            // Builds resource Uri
            string uri = string.Format(CultureInfo.InvariantCulture, "{0}/company/{1}/{2}/taxcode", CoreConstants.VERSION, this.serviceContext.RealmId, resourceString);

            // Creates request parameters
            RequestParameters parameters;

            if (this.serviceContext.IppConfiguration.Message.Request.SerializationFormat == Intuit.Ipp.Core.Configuration.SerializationFormat.Json)
            {
                parameters = new RequestParameters(uri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONJSON);
            }
            else
            {
                parameters = new RequestParameters(uri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONXML);
            }

            // Prepares request
            HttpWebRequest request = this.restHandler.PrepareRequest(parameters, taxCode);

            string response = string.Empty;

            try
            {
                // gets response
                response = this.restHandler.GetResponse(request);
            }
            catch (IdsException ex)
            {
                IdsExceptionManager.HandleException(ex);
            }

            CoreHelper.CheckNullResponseAndThrowException(response);

            // de serialize object
            IntuitResponse restResponse = (IntuitResponse)CoreHelper.GetSerializer(this.serviceContext, false).Deserialize <IntuitResponse>(response);

            this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Finished Executing Method Add.");
            return((Intuit.Ipp.Data.TaxService)(restResponse.AnyIntuitObject as Intuit.Ipp.Data.TaxService));
        }
예제 #4
0
        [TestMethod][Ignore]//change to request and response format as json and then run this test
        public void TaxCodeAddTestUsingoAuth()
        {
            String guid = Helper.GetGuid();

            GlobalTaxService.GlobalTaxService taxSvc           = new GlobalTaxService.GlobalTaxService(qboContextoAuth);
            Intuit.Ipp.Data.TaxService        taxCodetobeAdded = new Data.TaxService();
            taxCodetobeAdded.TaxCode = "taxC_" + guid;

            TaxAgency taxagency = Helper.FindOrAdd <TaxAgency>(qboContextoAuth, new TaxAgency());


            List <TaxRateDetails> lstTaxRate = new List <TaxRateDetails>();
            TaxRateDetails        taxdetail1 = new TaxRateDetails();

            taxdetail1.TaxRateName              = "taxR1_" + guid;
            taxdetail1.RateValue                = 3m;
            taxdetail1.RateValueSpecified       = true;
            taxdetail1.TaxAgencyId              = taxagency.Id.ToString();
            taxdetail1.TaxApplicableOn          = TaxRateApplicableOnEnum.Sales;
            taxdetail1.TaxApplicableOnSpecified = true;
            lstTaxRate.Add(taxdetail1);

            TaxRateDetails taxdetail2 = new TaxRateDetails();

            taxdetail2.TaxRateName              = "taxR2_" + guid;
            taxdetail2.RateValue                = 2m;
            taxdetail2.RateValueSpecified       = true;
            taxdetail2.TaxAgencyId              = taxagency.Id.ToString();
            taxdetail2.TaxApplicableOn          = TaxRateApplicableOnEnum.Sales;
            taxdetail2.TaxApplicableOnSpecified = true;
            lstTaxRate.Add(taxdetail2);

            //TaxRateDetails taxdetail3 = new TaxRateDetails();
            //taxdetail3.TaxRateName = "rate298";
            //taxdetail3.TaxRateId = "2";

            //lstTaxRate.Add(taxdetail3);

            taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();

            Intuit.Ipp.Data.TaxService taxCodeAdded = taxSvc.AddTaxCode(taxCodetobeAdded);
            Assert.IsNotNull(taxCodeAdded.TaxCodeId);
        }
예제 #5
0
        /// <summary>
        /// Adds an entity (asynchronously) under the specified realm in an asynchronous manner. The realm must be set in the context.
        /// </summary>
        /// <param name="entity">Entity to Add</param>
        public void AddTaxCodeAsync(Intuit.Ipp.Data.TaxService taxCode)
        {
            this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Called Method Add Asynchronously.");
            AsyncRestHandler asyncRestHandler = new AsyncRestHandler(this.serviceContext);

            asyncRestHandler.OnCallCompleted += new EventHandler <AsyncCallCompletedEventArgs>(this.AddTaxCodeAsyncCompleted);
            GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService> taxServiceCallCompletedEventArgs = new GlobalTaxServiceCallCompletedEventArgs <Intuit.Ipp.Data.TaxService>();
            string resourceString = taxCode.GetType().Name.ToLower(CultureInfo.InvariantCulture);



            try
            {
                // Builds resource Uri
                string uri = string.Format(CultureInfo.InvariantCulture, "{0}/company/{1}/{2}/taxcode", CoreConstants.VERSION, this.serviceContext.RealmId, resourceString);

                // Create request parameters
                RequestParameters parameters;
                if (this.serviceContext.IppConfiguration.Message.Request.SerializationFormat == Intuit.Ipp.Core.Configuration.SerializationFormat.Json)
                {
                    parameters = new RequestParameters(uri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONJSON);
                }
                else
                {
                    parameters = new RequestParameters(uri, HttpVerbType.POST, CoreConstants.CONTENTTYPE_APPLICATIONXML);
                }

                // Prepare request
                HttpWebRequest request = asyncRestHandler.PrepareRequest(parameters, taxCode);

                //// get response
                asyncRestHandler.GetResponse(request);
            }
            catch (SystemException systemException)
            {
                this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(TraceLevel.Error, systemException.Message);
                IdsException idsException = new IdsException(systemException.Message);
                taxServiceCallCompletedEventArgs.Error = idsException;
                this.OnAddTaxCodeAsyncCompleted(this, taxServiceCallCompletedEventArgs);
            }
        }
예제 #6
0
        public void AddTaxCodeSyncTest()
        {
            try
            {
                //GlobalTaxService taxSvc = new GlobalTaxService(context);
                //Intuit.Ipp.Data.TaxService  taxCodetobeAdded =  new Data.TaxService();
                //taxCodetobeAdded.TaxCode = "taxservic294";

                //List<TaxRateDetails> lstTaxRate = new List<TaxRateDetails>();
                //TaxRateDetails taxdetail1 = new TaxRateDetails();
                //taxdetail1.TaxRateName = "rat296";
                //taxdetail1.RateValue = 3m;
                //taxdetail1.RateValueSpecified = true;
                //taxdetail1.TaxAgencyId = "1";
                //taxdetail1.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
                //taxdetail1.TaxApplicableOnSpecified = true;
                //lstTaxRate.Add(taxdetail1);

                //TaxRateDetails taxdetail2 = new TaxRateDetails();
                //taxdetail2.TaxRateName = "rate297";
                //taxdetail2.RateValue = 2m;
                //taxdetail2.RateValueSpecified = true;
                //taxdetail2.TaxAgencyId = "1";
                //taxdetail2.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
                //taxdetail2.TaxApplicableOnSpecified = true;
                //lstTaxRate.Add(taxdetail2);

                //TaxRateDetails taxdetail3 = new TaxRateDetails();
                //taxdetail3.TaxRateName = "rate298";
                //taxdetail3.TaxRateId = "2";

                //lstTaxRate.Add(taxdetail3);

                //taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();

                //Intuit.Ipp.Data.TaxService taxCodeAdded = taxSvc.AddTaxCode(taxCodetobeAdded);
                //Assert.IsNotNull(taxCodeAdded.TaxCodeId);


                //GlobalTaxService taxSvc = new GlobalTaxService(context);
                //Intuit.Ipp.Data.TaxService taxCodetobeAdded = new Data.TaxService();
                //taxCodetobeAdded.TaxCode = "taxservic296";//change name everytime

                //List<TaxRateDetails> lstTaxRate = new List<TaxRateDetails>();
                //TaxRateDetails taxdetail1 = new TaxRateDetails();

                //taxdetail1.TaxRateId = "30";

                //lstTaxRate.Add(taxdetail1);



                //taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();

                //Intuit.Ipp.Data.TaxService taxCodeAdded = taxSvc.AddTaxCode(taxCodetobeAdded);



                GlobalTaxService           taxSvc           = new GlobalTaxService(context);
                Intuit.Ipp.Data.TaxService taxCodetobeAdded = new Data.TaxService();
                taxCodetobeAdded.TaxCode = "taxC_" + Guid.NewGuid().ToString("N");

                QueryService <TaxAgency> taxagency = new QueryService <TaxAgency>(context);
                TaxAgency taxagencyResult          = taxagency.ExecuteIdsQuery("select * from TaxAgency").FirstOrDefault <TaxAgency>();



                List <TaxRateDetails> lstTaxRate = new List <TaxRateDetails>();
                TaxRateDetails        taxdetail1 = new TaxRateDetails();
                taxdetail1.TaxRateName              = "taxR1_" + Guid.NewGuid().ToString("N");
                taxdetail1.RateValue                = 3m;
                taxdetail1.RateValueSpecified       = true;
                taxdetail1.TaxAgencyId              = taxagencyResult.Id.ToString();
                taxdetail1.TaxApplicableOn          = TaxRateApplicableOnEnum.Sales;
                taxdetail1.TaxApplicableOnSpecified = true;
                lstTaxRate.Add(taxdetail1);

                TaxRateDetails taxdetail2 = new TaxRateDetails();
                taxdetail2.TaxRateName              = "taxR2_" + Guid.NewGuid().ToString("N");
                taxdetail2.RateValue                = 2m;
                taxdetail2.RateValueSpecified       = true;
                taxdetail2.TaxAgencyId              = taxagencyResult.Id.ToString();
                taxdetail2.TaxApplicableOn          = TaxRateApplicableOnEnum.Sales;
                taxdetail2.TaxApplicableOnSpecified = true;
                lstTaxRate.Add(taxdetail2);

                //TaxRateDetails taxdetail3 = new TaxRateDetails();
                //taxdetail3.TaxRateName = "rate298";
                //taxdetail3.TaxRateId = "2";

                //lstTaxRate.Add(taxdetail3);

                taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();

                Intuit.Ipp.Data.TaxService taxCodeAdded = taxSvc.AddTaxCode(taxCodetobeAdded);
                Assert.IsNotNull(taxCodeAdded.TaxCodeId);
            }
            catch (System.Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
예제 #7
0
        public void AddTaxCodeAsyncTest()
        {
            //GlobalTaxService taxSvc = new GlobalTaxService(context);
            //Intuit.Ipp.Data.TaxService taxCodetobeAdded = new Data.TaxService();

            //taxCodetobeAdded.TaxCode = "taxservicetax428";

            //List<TaxRateDetails> lstTaxRate = new List<TaxRateDetails>();
            //TaxRateDetails taxdetail1 = new TaxRateDetails();
            //taxdetail1.TaxRateName = "rate2419";
            //taxdetail1.RateValue = 3m;
            //taxdetail1.RateValueSpecified = true;
            //taxdetail1.TaxAgencyId = "1";
            //taxdetail1.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
            //taxdetail1.TaxApplicableOnSpecified = true;
            //lstTaxRate.Add(taxdetail1);

            //TaxRateDetails taxdetail2 = new TaxRateDetails();
            //taxdetail2.TaxRateName = "rate2429";
            //taxdetail2.RateValue = 2m;
            //taxdetail2.RateValueSpecified = true;
            //taxdetail2.TaxAgencyId = "1";
            //taxdetail2.TaxApplicableOn = TaxRateApplicableOnEnum.Sales;
            //taxdetail2.TaxApplicableOnSpecified = true;
            //lstTaxRate.Add(taxdetail2);

            ////TaxRateDetails taxdetail3 = new TaxRateDetails();
            ////taxdetail3.TaxRateName = "rate3";
            ////taxdetail3.TaxRateId = "2";

            ////lstTaxRate.Add(taxdetail3);

            //taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();


            GlobalTaxService taxSvc = new GlobalTaxService(context);

            Intuit.Ipp.Data.TaxService taxCodetobeAdded = new Data.TaxService();
            taxCodetobeAdded.TaxCode = "taxC_" + Guid.NewGuid().ToString("N");

            QueryService <TaxAgency> taxagency = new QueryService <TaxAgency>(context);
            TaxAgency taxagencyResult          = taxagency.ExecuteIdsQuery("select * from TaxAgency").FirstOrDefault <TaxAgency>();



            List <TaxRateDetails> lstTaxRate = new List <TaxRateDetails>();
            TaxRateDetails        taxdetail1 = new TaxRateDetails();

            taxdetail1.TaxRateName              = "taxR1_" + Guid.NewGuid().ToString("N");
            taxdetail1.RateValue                = 3m;
            taxdetail1.RateValueSpecified       = true;
            taxdetail1.TaxAgencyId              = taxagencyResult.Id.ToString();
            taxdetail1.TaxApplicableOn          = TaxRateApplicableOnEnum.Sales;
            taxdetail1.TaxApplicableOnSpecified = true;
            lstTaxRate.Add(taxdetail1);

            TaxRateDetails taxdetail2 = new TaxRateDetails();

            taxdetail2.TaxRateName              = "taxR2_" + Guid.NewGuid().ToString("N");
            taxdetail2.RateValue                = 2m;
            taxdetail2.RateValueSpecified       = true;
            taxdetail2.TaxAgencyId              = taxagencyResult.Id.ToString();
            taxdetail2.TaxApplicableOn          = TaxRateApplicableOnEnum.Sales;
            taxdetail2.TaxApplicableOnSpecified = true;
            lstTaxRate.Add(taxdetail2);

            //TaxRateDetails taxdetail3 = new TaxRateDetails();
            //taxdetail3.TaxRateName = "rate298";
            //taxdetail3.TaxRateId = "2";

            //lstTaxRate.Add(taxdetail3);

            taxCodetobeAdded.TaxRateDetails = lstTaxRate.ToArray();



            try
            {
                ManualResetEvent manualEvent = new ManualResetEvent(false);
                taxSvc.OnAddTaxCodeAsyncCompleted = (sender, e) =>
                {
                    Assert.IsNotNull(e);
                    Intuit.Ipp.Data.TaxService addedTaxCode = e.TaxService;
                    Assert.IsTrue(!string.IsNullOrEmpty(addedTaxCode.TaxCodeId));
                    manualEvent.Set();
                };
                taxSvc.AddTaxCodeAsync(taxCodetobeAdded);
                manualEvent.WaitOne(30000);
            }
            catch (System.Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }