I am trying to create Payment Terms and/or a Payment Terms Template that automatically calculates the correct payments on a Sales Order.

Say I have a Sales Order with a Grand Total of $500. My payment schedule is DP + 4, so something like this:

Down payment (advanced payment?): $100 ← This is an arbitrary amount

Payment 1: $100 (25% of the remainder)

Payment 2: $100 (25% of the remainder)

Payment 3: $100 (25% of the remainder)

Payment 4: $100 (25% of the remainder)

In this case, each payment is 20%. However, the payment schedule could just as easily have been the following:

Down payment (advanced payment?): $400 ← This is an arbitrary amount

Payment 1: $25(25% of the remainder)

Payment 2: $25(25% of the remainder)

Payment 3: $25(25% of the remainder)

Payment 4: $25(25% of the remainder)

How do I implement this functionality with Payment Terms and/or the Payment Terms Template I’d like to avoid calculating the payment term percentages and amounts by hand.