Comments (7)
@robobeau I think the actual API accepts either the numerical enum value or the string from my testing?
from avatax-rest-v2-js-sdk.
Fixed in release 23.3.0 Please give it a try and let us know if you have any further issues https://github.com/avadev/AvaTax-REST-V2-JS-SDK/releases/tag/23.3.0 You'll have to opt-in to the feature by passing in enableStrictTypeConversion: true
to the constructor for the SDK.
from avatax-rest-v2-js-sdk.
There's still a problem, here, @svc-developer.
The typing for createTransaction
is expecting a model
that has a type
property defined as
/**
* @type {Enums.DocumentType}
* @memberof CreateTransactionModel
*/
type?: Enums.DocumentType | undefined;
But the documentation suggests that we need to be using a string
, for example "SalesInvoice"
instead of the enum value for DocumentType.SalesInvoice
, which is 1
.
from avatax-rest-v2-js-sdk.
@BioSurienDG Correct, @robobeau Let us know if that doesn't work for you
from avatax-rest-v2-js-sdk.
I have to convert the type to unknown before I can type it when using a string here.
const taxDocument = formatTaxDocument({
type: 'SalesInvoice' as unknown as CreateTransactionModel['type'],
shippingAddress: formattedShippingAddress,
items,
customerId,
commit: false,
currencyCode: 'USD',
})
export function formatTaxDocument(params: TaxDocumentParams) {
const taxDocument: CreateTransactionModel = {
type: params.type,
companyCode: process.env.AVATAX_COMPANY_CODE,
date: new Date(),
customerCode: params.customerId || 'N/A',
addresses: {
shipTo: params.shippingAddress,
shipFrom: {
locationCode: process.env.AVATAX_LOCATION_CODE,
},
},
lines: params.items,
commit: params.commit,
currencyCode: params.currencyCode,
}
return taxDocument
}
If I remove the parsing I get this TS error
Type 'string' is not assignable to type 'DocumentType | undefined'.ts(2322)
index.ts(43, 3): The expected type comes from property 'type' which is declared here on type 'TaxDocumentParams'
What's the best practice here? Is it using DocumentType.SalesInvoice
?
from avatax-rest-v2-js-sdk.
@uwitdat Yes, use the enums directly and it should work
from avatax-rest-v2-js-sdk.
Just ran into this issue as well. Maybe you could make enableStrictTypeConversion: true
required in TypeScript in the AvaTaxClient
constructor? That way for folks using TypeScript, they'll get the correct behavior. Those using JS can fall back to the default of string enums. (Side note, I do think numeric enums by default are a mistake and strings would be much more friendly.)
Also could you export enums and models from the top-level avatax
module so we don't need to reach into the import and have to write import * as AvaTaxEnums from 'avatax/lib/enums/index';
?
from avatax-rest-v2-js-sdk.
Related Issues (20)
- uploadCertificateImage does not work as intended HOT 1
- customHttpAgent is not nullable anymore HOT 1
- `voidTransaction` always throws when deleting a transaction even though it successfully deletes it HOT 1
- Can't create new client with Typescript - Docs example doesn't work HOT 4
- CreateTransaction - Can I provide the "final price" and avatax will calculate base price + tax so the final result will be the "final price" HOT 2
- Split shipment ShipFrom value HOT 3
- You forced us to do two `await res.text()`, we got `body used already for:...` HOT 2
- Why is `model` now optional in all the API functions? HOT 1
- Could not find a declaration file for module 'node-fetch' HOT 1
- Addresses undefined when using the `auditTransaction` function HOT 5
- Model required on voidTransaction HOT 3
- Doc: Missing comma (,) in the README.md file for configuration HOT 1
- "invalid json response body" when calling commit endpoint HOT 1
- BaseLogger is not exported
- `timeout` is optional according to README but required by TypeScript HOT 1
- "This document status is incorrect for this operation" with refundTransaction
- Console has an error of ReferenceError after add avatax sdk HOT 2
- Regression: `timeout` is optional according to README but required by TypeScript HOT 2
- DownloadCertificateImage ends with is not valid JSON error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avatax-rest-v2-js-sdk.