sunny

I have this transaction problem, expense and income column. periodically there i …

Sat 24 Feb, 2018 12:53 pm

I have this transaction problem, expense and income column. periodically there is a percentage charge on the income as management fee. which will be deducted from the income of the to get the remaining balance. 


my problem is that this transaction can be edited. that's the income can be edited to a higher value or lower value. which means the amount to be charge as management fee will be lower or higher due to the percentage.  and the balance as well. 


How will I write my code to reflect this changes. on balance and income. 


I also intend to report the balance for each month. 


For instance if I have the following income 10000, 20000, I will charge management fee of 10% Which is 3000. so my balance is 27,000. 

Now I get another income of let's say 50k, 60k, I charge 10% on the 110k which will be 11K from the 110k to give me 90k+27k total balance is 117k. 


my problem is how to recalculate this after the income is edit after a period of time. 


let's say 


let's say the 20k is changed to 30k,  bringing management fee to 4000. making first balance to be 28k. 

Database info. 

Transaction(

Transaction_id

Expense

Income 

Property_id

)

Management_fee(

Fee_id

Percentage 

Date 

Property_id

)


I also intend to update the corresponding income column on all the incomes management fee has been charged. So I I detect the particular column that was edited and run the calculations again. But how do I add the balance of the first, second... n balance provided the editing was done on past transactions that the management fee has been charged for long. 

Comments