O
O
Oleg Pravdin2018-06-14 22:04:09
Laravel
Oleg Pravdin, 2018-06-14 22:04:09

How to organize the storage of complex price lists in the database?

Hello. There is a project on Laravel. One of the tasks is to form the cost according to the formula volume_of_delivery_of_goods*price_for_conventional_unit. The scope of delivery is entered by the user. The unit price is formed from several parameters. The complexity is as follows: each separate set of options generates a separate (not calculated by the formula) cost.
Question: how to organize a model in Laravel to store such prices?. I was thinking of creating a Criteria model containing all product properties along with their id. In the "Price" model, specify (in the abstract) id and price. To make a binding of a variability through communication many to many. Those. an array of selected criteria comes from the client, and the table is searched for a price to which these and only these criteria apply.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Pravdin, 2018-06-19
@opravdin

Perhaps, from my description, an incorrect understanding of the problem as a whole has developed. I described it in more detail in a comment to another answer. I myself solved the problem through a separate table "Prices", where for each set of input parameters (fortunately the branching is not very large) the value of the cost is stored. We managed to simplify/formalize/remove some of the criteria and parameters, so in my case the lion's share of the solution is working on the task, on understanding it and choosing an approach to the solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question