// rocie - An enterprise grocery management system // // Copyright (C) 2026 Benedikt Peetz // SPDX-License-Identifier: GPL-3.0-or-later // // This file is part of Rocie. // // You should have received a copy of the License along with this program. // If not, see . use serde::{Deserialize, Serialize}; use utoipa::ToSchema; use crate::storage::sql::{ barcode::Barcode, mk_id, product_parent::ProductParentId, unit_property::UnitPropertyId, }; /// The base of rocie. /// /// Products can be bought and consumed and represent, what you actually have in storage. /// Not every product is bought, as some can also be obtained by cooking a recipe. #[derive(Clone, ToSchema, Serialize, Deserialize)] pub(crate) struct Product { /// The id of the product. pub(crate) id: ProductId, /// The parent this product has. /// /// This is effectively it's anchor in the product DAG. /// None means, that it has no parents and as such is in the toplevel. #[schema(nullable = false)] pub(crate) parent: Option, /// The property this product is measured in. /// /// (This is probably always either Mass, Volume or Quantity). pub(crate) unit_property: UnitPropertyId, /// The name of the product. /// /// This should be globally unique, to make searching easier for the user. pub(crate) name: String, /// An optional description of this product. #[schema(nullable = false)] pub(super) description: Option, /// Which barcodes are associated with this product. pub(super) associated_bar_codes: Vec, } mk_id!(ProductId and ProductIdStub);