Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mathishuettl's avatar

Price should be valid on with specific date

Hello,

I have a price-table that includes some rates it has the following structure:

ID, key, valid_from, price

Everytime when the price rises (most on 1st January) I want to add a record to the Table with a different valid_from and a different price. The Key should be the Same.

Because when I reprint an old invoice I want to have the same price then it was on the invoice date.

Does i need two Tables or can i use the group_by functionality here? Can someone give me an example if group_by is possible in my case?

I would solve it like this, but i think it's a bad solution:

I have a Table called Tariffs with the following structure: ID, key,

Then I have a Table called tarif_dates with the following structure: ID, tariff_id, valid_from, price

So my Tariffs hasMany tarif_dates.

0 likes
0 replies

Please or to participate in this conversation.