1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// rocie - An enterprise grocery management system
//
// Copyright (C) 2026 Benedikt Peetz <benedikt.peetz@b-peetz.de>
// 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 <https://www.gnu.org/licenses/gpl-3.0.txt>.
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<ProductParentId>,
/// 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<String>,
/// Which barcodes are associated with this product.
pub(super) associated_bar_codes: Vec<Barcode>,
}
mk_id!(ProductId and ProductIdStub);
|