Database Design for Invoices With Monthly Installments
<p>This question is an extension/expansion of an already answered question on StackOverflow: <a href="https://stackoverflow.com/questions/2679333/database-design-for-invoices-invoice-lines-revisions">Database Design for Invoices</a></p>

<p>However, I'd like to expand on the idea and find out the correct way to allow customers to pay for invoices using some type of installments (monthly payment) system.</p>

<p>In the answered question, the voted answer utilized a database schema that had the following tables:</p>

<ol>
<li>Orders table: used for draft/pending orders</li>
<li>Orders Details table: used for line items of pending orders</li>
<li>Invoices table: used to represent finalized (immutable) orders and how much the customer owes.</li>
<li>Payments table: when a customer makes a payment the total amount goes in here.</li>
<li>InvoicesPayments table: this shows how much of each payment should apply to a particular invoice. This table is needed because sometimes payments can apply to more than one invoice.</li>
</ol>

<p><em>(for sake of simplification and because this question's focus is the table design I've left out details like triggers, etc.)</em></p>

<p><a href="https://i.stack.imgur.com/HUPiX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HUPiX.png" alt="Simplified Database Schema"></a></p>

<p>How can I allow for invoices to be broken up into monthly installments? The requirements are as follows:</p>

<ol>
<li>At the time the order is placed the customer will be able to select how much they want to pay as a down payment and then pay X number of monthly installments until the balance is paid.</li>
<li>For now we can ignore things like interest rates.</li>
<li>Sometimes a customer will make a payment that will cover more than one monthly payment. For example, lets say they forget to pay one month and next month they pay for the current month and the past month in a single payment.</li>
</ol>

<p>Any help/guidance you can offer would be most appreciated. Thank you!</p>

<p><strong>-- AFTERNOON UPDATE --</strong></p>

<p>After considering the responses so far and doing some tinkering on my own, what do you think about having a schema like the following:</p>

<p><a href="https://i.stack.imgur.com/eyn8j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eyn8j.png" alt="schema 2.0"></a></p>

<p>In the above proposed schema, all invoices will have a ScheduledPayments record.  If the invoice is due all at once (pay in full), it will have one record in there.  If the invoice is paid in installments it will have X number of records for each payment (plus any down payment).</p>

<p>Then, when a payment is made, a record is added to the payments table and one or more records is added to the relationship table "ScheduledPaymentsPayments" which will connect a payment to both invoice(s) and monthly payment(s).</p>

<p>What do you think of this solution? Do you foresee any problems with it or can you suggest any alternatives that might be better?</p>