question

Sukhbir Singh avatar image
Sukhbir Singh asked Sukhbir Singh commented

Facing com.clover.sdk.v1.ClientException when adding Discount in the Order

Hi,

We are facing the following exception when we are trying to add Discount for an order:

com.clover.sdk.v1.ClientException: status code: 400 Order{json='{"id":"DJF30KMZWAVF4","device":{"id":"3d486638-f92b-d45b-f713-3a7ceb73d833"},"currency":"USD","isVat":false,"groupLineItems":false,"testMode":false,"createdTime":1598626736497,"clientCreatedTime":1598626736497,"taxRemoved":false,"manualTransaction":false,"total":970,"employee":{"id":"0QG23WH51JG3G"},"state":"open","lineItems":{"elements":[{"id":"620V654S2DNFA","item":{"id":"5G4ZCN9QHTGZY"},"createdTime":1598626747924,"binName":null,"userData":null,"itemCode":"","price":222,"alternateName":"","name":"Biscuit","exchanged":false,"refunded":false,"printed":false,"isRevenue":true,"taxRates":{"elements":[{"id":"C3D1GYRYF4EPA","name":"TN Food","rate":925000,"taxAmount":0,"isDefault":true,"taxType":null},{"id":"Q5C80S1TPJSY4","name":"Tax","rate":875,"taxAmount":0,"isDefault":true,"taxType":null}]}},{"id":"GQM9574X2V1HP","item":{"id":"5G4ZCN9QHTGZY"},"createdTime":1598626772360,"binName":null,"userData":null,"itemCode":"","price":222,"alternateName":"","name":"Biscuit","exchanged":false,"refunded":false,"printed":false,"isRevenue":true,"taxRates":{"elements":[{"id":"C3D1GYRYF4EPA","name":"TN Food","rate":925000,"taxAmount":0,"isDefault":true,"taxType":null},{"id":"Q5C80S1TPJSY4","name":"Tax","rate":875,"taxAmount":0,"isDefault":true,"taxType":null}]},"discounts":null,"modifications":null,"payments":null},{"id":"5N7CQNSE298WJ","item":{"id":"5G4ZCN9QHTGZY"},"createdTime":1598626772521,"binName":null,"userData":null,"itemCode":"","price":222,"alternateName":"","name":"Biscuit","exchanged":false,"refunded":false,"printed":false,"isRevenue":true,"taxRates":{"elements":[{"id":"C3D1GYRYF4EPA","name":"TN Food","rate":925000,"taxAmount":0,"isDefault":true,"taxType":null},{"id":"Q5C80S1TPJSY4","name":"Tax","rate":875,"taxAmount":0,"isDefault":true,"taxType":null}]},"discounts":null,"modifications":null,"payments":null},{"id":"Z4TAWQXBV3X0T","item":{"id":"5G4ZCN9QHTGZY"},"createdTime":1598626772775,"binName":null,"userData":null,"itemCode":"","price":222,"alternateName":"","name":"Biscuit","exchanged":false,"refunded":false,"printed":false,"isRevenue":true,"taxRates":{"elements":[{"id":"C3D1GYRYF4EPA","name":"TN Food","rate":925000,"taxAmount":0,"isDefault":true,"taxType":null},{"id":"Q5C80S1TPJSY4","name":"Tax","rate":875,"taxAmount":0,"isDefault":true,"taxType":null}]},"discounts":null,"modifications":null,"payments":null}]}}', bundle=null, changeLog=null}

08-28 07:59:43.865 8999-10155/app_package W/System.err: at com.clover.sdk.v1.ServiceConnector.throwOnFailure(ServiceConnector.java:327)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at com.clover.sdk.v1.ServiceConnector.execute(ServiceConnector.java:260)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at com.clover.sdk.v3.order.OrderV31Connector.addDiscount(OrderV31Connector.java:432)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at com.connectivity.CloverConnectivity$DiscountAsyncTask.doInBackground(CloverConnectivity.java:745)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at com.connectivity.CloverConnectivity$DiscountAsyncTask.doInBackground(CloverConnectivity.java:737)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:292)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

08-28 07:59:43.865 8999-10155/app_package W/System.err: at java.lang.Thread.run(Thread.java:818)


I am using the following code to add the discount:

Discount discount = new Discount();
discount.setName("Discount Caption");
discount.setAmount(amount);
mOrderConnector.addDiscount(orderId, discount);


Please suggest the solution to resolve it. Or let me know if I missed something.


Thanks.

OrdersPaymentsDiscounts
10 |2000 characters needed characters left characters exceeded

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

1 Answer

David Marginian avatar image
David Marginian answered Sukhbir Singh commented

Is amount a positive or negative number? If positive, can you try with a negative number? See https://docs.clover.com/docs/working-with-orders?source=post_page---------------------------#adding-discounts. Even though you aren't using the REST API I believe the same logic applies.

1 comment
10 |2000 characters needed characters left characters exceeded

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

Yes, It's working. Thanks.

0 Likes 0 ·

Welcome to the
Clover Developer Community