How can I access already modified table data?

Asked

Viewed 29 times

1

I’m developing software for a Home Care company. The software is being created exclusively for a particular client so it works according to her head. No wonder the operation.

This company has its patients, who pay a fixed monthly amount. Often the patient dispenses with the services for a period and then comes back. I need to do something very simple that is subtract from the monthly fee 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 can do.

But I also have to add up the net profit that all patients generated and so know the total net profit of the month.

You can’t do it @paciente.lucro_liquido = @paciente.valor_do_contrato - @paciente.custo_1 - @paciente.custo_2 because in the following month the contract value and costs change and this would change the values of the previous months.

What is the best way to resolve this? How can I separate information month by month?

2 answers

1

One way would be to have a model to record customer payments. Then do a custom query. Dai in SQL query you do and sum the total values with a Where passing the month.

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.