First thing is this is a long question. So please first read it then give me your suggestion.

currently i am working on a banking projects for my degree. Where i am implementing a simple bank savings account. Where account holder can deposit and withdraw money.

The account starts with a opening balance. Then user can add or withdraw money. And also i have to calculate their interest (Flat 4% per year).

The following transaction is to be made

``````Date         TNX Type     Amount      Interest     Remaining     LastTXDate
01/03/13    + Opening   + 10000          0.00       10000.00     01/03/13
15/03/13    + Deposite  +  5000          0.00        5000.00     15/03/13
09/04/13    + Deposite  +  2500          0.00        2500.00     09/04/13
============================================================================

25/04/13    - Withdraw  -  5000
17/05/13    - Withdraw  -  6000
21/06/13    + Deposite  + 10000
``````

There are some rules

If a deposit made in between first 10 days of a month then interest will be calculated form the deposit date, Else interest will be calculated from 1 day of next month.
I store all deposit and withdraw TNX into a table called 'savings'.

Now my question is how can i calculate interest? Suggest me any logic. No code required.

Actually i have a logic but don't know if it it effective or not.

My logic is like follow

When a withdraw made, i first search last deposit record with remaining amount.
Then i calculate the Maturity days for that withdraw amount,
Then i calculate interest for that withdraw amount and save it to that
deposit record's interest field.
Am i right with this logic or i have to change it? Any suggestion will be helpful.

Using your logic, if someone made a deposit on the 9th, then a second deposit on the 11th, and then a withdrawal on the 15th, then there would be no interest calculated since the last deposit record would be after the 10th, correct? This would violate your deposit between first …

## All 2 Replies

Using your logic, if someone made a deposit on the 9th, then a second deposit on the 11th, and then a withdrawal on the 15th, then there would be no interest calculated since the last deposit record would be after the 10th, correct? This would violate your deposit between first 10 days of a month rule.

If you want to calculate interest on withdrawal, then I would suggest going through the records since the last withdrawal, and applying your rules.

Would be weird for the account holder though, since they would only see interest on their statements when they made a withdrawal.

Well what I think you can do is count the withdrawals made and for each withdrawal add a date because your interest seems as if it not a static so when you add the date that will be easy to track the withdrawal made.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.