×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Finding Best Penalty

## Finding Best Penalty

(OP)
This is similar to the
[url=http://www.tek-tips.com/viewthread.cfm?qid=1381440&amp;page=1]Finding small amounts from a larger total[/url] 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.
Replies continue below

### RE: Finding Best Penalty

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.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!