question

wsetchell avatar image
wsetchell asked Jacob Abrams answered

Order tax total

What's the best way to find the total tax for an Order?

It seems like you could find it from subtracting each line item's price from the order total, but that seems messy. Is there a cleaner way?

long getTaxTotal(Order order) {
  long subTotal = 0;
  for (LineItem lineItem : order.getLineItems()) {
    subTotal += lineItem.getPrice()
  }
  return order.getTotal() - subTotal;
}
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

Jacob Abrams avatar image
Jacob Abrams answered

We provide a calculation class com.clover.sdk.v3.order.OrderCalc in our clover-android-sdk that computes various values using an Order. Try the following:

long tax = new OrderCalc(o).getTax();

10 |2000

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

Welcome to the
Clover Developer Community