question

tg avatar image
tg asked Sukhbir Singh commented

How do you set a tax rate via the SDK?

Attempting to follow the patterns of the SDK but keep getting:

status code: 400 cannot update one or more of these fields: LineItem{json='{"taxRates":{"elements":[{"name":"Our Tax Rate","rate":1000}]}}', bundle=null, changeLog=null}

List<LineItem> lineItemList = orderConnector.getOrder(orderId).getLineItems(); TaxRate taxRate = new TaxRate(); taxRate.setRate(1000l); taxRate.setName("Our Tax Rate"); List<TaxRate> taxRates = new ArrayList<>(); taxRates.add(taxRate); LineItem lineItem = lineItemList.get(0); lineItem.setTaxRates(taxRates); orderConnector.updateLineItems(orderId, lineItemList);

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Mark Mullan avatar image
Mark Mullan Deactivated answered Sukhbir Singh commented

Hi tg,

I think you may find this thread relevant: https://devask.clover.com/question/2463/how-do-i-change-the-price-of-a-lineitem-using-the-android-sdk/

8 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tg avatar image tg commented ·

Hey Mark

I tried that method and still get the same error. This makes me wonder is it even possible to set a tax rate at the line item level?

Even if I create a new LineItem without connecting it to an Item I get the same error at: newLineItem.setTaxRates(taxRates); Any suggestions?

0 Likes 0 ·
Mark Mullan avatar image Mark Mullan commented ·

Hey tg,

Thanks for the follow up. I'm encountering the same obstacles you are. Let me look into this, and I'll get back to you if I find anything. Indeed, it does seem difficult, if not impossible, to add/remove TaxRates from a LineItem. It seems that TaxRates need to be set/removed at the Order level.

I'll keep you posted.

0 Likes 0 ·
tg avatar image tg commented ·

Hey Mark

Setting it at the order level would work for our use case, do you have an example of that? Couldnt find anything in the OrderConnector docs (https://clover.github.io/clover-andro...)

0 Likes 0 ·
Mark Mullan avatar image Mark Mullan commented ·

Hi tg,

Thanks for your patience - I believe I misspoke about adding TaxRates at the Order level as well. I've spent the past few days working on trying to assign TaxRates at various levels via our SDKs. The only way I can find is at the Inventory/Item level, via InventoryConnector.assignTaxRatesToItem(final String itemId, final List<String> taxRates).

InventoryConnector repo here.

0 Likes 0 ·
Sukhbir Singh avatar image Sukhbir Singh Mark Mullan commented ·

What value we need to pass on the second param of assignTaxRatesToItem() method?

0 Likes 0 ·
Mark Mullan avatar image Mark Mullan commented ·

Again, this will set default tax rates on an item, so you'll want to include accompanying logic accordingly.

Indeed, our Register app is built with our public facing Android SDK, and it seems this is the only way to assign TaxRates as well. i.e., There's no way to add/remove specific TaxRates to a LineItem as is.

I'll continue looking into this and get back to you with any additional findings. If anything, our Item.setTaxRates() and lineItem.setTaxRates() methods may have to be revisited.

Thanks-

Mark

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community