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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
//! `ProductOrder` — a request to provide, change or cease products.
use crate::core::macros::{tmf_entity, tmf_patch_body, tmf_struct};
use crate::core::{
Agreement, BillingAccount, ExternalIdentifier, Note, Payment, ProductOfferingQualification,
Quote, Ref, RelatedParty, Timestamp,
};
use serde::{Deserialize, Serialize};
use super::common::{OrderPrice, OrderRelationship, RelatedChannel};
use super::item::{ProductOrderItem, ProductOrderItemCreate, ProductOrderItemRef};
use super::state::{InitialProductOrderState, ProductOrderState};
tmf_struct! {
@name = "ProductOrder", @ref = "ProductOrderRef";
/// A request to provide, change or cease one or more products.
///
/// This is the **read model**. Use [`ProductOrderCreate`] for `POST` and
/// [`ProductOrderUpdate`] for `PATCH`.
pub struct ProductOrder {
/// Server-assigned identifier.
id: String,
/// Canonical URI of this order.
href: String,
/// Narrative description.
description: String,
/// Category the order falls under.
category: String,
/// Priority, conventionally `0` (highest) to `4`.
priority: String,
/// Current fulfilment state.
state: ProductOrderState,
/// When the order was created.
creation_date: Timestamp,
/// When fulfilment finished.
completion_date: Timestamp,
/// When the provider expects to finish.
expected_completion_date: Timestamp,
/// When the buyer asked for fulfilment to finish.
requested_completion_date: Timestamp,
/// When the buyer asked for fulfilment to start.
requested_start_date: Timestamp,
/// When the order was cancelled.
cancellation_date: Timestamp,
/// Why the order was cancelled.
cancellation_reason: String,
/// Where to send progress notifications.
notification_contact: String,
/// The state the buyer asked the order to start in.
requested_initial_state: InitialProductOrderState,
/// The lines making up the order.
product_order_item: Vec<ProductOrderItem>,
/// Roll-up totals across the order.
order_total_price: Vec<OrderPrice>,
/// The account the order is billed to.
billing_account: Ref<BillingAccount>,
/// Payments settling the order — TMF676.
payment: Vec<Ref<Payment>>,
/// The quote the order was raised from — TMF648.
quote: Vec<Ref<Quote>>,
/// Qualifications establishing the order is deliverable — TMF679.
product_offering_qualification: Vec<Ref<ProductOfferingQualification>>,
/// Agreements the order is placed under.
agreement: Vec<Ref<Agreement>>,
/// Channels the order came through.
channel: Vec<RelatedChannel>,
/// Parties involved: buyer, seller, contact.
related_party: Vec<RelatedParty>,
/// Links to other orders.
order_relationship: Vec<OrderRelationship>,
/// Notes attached to the order.
note: Vec<Note>,
/// Identifiers in external systems.
external_id: Vec<ExternalIdentifier>,
/// Errors raised during fulfilment.
product_order_error_message: Vec<OrderErrorMessage>,
/// Milestones reached during fulfilment.
product_order_milestone: Vec<OrderMilestone>,
/// Warnings that fulfilment may miss its dates.
product_order_jeopardy_alert: Vec<OrderJeopardyAlert>,
}
}
tmf_entity!(ProductOrder);
tmf_struct! {
@name = "ProductOrder";
/// Body of a `POST /productOrder` — the v5 `ProductOrder_FVO`.
///
/// This is the strictest create body in the crate, and deliberately so.
/// TMF622 removes every server-owned member from the create schema —
/// `state`, `creationDate`, `completionDate`, `expectedCompletionDate`,
/// `cancellationDate` and `cancellationReason` are all absent, so they
/// cannot be sent by accident — and requires `productOrderItem`.
///
/// ```
/// use rutmf::core::Ref;
/// use rutmf::order::{ProductOrderCreate, ProductOrderItemCreate};
/// use rutmf::product::ProductOffering;
///
/// let order = ProductOrderCreate::builder()
/// .product_order_item(vec![ProductOrderItemCreate::add(
/// "1",
/// Ref::<ProductOffering>::new("7655"),
/// )])
/// .description("Firewall for the Berlin office")
/// .build();
/// assert_eq!(order.product_order_item.len(), 1);
/// ```
pub struct ProductOrderCreate {
@required {
/// The lines making up the order. **Required on create.**
product_order_item: Vec<ProductOrderItemCreate>,
}
/// Client-supplied identifier, where the server permits one.
id: String,
/// Narrative description.
description: String,
/// Category the order falls under.
category: String,
/// Priority, conventionally `0` (highest) to `4`.
priority: String,
/// The state to submit the order in — only `draft` or `acknowledged`.
requested_initial_state: InitialProductOrderState,
/// When the buyer asks fulfilment to start.
requested_start_date: Timestamp,
/// When the buyer asks fulfilment to finish.
requested_completion_date: Timestamp,
/// Where to send progress notifications.
notification_contact: String,
/// Roll-up totals across the order.
order_total_price: Vec<OrderPrice>,
/// The account to bill.
billing_account: Ref<BillingAccount>,
/// Payments settling the order.
payment: Vec<Ref<Payment>>,
/// The quote the order was raised from.
quote: Vec<Ref<Quote>>,
/// Qualifications establishing the order is deliverable.
product_offering_qualification: Vec<Ref<ProductOfferingQualification>>,
/// Agreements the order is placed under.
agreement: Vec<Ref<Agreement>>,
/// Channels the order came through.
channel: Vec<RelatedChannel>,
/// Parties involved: buyer, seller, contact.
related_party: Vec<RelatedParty>,
/// Links to other orders.
order_relationship: Vec<OrderRelationship>,
/// Notes attached to the order.
note: Vec<Note>,
/// Identifiers in external systems.
external_id: Vec<ExternalIdentifier>,
/// Errors, where a server accepts them on create.
product_order_error_message: Vec<OrderErrorMessage>,
/// Milestones, where a server accepts them on create.
product_order_milestone: Vec<OrderMilestone>,
/// Jeopardy alerts, where a server accepts them on create.
product_order_jeopardy_alert: Vec<OrderJeopardyAlert>,
}
}
tmf_struct! {
@name = "ProductOrder";
/// Body of a `PATCH /productOrder/{id}` — the v5 `ProductOrder_MVO`.
///
/// `id`, `href`, `creationDate` and `requestedInitialState` are absent: the
/// first three are server-owned and the fourth only makes sense at creation.
pub struct ProductOrderUpdate {
/// New description.
description: String,
/// New category.
category: String,
/// New priority.
priority: String,
/// New state.
state: ProductOrderState,
/// New completion date.
completion_date: Timestamp,
/// New expected completion date.
expected_completion_date: Timestamp,
/// New requested start date.
requested_start_date: Timestamp,
/// New requested completion date.
requested_completion_date: Timestamp,
/// New cancellation date.
cancellation_date: Timestamp,
/// New cancellation reason.
cancellation_reason: String,
/// New notification contact.
notification_contact: String,
/// Replacement lines.
product_order_item: Vec<ProductOrderItem>,
/// Replacement order totals.
order_total_price: Vec<OrderPrice>,
/// Replacement billing account.
billing_account: Ref<BillingAccount>,
/// Replacement payments.
payment: Vec<Ref<Payment>>,
/// Replacement quotes.
quote: Vec<Ref<Quote>>,
/// Replacement qualifications.
product_offering_qualification: Vec<Ref<ProductOfferingQualification>>,
/// Replacement agreements.
agreement: Vec<Ref<Agreement>>,
/// Replacement channels.
channel: Vec<RelatedChannel>,
/// Replacement related parties.
related_party: Vec<RelatedParty>,
/// Replacement order relationships.
order_relationship: Vec<OrderRelationship>,
/// Replacement notes.
note: Vec<Note>,
/// Replacement external identifiers.
external_id: Vec<ExternalIdentifier>,
/// Replacement error messages.
product_order_error_message: Vec<OrderErrorMessage>,
/// Replacement milestones.
product_order_milestone: Vec<OrderMilestone>,
/// Replacement jeopardy alerts.
product_order_jeopardy_alert: Vec<OrderJeopardyAlert>,
}
}
tmf_struct! {
@name = "ProductOrderErrorMessage";
/// An error raised while fulfilling an order.
pub struct OrderErrorMessage {
/// Application-relevant error code.
code: String,
/// Explanation safe to show to a user.
reason: String,
/// Further detail and corrective actions.
message: String,
/// HTTP-style status, carried as a string.
status: String,
/// URI of documentation describing the error.
reference_error: String,
/// When the error was raised.
timestamp: Timestamp,
/// The order lines this error relates to.
product_order_item: Vec<ProductOrderItemRef>,
}
}
/// Whether a milestone has been met.
///
/// TMF622 writes these values with a leading capital and a hyphen — unlike
/// every other vocabulary in the API — so the wire names are spelled out rather
/// than derived.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum OrderMilestoneStatus {
/// Not yet met, and still within its window.
#[serde(rename = "Yet-To-Reach")]
YetToReach,
/// Met.
#[serde(rename = "Completed")]
Completed,
/// Missed.
#[serde(rename = "Violated")]
Violated,
/// A value outside the v5 enumeration, preserved verbatim.
#[serde(untagged)]
Other(String),
}
tmf_struct! {
@name = "ProductOrderMilestone";
/// A milestone reached while fulfilling an order.
pub struct OrderMilestone {
/// Identifier of the milestone.
id: String,
/// Name of the milestone.
name: String,
/// Narrative description.
description: String,
/// Status of the milestone.
status: OrderMilestoneStatus,
/// Free-text message.
message: String,
/// When the milestone was reached.
milestone_date: Timestamp,
/// The order lines this milestone relates to.
product_order_item: Vec<ProductOrderItemRef>,
}
}
tmf_struct! {
@name = "ProductOrderJeopardyAlert";
/// A warning that an order may miss its committed dates.
pub struct OrderJeopardyAlert {
/// Identifier of the alert.
id: String,
/// Name of the alert.
name: String,
/// Kind of jeopardy.
jeopardy_type: String,
/// The exception that triggered the alert.
exception: String,
/// Free-text message.
message: String,
/// When the alert was raised.
alert_date: Timestamp,
/// The order lines this alert relates to.
product_order_item: Vec<ProductOrderItemRef>,
}
}
tmf_patch_body!(ProductOrderUpdate);