Is there a formula to solve this combinations/permutations problem?

Hello, this is a bit of an interesting problem that I can't get my head around. To help explain the problem, let's compare it to Netflix's service.

Let's say you belong to Mathflix, a monthly subscription service that rents math books. Say you have a plan that allows you to read two books at home at any given time, and to read a maximum of 4 books per month.

Every day a computer runs through the membership tables at Mathflix and tries to decide if any members should be shipped new books.

Is there a formula that can always calculate the correct number of books a person should receive assuming the following constants?

Books-Limit-Per-Month = 4

Books-Limit-At-Home = 2

And the following variables:

Current-Books-At-Home

Current-Books-Queued-For-Shipping

Current-Books-Received-This-Month

I've tried all sorts of combinations and failed. The problem seems a lot simpler than it actually is. I would appreciate any input.

Many thanks