Ejemplo n.º 1
0
        private GetTaxRequest BuildTaxRequest(Customer cust, Avalara.AvaTax.Adapter.AddressService.Address originAddress, DocumentType docType)
        {
            // Instantiate a new GetTaxRequest
            GetTaxRequest avalaraTaxRequest = new GetTaxRequest
            {
                OriginAddress = originAddress,
                CompanyCode   = CompanyCode,
                CustomerCode  = cust.CustomerID.ToString(),
                DetailLevel   = DetailLevel.Tax,
                CurrencyCode  = Localization.StoreCurrency(),
                DocCode       = ("DocDate" + System.DateTime.Now.ToString()),
                DocDate       = System.DateTime.Today,
                DocType       = docType,
                Discount      = System.Decimal.Zero,
            };

            avalaraTaxRequest.TaxOverride.TaxDate = System.DateTime.Today;

            if (cust.LevelHasNoTax)
            {
                avalaraTaxRequest.ExemptionNo = (cust.CustomerLevelName.Length > 25 ? cust.CustomerLevelName.Substring(0, 25) : cust.CustomerLevelName)
                                                ?? "Customer Level Tax Exempt"; //Avalara can't handle more than 25 chars here
            }
            return(avalaraTaxRequest);
        }