/**
* Represents an item in the order system.
*/
class Item {
/**
* Creates an instance of an Item.
* @param {string} itemId - The unique identifier for the item.
* @param {string} name - The name of the item.
* @param {string} description - A brief description of the item.
* @param {number} price - The price per unit of the item.
* @param {number} quantity - The quantity of the item in stock or ordered.
* @param {string} category - The category of the item (e.g., electronics, groceries).
* @param {number} [taxRate=0] - The tax rate applied to the item (default is 0).
*/
constructor(itemId, name, description, price, quantity, category, taxRate = 0){
this.itemId = itemId;
this.name = name;
this.description = description;
this.price = price;
this.quantity = quantity;
this.category = category;
this.taxRate = taxRate;
}
/**
* Calculates the total price of the item, including tax.
* @returns {number} The total price, including tax.
*/
getTotalPrice() {
return this.price * this.quantity * (1 + this.taxRate);//Calculate total price including tax = (price * quantity) + tax
}
}
export default Item ;