D
D
Dilik Pulatov2021-04-29 10:32:11
PostgreSQL
Dilik Pulatov, 2021-04-29 10:32:11

What is the best way to implement price history in reports?

We develop a CRM system for a client to automate his reports. Now we have come to such an extent that you need to figure out how to properly store the prices of products in the database so that the price history is preserved and that it is easy to calculate the report. So there is a list of products and there are several warehouses and shops. Among stores and warehouses there is a report type - Arrival Expenses or Transfer of goods from one warehouse to another warehouse. When adding reports, you need to specify the prices of the goods and at the same time you need to save the old prices as history (I myself have an idea, but I'm new to this, so I want to hear the opinions of experienced developers). I know now many CRM systems have already come up with this structure, but I still don’t know how best to do it. Let me know if you have experience, or a source that will answer my questions. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cicatrix, 2021-04-29
@cicatrix

What's there to think about?
Product ID / Modified date / Price

A
Anton R., 2021-04-29
@anton_reut

For each price, enter an additional field id_old_price, where the id of the old price will be stored, if it was, this will allow you to create price history chains of any length.
And enter the current_price field which will have a flag of 1 or 0 and will indicate that this price should be displayed on the site if the flag is 1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question