コード例 #1
0
        public async Task CancelTaxTest()
        {
            // Header Level Elements
            // Required Header Level Elements
            var    configSection = ConfigurationHelper.GetConfiguration();
            string accountNumber = configSection["accountNumber"];
            string licenseKey    = configSection["licenseKey"];
            string serviceUrl    = configSection["serviceUrl"];

            ITaxService taxSvc = new TaxService(accountNumber, licenseKey, serviceUrl);

            CancelTaxRequest cancelTaxRequest = new CancelTaxRequest
            {
                CompanyCode = "APITrialCompany",
                DocType     = DocType.SalesInvoice,
                DocCode     = "INV001",
                CancelCode  = CancelCode.DocVoided
            };

            // Required Request Parameters

            CancelTaxResult cancelTaxResult = await taxSvc.CancelTax(cancelTaxRequest);

            // Print results
            Console.WriteLine("CancelTaxTest Result: {0}", cancelTaxResult.ResultCode);
            if (!cancelTaxResult.ResultCode.Equals(SeverityLevel.Success))
            {
                foreach (Message message in cancelTaxResult.Messages)
                {
                    Console.WriteLine(message.Summary);
                }
            }
        }
コード例 #2
0
        public static CancelTaxResult Execute(bool inProduction, string strOCN, out string summary)
        {
            summary = "";
            TaxServiceWrapper taxSvcWrapper = new TaxServiceWrapper();
            TaxSvc            taxSvc        = taxSvcWrapper.GetTaxSvcInstance(inProduction);

            CancelTaxRequest cancelTaxRequest = new CancelTaxRequest();

            // Required Request Parameters
            cancelTaxRequest.CompanyCode = Properties.Settings.Default.CompanyCode;
            cancelTaxRequest.DocType     = DocumentType.SalesInvoice;
            cancelTaxRequest.DocCode     = strOCN;
            cancelTaxRequest.CancelCode  = CancelCode.DocVoided;

            CancelTaxResult cancelTaxResult = taxSvc.CancelTax(cancelTaxRequest);

            if (!cancelTaxResult.ResultCode.Equals(SeverityLevel.Success))
            {
                foreach (Message message in cancelTaxResult.Messages)
                {
                    summary = message.Summary;
                }
            }

            return(cancelTaxResult);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: amna-hashim/AvaTaxLibrary
        public static void Main()
        {
            try
            {
                string summary;
                #region Report Tax
                CustomerOrder order = new CustomerOrder();
                order.AddressLine1 = "631 LUPINE DR";
                order.City         = "FORT COLLINS";
                order.Country      = "US";
                order.State        = "CO";
                order.PostalCode   = "80524";
                order.InProduction = false;
                order.IsCommit     = false;
                order.OCN          = "041025304MS";
                order.Quantity     = 1;
                order.TotalAmount  = 66.98m;
                order.TotalTax     = 4.96m;

                GetTaxResult  getTaxResult  = GetTax.Execute(order, out summary);
                PostTaxResult postTaxResult = PostTax.Execute(order, getTaxResult, out summary);
                #endregion

                #region same day cancellation or when shipment charges is filed
                CustomerOrder cancel = new CustomerOrder();
                cancel.InProduction = false;
                cancel.OCN          = "041025304MS";
                CancelTaxResult cancelTaxResult = CancelTax.Execute(cancel.InProduction, cancel.OCN, out summary);
                #endregion

                #region harware refund
                CustomerOrder refund = new CustomerOrder();
                refund.AddressLine1 = "631 LUPINE DR";
                refund.City         = "FORT COLLINS";
                refund.Country      = "US";
                refund.State        = "CO";
                refund.PostalCode   = "80524";
                refund.InProduction = false;
                refund.IsCommit     = false;
                refund.OCN          = "041025304MS";
                refund.Quantity     = 1;
                refund.TotalAmount  = 54.99m; // hardware cost
                refund.TotalTax     = 4.06m;  // tax portion of hardware cost

                AdjustTaxResult adjustTaxResult = AdjustTaxTest.Execute(refund, out summary);
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine("An Exception Occured: " + ex.Message);
            }
            finally
            {
                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
        private void buttonCancelTax_Click(object sender, EventArgs e)
        {
            try
            {
                //##############################################################################
                //### 1st WE CREATE THE REQUEST OBJECT FOR DOCUMENT THAT SHOULD BE CANCELLED ###
                //##############################################################################
                CancelTaxRequest cancelTaxRequest = new CancelTaxRequest();

                //###########################################################
                //### 2nd WE LOAD THE REQUEST-LEVEL DATA INTO THE REQUEST ###
                //###########################################################
                cancelTaxRequest.CancelCode = (CancelCode)comboCancelCode.SelectedItem;

                cancelTaxRequest.CompanyCode = textCompanyCode.Text;
                cancelTaxRequest.DocType     = (DocumentType)comboDocType.SelectedItem;
                cancelTaxRequest.DocCode     = textDocCode.Text;

                //##############################################################################################
                //### 3rd WE INVOKE THE CANCELTAX() METHOD OF THE TAXSVC OBJECT AND GET BACK A RESULT OBJECT ###
                //##############################################################################################
                Util.PreMethodCall(this, lblStatus);

                TaxSvc taxSvc = new TaxSvc();
                ((formMain)this.Owner).SetConfig(taxSvc);                              //set the Url and Security configuration

                _cancelTaxResult = taxSvc.CancelTax(cancelTaxRequest);

                Util.PostMethodCall(this, lblStatus);

                //#####################################
                //### 4th WE READ THE RESULT OBJECT ###
                //#####################################
                lblResultCode.Text = _cancelTaxResult.ResultCode.ToString();
                Util.SetMessageLabelText(lblResultMsg, _cancelTaxResult);

                cancelTaxRequest = null;
                taxSvc           = null;
            } catch (Exception ex)
            {
                Util.ShowError(ex);
            } finally
            {
                Util.PostMethodCall(this, lblStatus);
            }
        }
コード例 #5
0
ファイル: AvaTax.cs プロジェクト: lulzzz/BrandStore
        public void VoidTax(Order order)
        {
            if (!Enabled)
            {
                throw new InvalidOperationException("AvalaraInactiveException");
            }

            CancelTaxRequest cancelTaxRequest = new CancelTaxRequest
            {
                CancelCode  = CancelCode.DocVoided,
                CompanyCode = CompanyCode,
                DocType     = DocumentType.SalesInvoice,
                DocCode     = order.OrderNumber.ToString(),
            };

            TaxSvc          taxService      = CreateTaxService();
            CancelTaxResult cancelTaxResult = taxService.CancelTax(cancelTaxRequest);

            foreach (Message message in cancelTaxResult.Messages)
            {
                LogErrorMessage(message);
            }
        }