How to maintain rates in old transactions
Hello friends,
This query might sound very basic, but I have some doubts about it.
I am starting to develop a small sale-order system for my own food business.
-> I have a Menu table with price for each item.
-> Now I want to make SaleOrders table and a child table OrderItems.
->In OrderItems I will pick up the price of each item from the reference of Menu table (I will setup the reference in OrderItems table).
Everything is fine according to me till here. Problem starts from here. In the future if I change the price of any item in the Menu table, it will make effect (change item price) in all the historical orders as well (since there is a reference to menu table in the OrderItems table).
So how do I go about this. I do not want the price to change for items in the historical orders, thus changing the total of all the historical orders and create problem in accounting. But I do want the new orders to pick up the latest price from the Menu table always.
The only way I can think of right now is that the rate from the Menu table will only be copied to the Rate field in OrderItems table if the it is empty. It will only be empty for the first time when the OrderItem is being created in the SaleOrder table.
This way we can change the rate in the Menu table in the future and it will not affect the historical transactions.
Please let me know if I am using the right approach !!
Please help !!
7 replies
-
Hi Keep a reference between OrderItems and Menu so that you can keep track of sales of each item historically but create a price field in OrderItems and in the Trigger after update section of this reference put something like this
Price := Menu.Price
Base all your calculations on this OrderItems.Price field.
I'd also save the description, as these often change over time.
I have written dozens of ordering / invoicing / ERP systems so please feel free to ask any questions on this subject.
Regards John
-
Yes, that sounds correct although the link links the whole record so you can see any of the fields if you want to.
-
see comment in your other thread
Content aside
- 3 mths agoLast active
- 7Replies
- 48Views
-
3
Following