avadev / AvaTax-REST-V2-DotNet-SDK

AvaTax v2 SDK for languages using the Dot Net Framework
Apache License 2.0
28 stars 37 forks source link

Error converting value "G" to type #130

Closed daschy closed 4 years ago

daschy commented 4 years ago

I am using version 20.1

Occurs when calling TransactionBuilder.create.

This issue is blocking our system. Since the tax calculation is not possible.

This issue occured since today (20 March 2020)

The response is the following

{
   "id":0,
   "code":"06b1d7ee-87c6-4815-9df3-b2fa1c5e7029",
   "companyId":...,
   "date":"2020-03-20",
   "paymentDate":"2020-03-20",
   "status":"Temporary",
   "type":"SalesOrder",
   "customerVendorCode":"...",
   "customerCode":"None",
   "reconciled":false,
   "totalAmount":9.99,
   "totalExempt":0.0,
   "totalDiscount":0.0,
   "totalTax":0.8,
   "totalTaxable":9.99,
   "totalTaxCalculated":0.8,
   "adjustmentReason":"NotAdjusted",
   "locked":false,
   "version":1,
   "exchangeRateEffectiveDate":"2020-03-20",
   "exchangeRate":1.0,
   "modifiedDate":"2020-03-20T10:54:46.3137384Z",
   "modifiedUserId":46107,
   "taxDate":"2020-03-20T00:00:00",
   "lines":[
      {
         "id":0,
         "transactionId":0,
         "lineNumber":"1",
         "discountAmount":0.0,
         "exemptAmount":0.0,
         "exemptCertId":0,
         "isItemTaxable":true,
         "itemCode":"14494953-91fc-4b76-81c7-0bf5ad0c6fcc",
         "lineAmount":9.99,
         "quantity":1.0,
         "reportingDate":"2020-03-20",
         "tax":0.8,
         "taxableAmount":9.99,
         "taxCalculated":0.8,
         "taxCode":"P0000000",
         "taxCodeId":8087,
         "taxDate":"2020-03-20",
         "taxIncluded":false,
         "details":[
            {
               "id":0,
               "transactionLineId":0,
               "transactionId":0,
               "country":"US",
               "region":"NY",
               "exemptAmount":0.0,
               "jurisCode":"36",
               "jurisName":"NEW YORK",
               "stateAssignedNo":"",
               "jurisType":"STA",
               "jurisdictionType":"State",
               "nonTaxableAmount":0.0,
               "rate":0.040000,
               "tax":0.4,
               "taxableAmount":9.99,
               "taxType":"Sales",
               "taxSubTypeId":"S",
               "taxName":"NY STATE TAX",
               "taxAuthorityTypeId":45,
               "taxCalculated":0.4,
               "rateType":"G",
               "rateTypeCode":"G",
               "unitOfBasis":"PerCurrencyUnit",
               "isNonPassThru":false,
               "isFee":false
            },
            {
               "id":0,
               "transactionLineId":0,
               "transactionId":0,
               "country":"US",
               "region":"NY",
               "exemptAmount":0.0,
               "jurisCode":"093",
               "jurisName":"SCHENECTADY",
               "stateAssignedNo":"SC 4241",
               "jurisType":"CTY",
               "jurisdictionType":"County",
               "nonTaxableAmount":0.0,
               "rate":0.040000,
               "tax":0.4,
               "taxableAmount":9.99,
               "taxType":"Sales",
               "taxSubTypeId":"S",
               "taxName":"NY COUNTY TAX",
               "taxAuthorityTypeId":45,
               "taxCalculated":0.4,
               "rateType":"G",
               "rateTypeCode":"G",
               "unitOfBasis":"PerCurrencyUnit",
               "isNonPassThru":false,
               "isFee":false
            }
         ],
         "nonPassthroughDetails":[

         ],
         "hsCode":"",
         "costInsuranceFreight":0.0,
         "vatCode":"",
         "vatNumberTypeId":0
      }
   ],
   "addresses":[
      {
         "id":0,
         "transactionId":0,
         "boundaryLevel":"Zip5",
         "line1":"Voluptas omnis omnis qui excepteur est cupidatat ",
         "line2":"",
         "line3":"",
         "city":"Schenectady",
         "region":"NY",
         "postalCode":"12345",
         "country":"US",
         "taxRegionId":4001906,
         "latitude":"42.809888",
         "longitude":"-73.951787"
      }
   ],
   "summary":[
      {
         "country":"US",
         "region":"NY",
         "jurisType":"State",
         "jurisCode":"36",
         "jurisName":"NEW YORK",
         "taxAuthorityType":45,
         "stateAssignedNo":"",
         "taxType":"Sales",
         "taxSubType":"S",
         "taxName":"NY STATE TAX",
         "rateType":"G",
         "taxable":9.99,
         "rate":0.040000,
         "tax":0.4,
         "taxCalculated":0.4,
         "nonTaxable":0.0,
         "exemption":0.0
      },
      {
         "country":"US",
         "region":"NY",
         "jurisType":"County",
         "jurisCode":"093",
         "jurisName":"SCHENECTADY",
         "taxAuthorityType":45,
         "stateAssignedNo":"SC 4241",
         "taxType":"Sales",
         "taxSubType":"S",
         "taxName":"NY COUNTY TAX",
         "rateType":"G",
         "taxable":9.99,
         "rate":0.040000,
         "tax":0.4,
         "taxCalculated":0.4,
         "nonTaxable":0.0,
         "exemption":0.0
      }
   ]
}

