0FI_AP_4 gets data from table BSIK. You may check the document in BSEG to check the more info on discount.
Also FI_FIND_PAYMENT_CONDITIONS module will perform these calculations on day basis. If you need more information checkTable Field for Discount Type in Payment Terms