I am developing software for a Home Care business. The software is being created exclusively for a particular client so it works according to her head. Do not be surprised at how it works.
This company has its patients, who pay a fixed monthly amount. Often the patient waives the services for a period and then returns. I need to do something very simple that is to subtract from the monthly value of each client the costs that the company had with him in a given month and thus reach the net profit.
So far so good, I know how to do it.But I also have to add up the net profit that all patients generated and thus know the total net profit for the month.
You can not @paciente.lucro_liquido = @paciente.valor_do_contrato - @paciente.custo_1 - @paciente.custo_2
because the next month the contract value and costs change and this would change the values of the previous months.
What is the best way to solve this? How can I separate the month-to-month information?