Calculate tax total correctly which depends on the item that could be an Order or a LineItem. Tax adjustments are stored differently in these two cases.

Fixes #4830
Fixes #4829