Repository navigation
Expand file tree
/
Copy pathtravel-service.cds
More file actions
58 lines (51 loc) · 2.26 KB
/
Copy pathtravel-service.cds
File metadata and controls
58 lines (51 loc) · 2.26 KB
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
using { sap, sap.capire.travels as db, sap.capire.xflights } from '../db/schema';
@agent @odata @path: 'travel' service TravelService {
entity Travels as projection on db.Travels actions {
action acceptTravel();
action rejectTravel();
action reopenTravel();
action deductDiscount( percent: Percentage not null ) returns Travels;
}
@description: 'Create a new travel. Returns the assigned ID of the travel.'
action createTravel(
@description: 'Description'
Description: Travels:Description not null,
@description: 'Begin date in YYYY-MM-DD format'
BeginDate: Date not null,
@description: 'End date in YYYY-MM-DD format'
EndDate: Date not null,
@description: 'Currency code (default: EUR). Query Currencies to find valid currency codes.'
currencyCode: Travels:Currency.code,
@description: 'Booking fee amount (default: 0)'
BookingFee: db.Price) returns Travels:ID;
@description: ```
Update the header data of an existing travel: description, begin date, end date.
Only the fields you provide are updated.
```
action updateTravel(
@description: 'The integer ID of the travel'
TravelID: Travels:ID not null,
@description: 'New description'
Description: Travels:Description,
@description: 'New begin date in YYYY-MM-DD format'
BeginDate: Date,
@description: 'New end date in YYYY-MM-DD format'
EndDate: Date);
@description: ```
Add a flight booking to an existing travel. Before calling this query Flights to
find a valid flight and obtain its ID and date. The FlightID is a string like
'LH0400', the FlightDate is the flight's departure date in YYYY-MM-DD format.
```
action addFlightToTravel(
@description: 'The integer ID of the travel'
TravelID: Travels:ID not null,
@description: 'The flight ID (e.g. ''LH0400'')'
FlightID: Flights:ID not null,
@description: 'The flight date in YYYY-MM-DD format'
FlightDate: Flights:date not null);
// Also expose Flights and Currencies for travel booking UIs and Value Helps
@readonly entity Flights as projection on xflights.Flights;
@readonly entity Supplements as projection on xflights.Supplements;
@readonly entity Currencies as projection on sap.common.Currencies;
}
type Percentage : Integer @assert.range: [1,100];