Create an invoice with Payment term as 2% 10 Net 30 and grand total is say 237.50
Create Payment and select invoice created in #1, it will populate payment amount as 232.75 and discount amount as 4.75.
Change the payment amount from 232.75 to 10. However discount amount would be not updated and would be still at 4.75
Complete this payment with payment amount as 10 and discount as 4.75
Again create new payment for invoice in #1, payment amount would be 218 and discount amount would be 4.75
Here while calculating discount, system doesn't consider payment amount and based on invoice grand total amount and not even invoice open amount, it calculates discount.
Performed above scenario in https://test.idempiere.org/webui/
I believe discount should be calculated based on the amount of payment and not based on the invoice grand total.