title: looking for a simple database design for accounts receivable
body: <p>I am in the process of adding accounts receivable to one of my webapps. Essentially, I want to be able to create sales invoices and record payments received.</p>
  
  <p>The reports, I generate are </p>
  
  <ul>
  <li>statement with balance outstanding</li>
  <li>invoice</li>
  <li>receipt</li>
  </ul>
  
  <p>To create a statement, I was thinking of doing a union of receipts and invoices ordered by date.</p>
  
  <p>I also need to cater for <code>refunds/credits</code>, which i am doing by refund = receipts with a negative amount, and credit = invoice with a negative amount.</p>
  
  <p>All the invoices/receipts are exported to a full accounting package (so don't require double entry system at this end)</p>
  
  <p>What i have come up with is</p>
  
  <pre><code>INVOICES
  id
  customer_id
  total
  tax_amount
  reference
  user_id
  created
  
  INVOICE_LINES
  id
  invoice_id
  description
  qty
  unit_price
  total
  tax_amount
  
  RECEIPTS
  id
  customer_id
  reference
  internal_notes
  amount
  user_id
  created
  </code></pre>
  
  <p>Is there anything that i am missing? </p>
  
  <p>Would a single transactions table be simpler instead of having separate invoice/receipt tables?</p>
  
  <p>Another thought, is it normal to link a receipt to an invoice? what if a receipt was for multiple invoices.</p>
  
  <p>Any advice appreciated (simplicity is the goal)</p>