automapper_validation/generated/fv2610/
invoic_conditions_fv2610.rs1#![allow(clippy::style, clippy::complexity)]
9
10#[allow(unused_imports)]
11use crate::eval::format_validators::*;
12use crate::eval::{ConditionEvaluator, ConditionResult, EvaluationContext};
13use crate::generated::fv2510::InvoicConditionEvaluatorFV2510;
14
15pub struct InvoicConditionEvaluatorFV2610 {
20 fallback: InvoicConditionEvaluatorFV2510,
21}
22
23impl Default for InvoicConditionEvaluatorFV2610 {
24 fn default() -> Self {
25 Self {
26 fallback: InvoicConditionEvaluatorFV2510::default(),
27 }
28 }
29}
30
31const FV2610_OVERRIDES: &[u32] = &[5, 6, 56, 90, 527, 903, 2000];
33
34impl ConditionEvaluator for InvoicConditionEvaluatorFV2610 {
35 fn message_type(&self) -> &str {
36 "INVOIC"
37 }
38
39 fn format_version(&self) -> &str {
40 "FV2610"
41 }
42
43 fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
44 match condition {
45 5 => self.evaluate_5(ctx),
46 6 => self.evaluate_6(ctx),
47 56 => self.evaluate_56(ctx),
48 90 => self.evaluate_90(ctx),
49 527 => self.evaluate_527(ctx),
50 903 => self.evaluate_903(ctx),
51 2000 => self.evaluate_2000(ctx),
52 other => self.fallback.evaluate(other, ctx),
53 }
54 }
55
56 fn is_external(&self, condition: u32) -> bool {
57 self.fallback.is_external(condition)
58 }
59
60 fn is_known(&self, condition: u32) -> bool {
61 FV2610_OVERRIDES.contains(&condition) || self.fallback.is_known(condition)
62 }
63}
64
65impl InvoicConditionEvaluatorFV2610 {
66 fn evaluate_5(&self, ctx: &EvaluationContext) -> ConditionResult {
68 match ctx.has_qualified_value("NAD", 0, "MR", 8, 0, &["DE"]) {
69 ConditionResult::True => ConditionResult::False,
70 ConditionResult::False => ConditionResult::True,
71 ConditionResult::Unknown => ConditionResult::Unknown,
72 }
73 }
74
75 fn evaluate_6(&self, ctx: &EvaluationContext) -> ConditionResult {
77 ctx.has_qualified_value("NAD", 0, "MR", 8, 0, &["DE"])
78 }
79
80 fn evaluate_56(&self, ctx: &EvaluationContext) -> ConditionResult {
82 ctx.dtm_ge("137", "202301010000")
83 }
84
85 fn evaluate_90(&self, ctx: &EvaluationContext) -> ConditionResult {
88 ctx.format_check("DTM", 0, 1, |val| {
89 let comparable = val.get(..12).unwrap_or(val);
90 ConditionResult::from(!comparable.is_empty() && comparable < "202701010000")
91 })
92 }
93
94 fn evaluate_527(&self, _ctx: &EvaluationContext) -> ConditionResult {
96 ConditionResult::True
98 }
99
100 fn evaluate_903(&self, ctx: &EvaluationContext) -> ConditionResult {
102 if let Some(val) = ctx.resolved_value {
103 return ConditionResult::from(val == "1");
104 }
105 ConditionResult::Unknown
106 }
107
108 fn evaluate_2000(&self, _ctx: &EvaluationContext) -> ConditionResult {
110 ConditionResult::True
112 }
113}