Skip to main content

spri/model/
order.rs

1//! Orders (`auftrag`): the header and the eight business cases.
2//!
3//! Source: XSD 4.00.03 `oss-order.xsd` (`AuftragType` and the extensions of
4//! `GeschaeftsfallType`), `oss-product-FTTx.xsd` (the FTTx products) and `oss-type-complex.xsd`.
5
6use jiff::civil::Date;
7
8use super::{
9    Anlage, Ansprechpartner, AnsprechpartnerMitRolle, Auftraggeber, Kenner, Person, StandortA, StandortVersand,
10    Wunschtermin,
11};
12use crate::{
13    Abfragestelle, Aenderungskennzeichen, Aktionscode, Anrede, Diagnosename, Durchwahlnummer, Emailadresse,
14    ExterneAuftragsnummer, Freitext, GeschaeftsfallArt, GeschaeftsfallCode, HomeId, LineId, Montagehinweis, Nachname,
15    Onkz, Portierungskenner, Produktbezeichner, Rufnummer, RufnummernBlock, SeriennummerOnt, StoerungsNr, Technologie,
16    Telefonnummer, Vertragsnummer, VorabstimmungsId, Vorname, WitaVertragsnummer,
17};
18
19/// An order (`AuftragType`), sent by the service provider (Auftraggeber) to the network owner
20/// (Leistungserbringer) in `annehmenAuftragRequest`.
21#[derive(Debug, Clone, PartialEq, Eq)]
22pub struct Auftrag {
23    /// `externeAuftragsnummer`: the service provider's order number. A cancellation or
24    /// postponement repeats it (S/PRI 4.4 §5.1.3, §5.1.4).
25    pub externe_auftragsnummer: ExterneAuftragsnummer,
26    /// `auftraggeber`.
27    pub auftraggeber: Auftraggeber,
28    /// `besteller`: who orders on behalf of the Auftraggeber, if not the Auftraggeber itself.
29    pub besteller: Option<Auftraggeber>,
30    /// `geschaeftsfall`: the business case and its data.
31    pub geschaeftsfall: Geschaeftsfall,
32    /// `geschaeftsfallArt`.
33    pub geschaeftsfall_art: GeschaeftsfallArt,
34    /// `aenderungskennzeichen`: standard order, cancellation or postponement.
35    pub aenderungskennzeichen: Aenderungskennzeichen,
36    /// `terminNeu`.
37    pub termin_neu: Option<Date>,
38    /// `kenner`: project and order grouping.
39    pub kenner: Option<Kenner>,
40}
41
42/// The business case of an order: the concrete type of the abstract `GeschaeftsfallType`,
43/// written as `xsi:type`.
44#[derive(Debug, Clone, PartialEq, Eq)]
45#[allow(clippy::large_enum_variant)]
46pub enum Geschaeftsfall {
47    /// `NEU` — `BereitstellungType`: a new line.
48    Neu(Bereitstellung),
49    /// `KUE-AG` — `KuendigungType`: the service provider cancels a line.
50    KueAg(Kuendigung),
51    /// `LAE` — `LeistungsaenderungType`: change of the service (product).
52    Lae(Leistungsaenderung),
53    /// `AEN-LMAE` — `LeistungsmerkmalAenderungType`: change of features.
54    AenLmae(LeistungsmerkmalAenderung),
55    /// `EST` — `EntstoerungType`: a fault report.
56    Est(Entstoerung),
57    /// `PV` — `ProviderwechselType`: take over a line from another service provider, after a
58    /// WBCI pre-agreement.
59    Pv(Providerwechsel),
60    /// `GET` — `DiagnoseGetType`: read diagnostic values.
61    Get(Diagnose),
62    /// `SET` — `DiagnoseSetType`: trigger diagnostic operations.
63    Set(Diagnose),
64}
65
66impl Geschaeftsfall {
67    /// The business case code, e.g. `PV`.
68    #[must_use]
69    pub const fn code(&self) -> GeschaeftsfallCode {
70        match self {
71            Self::Neu(_) => GeschaeftsfallCode::Neu,
72            Self::KueAg(_) => GeschaeftsfallCode::KueAg,
73            Self::Lae(_) => GeschaeftsfallCode::Lae,
74            Self::AenLmae(_) => GeschaeftsfallCode::AenLmae,
75            Self::Est(_) => GeschaeftsfallCode::Est,
76            Self::Pv(_) => GeschaeftsfallCode::Pv,
77            Self::Get(_) => GeschaeftsfallCode::Get,
78            Self::Set(_) => GeschaeftsfallCode::Set,
79        }
80    }
81
82    /// The WBCI Vorabstimmungs-ID the order carries: always in `PV`, optional in `NEU` and
83    /// `KUE-AG`, none in the other cases (S/PRI 4.4 §5.5.1.1).
84    #[must_use]
85    pub const fn vorabstimmungs_id(&self) -> Option<&VorabstimmungsId> {
86        match self {
87            Self::Neu(n) => n.vorabstimmungs_id.as_ref(),
88            Self::KueAg(k) => k.vorabstimmungs_id.as_ref(),
89            Self::Pv(p) => Some(&p.vorabstimmungs_id),
90            Self::Lae(_) | Self::AenLmae(_) | Self::Est(_) | Self::Get(_) | Self::Set(_) => None,
91        }
92    }
93
94    /// The line the order is about, if the business case names one (all but `NEU`).
95    #[must_use]
96    pub const fn line_id(&self) -> Option<&LineId> {
97        match self {
98            Self::Neu(_) => None,
99            Self::KueAg(k) => Some(&k.line_id),
100            Self::Lae(l) => Some(&l.line_id),
101            Self::AenLmae(l) => Some(&l.line_id),
102            Self::Est(e) => Some(&e.line_id),
103            Self::Pv(p) => Some(&p.line_id),
104            Self::Get(d) | Self::Set(d) => Some(&d.line_id),
105        }
106    }
107}
108
109/// The order's contact persons (`order:AnsprechpartnerType`).
110#[derive(Debug, Clone, PartialEq, Eq, Hash)]
111pub struct AnsprechpartnerAuftrag {
112    /// `auftragsmanagement`: the service provider's order management.
113    pub auftragsmanagement: Ansprechpartner,
114    /// `ansprechpartner`: further contacts with their role.
115    pub weitere: Vec<AnsprechpartnerMitRolle>,
116}
117
118/// A product from the product catalogue (`produkt`, FTTx: `ProduktFTTXType`).
119#[derive(Debug, Clone, PartialEq, Eq, Hash)]
120pub struct Produkt {
121    /// `bezeichner`.
122    pub bezeichner: Produktbezeichner,
123}
124
125impl From<Produktbezeichner> for Produkt {
126    fn from(bezeichner: Produktbezeichner) -> Self {
127        Self { bezeichner }
128    }
129}
130
131/// A change position (`AenderungPositionType`): a product added, changed or removed.
132#[derive(Debug, Clone, PartialEq, Eq, Hash)]
133pub struct AenderungPosition {
134    /// `produkt`.
135    pub produkt: Produkt,
136    /// `aktionscode`.
137    pub aktionscode: Aktionscode,
138}
139
140/// `NEU` (`BereitstellungType`) with the FTTx product.
141#[derive(Debug, Clone, PartialEq, Eq)]
142pub struct Bereitstellung {
143    /// `vorabstimmungId`: the WBCI pre-agreement, when a provisioning replaces another
144    /// provider's line (S/PRI 4.4 §5.1.4).
145    pub vorabstimmungs_id: Option<VorabstimmungsId>,
146    /// `anlage`.
147    pub anlage: Option<Anlage>,
148    /// `ansprechpartner`.
149    pub ansprechpartner: AnsprechpartnerAuftrag,
150    /// `termine/auftraggeberWunschtermin`.
151    pub wunschtermin: Wunschtermin,
152    /// `auftragsposition/produkt`.
153    pub produkt: Produkt,
154    /// `auftragsposition/geschaeftsfallProdukt` (`FTTXBereitstellungType`).
155    pub fttx: FttxBereitstellung,
156    /// `auftragsposition/position/produkt`: further products.
157    pub positionen: Vec<Produkt>,
158}
159
160/// The FTTx data of a provisioning (`FTTXBereitstellungType`).
161#[derive(Debug, Clone, PartialEq, Eq)]
162pub struct FttxBereitstellung {
163    /// `standortA`: where the line goes.
164    pub standort_a: StandortA,
165    /// `standortVersand`: where hardware is shipped.
166    pub standort_versand: Option<StandortVersand>,
167    /// `vormieter`: the previous tenant, to find the line.
168    pub vormieter: Option<Vormieter>,
169    /// `montageleistung`: installation at the customer.
170    pub montageleistung: Option<Montageleistung>,
171    /// `WitaExtendedInfosGroup`.
172    pub wita: WitaExtendedInfos,
173}
174
175/// The previous tenant (`FTTxVormieterType`).
176#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
177pub struct Vormieter {
178    /// `person`.
179    pub person: Option<VormieterPerson>,
180    /// `homeId/homeIdNummer`.
181    pub home_id: Option<HomeId>,
182    /// `seriennummerONT`.
183    pub seriennummer_ont: Option<SeriennummerOnt>,
184}
185
186/// The previous tenant's name.
187#[derive(Debug, Clone, PartialEq, Eq, Hash)]
188pub struct VormieterPerson {
189    /// `vorname`.
190    pub vorname: Option<Vorname>,
191    /// `nachname`.
192    pub nachname: Nachname,
193}
194
195/// Installation at the customer (`MontageleistungType`).
196#[derive(Debug, Clone, PartialEq, Eq, Hash)]
197pub struct Montageleistung {
198    /// `ansprechpartner`: who lets the installer in.
199    pub ansprechpartner: Ansprechpartner,
200    /// `montagehinweis`.
201    pub montagehinweis: Option<Montagehinweis>,
202}
203
204/// WITA references (`WitaInfosGroup`).
205#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
206pub struct WitaInfos {
207    /// `witaVertragsnummer`.
208    pub wita_vertragsnummer: Option<WitaVertragsnummer>,
209    /// `technologie`.
210    pub technologie: Option<Technologie>,
211}
212
213/// WITA references, line search and number porting (`WitaExtendedInfosGroup`).
214#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
215pub struct WitaExtendedInfos {
216    /// `witaVertragsnummer`, `technologie`.
217    pub wita: WitaInfos,
218    /// `bestandssuche`: find the existing line by its number.
219    pub bestandssuche: Option<OnkzRufnummer>,
220    /// `rufnummernPortierung`.
221    pub rufnummern_portierung: Option<RufnummernPortierung>,
222    /// `abgebenderEKP`.
223    pub abgebender_ekp: Option<bool>,
224}
225
226/// An area code and a number (`onkz`, `rufnummer`).
227#[derive(Debug, Clone, PartialEq, Eq, Hash)]
228pub struct OnkzRufnummer {
229    /// `onkz`.
230    pub onkz: Onkz,
231    /// `rufnummer`.
232    pub rufnummer: Rufnummer,
233}
234
235/// A block of PBX numbers (`zuPortierenderRufnummernblock`).
236#[derive(Debug, Clone, PartialEq, Eq, Hash)]
237pub struct Rufnummernblock {
238    /// `rnrBlockVon`.
239    pub von: RufnummernBlock,
240    /// `rnrBlockBis`.
241    pub bis: RufnummernBlock,
242}
243
244/// The numbers to port (`rufnummernPortierung`).
245#[derive(Debug, Clone, PartialEq, Eq, Hash)]
246pub struct RufnummernPortierung {
247    /// `anlagenanschluss` or `einzelanschluss`.
248    pub anschluss: PortierungAnschluss,
249    /// `portierungskenner`.
250    pub portierungskenner: Portierungskenner,
251}
252
253/// The numbers of a PBX or a single line.
254#[derive(Debug, Clone, PartialEq, Eq, Hash)]
255pub enum PortierungAnschluss {
256    /// `anlagenanschluss`: a PBX line.
257    Anlage {
258        /// `onkzDurchwahlAbfragestelle/onkz`.
259        onkz: Onkz,
260        /// `onkzDurchwahlAbfragestelle/durchwahlnummer`.
261        durchwahlnummer: Durchwahlnummer,
262        /// `onkzDurchwahlAbfragestelle/abfragestelle`.
263        abfragestelle: Abfragestelle,
264        /// `zuPortierenderRufnummernblock`: 1 to 5.
265        bloecke: Vec<Rufnummernblock>,
266    },
267    /// `einzelanschluss/rufnummernliste`: 1 to 10 numbers.
268    Rufnummern(Vec<OnkzRufnummer>),
269    /// `einzelanschluss/alleRufnummern` (`J`): all numbers of the line.
270    AlleRufnummern,
271}
272
273/// `KUE-AG` (`KuendigungType`).
274#[derive(Debug, Clone, PartialEq, Eq)]
275pub struct Kuendigung {
276    /// `vertragsnummer`.
277    pub vertragsnummer: Vertragsnummer,
278    /// `lineId`.
279    pub line_id: LineId,
280    /// `vorabstimmungId`.
281    pub vorabstimmungs_id: Option<VorabstimmungsId>,
282    /// `anlage`.
283    pub anlage: Option<Anlage>,
284    /// `ansprechpartner`.
285    pub ansprechpartner: AnsprechpartnerAuftrag,
286    /// `termine/auftraggeberWunschtermin`.
287    pub wunschtermin: Wunschtermin,
288    /// `auftragsposition/geschaeftsfallProdukt` (`FTTXKuendigungType`): WITA references.
289    pub fttx: Option<WitaInfos>,
290}
291
292/// `LAE` (`LeistungsaenderungType`).
293#[derive(Debug, Clone, PartialEq, Eq)]
294pub struct Leistungsaenderung {
295    /// `vertragsnummer`.
296    pub vertragsnummer: Vertragsnummer,
297    /// `lineId`.
298    pub line_id: LineId,
299    /// `anlage`.
300    pub anlage: Option<Anlage>,
301    /// `ansprechpartner`.
302    pub ansprechpartner: AnsprechpartnerAuftrag,
303    /// `termine/auftraggeberWunschtermin`.
304    pub wunschtermin: Wunschtermin,
305    /// `auftragsposition/produkt`: the new product.
306    pub produkt: Produkt,
307    /// `auftragsposition/position`: changed positions (any number).
308    pub positionen: Vec<AenderungPosition>,
309}
310
311/// `AEN-LMAE` (`LeistungsmerkmalAenderungType`).
312#[derive(Debug, Clone, PartialEq, Eq)]
313pub struct LeistungsmerkmalAenderung {
314    /// `vertragsnummer`.
315    pub vertragsnummer: Vertragsnummer,
316    /// `lineId`.
317    pub line_id: LineId,
318    /// `anlage`.
319    pub anlage: Option<Anlage>,
320    /// `ansprechpartner`.
321    pub ansprechpartner: AnsprechpartnerAuftrag,
322    /// `termine/auftraggeberWunschtermin`.
323    pub wunschtermin: Wunschtermin,
324    /// `auftragsposition/produkt`.
325    pub produkt: Produkt,
326    /// `auftragsposition/position`: the changed features, at least one.
327    pub positionen: Vec<AenderungPosition>,
328}
329
330/// `EST` (`EntstoerungType`).
331#[derive(Debug, Clone, PartialEq, Eq)]
332pub struct Entstoerung {
333    /// `vertragsnummer`.
334    pub vertragsnummer: Vertragsnummer,
335    /// `lineId`.
336    pub line_id: LineId,
337    /// `anlage`.
338    pub anlage: Option<Anlage>,
339    /// `ansprechpartner`.
340    pub ansprechpartner: AnsprechpartnerAuftrag,
341    /// `kontaktEndkunde`.
342    pub kontakt_endkunde: KontaktEndkunde,
343    /// `termine/auftraggeberWunschtermin`.
344    pub wunschtermin: Wunschtermin,
345    /// `stoerungsNrAuftraggeber`: the service provider's ticket.
346    pub stoerungs_nr_auftraggeber: StoerungsNr,
347    /// `reklamation`: a complaint about an earlier repair.
348    pub reklamation: Option<Reklamation>,
349    /// `vorpruefungErfolgt`: the service provider checked the line first.
350    pub vorpruefung_erfolgt: bool,
351    /// `stoerungsbeschreibung`.
352    pub stoerungsbeschreibung: Freitext,
353    /// `expressentstoerung`.
354    pub expressentstoerung: Option<bool>,
355}
356
357/// The end customer to contact for a repair (`AnsprechpartnerESTType`).
358#[derive(Debug, Clone, PartialEq, Eq, Hash)]
359pub struct KontaktEndkunde {
360    /// `anrede`.
361    pub anrede: Anrede,
362    /// `vorname`.
363    pub vorname: Vorname,
364    /// `nachname`.
365    pub nachname: Nachname,
366    /// `telefonnummer`.
367    pub telefonnummer: Option<Telefonnummer>,
368    /// `mobilfunknummer`.
369    pub mobilfunknummer: Option<Telefonnummer>,
370    /// `faxnummer`.
371    pub faxnummer: Option<Telefonnummer>,
372    /// `emailadresse`.
373    pub emailadresse: Option<Emailadresse>,
374    /// `kontaktaufnahmeErwuenscht`.
375    pub kontaktaufnahme_erwuenscht: bool,
376}
377
378impl KontaktEndkunde {
379    /// The contact as a [`Person`].
380    #[must_use]
381    pub fn person(&self) -> Person {
382        Person { anrede: self.anrede, vorname: Some(self.vorname.clone()), nachname: self.nachname.clone() }
383    }
384}
385
386/// A complaint about an earlier repair (`EntstoerungsReklamationType`).
387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
388pub struct Reklamation {
389    /// `stoerungsNrLeistungserbringer`.
390    pub stoerungs_nr_leistungserbringer: StoerungsNr,
391    /// `reklamationsgrund`.
392    pub reklamationsgrund: Freitext,
393}
394
395/// `PV` (`ProviderwechselType`): take over a line after a WBCI pre-agreement.
396#[derive(Debug, Clone, PartialEq, Eq)]
397pub struct Providerwechsel {
398    /// `lineId`: the line to take over.
399    pub line_id: LineId,
400    /// `vorabstimmungId`: the WBCI pre-agreement — the same type as `wbci::VorabstimmungsId`.
401    pub vorabstimmungs_id: VorabstimmungsId,
402    /// `anlage`.
403    pub anlage: Option<Anlage>,
404    /// `ansprechpartner`.
405    pub ansprechpartner: AnsprechpartnerAuftrag,
406    /// `termine/auftraggeberWunschtermin`.
407    pub wunschtermin: Wunschtermin,
408    /// `auftragsposition/produkt`.
409    pub produkt: Produkt,
410    /// `auftragsposition/geschaeftsfallProdukt` (`FTTXProviderwechselType`).
411    pub fttx: FttxProviderwechsel,
412    /// `auftragsposition/position/produkt`: further products.
413    pub positionen: Vec<Produkt>,
414}
415
416/// The FTTx data of a provider switch (`FTTXProviderwechselType`).
417#[derive(Debug, Clone, PartialEq, Eq)]
418pub struct FttxProviderwechsel {
419    /// `standortA`.
420    pub standort_a: StandortA,
421    /// `montageleistung`.
422    pub montageleistung: Option<Montageleistung>,
423}
424
425/// `GET` and `SET` (`DiagnoseGetType`, `DiagnoseSetType`).
426#[derive(Debug, Clone, PartialEq, Eq, Hash)]
427pub struct Diagnose {
428    /// `vertragsnummer`.
429    pub vertragsnummer: Vertragsnummer,
430    /// `lineId`.
431    pub line_id: LineId,
432    /// `auftragsposition/parameter/operation`: the diagnostic operations, at least one.
433    pub operationen: Vec<Diagnosename>,
434}