I’m developing an application where employees have a list of tasks to execute. And for each task they’re using some items. For example: a mechanic is working on a car and has to replace the bumper for a new one, so the mechanic goes to the warehouse and takes a new item. That specific item has a unitprice. So when the guy picks up his fixed car he pays that specific price for the bumper. But let’s say that the prices are being changed after a couple of weeks. So i change the unit price for that item. But in the history of that task it still has to be the old price.
I was wondering what ways you can best keep a history for this. I was thinking of copying that specific Item before changing the price and then update the task with the item with the old price. After that i will do an update of the item with the new price.
Or are there any other ways to achieve this? I’m using Fluent NHibernate to take care of my database
Let’s say these are my classes (a bit simplyfied and enough for the example)
public class Task
{
public virtual int Id;
public virtual string Description;
public virtual IList<Item> Items;
}
public class Item
{
public virtual int Id;
public virtual string ItemName;
public virtual decimal UnitPrice;
}
Any help welcome 🙂
There are two basic strategies for this:
Iteminto a separate table/class (e.g.ItemInTask) which captures the exact unit data that was used when the Task was created.