Click here to Skip to main content
15,747,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a POS and Inventory Management Web Application and am facing an issue in updating the price list.

When there is a change in the price of a product. I want to update the price in the database but this price change must not affect the old stock of the same product already in the store am looking for a logic to handle this.

How can i differentiate the old stock and the new stock with the updated price.

Please help me in solving this issue.

Thanks In Advance.

What I have tried:

versioning for the product but it makes trouble while generating the sales reports and also it will be annoying if a price of a product changes frequently
Updated 21-Dec-16 20:16pm

1 solution

Date time is the key here. Use the data time of price update and that of stock arrival.
Every product in your database will have a unique id or code, say product_id, every product should have only one id. As for keeping records of price change, you will need a table say price_change to keep min these 3 pieces of information:
product_id, datetime, price

Every price change should be inserted into this table as a new record.
If you do not want to have another id for every insertion, you can use the combination of the product_id + datetime to identify each price change and a particular batch of stock based on its arrival date time.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900