Author |
Topic |
Jawad Khan
Starting Member
21 Posts |
Posted - 2008-09-25 : 04:23:50
|
Hi everyone, I've developed a database for a double entry accounts system. I was inspired with the article by Michael Wigley. [url]http://homepages.tcp.co.uk/~m-wigley/gc_wp_ded.html[/url]To the simplest here is my database structure.Here is some sample data.AccountsAccount ID-------AccountName1----------------Cash2----------------Inventory3----------------Owner4----------------Sales5----------------CostOfGoodsSoldNow I am inserting 3 sample transactions. The first transaction is the owner investment say $10,000. You may notice that two records are inserted in DebitsCredits table. One for debits account (Cash Here) and one for credit account (Owner here).The second Transaction is Purchase of inventory $5,000. And the third entry is for a sales of Amount $100 and cost of goods is $80.(for Any person having no accounting background Let me explain the sales. If I purchase an item for $80 and sale it for $100 then Cash is debited by $100, Sales account is credited by $100, while inventory account is credited by $80 and Cost of goods sold is debited by $80)TransactionsTransactionID-------TransactionDate-------TransactionType1-------------------1/Jan/07--------------Invest2-------------------3/Jan/07--------------Purchase3-------------------5/Jan/07--------------SalesDebitsCreditsid-------TransactionID-------AccountID-------Amount-----Type1--------1-------------------1---------------10,000-----Debit2--------1-------------------3---------------10,000-----Credit3--------2-------------------2---------------5,000-----Debit4--------2-------------------1---------------5,000-----Credit5--------3-------------------1---------------100-------Debit6--------3-------------------4---------------100-------Credit7--------3-------------------5---------------80--------Debit8--------3-------------------2---------------80--------CreditEverything seems fine and nice. I can calculate the balance of any account (say cash account id=1) by the following query.Select Sum(Amount) from (Select Sum(Amount) from DebitsCredits where Type='Debit" and AccountID=1Union AllSelect Sum(Amount) * -1 from DebitsCredits where Type='Credit" and AccountID=1) As DerivedTableThe problem comes with very large volume of data and for the Sales account and the CostOfGoods account.The sales account is only credited and the costofgoods account is only debited during the whole business period. So the balance of these two accounts are a huge amount. In my case, the accounting period was of 12 months and this query returned with an overflow message in 10th month.I wonder whether this approach is a good one or there are other better approaches??? |
|
Rajendra
Starting Member
5 Posts |
Posted - 2008-10-02 : 13:18:40
|
Need to Redesign database ...One Daybook master to be created..bookid pkbooknm mappedaccountid ->(fk) accountsnow insert one row in day book tabke for every sales/cash/bank book with respective accountidDebitCredit table should have column of bookidNow for sales transaction inset only one row in debitcredit table with Accountid of customer and boookid of sales book and type = Debit. Effect on Sales account is implicitly Credit (Inverse of type field ) with same amount and date; and so on for every other transaction. Try to recollect Double entery system Rule--> for Every transaction should affect two account with same amount/date but exactly reverse type. ofcourse; Query to calculate balance of SALES /CASH (daybook accounts) should invert type.Here i have given simple transaction Example; It is complex implement(some more tables /trigger also required)but can reduce number of rows exactly half in debitcredit table |
|
|
Jawad Khan
Starting Member
21 Posts |
Posted - 2008-10-03 : 06:29:33
|
So you say that I should do only one entry (only for debit) as the other (Credit) entry is understood by default. but the problem is the following transaction:Here a purchase is made and partial payment is doneDebitsCreditsid-------TransactionID-------AccountID-------Amount-----Type1--------101-------------------2---------------10,000-----Debit2--------101-------------------1---------------6,000-----Credit3--------101-------------------6---------------4,000-----CreditHere AccountID 6 refers to an account called accounts payable. |
|
|
Jawad Khan
Starting Member
21 Posts |
Posted - 2008-10-18 : 06:29:08
|
Hi guys! 192 views and no suggestions!!!!!!! c'mon. |
|
|
fdtoo
Starting Member
28 Posts |
Posted - 2008-11-10 : 05:50:12
|
Jawad, You need to include a field to capture account_type. This field helps in report filtering, when user needs to run report for transaction listing, balance sheet, profit and loss, etc. An account type generally will group each transaction records under the following category: 1) Liability 2) Asset 3) Equity 4) Revenue 5) Cost_of_Sale 6) expense 7) tax As for my design. I would generally insert both debit and credit in the same table, with credit having a - symbol. I find it much easier to perform summation on a set of records. |
|
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2008-11-11 : 15:58:40
|
A negative amount is a decrease in assets but a negative amount is an increase in liabilities. Ahh, accounting is such fun. Anyway, I agree with fdtoo, all transactions entries should be in one table with an account ID and the amount of the transaction. On the account table, you should have an account type like the list already posted and your account description. Never keeping running totals on a table as these can all be derived based on transactions. I'm guessing this is homework as "accounting is accounting is accounting" and there are so many off the shelf packages that can be purchased way cheaper the developing a full-blown account system in-house - IMO.Anyway, something like this would work better. Keep in mind, I am solely basing the design on what you've posted. I see a need for a few other tables, at a minimum!Transactions:Auto number - identity field, primary keyTransaction ID - usually user-defined (a purchase order number, invoice number, etc.) that groups a batch of transactions.AccountIdAmountDateEnteredPosted Flag - yes/no (has it been posted or is it pending??) This would be used by the various financial reportsany additional fields related to a transactionAccounts:AccountId - primary key Account Number - usually user defined and used in chart of accountsAccountDescriptionAccountTypeany additional fields related to an accountTerry |
|
|
chriscowart
Starting Member
1 Post |
Posted - 2009-01-03 : 16:52:35
|
Here's how I've designed a 'complete' accounting package. As you know, accounting is simply Dr. = Cr. and A = L + NW + R - E and its all tracked in a General LedgerSample Data:ChartOfAccounts -- note that the type field can only be Asset, Liability, Equity, Income, or Expense+----+------+----------------+-----------+| id | num | name | type |+----+------+----------------+-----------+| 1 | 1010 | Cash In Bank | Asset || 2 | 2550 | Investments | Net Worth |+----+------+----------------+-----------+Ledger+----+------------+------------+--------------------+------------+-----------+| id | accountNum | date | ref | dr | cr |+----+------------+------------+--------------------+------------+-----------+| 1 | 1010 | 2008-01-01 | Joe Doe Investment | 10,000.00 | || 2 | 2550 | 2008-01-01 | Joe Doe Investment | 0.00 | 10,000.00 |+----+------------+------------+--------------------+------------+-----------+To get a trial balance:select sum(dr) - sum(cr) from LedgerTo get totals for each account:select sum(dr), sum(cr) from Ledger group by accountNumI know this is pretty basic, but figure it'll be insightful for you to see how I've implemented this system. |
|
|
fdtoo
Starting Member
28 Posts |
Posted - 2010-10-22 : 04:09:47
|
Lawson, my friend said there is a book describing literally everything on accounting system design. It appears to be hosted somewhere in smashwords. |
|
|
rahulakacyrus
Starting Member
2 Posts |
Posted - 2010-11-01 : 09:02:41
|
Hi Everyone,Can anyone help me with interfacing the journal table above with sales and purchase table.For example,sales table generates some transactions that needs to be recorded(advance,balance payments etc.) and purchase has similar entries.How do we know what sales/purchase has what transactions? |
|
|
fdtoo
Starting Member
28 Posts |
Posted - 2010-12-28 : 02:42:15
|
To answer your question here, is you need to maintain your sales and purchases transaction in separate tables, which can be referenced to the journal table by a FK. Your journal entries would be captured in your journal table, whereas your sales and purchase transaction would be captured in their respective individual tables. I created my own accounting database, owing much to the book which you could download at accountingdes.com |
|
|
|