Customisation in erpnext (payment deduction against late delivery in items)

Customer deducts money 0.5 % per week upto maximum 5% against late delivery material from invoice value. How we setup and track , how much amount is deducted per items.