Following the exception

Newtonsoft.Json.JsonSerializationException: Error converting value "G" to type 'System.Nullable`1[Avalara.AvaTax.RestClient.RateType]'. Path 'lines[0].details[0].rateType', line 1, position 1345.
 ---> System.ArgumentException: Requested value 'G' was not found.
   at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, NamingStrategy namingStrategy, String value, Boolean disallowNumber)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
macdonaldster commented 4 years ago

Hi, I am seeing this when we call the sandbox API but not yet in live. 🤞

mlstubblefield commented 4 years ago

I'm getting this as well - last time I saw something like this in the sandbox, I got it in production about a week later. Please help! We rely heavily on this software!

mlstubblefield commented 4 years ago

Not sure if it helps, but this doc suggests that rate type was deprecated some time ago. https://developer.avalara.com/api-reference/avatax/rest/v2/models/enums/TransactionSummary%20%3E%20rateType/

We don't use rate type, it's just failing to deserialize.

stephenhewitt-csgpro commented 4 years ago

I too am suddenly experiencing this issue in the sandbox. FYI, I am on 19.11.0 but also tried 20.1.1. It appears to me that there has been a change in the API?

kaynab commented 4 years ago

We are also seeing this in develop. The issue is that the Avalara v2 rest api is returning back 'G' now instead of what I presume was 71. This does not match the Avalara.AvaTax.RestClient.RateType enum and results in the error.

For reference, the response from Avalara: "lines": [{ **snip** "details": [{ **snip** "rateType": "G",

Commenting out the deprecated RateType field in TransactionSummary.cs and TransactionLineDetailModel.cs allows everything to flow fine.

IMO this is a breaking change on the api side as updating the avatax client for all deployments is not going to be trivial.

daschy commented 4 years ago

Quick workaround:

 var builder = new TransactionBuilder(....);
 var response = _avataxClient.RestCall<MyTransactionModel>(
                    "POST", 
                    new AvaTaxPath("/api/v2/transactions/create"), 
                   builder.GetCreateTransactionModel());

Where MyTransactionModel is the custom implementation of the response.

nicoAthleteReg commented 4 years ago

I'm having the same problem. I updated to the NuGet package 20.1.1 but still the same problem. we can't keep working until this problem is resolved

kaynab commented 4 years ago

I received this response to my inquiry with Avalara support:

The error is due to a problem with our Avatax sandbox service. Our engineers are working to resolve it at this time. Please retry your process later today or tomorrow.

So it looks like its being treated as an issue on the API side.

mjwills commented 4 years ago

https://community.avalara.com/avalara/topics/avalara-tax-sandbox-api-issue

qjavalara commented 4 years ago

This issue should have been resolved earlier this week.