This question was **closed** Apr 02 at 09:46 PM by Clover_Community_Bot for the following reason: automated

Hello, I would like to understand how to calculate tax for orders created via API. Per Clover documentation at https://docs.clover.com/build/web-app...

I see tax calculation is only done at once on order working total. How is this possible to calculate it at order level since every inventory item in clover can be associated with one or more tax rates? How do i apply these tax rates at order level?

I am using pay api to make a payment for the order with my calculated totals that is turning out a cent less or more that the order total that clover calculates thru the Orders app. So i would like to know how to calculate tax properly if it needs to be done per item and its tax rates and/or on whole order sum total?

Could you kindly clarify?

Regards, Liju

Comment

suresh.gupta

**Answer** by Jacob Abrams
·
Oct 26, 2015 at 03:44 PM

Since you are performing this calculation on your server you will need to do a little bit more work. We provide a pure Java calc.jar that we use to perform calculations. You can get it here: https://github.com/clover/clover-andr...

Import that JAR into your project and then use the internal Calc class to perform computations. You will probably want to have some kind of Java classes to represent Clover orders that you convert from JSON, you can GSON or Jackson to convert the JSON to your instances. Once you have Order objects you need to implement the Calc.Order interface and give it to Calc instance like so:

```
com.clover.core.internal.calc.Calc.Order calcOrder = new com.clover.core.internal.calc.Calc.Order() {
// TODO: Implement all Calc.Order methods using your own Clover Order object
};
Calc c = new Calc(calcOrder);
c.getTax();
```

Take a look at https://github.com/clover/clover-andr... for an example how we implemented this interface for our Android SDK, you won't be able to use our v3 classes on your server, you will implement the interface using your own classes.

Thanks for your reply, but I am doing the calculations on my web-server. Both order creation and payment for the orders are being done via Clover REST API calls.

Actually, my web server is written in NodeJs, do you have anything to help with this to do the calculations?

Sorry we don't supply a Javascript calculation library. You could try using a Node.js to Java bridge such as https://github.com/joeferner/node-java

Jacob, Thanks for your responses. Will take a look at the resources you have provided for a a solution. Appreciate your help.

@Liju By any chance, have you found a solution for nodejs tax calculation?

Copyright © 2010-16 DZone, Inc. - All rights reserved.

- Anonymous
- Sign in
- Create
- Ask a question
- Post an idea
- Create an article
- Spaces
- App Market Developer Platform
- Clover GO
- Ideas & Feedback
- Semi-Integration
- Explore
- Topics
- Questions
- Ideas
- Articles