How can I access already modified table data?

1

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?

    
asked by anonymous 13.09.2017 / 04:00

2 answers

1

Hello, well, and if you separate, put in different tables. Every month, you call a new record of that patient. From what I see is an association of 1 for n.

link

Give it a go. Maybe it helps.

    
14.09.2017 / 13:28
1

One way would be to have a template for recording customer payments. Then do a custom query. Dai in the SQL query you do and sum the total of values with a where passing the month.

    
26.09.2017 / 06:14