Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Best Penalty

Status
Not open for further replies.

Skie

Programmer
Jun 21, 2004
475
0
0
US
This is similar to the
Finding small amounts from a larger total thread, but a little more complicated.

Basically I have the following pieces of data:
Due Amount
Due Date
Payment Amount
Payment Date
Penalty % (This is based on how different the Due Date is from the Payment Date.)
Penalty Amount (The Due Amount * Penalty %)

A couple things to keep in mind:
The Penalty % will max out once the dates are 15 days different. So, if and due amount is for sure going to incur the full penalty, you might as well pay it with the last payment available.
Payments can be split and used for more than one due amount.

The only method I can think of to handle this is the brute force method. Run through each possibility and keep the lowest or the first "$0.00".

But, if someone has thoughts on an algorithm or a better solution I'm definately open to it.
 
There are some situations you can optimize. Eg when a payment equals a certain due amount of course. Another situation is only one due amount has some decimals and the paid amount matches that one.

In this case a customer friendly routine would optmize the penalty amount to be as low as possible. What's difficult to compute is if there is one payment with a low Penalty amount that is not past the 15 days period, so it will rise, but there is some other due amount which would give a higher penalty, which one to mark as paid. You'd need to make an assumtion on the date the customer will pay the rest after being informed of having some due amount still open. You might cash in the due amount for the worst case, then do a backward optimization after you received all payments, optimize retrospectively and make a refund.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top