Xero doesn’t support line items that have a mix of GST and non-GST items. To add a mixed invoice you have to add the taxable amount on one line and the non-taxable amount on another. Unfortunately many invoices simply provide the total amount paid and the GST included, which means doing the calculations (estimations) yourself.
Most of the time you can just multiply the GST paid by 10 to find out the taxable portion and use that to derive the exempt portion:
# converted to cents for simplicity
total = 9794
gst = 566
taxable = gst * 10 # => 5660
exempt = total - gst - taxable # => 3568
In this case I happen to know the “correct” amounts were actually $56.65 taxable and $35.63 exempt but we can’t know that for sure based on the inputs we were provided. Our calculated answers are within the range of valid solutions and everything adds up correctly.
However, this formula doesn’t handle some (legal) edge cases. On a $9 invoice with $0.82 GST we end up with a taxable portion of $8.20 and an exempt portion of -$0.02. It’s an easy mistake to make.
To correctly derive valid values for the taxable and exempt portions in this case we need to add a conditional:
total = 900
gst = 82
taxable = gst * 10 # 820
if taxable + gst > total
taxable = total - gst # 818
end
exempt = total - gst - taxable