Answer the question
In order to leave comments, you need to log in
How can I change order parameters?
How to correctly change the delivery price in the order if the parameters of this delivery are frequently changed
, I have an order in the database, the order has the properties
id
.....
id_delivery_delivery_sum
amount_assembly
amount_of_services
there
is also a table with deliveries
id
.....
percentage_of_goods percentage_assembly in the
order
sum_additional_services
The logic is as follows:
1) the client collects a basket of goods
2) selects one delivery (each delivery has its own percentage of accrual)
3) we get the total amounts in the order
For example: an order for 1,000 rubles, delivery "to the apartment", and this delivery set percentage 10, assembly as 5, additional 100r
Those we take from 1.000r 10% + 5% + 100r and get the amount of services and these parameters are saved in the order table when creating an order
(fields delivery_amount, assembly_amount_amount_of_services)
Accordingly, if the client completes the order, then we know its delivery (delivery_id) and pulling out its percentages (parameters), we re-read all the amounts in the order, everything is ok.
Those in the order, we store a link to the delivery, from which we take the accrual rules, which we consider and save in the order.
I faced such a problem:
we have 100000+ completed orders and another 1000 in the warehouse have already been paid for and are ready for delivery.
business requires that delivery percentages change,
those were
delivery "to the apartment" -> percentage 10, assembly as 5, additional 100r
needs to be done
delivery "to the apartment" -> percentage 12, assembly as 6, additional 100r
and so on (in fact there are 12 options, which still depend on the amount and weight of the goods, and not only on the type to the house, apartment, pvz)
those plate " delivery" 12 lines
if I correct it in the database, then for new orders it will work as it should, BUT !!!!
I need to save the numbers of old orders that have already been issued or are in stock ..
those client placed an order for 10% paid, we gave it away.
came in 30 days (we already have different delivery rules) and handed over some defective goods,
so I need to recalculate his order
(subtract the cost of the defect, refer to the delivery table, get interest and calculate new amounts)
BUT the client made out for 10%, and now, when I turn to the delivery, I will receive a new 12%, and this is not fair to the client
, I need to somehow understand that his order is always considered "at the old" percentage.
so the question is how can I store these OLD parameters so that all old orders, in case of their recalculation, are calculated by interest at the time of registration?
the option is simply to create new deliveries in the table ..
those delivery names will be the same, but the percentages are new and enter some kind of flag that will be responsible for currently active deliveries for the client part.
but I don't know if this is the right approach?
Answer the question
In order to leave comments, you need to log in
Primary documents (in your case: the order and its delivery) must be unchanged. Store this data in the orders table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question