How is the «Apply Customer Tax» («Before Discount» / «After Discount») option handled?

Details: How is \Magento\Tax\Model\Config::applyTaxAfterDiscount() implemented and used?

See also:

How to setup the «Apply Customer Tax» option in accordance with the Russian tax law?