I have two table, accounts describing various accounts and gives the account 
balance and ledger, which recodrs all account transactions.

Playing around with the accounting tables, I have an user transaction that 
goes into the ledger but the values placed in the ledger balance columns 
depend on whether the entry is an asset, liability, or equity. 

The accounts table inform me of the type of entry, and has  columns 
(account int,   type enum (liability,asset,equity)

I have the account type and account number and cash value from the user form 
(user is making some transaction to an account, now I want to enter the 
transaction properly into the ledger)

 To make a journal entry:
// First get the account type
SELECT @type:= type from accounts where accounts.number="user_selected";

// then the hard part
INSERT into journal values 
case @type   
WHEN "equity" THEN
 (place account.number, value in second and fifth column)
WHEN "asset" THEN
 (place account.number, value in fsecond and fiftth column)
WHEN "liability" THEN
 (place account.number, value in third and fourth column);


or is it:

INSERT into journal values(account.number,
// and four separate case statements for each succeeding column)

or 

CASE @type
WHEN "equity" THEN
[do this complete INSERT statement
WHEN "equity" THEN
[do this different INSERT statement
WHEN "equity" THEN
[do this INSERT statement

or

none of the above


Matt Young
EverydaySoftware.biz


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to