How does discount apply to the products and order?

Product level discount will be applied on the product price before any tax calculation. i.e, Product Price – Product Discount + Product Tax (product tax calculated on Product Price – Product Discount)

Order level discount will be applied on the order total (total + product price) before any order tax calculation. i.e, Order Total – Order Discount + Order Tax (order tax calculated on Order Total – Order Discount)