Click here to Skip to main content
15,906,341 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear Team,

Seek Help in understanding the logic of writing code for availing the closing balance. i m practising on inventory system where there will be an account maintained on daily basis for deposit and withdrawal. Deposit and withdrawal part have been developed by me, what i am unable to write is the closing balance logic.

Whenever user will log in and check the closing balance, he should be able to have it.
can anybody help in this regards

raj
Posted

1 solution

dear rajeshsinh,

You should maintain a table of transactions. It should keep all transactions including opening balances. Usually a transaction should contain tran id, date, amount, account.

If it is debit u can give the amount as +ve and for the credit amounts u can give -ve values. For getting the balance, you may select the sum of amount field for that account. That column will be the balance of the account.

you can do like this:

select sum(amount) as balance from acctran where acode='1234' and docdate>='01/apr/2013' and docdate<='08/sep/2013';

the balance column will be the account balance.

with regards,

Sunil
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900