question

Ajmal M A avatar image
Ajmal M A asked dhanaraj commented

ClientException: cannot update one or more of these fields: LineItem When adding TaxRate

When I try to add taxrate to lineitem and add that lineitem to order the following error occured :

com.clover.sdk.v1.ClientException: cannot update one or more of these fields: LineItem{json='{"taxRates":{"elements":[{"id":"SVhhhyStrq","isDefault":true,"name":"Service Tax","rate":5}]},"id":"GC8H6QN3MHPSJ","price":3799}', bundle=null, changeLog=null} at com.clover.sdk.v1.ServiceConnector.throwOnFailure(ServiceConnector.java:280) at com.clover.sdk.v1.ServiceConnector.execute(ServiceConnector.java:213) at com.clover.sdk.v3.order.OrderConnector.addCustomLineItem(OrderConnector.java:252) at com.SocketService$CreateOrdedrClover.run(SocketService.java:1465)

The executed code was like :

                TaxRate taxRate = new TaxRate();
                taxRate.setId(id);
                taxRate.setRate(rate);
                taxRate.setName("Service Tax");
                taxRate.setIsDefault(true);
                List<TaxRate> taxRates = new ArrayList<TaxRate>();
                taxRates.add(taxRate);
                currentLineItem.setTaxRates(taxRates);
                orderConnector.addCustomLineItem(order.getId(),currentLineItem,true);

Please help me to solve this issue. can i add taxrate to each line item ? Can i add taxamount for an order?

Orders
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

sam avatar image
sam Deactivated answered dhanaraj commented

No, at the moment, there is no way of adding a tax rate to individual line item. TaxRates must be set on a inventory/item object. InventoryConnector.assignTaxRatesToItem(final String itemId, final List<string> taxRates)

1 comment
10 |2000

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

dhanaraj avatar image dhanaraj commented ·

inventoryConnector.assignTaxRatesToItem(added_item.getId(), newTaxRates);

0 Likes 0 ·

Welcome to the
Clover Developer Community