use ifc_model::EntityId;
use super::datetime::DateTimeValue;
use crate::ArithmeticOperator;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum CostItemType {
UserDefined,
NotDefined,
}
impl CostItemType {
pub(crate) const fn token(self) -> &'static str {
match self {
Self::UserDefined => "USERDEFINED",
Self::NotDefined => "NOTDEFINED",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum CostScheduleType {
Budget,
CostPlan,
Estimate,
Tender,
PricedBillOfQuantities,
UnpricedBillOfQuantities,
ScheduleOfRates,
UserDefined,
NotDefined,
}
impl CostScheduleType {
pub(crate) const fn token(self) -> &'static str {
match self {
Self::Budget => "BUDGET",
Self::CostPlan => "COSTPLAN",
Self::Estimate => "ESTIMATE",
Self::Tender => "TENDER",
Self::PricedBillOfQuantities => "PRICEDBILLOFQUANTITIES",
Self::UnpricedBillOfQuantities => "UNPRICEDBILLOFQUANTITIES",
Self::ScheduleOfRates => "SCHEDULEOFRATES",
Self::UserDefined => "USERDEFINED",
Self::NotDefined => "NOTDEFINED",
}
}
}
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub enum CostValueKind<'a> {
Monetary(f64),
Components {
operator: ArithmeticOperator,
components: &'a [EntityId],
},
}
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub struct CostValueDraft<'a> {
pub name: Option<&'a str>,
pub description: Option<&'a str>,
pub applicable_date: Option<DateTimeValue<'a>>,
pub fixed_until_date: Option<DateTimeValue<'a>>,
pub category: Option<&'a str>,
pub condition: Option<&'a str>,
pub kind: CostValueKind<'a>,
}
impl CostValueDraft<'_> {
#[must_use]
pub fn monetary(amount: f64) -> Self {
Self {
kind: CostValueKind::Monetary(amount),
..Self::default()
}
}
}
impl Default for CostValueDraft<'_> {
fn default() -> Self {
Self {
name: None,
description: None,
applicable_date: None,
fixed_until_date: None,
category: None,
condition: None,
kind: CostValueKind::Monetary(0.0),
}
}
}
#[derive(Debug, Clone, Copy, Default)]
#[non_exhaustive]
pub struct CostItemDraft<'a> {
pub global_id: &'a str,
pub name: Option<&'a str>,
pub description: Option<&'a str>,
pub object_type: Option<&'a str>,
pub identification: Option<&'a str>,
pub predefined_type: Option<CostItemType>,
pub cost_values: &'a [EntityId],
}
#[derive(Debug, Clone, Copy, Default)]
#[non_exhaustive]
pub struct CostScheduleDraft<'a> {
pub global_id: &'a str,
pub name: Option<&'a str>,
pub description: Option<&'a str>,
pub object_type: Option<&'a str>,
pub identification: Option<&'a str>,
pub predefined_type: Option<CostScheduleType>,
pub status: Option<&'a str>,
pub submitted_on: Option<DateTimeValue<'a>>,
pub update_date: Option<DateTimeValue<'a>>,
}
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub struct NestingDraft<'a> {
pub global_id: &'a str,
pub parent: EntityId,
pub children: &'a [EntityId],
}
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub struct ScheduleAssignmentDraft<'a> {
pub global_id: &'a str,
pub schedule: EntityId,
pub items: &'a [EntityId],
}
impl<'a> CostValueDraft<'a> {
#[must_use]
pub fn name(mut self, value: &'a str) -> Self {
self.name = Some(value);
self
}
#[must_use]
pub fn description(mut self, value: &'a str) -> Self {
self.description = Some(value);
self
}
#[must_use]
pub fn applicable_date(mut self, value: impl Into<DateTimeValue<'a>>) -> Self {
self.applicable_date = Some(value.into());
self
}
#[must_use]
pub fn fixed_until_date(mut self, value: impl Into<DateTimeValue<'a>>) -> Self {
self.fixed_until_date = Some(value.into());
self
}
#[must_use]
pub fn category(mut self, value: &'a str) -> Self {
self.category = Some(value);
self
}
#[must_use]
pub fn condition(mut self, value: &'a str) -> Self {
self.condition = Some(value);
self
}
#[must_use]
pub fn kind(mut self, value: CostValueKind<'a>) -> Self {
self.kind = value;
self
}
}
impl<'a> CostItemDraft<'a> {
#[must_use]
pub fn new(global_id: &'a str) -> Self {
Self {
global_id,
..Self::default()
}
}
#[must_use]
pub fn name(mut self, value: &'a str) -> Self {
self.name = Some(value);
self
}
#[must_use]
pub fn description(mut self, value: &'a str) -> Self {
self.description = Some(value);
self
}
#[must_use]
pub fn object_type(mut self, value: &'a str) -> Self {
self.object_type = Some(value);
self
}
#[must_use]
pub fn identification(mut self, value: &'a str) -> Self {
self.identification = Some(value);
self
}
#[must_use]
pub fn predefined_type(mut self, value: CostItemType) -> Self {
self.predefined_type = Some(value);
self
}
#[must_use]
pub fn cost_values(mut self, value: &'a [EntityId]) -> Self {
self.cost_values = value;
self
}
}
impl<'a> CostScheduleDraft<'a> {
#[must_use]
pub fn new(global_id: &'a str) -> Self {
Self {
global_id,
..Self::default()
}
}
#[must_use]
pub fn name(mut self, value: &'a str) -> Self {
self.name = Some(value);
self
}
#[must_use]
pub fn description(mut self, value: &'a str) -> Self {
self.description = Some(value);
self
}
#[must_use]
pub fn object_type(mut self, value: &'a str) -> Self {
self.object_type = Some(value);
self
}
#[must_use]
pub fn identification(mut self, value: &'a str) -> Self {
self.identification = Some(value);
self
}
#[must_use]
pub fn predefined_type(mut self, value: CostScheduleType) -> Self {
self.predefined_type = Some(value);
self
}
#[must_use]
pub fn status(mut self, value: &'a str) -> Self {
self.status = Some(value);
self
}
#[must_use]
pub fn submitted_on(mut self, value: impl Into<DateTimeValue<'a>>) -> Self {
self.submitted_on = Some(value.into());
self
}
#[must_use]
pub fn update_date(mut self, value: impl Into<DateTimeValue<'a>>) -> Self {
self.update_date = Some(value.into());
self
}
}
impl<'a> NestingDraft<'a> {
#[must_use]
pub const fn new(global_id: &'a str, parent: EntityId, children: &'a [EntityId]) -> Self {
Self {
global_id,
parent,
children,
}
}
}
impl<'a> ScheduleAssignmentDraft<'a> {
#[must_use]
pub const fn new(global_id: &'a str, schedule: EntityId, items: &'a [EntityId]) -> Self {
Self {
global_id,
schedule,
items,
}
}
}