avadev / AvaTax-REST-V2-PHP-SDK

Sales Tax API SDK for PHP and AvaTax REST
https://developer.avalara.com/sdk/
Apache License 2.0
48 stars 95 forks source link

AS-115:How to specify a unit for parameters that accept units #177

Closed rahulv-dev closed 2 years ago

rahulv-dev commented 2 years ago

As mentioned in the original github issue, this feature is already available in C# and Java SDK.

In the current implementation of PHP SDK, we don't have a way to specify the units for line parameters and by default it always ends up with "Meter". The parameters in response currently looks like: "parameters": [ { "name": "ScreenSize", "value": "22", "unit": "Meter" } ],

With new changes, we added a new function which takes units as a parameter and the same ends up being used and the request would like the following:

$tb = new Avalara\TransactionBuilder($client, "DEFAULT", Avalara\DocumentType::C_SALESINVOICE, 'ABC'); $t = $tb->withAddress('SingleLocation', '123 Main Street', null, null, 'Irvine', 'CA', '92615', 'US') ->withLine(100.0, 1, null, "P0000000") ->withLineParameterAndUnit("ScreenSize", 22.0, "inch") ->create();

And the response would look like: (Function override is not an option in PHP)

"parameters": [ { "name": "ScreenSize", "value": "22", "unit": "Inch" } ],