Details: How is the «Apply Discount On Prices» («Excluding Tax» / «Including Tax») option handled?
See also:
\Magento\Tax\Model\Config::applyTaxAfterDiscount()