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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//! `mako-mabis` — MABIS (Marktprozesse für Bilanzkreis- und
//! Aggregationsverantwortliche) process engine for German electricity market
//! balance group accounting (BDEW MaKo).
//!
//! ## Process family
//!
//! MABIS governs the billing and settlement processes for
//! Bilanzkreisverantwortliche (BKV) in the German **electricity** balancing
//! market. There is no gas component in MABIS.
//!
//! | Process | PID | Status |
//! |---|---|---|
//! | Bilanzkreisabrechnung Strom | **13003** | ✅ Implemented |
//! | Clearingliste DZR (BIKO → NB/ÜNB) | **55069** | ✅ Implemented |
//! | Clearingliste BAS (BIKO → BKV) | **55070** | ✅ Implemented |
//! | Lieferantenclearingliste (NB → LF) | **55065** | ✅ Implemented |
//!
//! > **PID 13003** is the MSCONS Summenzeitreihe PID (`"Summenzeitreihen und
//! > Ausfallarbeitssummen"`), confirmed in MSCONS AHB 2.4c/2.5 (all FV versions)
//! > and the BDEW MSCONS AHB 3.1g PDF §5 page 14. The `edi-energy` MSCONS
//! > profiles contain full segment rules for PID 13003 from FV2024-04-01 onward.
//!
//! ## PIDs 13002–13028 belong to Messwesen, not MABIS
//!
//! The `edi-energy` MSCONS AHB profiles contain PIDs 13002–13028. These are
//! **Messwerten-PIDs** (meter data exchange) — e.g. 13002 "Messwerte
//! Zählerstand Gas", 13017 "Messwerte Zählerstand Strom" — and belong to the
//! Messwesen process family, not to MABIS billing. They must not be registered
//! under any `"mabis-billing"` workflow identifier.
//!
//! ## Architecture
//!
//! Each BDEW process variant is a separate [`mako_engine::workflow::Workflow`]
//! implementation. This crate contains **only pure domain logic** — no I/O,
//! no EDIFACT parsing, no network calls.
//!
//! ## Key difference from supplier-switch processes
//!
//! | Aspect | GPKE / WiM / GeLi Gas | MABIS |
//! |---|---|---|
//! | Trigger | Single inbound EDIFACT | **Abrechnungssummenzeitreihe from BIKO** |
//! | Location scope | Single MeLo / MaLo | **Many MaLo streams per Bilanzkreis** |
//! | Message types | UTILMD + APERAK | **MSCONS Summenzeitreihen + Prüfmitteilung** |
//! | Counterparty | NB / LFA | **BIKO (Bilanzkoordinator)** |
//! | Response Frist | 24 h / 5 Wkt / 10 Wkt | **1 Werktag (Prüfmitteilung, BK6-24-174 §13.8)** |
//!
//! ## Multi-stream aggregation note
//!
//! In a full production implementation, the BIKO's Abrechnungssummenzeitreihe
//! already contains the pre-aggregated billing totals for the billing period.
//! No client-side aggregation is required before issuing `ReceiveSummenzeitreihe`.
//! Any per-MaLo MSCONS meter data streams are managed separately outside this
//! workflow (e.g., via `ProjectionRunner::run_all_streams` in a read-model).
//!
//! ## Command construction example
//!
//! ```rust,ignore
//! use mako_mabis::{MabisBillingWorkflow, BillingCommand, BillingVersion};
//! use mako_engine::types::{BikoId, BillingPeriod, BkvId, MessageRef, Pruefidentifikator};
//!
//! // Called from the EDIFACT adapter when an inbound MSCONS Summenzeitreihe
//! // from the BIKO is validated and decoded.
//! let cmd = BillingCommand::ReceiveSummenzeitreihe {
//! pid: Pruefidentifikator::new(13003).expect("13003 is valid"),
//! billing_period: BillingPeriod::new("2025-09"),
//! bkv_id: BkvId::new("4033872000022"),
//! biko_id: BikoId::new("10YDE-VE-TRANSMIX"),
//! version: BillingVersion::Vorlaeufig,
//! message_ref: MessageRef::new("MSCONS-BKA-2025-09-001"),
//! };
//! process.execute(cmd).await?;
//! ```
// German MaKo terms and BDEW acronyms produce many false positives
// process handle() functions are necessarily verbose
// sometimes intentional for process-family readability
// existing code style; rewrite in follow-up
pub use ;
pub use ;
// ── EngineModule ──────────────────────────────────────────────────────────────
/// Engine module for the MABIS process family.
///
/// Registers:
/// - PID 13003, 13010–13012 (MSCONS Summenzeitreihe — Bilanzkreisabrechnung Strom)
/// - PIDs 55065, 55069, 55070 (UTILMD Clearinglisten)
/// - PIDs 21000–21005 (IFTSTA MaBiS Statusmeldungen)
;