Database Design for Credit Purchase

database-design

I have the following table that holds the purchase order

po_id
supplier_id
transaction_type  -- either cash or credit

and other table that holds the items

po_id 
product_id
quantity
unit_price

Now, how should I handle payment transactions, as payments can either be cash, or credit. If credit, the payment can be made in multiple transactions. and if Cash, there should not be any outstanding payments for this particular purchase order. How can I design a schema that identifies outstanding amounts per purchase order and reflect that in a double entry accounting schema.

Best Answer

Consider handling all money related transactions using a double entry accounting model. Any real world application will eventually need to handle the complexity that this model supports and it is a well understood design pattern.

See this question on this site and a similar question on Stack Overflow for more insights into this design.