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
//! [`billing::Tariff`] implementation bridge for EEG/KWKG settlement.
//!
//! [`EegSettleTariff`] wraps a pre-computed [`SettleOutput`] and exposes it
//! via the [`billing::Tariff`] trait, enabling EEG settlement results to be
//! used in `billing::BillingDocument` generation alongside other tariffs.
//!
//! ## Workflow
//!
//! 1. Call [`crate::calculate_settlement`] to compute the settlement output.
//! 2. Handle non-billable status variants (`NoData`, `PriceMissing`).
//! 3. Wrap the output in [`EegSettleTariff`].
//! 4. Call `.bill(meta, &())` to produce a `BillingDocument`.
//!
//! ## Tax layers
//!
//! `EegSettleTariff::tax_layers()` intentionally returns an **empty** list.
//! The VAT treatment for EEG feed-in depends on the operator's tax status:
//! - **Regelbesteuerung (19% MwSt)**: add `FixedRateTax::new("MwSt", dec!(0.19))`
//! - **Kleinunternehmer (§19 UStG)**: no VAT (common for residential rooftop PV)
//! - **§12 Abs. 3 UStG** (Photovoltaik ≤30 kWp after 01.01.2023): no VAT registration
//!
//! The caller adds the appropriate tax layer before calling `.bill()`.
//!
//! ## Example
//!
//! ```rust
//! use eeg_billing::{SettleInput, SettlementScheme, SettlementStatus, calculate_settlement};
//! use eeg_billing::tariff::EegSettleTariff;
//! use billing::{DocumentMeta, Period};
//! use rust_decimal_macros::dec;
//!
//! let output = calculate_settlement(&SettleInput {
//! scheme: eeg_billing::SettlementScheme::FeedInTariff { verguetungssatz_ct: dec!(8.11) },
//! einspeisemenge_kwh: Some(dec!(500)),
//! ..SettleInput::default()
//! });
//!
//! assert_eq!(output.status, SettlementStatus::Calculated);
//!
//! let tariff = EegSettleTariff::new(&output);
//! use billing::Tariff as _;
//! let doc = tariff.bill(
//! DocumentMeta {
//! invoice_number: "EEG-2026-07-001".into(),
//! period_label: "Juli 2026".into(),
//! period: Some(Period::from_display("2026-07-01", "2026-07-31")),
//! issuer_id: Some("9904234560001".into()), // NB MP-ID
//! issue_date: Some("2026-07-13".into()),
//! ..Default::default()
//! },
//! &(),
//! ).unwrap();
//!
//! assert_eq!(doc.net_total(), billing::Amount::parse("40.55000").unwrap());
//! ```
use ;
use crate;
// ── EegSettleTariff ──────────────────────────────────────────────────────────
/// [`billing::Tariff`] adapter for EEG/KWKG settlement results.
///
/// Wraps a pre-computed [`SettleOutput`] and exposes it through the `Tariff` trait
/// so EEG settlement can be composed with other billing positions and documents.
///
/// See [module-level docs](crate::tariff) for usage and VAT guidance.
// ── EegSettleTariffRegelbesteuerung ──────────────────────────────────────────
/// Convenience wrapper that includes 19 % Umsatzsteuer (Regelbesteuerung).
///
/// Correct for:
/// - Commercial operators (Gewerbetreibende)
/// - Operators who opted into Regelbesteuerung
/// - Plants > 30 kWp or commissioned before 01.01.2023
///
/// NOT for Kleinunternehmer (§19 UStG) or §12 Abs. 3 exempt plants (PV ≤30 kWp, post-2023).
/// Use [`EegSettleTariff12Abs3`] or [`EegSettleTariff`] for those.
///
/// # Deprecated name
///
/// Previously called `EegSettleTariffMitMwSt` — renamed to use the legal term
/// "Umsatzsteuer" and the correct tax-status name.
pub type EegSettleTariffMitMwSt<'a> = ;
/// See [`EegSettleTariffMitMwSt`] (now an alias for `EegSettleTariffRegelbesteuerung`).
// ── Status check helpers ──────────────────────────────────────────────────────
/// Convenience alias: `EegSettleTariff` for plants exempt under **§12 Abs. 3 UStG**
/// (Solar PV ≤ 30 kWp, commissioned after 01.01.2023).
///
/// Produces the same document as `EegSettleTariff` (empty tax layers),
/// but the name makes the VAT reasoning explicit in calling code.
pub type EegSettleTariff12Abs3<'a> = ;
/// Convenience alias: `EegSettleTariff` for Kleinunternehmer operators (§19 UStG).
pub type EegSettleTariffKleinunternehmer<'a> = ;
/// Return `true` when the settlement output can be turned into a billing document.
///
/// `NoData` and `PriceMissing` produce empty documents (no positions to bill);
/// `Sanctioned` produces a EUR 0 audit line via `settlement_to_line_items()`.
/// `FoerderungBeendet` produces an empty document.
/// `Calculated` produces the normal positions.