When a discount is applied to an invoice, it is applied to each line individually and rounded to the nearest cent and then summed up to a total. The reason for this relates to sales tax. We cannot simply apply an X% discount to the pre-tax total of the invoice and calculate the tax on that total, we have to apply it to each line item as sales tax may be different at each line item (some lines are taxable, some are not).
This is the reason for the discrepancy of a couple cents in the calculation.