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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
//! WiM Rechnung — the INVOIC billing processes of WiM Strom and WiM Gas.
//!
//! The process lives in [`mako_invoic`]; this module declares the WiM family
//! and the one thing that is genuinely WiM's own — which
//! Ablehnungs-Entscheidungsbaum a Gas refusal is answered from.
//!
//! The workflow hosts **both** sides of each exchange, and the deployment's
//! Marktrolle selects which commands it issues:
//!
//! - **MSB (invoicer):** `SendInvoic` records the outbound invoice, then awaits
//! the payer's REMADV (33001–33004) and may refuse it with a COMDIS.
//! - **Payer:** `ReceiveInvoic` ingests it, then `SettleInvoice` /
//! `DisputeInvoice` returns the REMADV.
//!
//! **31009 belongs exclusively to the WiM domain** and must not be registered
//! by `mako-gpke` — see `GPKE_INVOIC_PIDS` there for the explicit exclusion.
//!
//! # Answer windows
//!
//! Every WiM invoice is answered against the **Zahlungsziel it carries**
//! (`SG8 DTM+265`), never a flat Werktage count from arrival. Where the answer
//! sits relative to that date depends on who pays:
//!
//! | Rechnung | Zahler | Spätester ÜT der Antwort | Fundstelle |
//! |---|---|---|---|
//! | MSB-Rechnung 31009 | NB | **4. WT vor** dem Zahlungsziel | WiM Teil 1 Kap. 6.2 Nr. 2 |
//! | MSB-Rechnung 31009 | LF · ESA | zum Zahlungsziel | Kap. 3.6.3.8.2 Nr. 2/4 |
//! | WiM-Rechnung 31003 | NB · MSBN | zum Zahlungsziel | Kap. 3.7.2 Nr. 2/4 |
//!
//! The MSB's Mitteilung that a refused invoice was correct after all (COMDIS
//! 29001) is due by the **2. WT vor** dem Zahlungsziel (Kap. 6.2 Nr. 3), and
//! the Zahlungsziel itself may not fall short of 10 Werktage after receipt.
//! [`mako_fristen::vorlauf`] holds all four as one table; `makod` registers the
//! process deadline from it.
//!
//! # Regulatory basis
//!
//! - **BNetzA BK6-24-174 Anlage 2a** — WiM Strom Teil 1, Kap. 3.6.3.8 / 3.7 / 6
//! - **AWH WiM Gas 2.0** — Kap. 4.7 (Abrechnung von Dienstleistungen)
//! - **INVOIC AHB 1.0b** — EDI@Energy invoice message format
use Pruefidentifikator;
use ;
// ── PID set ───────────────────────────────────────────────────────────────────
/// WiM billing Prüfidentifikatoren (INVOIC AHB 1.0b), in **both Sparten**.
///
/// | PID | Name | Empfänger | Sparte | Fundstelle |
/// |---|---|---|---|---|
/// | 31009 | MSB-Rechnung | NB · LF · ESA | Strom | GPKE Teil 3, WiM Strom Teil 1/2, AWH Änd. Technik |
/// | 31003 | WiM-Rechnung (Abrechnung von Dienstleistungen im Messwesen) | NB · MSBN | **beide** | WiM Strom Teil 1 Kap. 3.7, AWH WiM Gas 2.0 Kap. 4.7 |
/// | 31004 | Stornorechnung | wie die Ursprungsrechnung | **neutral** | INVOIC AHB §3.1.2 |
///
/// **31003 is not the Gas twin of 31009.** They are different Abrechnungen:
/// 31009 bills the *Messstellenbetrieb* to the NB, LF or ESA and exists only in
/// Strom; 31003 bills the *Dienstleistungen* between the abgebender and the
/// aufnehmender MSB — the temporäre Fortführung, the Geräteübernahme and a
/// Zwischen- oder Kontrollablesung — and exists in both Sparten.
///
/// The Gas Ablehnung splits by **who refuses whose invoice**, not by PID
/// (EBD 4.3 Kap. 14.7) — [`gas_ablehnungs_ebd`] resolves it.
pub const WIM_INVOIC_PIDS: & = &;
/// REMADV PIDs answering a WiM invoice.
///
/// The shared [`mako_invoic::REMADV_PIDS`] set. Settlement is „ganz oder gar
/// nicht" (no Teilzahlung), so 33002/33003/33004 are all Abweisungen and only
/// 33001 confirms.
///
/// 33003/33004 are **Strom-only**: the Gas WiM-Rechnung 31003 is rejected with
/// 33002 alone (REMADV AHB 1.0a; PID-Übersicht 4.0 rows 39780–39910). Inbound
/// REMADV routing is by correlation (RFF+Z13 → the original message reference),
/// so this set governs which PIDs the workflow *accepts*, not routing.
pub const WIM_REMADV_PIDS: & = REMADV_PIDS;
/// COMDIS PID for inbound Ablehnung REMADV in WiM (payer role).
pub const WIM_COMDIS_ABLEHNUNG_PID: Pruefidentifikator = COMDIS_ABLEHNUNG_PID;
/// Workflow key for WiM billing processes.
pub const WORKFLOW_NAME: &str = "wim-invoic";
/// Deadline label for the INVOIC settlement response window.
///
/// The window itself is
/// [`mako_fristen::vorlauf::rechnung_antwort_spaetester_uet`] — it is anchored
/// on the Zahlungsziel the invoice carries and on the payer's Marktrolle, so
/// the workflow labels the deadline and `makod` dates it.
pub const SETTLEMENT_WINDOW_LABEL: &str = "wim-invoic-settlement-deadline";
// ── The family ────────────────────────────────────────────────────────────────
/// The WiM billing family.
;
/// The WiM billing workflow (PIDs 31009, 31003, 31004).
pub type WimInvoicWorkflow = ;
// ── Gas Ablehnung ─────────────────────────────────────────────────────────────
/// Who refused the Gas invoice, and what it invoiced — the pair that picks the
/// Ablehnungs-Entscheidungsbaum.
/// The Gas Ablehnungs-Entscheidungsbaum for a refusal.
///
/// EBD 4.3 Kap. 14.7 splits one INVOIC family across five trees, and the PID is
/// not what tells them apart: `E_2014`/`E_2016` are the NB's, `E_2015` the
/// MSBN's, and the two Storno trees repeat that split. `E_2017`
/// („Nichtzahlungsavis prüfen") has no tree, „da keine Antwort gegeben wird",
/// so a Zahlungsavis carries no `AJT`.
pub const