automapper-validation 0.1.60

AHB condition expression parsing, evaluation, and EDIFACT validation
Documentation
// <auto-generated>
// Generated by automapper-generator generate-conditions
// AHB: xml-migs-and-ahbs/FV2610/QUOTES_AHB_1_1a_20260401.xml
// Generated: 2026-04-22T18:07:36Z
// Delegates unchanged conditions to QuotesConditionEvaluatorFV2510 (FV2510).
// </auto-generated>

#![allow(clippy::style, clippy::complexity)]

#[allow(unused_imports)]
use crate::eval::format_validators::*;
use crate::eval::{ConditionEvaluator, ConditionResult, EvaluationContext};
use crate::generated::fv2510::QuotesConditionEvaluatorFV2510;

/// Condition evaluator for QUOTES FV2610.
///
/// Delegates to [`QuotesConditionEvaluatorFV2510`] for conditions whose AHB description is
/// unchanged from that version. Local overrides: [2060, 2061, 2062, 2063, 2064].
pub struct QuotesConditionEvaluatorFV2610 {
    fallback: QuotesConditionEvaluatorFV2510,
}

impl Default for QuotesConditionEvaluatorFV2610 {
    fn default() -> Self {
        Self {
            fallback: QuotesConditionEvaluatorFV2510::default(),
        }
    }
}

/// Condition IDs whose implementation differs from the fallback.
const FV2610_OVERRIDES: &[u32] = &[2060, 2061, 2062, 2063, 2064];

impl ConditionEvaluator for QuotesConditionEvaluatorFV2610 {
    fn message_type(&self) -> &str {
        "QUOTES"
    }

    fn format_version(&self) -> &str {
        "FV2610"
    }

    fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
        match condition {
            2060 => self.evaluate_2060(ctx),
            2061 => self.evaluate_2061(ctx),
            2062 => self.evaluate_2062(ctx),
            2063 => self.evaluate_2063(ctx),
            2064 => self.evaluate_2064(ctx),
            other => self.fallback.evaluate(other, ctx),
        }
    }

    fn is_external(&self, condition: u32) -> bool {
        self.fallback.is_external(condition)
    }

    fn is_known(&self, condition: u32) -> bool {
        FV2610_OVERRIDES.contains(&condition) || self.fallback.is_known(condition)
    }
}

impl QuotesConditionEvaluatorFV2610 {
    /// [2060] Pro Nachricht ist die SG27 LIN+Z64 (Erforderliches Produkt Schaltzeitdefinitionen) maximal einmal anzugeben.
    // REVIEW: Cardinality constraint: SG27 LIN+Z64 (Erforderliches Produkt Schaltzeitdefinitionen) may appear at most once per message. LIN+Z64 puts Z64 at elements[0][0]; count_qualified_in_group with elem=0 checks that. Returns True (constraint satisfied) when count ≤ 1, False when violated. Zero occurrences also satisfies the constraint. (medium confidence)
    fn evaluate_2060(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.count_qualified_in_group("LIN", 0, "Z64", &["SG27"]) <= 1)
    }

    /// [2061] Pro Nachricht ist die SG27 LIN++Z65 (Erforderliches Produkt Leistungskurvendefinitionen) maximal einmal anzugeben.
    // REVIEW: Cardinality constraint: SG27 LIN++Z65 (Leistungskurvendefinitionen) may appear at most once. The double-plus notation means element 0 is empty and Z65 is at elements[1][0]; count_qualified_in_group with elem=1 matches that position. (medium confidence)
    fn evaluate_2061(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.count_qualified_in_group("LIN", 1, "Z65", &["SG27"]) <= 1)
    }

    /// [2062] Pro Nachricht ist die SG27 LIN++Z66 (Erforderliches Produkt Ad-hoc-Steuerkanal) maximal einmal anzugeben.
    // REVIEW: Cardinality constraint: SG27 LIN++Z66 (Ad-hoc-Steuerkanal) may appear at most once. LIN++Z66 places Z66 at elements[1][0]; count_qualified_in_group with elem=1 checks that position across all SG27 instances. (medium confidence)
    fn evaluate_2062(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.count_qualified_in_group("LIN", 1, "Z66", &["SG27"]) <= 1)
    }

    /// [2063] Pro Nachricht ist die SG27 LIN++Z67 (Erforderliches Messprodukt für Werte nach Typ 2 aus Backend) maximal einmal anzugeben.
    // REVIEW: Cardinality constraint: SG27 LIN++Z67 (Messprodukt für Werte nach Typ 2 aus Backend) may appear at most once. LIN++Z67 places Z67 at elements[1][0]; count_qualified_in_group with elem=1 checks that position. (medium confidence)
    fn evaluate_2063(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.count_qualified_in_group("LIN", 1, "Z67", &["SG27"]) <= 1)
    }

    /// [2064] Pro Nachricht ist die SG27 LIN++Z68 (Erforderliches Produkt Konfigurationserlaubnis für Werte nach Typ 2 aus SMGW) maximal einmal anzugeben.
    // REVIEW: Cardinality constraint: SG27 LIN++Z68 (Konfigurationserlaubnis für Werte nach Typ 2 aus SMGW) may appear at most once. LIN++Z68 places Z68 at elements[1][0]; count_qualified_in_group with elem=1 checks that position. (medium confidence)
    fn evaluate_2064(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.count_qualified_in_group("LIN", 1, "Z68", &["SG27"]) <= 1)
    }
}