From 9a0959c197f299960c8c34819afe5ed2ba8bfa8e Mon Sep 17 00:00:00 2001 From: Matthias Schur <107557548+MattSchur@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:34:20 +0200 Subject: [PATCH] Remove "to_" prefix from associations --- app/labels.cds | 16 ++--- app/travel_analytics/annotations.cds | 20 +++--- app/travel_processor/field-control.cds | 36 +++++----- app/travel_processor/layouts.cds | 30 ++++---- app/travel_processor/webapp/manifest.json | 6 +- .../webapp/test/integration/OpaJourney.js | 22 +++--- app/value-helps.cds | 24 +++---- db/data/sap.fe.cap.travel-Booking.csv | 2 +- .../sap.fe.cap.travel-BookingSupplement.csv | 2 +- db/data/sap.fe.cap.travel-Travel.csv | 2 +- db/schema.cds | 26 +++---- srv/analytics-service.cds | 30 ++++---- .../sflight/processor/CreationHandler.java | 16 ++--- .../processor/RecalculatePriceHandler.java | 8 +-- srv/travel-service.js | 68 +++++++++---------- test/odata.test.js | 16 ++--- 16 files changed, 162 insertions(+), 162 deletions(-) diff --git a/app/labels.cds b/app/labels.cds index 887e94d2..e86e34ca 100644 --- a/app/labels.cds +++ b/app/labels.cds @@ -13,8 +13,8 @@ annotate schema.Travel with @title: '{i18n>Travel}' { BookingFee @title: '{i18n>BookingFee}' @Measures.ISOCurrency: CurrencyCode_code; TotalPrice @title: '{i18n>TotalPrice}' @Measures.ISOCurrency: CurrencyCode_code; TravelStatus @title: '{i18n>TravelStatus}' @Common.Text: TravelStatus.name @Common.TextArrangement: #TextOnly; - to_Customer @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; - to_Agency @title: '{i18n>AgencyID}' @Common.Text: to_Agency.Name; + Customer @title: '{i18n>CustomerID}' @Common.Text: Customer.LastName; + Agency @title: '{i18n>AgencyID}' @Common.Text: Agency.Name; } annotate schema.TravelStatus with { @@ -23,7 +23,7 @@ annotate schema.TravelStatus with { annotate schema.Booking with @title: '{i18n>Booking}' { BookingUUID @UI.Hidden; - to_Travel @UI.Hidden; + Travel @UI.Hidden; BookingID @title: '{i18n>BookingID}'; BookingDate @title: '{i18n>BookingDate}'; ConnectionID @title: '{i18n>ConnectionID}'; @@ -31,8 +31,8 @@ annotate schema.Booking with @title: '{i18n>Booking}' { FlightDate @title: '{i18n>FlightDate}'; FlightPrice @title: '{i18n>FlightPrice}' @Measures.ISOCurrency: CurrencyCode_code; BookingStatus @title: '{i18n>BookingStatus}' @Common.Text: BookingStatus.name @Common.TextArrangement: #TextOnly; - to_Carrier @title: '{i18n>AirlineID}' @Common.Text: to_Carrier.Name; - to_Customer @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; + Carrier @title: '{i18n>AirlineID}' @Common.Text: Carrier.Name; + Customer @title: '{i18n>CustomerID}' @Common.Text: Customer.LastName; } annotate schema.BookingStatus with { @@ -41,9 +41,9 @@ annotate schema.BookingStatus with { annotate schema.BookingSupplement with @title: '{i18n>BookingSupplement}' { BookSupplUUID @UI.Hidden; - to_Booking @UI.Hidden; - to_Travel @UI.Hidden; - to_Supplement @title: '{i18n>SupplementID}' @Common.Text: to_Supplement.Description; + Booking @UI.Hidden; + Travel @UI.Hidden; + Supplement @title: '{i18n>SupplementID}' @Common.Text: Supplement.Description; Price @title: '{i18n>Price}' @Measures.ISOCurrency: CurrencyCode_code; BookingSupplementID @title: '{i18n>BookingSupplementID}'; CurrencyCode @title: '{i18n>CurrencyCode}'; diff --git a/app/travel_analytics/annotations.cds b/app/travel_analytics/annotations.cds index 496109d3..ec6a7e2e 100644 --- a/app/travel_analytics/annotations.cds +++ b/app/travel_analytics/annotations.cds @@ -349,12 +349,12 @@ annotate service.Bookings with @UI : { }] }], FieldGroup #TravelInformation : { Data : [ - { Value : to_Travel.TravelID, + { Value : Travel.TravelID, Label : '{i18n>TravelID}' }, - { Value : to_Travel.Description }, - { Value : to_Travel.to_Agency.Name, }, - { Value : to_Travel.CustomerName, }, - { Value : to_Travel.TravelStatus.code, + { Value : Travel.Description }, + { Value : Travel.Agency.Name, }, + { Value : Travel.CustomerName, }, + { Value : Travel.TravelStatus.code, Label : '{i18n>Status}' }, // why does the label not come from below? ]}, FieldGroup #BookingInformation : { Data : [ @@ -368,15 +368,15 @@ annotate service.Bookings with @UI : { ]}, FieldGroup #FlightInformation : { Data : [ { Value : airline, }, - { Value : to_Carrier.AirlinePicURL, }, + { Value : Carrier.AirlinePicURL, }, { Value : ConnectionID }, // Java doesn't work with these association paths - // { Value : to_Flight.PlaneType }, - // { Value : to_Flight.to_Connection.DepartureAirport.AirportID, + // { Value : Flight.PlaneType }, + // { Value : Flight.to_Connection.DepartureAirport.AirportID, // Label: '{i18n>DepartureAirport}' }, - // { Value : to_Flight.to_Connection.DestinationAirport.AirportID, + // { Value : Flight.to_Connection.DestinationAirport.AirportID, // Label: '{i18n>ArrivalAirport}' }, - // { Value : to_Flight.to_Connection.Distance, }, + // { Value : Flight.to_Connection.Distance, }, // Workaround: { Value : PlaneType }, diff --git a/app/travel_processor/field-control.cds b/app/travel_processor/field-control.cds index 9c69d303..25518214 100644 --- a/app/travel_processor/field-control.cds +++ b/app/travel_processor/field-control.cds @@ -11,8 +11,8 @@ annotate TravelService.Travel with @(Common.SideEffects: { BookingFee @Common.FieldControl : TravelStatus.fieldControl; BeginDate @Common.FieldControl : TravelStatus.fieldControl; EndDate @Common.FieldControl : TravelStatus.fieldControl; - to_Agency @Common.FieldControl : TravelStatus.fieldControl; - to_Customer @Common.FieldControl : TravelStatus.fieldControl; + Agency @Common.FieldControl : TravelStatus.fieldControl; + Customer @Common.FieldControl : TravelStatus.fieldControl; } actions { rejectTravel @( @@ -31,7 +31,7 @@ annotate TravelService.Travel with @(Common.SideEffects: { annotate TravelService.Travel @( Common.SideEffects#ReactonItemCreationOrDeletion : { SourceEntities : [ - to_Booking + Bookings ], TargetProperties : [ 'TotalPrice' @@ -39,29 +39,29 @@ annotate TravelService.Travel @( } ); -annotate TravelService.Booking with @UI.CreateHidden : to_Travel.TravelStatus.createDeleteHidden; -annotate TravelService.Booking with @UI.DeleteHidden : to_Travel.TravelStatus.createDeleteHidden; +annotate TravelService.Booking with @UI.CreateHidden : Travel.TravelStatus.createDeleteHidden; +annotate TravelService.Booking with @UI.DeleteHidden : Travel.TravelStatus.createDeleteHidden; annotate TravelService.Booking { BookingDate @Core.Computed; - ConnectionID @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - FlightDate @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - FlightPrice @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - BookingStatus @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Carrier @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Customer @Common.FieldControl : to_Travel.TravelStatus.fieldControl; + ConnectionID @Common.FieldControl : Travel.TravelStatus.fieldControl; + FlightDate @Common.FieldControl : Travel.TravelStatus.fieldControl; + FlightPrice @Common.FieldControl : Travel.TravelStatus.fieldControl; + BookingStatus @Common.FieldControl : Travel.TravelStatus.fieldControl; + Carrier @Common.FieldControl : Travel.TravelStatus.fieldControl; + Customer @Common.FieldControl : Travel.TravelStatus.fieldControl; }; annotate TravelService.Booking with @( Capabilities.NavigationRestrictions : { RestrictedProperties : [ { - NavigationProperty : to_BookSupplement, + NavigationProperty : BookSupplements, InsertRestrictions : { - Insertable : to_Travel.TravelStatus.insertDeleteRestriction + Insertable : Travel.TravelStatus.insertDeleteRestriction }, DeleteRestrictions : { - Deletable : to_Travel.TravelStatus.insertDeleteRestriction + Deletable : Travel.TravelStatus.insertDeleteRestriction } } ] @@ -70,9 +70,9 @@ annotate TravelService.Booking with @( annotate TravelService.BookingSupplement { - Price @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Supplement @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Booking @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Travel @Common.FieldControl : to_Travel.TravelStatus.fieldControl; + Price @Common.FieldControl : Travel.TravelStatus.fieldControl; + Supplement @Common.FieldControl : Travel.TravelStatus.fieldControl; + Booking @Common.FieldControl : Travel.TravelStatus.fieldControl; + Travel @Common.FieldControl : Travel.TravelStatus.fieldControl; }; diff --git a/app/travel_processor/layouts.cds b/app/travel_processor/layouts.cds index 7e581edd..5c64c2db 100644 --- a/app/travel_processor/layouts.cds +++ b/app/travel_processor/layouts.cds @@ -33,8 +33,8 @@ annotate TravelService.Travel with @UI : { }] }, SelectionFields : [ - to_Agency_AgencyID, - to_Customer_CustomerID, + Agency_AgencyID, + Customer_CustomerID, TravelStatus_code ], LineItem : [ @@ -46,11 +46,11 @@ annotate TravelService.Travel with @UI : { @UI.Importance : #High }, { - Value : to_Agency_AgencyID, + Value : Agency_AgencyID, @HTML5.CssDefaults: {width:'16em'} }, { - Value : to_Customer_CustomerID, + Value : Customer_CustomerID, @UI.Importance : #High, @HTML5.CssDefaults: {width:'14em'} }, @@ -93,13 +93,13 @@ annotate TravelService.Travel with @UI : { }, { // booking list $Type : 'UI.ReferenceFacet', ID : 'BookingList', - Target : 'to_Booking/@UI.PresentationVariant', + Target : 'Bookings/@UI.PresentationVariant', Label : '{i18n>Bookings}' }], FieldGroup#TravelData : { Data : [ { Value : TravelID }, - { Value : to_Agency_AgencyID }, - { Value : to_Customer_CustomerID }, + { Value : Agency_AgencyID }, + { Value : Customer_CustomerID }, { Value : Description }, { $Type : 'UI.DataField', @@ -127,7 +127,7 @@ annotate TravelService.Booking with @UI : { HeaderInfo : { TypeName : '{i18n>Bookings}', TypeNamePlural : '{i18n>Bookings}', - Title : { Value : to_Customer.LastName }, + Title : { Value : Customer.LastName }, Description : { Value : BookingID } }, PresentationVariant : { @@ -140,11 +140,11 @@ annotate TravelService.Booking with @UI : { }, SelectionFields : [], LineItem : [ - { Value : to_Carrier.AirlinePicURL, Label : ' '}, + { Value : Carrier.AirlinePicURL, Label : ' '}, { Value : BookingID }, { Value : BookingDate }, - { Value : to_Customer_CustomerID }, - { Value : to_Carrier_AirlineID }, + { Value : Customer_CustomerID }, + { Value : Carrier_AirlineID }, { Value : ConnectionID, Label : '{i18n>FlightNumber}' }, { Value : FlightDate }, { Value : FlightPrice }, @@ -171,13 +171,13 @@ annotate TravelService.Booking with @UI : { }, { // supplements list $Type : 'UI.ReferenceFacet', ID : 'SupplementsList', - Target : 'to_BookSupplement/@UI.PresentationVariant', + Target : 'BookSupplements/@UI.PresentationVariant', Label : '{i18n>BookingSupplements}' }], FieldGroup #GeneralInformation : { Data : [ { Value : BookingID }, { Value : BookingDate, }, - { Value : to_Customer_CustomerID }, + { Value : Customer_CustomerID }, { Value : BookingDate, }, { Value : BookingStatus_code, Criticality : { $edmJson: { $If: [{$Eq: [{ $Path: 'BookingStatus_code'}, 'N']}, 2, @@ -185,7 +185,7 @@ annotate TravelService.Booking with @UI : { } ]}, FieldGroup #Flight : { Data : [ - { Value : to_Carrier_AirlineID }, + { Value : Carrier_AirlineID }, { Value : ConnectionID }, { Value : FlightDate }, { Value : FlightPrice } @@ -213,7 +213,7 @@ annotate TravelService.BookingSupplement with @UI : { }, LineItem : [ { Value : BookingSupplementID }, - { Value : to_Supplement_SupplementID, Label : '{i18n>ProductID}' }, + { Value : Supplement_SupplementID, Label : '{i18n>ProductID}' }, { Value : Price, Label : '{i18n>ProductPrice}' } ], }; diff --git a/app/travel_processor/webapp/manifest.json b/app/travel_processor/webapp/manifest.json index a124dd95..476d3092 100644 --- a/app/travel_processor/webapp/manifest.json +++ b/app/travel_processor/webapp/manifest.json @@ -110,7 +110,7 @@ "target": "TravelObjectPage" }, { - "pattern": "Travel({key})/to_Booking({key2}):?query:", + "pattern": "Travel({key})/Bookings({key2}):?query:", "name": "BookingObjectPage", "target": "BookingObjectPage" } @@ -148,14 +148,14 @@ "settings": { "entitySet": "Travel", "navigation": { - "to_Booking": { + "Bookings": { "detail": { "route": "BookingObjectPage" } } }, "controlConfiguration": { - "to_Booking/@com.sap.vocabularies.UI.v1.LineItem": { + "Bookings/@com.sap.vocabularies.UI.v1.LineItem": { "tableSettings": { "type": "ResponsiveTable", "personalization": { diff --git a/app/travel_processor/webapp/test/integration/OpaJourney.js b/app/travel_processor/webapp/test/integration/OpaJourney.js index c2503f39..1822b4c5 100644 --- a/app/travel_processor/webapp/test/integration/OpaJourney.js +++ b/app/travel_processor/webapp/test/integration/OpaJourney.js @@ -42,13 +42,13 @@ sap.ui.define(["sap/ui/test/opaQunit"], function (opaTest) { // Value help Agency ID When.onTheDetailPage .onForm({ section: "Travel", fieldGroup: "TravelData" }) - .iOpenValueHelp({ property: "to_Agency_AgencyID" }); + .iOpenValueHelp({ property: "Agency_AgencyID" }); When.onTheDetailPage.onValueHelpDialog().iSelectRows({ 0: "070006" }); // Value help Customer ID When.onTheDetailPage .onForm({ section: "Travel", fieldGroup: "TravelData" }) - .iOpenValueHelp({ property: "to_Customer_CustomerID" }); + .iOpenValueHelp({ property: "Customer_CustomerID" }); When.onTheDetailPage.onValueHelpDialog().iSelectRows({ 0: "000001" }); // Starting date @@ -199,7 +199,7 @@ sap.ui.define(["sap/ui/test/opaQunit"], function (opaTest) { When.onTheDetailPage.iGoToSection("Booking"); // Check buttons for bookings Then.onTheDetailPage - .onTable({ property: "to_Booking" }) + .onTable({ property: "Bookings" }) .iCheckDelete({ visible: false, enabled: false }) .and.iCheckCreate({ visible: false, enabled: false }); @@ -221,7 +221,7 @@ sap.ui.define(["sap/ui/test/opaQunit"], function (opaTest) { When.onTheDetailPage.iGoToSection("General Information"); When.onTheDetailPage - .onTable({ property: "to_Booking" }) + .onTable({ property: "Bookings" }) .iPressRow({ BookingID: "1" }); Then.onTheDetailItemPage.iSeeThisPage(); @@ -245,10 +245,10 @@ sap.ui.define(["sap/ui/test/opaQunit"], function (opaTest) { // Check buttons for booking supplements When.onTheDetailItemPage.iGoToSection("Booking Supplement"); When.onTheDetailItemPage - .onTable({ property: "to_BookSupplement" }) + .onTable({ property: "BookSupplements" }) .iSelectRows({ BookingSupplementID: "1" }); Then.onTheDetailItemPage - .onTable({ property: "to_BookSupplement" }) + .onTable({ property: "BookSupplements" }) .iCheckDelete({ visible: true, enabled: false }) .and.iCheckCreate({ visible: true, enabled: false }); @@ -276,10 +276,10 @@ sap.ui.define(["sap/ui/test/opaQunit"], function (opaTest) { When.onTheDetailPage.iGoToSection("Booking"); // Check buttons When.onTheDetailPage - .onTable({ property: "to_Booking" }) + .onTable({ property: "Bookings" }) .iSelectRows({ BookingID: "2" }); Then.onTheDetailPage - .onTable({ property: "to_Booking" }) + .onTable({ property: "Bookings" }) .iCheckDelete({ visible: true, enabled: true }) .and.iCheckCreate({ visible: true, enabled: true }); @@ -301,7 +301,7 @@ sap.ui.define(["sap/ui/test/opaQunit"], function (opaTest) { When.onTheDetailPage.iGoToSection("General Information"); When.onTheDetailPage - .onTable({ property: "to_Booking" }) + .onTable({ property: "Bookings" }) .iPressRow({ BookingID: "2" }); Then.onTheDetailItemPage.iSeeThisPage(); @@ -324,10 +324,10 @@ sap.ui.define(["sap/ui/test/opaQunit"], function (opaTest) { // Check buttons for booking supplements When.onTheDetailItemPage.iGoToSection("Booking Supplements"); When.onTheDetailItemPage - .onTable({ property: "to_BookSupplement" }) + .onTable({ property: "BookSupplements" }) .iSelectRows({ BookingSupplementID: "1" }); Then.onTheDetailItemPage - .onTable({ property: "to_BookSupplement" }) + .onTable({ property: "BookSupplements" }) .iCheckDelete({ visible: true, enabled: true }) .and.iCheckCreate({ visible: true, enabled: true }); diff --git a/app/value-helps.cds b/app/value-helps.cds index 94cea013..93ac0be5 100644 --- a/app/value-helps.cds +++ b/app/value-helps.cds @@ -8,11 +8,11 @@ annotate schema.Travel { TravelStatus @Common.ValueListWithFixedValues; - to_Agency @Common.ValueList: { + Agency @Common.ValueList: { CollectionPath : 'TravelAgency', Label : '', Parameters : [ - {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: to_Agency_AgencyID, ValueListProperty: 'AgencyID'}, // local data property is the foreign key + {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: Agency_AgencyID, ValueListProperty: 'AgencyID'}, // local data property is the foreign key {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'Name'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'Street'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'PostalCode'}, @@ -24,11 +24,11 @@ annotate schema.Travel { ] }; - to_Customer @Common.ValueList: { + Customer @Common.ValueList: { CollectionPath : 'Passenger', Label : 'Customer ID', Parameters : [ - {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: to_Customer_CustomerID, ValueListProperty: 'CustomerID'}, + {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: Customer_CustomerID, ValueListProperty: 'CustomerID'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'FirstName'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'LastName'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'Title'}, @@ -60,11 +60,11 @@ annotate schema.Booking { BookingStatus @Common.ValueListWithFixedValues; - to_Customer @Common.ValueList: { + Customer @Common.ValueList: { CollectionPath : 'Passenger', Label : '', Parameters : [ - {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: to_Customer_CustomerID, ValueListProperty: 'CustomerID'}, + {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: Customer_CustomerID, ValueListProperty: 'CustomerID'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'FirstName'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'LastName'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'Title'}, @@ -77,11 +77,11 @@ annotate schema.Booking { ] }; - to_Carrier @Common.ValueList: { + Carrier @Common.ValueList: { CollectionPath : 'Airline', Label : '', Parameters : [ - {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: to_Carrier_AirlineID, ValueListProperty: 'AirlineID'}, + {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: Carrier_AirlineID, ValueListProperty: 'AirlineID'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'Name'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'CurrencyCode_code'} ] @@ -91,7 +91,7 @@ annotate schema.Booking { CollectionPath : 'Flight', Label : '', Parameters : [ - {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: to_Carrier_AirlineID, ValueListProperty: 'AirlineID'}, + {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: Carrier_AirlineID, ValueListProperty: 'AirlineID'}, {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: ConnectionID, ValueListProperty: 'ConnectionID'}, {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: FlightDate, ValueListProperty: 'FlightDate'}, {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: FlightPrice, ValueListProperty: 'Price'}, @@ -108,7 +108,7 @@ annotate schema.Booking { CollectionPath : 'Flight', Label : '', Parameters : [ - {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: to_Carrier_AirlineID, ValueListProperty: 'AirlineID'}, + {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: Carrier_AirlineID, ValueListProperty: 'AirlineID'}, {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: ConnectionID, ValueListProperty: 'ConnectionID'}, {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: FlightDate, ValueListProperty: 'FlightDate'}, {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: FlightPrice, ValueListProperty: 'Price'}, @@ -137,11 +137,11 @@ annotate schema.Booking { annotate schema.BookingSupplement { - to_Supplement @Common.ValueList: { + Supplement @Common.ValueList: { CollectionPath : 'Supplement', Label : '', Parameters : [ - {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: to_Supplement_SupplementID, ValueListProperty: 'SupplementID'}, + {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: Supplement_SupplementID, ValueListProperty: 'SupplementID'}, {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: Price, ValueListProperty: 'Price'}, {$Type: 'Common.ValueListParameterInOut', LocalDataProperty: CurrencyCode_code, ValueListProperty: 'CurrencyCode_code'}, {$Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'Description'} diff --git a/db/data/sap.fe.cap.travel-Booking.csv b/db/data/sap.fe.cap.travel-Booking.csv index 9f89dbaf..e6c51f30 100644 --- a/db/data/sap.fe.cap.travel-Booking.csv +++ b/db/data/sap.fe.cap.travel-Booking.csv @@ -1,4 +1,4 @@ -BookingUUID;to_Travel_TravelUUID;BookingID;BookingDate;to_Customer_CustomerID;to_Carrier_AirlineID;ConnectionID;FlightDate;FlightPrice;CurrencyCode_code;BookingStatus_code;LastChangedAt +BookingUUID;Travel_TravelUUID;BookingID;BookingDate;Customer_CustomerID;Carrier_AirlineID;ConnectionID;FlightDate;FlightPrice;CurrencyCode_code;BookingStatus_code;LastChangedAt 7A757221A8E4645C17002DF03754AB66;52657221A8E4645C17002DF03754AB66;0001;2022-07-27;000099;SW;1537;2022-07-29;438.00;USD;N;2022-07-15T18:48:08Z 7B757221A8E4645C17002DF03754AB66;52657221A8E4645C17002DF03754AB66;0002;2022-07-27;000660;SW;1537;2022-07-29;438.00;USD;N;2022-07-15T18:48:08Z 7C757221A8E4645C17002DF03754AB66;53657221A8E4645C17002DF03754AB66;0001;2022-07-09;000093;SW;1537;2022-07-29;438.00;USD;N;2022-07-15T20:07:58Z diff --git a/db/data/sap.fe.cap.travel-BookingSupplement.csv b/db/data/sap.fe.cap.travel-BookingSupplement.csv index 37f517d2..c0230584 100644 --- a/db/data/sap.fe.cap.travel-BookingSupplement.csv +++ b/db/data/sap.fe.cap.travel-BookingSupplement.csv @@ -1,4 +1,4 @@ -BookSupplUUID;to_Travel_TravelUUID;to_Booking_BookingUUID;BookingSupplementID;to_Supplement_SupplementID;Price;CurrencyCode_code;LastChangedAt +BookSupplUUID;Travel_TravelUUID;Booking_BookingUUID;BookingSupplementID;Supplement_SupplementID;Price;CurrencyCode_code;LastChangedAt 4D997221A8E4645C17002DF03754AB66;53657221A8E4645C17002DF03754AB66;82757221A8E4645C17002DF03754AB66;01;BV-0008;3.50;EUR;2022-07-15T20:07:58Z 57997221A8E4645C17002DF03754AB66;54657221A8E4645C17002DF03754AB66;86757221A8E4645C17002DF03754AB66;01;BV-0007;3.50;EUR;2022-07-14T02:37:18Z 5A997221A8E4645C17002DF03754AB66;54657221A8E4645C17002DF03754AB66;87757221A8E4645C17002DF03754AB66;01;BV-0006;3.50;EUR;2022-07-14T02:37:18Z diff --git a/db/data/sap.fe.cap.travel-Travel.csv b/db/data/sap.fe.cap.travel-Travel.csv index fb5007be..8c6e1608 100644 --- a/db/data/sap.fe.cap.travel-Travel.csv +++ b/db/data/sap.fe.cap.travel-Travel.csv @@ -1,4 +1,4 @@ -TravelUUID;TravelID;to_Agency_AgencyID;to_Customer_CustomerID;BeginDate;EndDate;BookingFee;TotalPrice;CurrencyCode_code;Description;TravelStatus_code;createdBy;createdAt;LastChangedBy;LastChangedAt +TravelUUID;TravelID;Agency_AgencyID;Customer_CustomerID;BeginDate;EndDate;BookingFee;TotalPrice;CurrencyCode_code;Description;TravelStatus_code;createdBy;createdAt;LastChangedBy;LastChangedAt 52657221A8E4645C17002DF03754AB66;00000001;070007;000608;2022-07-29;2022-07-29;20.00;900.00;USD;Business Trip for Christine, Pierre;O;Meier;2022-07-13T19:54:13Z;Lindwurm;2022-07-15T20:07:58Z 53657221A8E4645C17002DF03754AB66;00000002;070046;000093;2022-07-29;2023-05-28;80.00;4164.00;USD;Vacation;O;Detemple;2022-06-25T22:05:32Z;Mustermann;2022-07-14T02:37:18Z 54657221A8E4645C17002DF03754AB66;00000003;070042;000665;2022-07-29;2023-05-28;40.00;1871.00;USD;Vacation;O;Rahn;2022-07-09T04:32:59Z;Hoffen;2022-07-26T20:16:11Z diff --git a/db/schema.cds b/db/schema.cds index 5c508f94..3f8bc690 100644 --- a/db/schema.cds +++ b/db/schema.cds @@ -19,9 +19,9 @@ entity Travel : managed { CurrencyCode : Currency; Description : String(1024); TravelStatus : Association to TravelStatus @readonly; - to_Agency : Association to TravelAgency; - to_Customer : Association to Passenger; - to_Booking : Composition of many Booking on to_Booking.to_Travel = $self; + Agency : Association to TravelAgency; + Customer : Association to Passenger; + Bookings : Composition of many Booking on Bookings.Travel = $self; }; annotate Travel with @( @@ -46,13 +46,13 @@ entity Booking : managed { FlightPrice : Decimal(16, 3); CurrencyCode : Currency; BookingStatus : Association to BookingStatus; - to_BookSupplement : Composition of many BookingSupplement on to_BookSupplement.to_Booking = $self; - to_Carrier : Association to Airline; - to_Customer : Association to Passenger; - to_Travel : Association to Travel; - to_Flight : Association to Flight on to_Flight.AirlineID = to_Carrier.AirlineID - and to_Flight.FlightDate = FlightDate - and to_Flight.ConnectionID = ConnectionID; + BookSupplements : Composition of many BookingSupplement on BookSupplements.Booking = $self; + Carrier : Association to Airline; + Customer : Association to Passenger; + Travel : Association to Travel; + Flight : Association to Flight on Flight.AirlineID = Carrier.AirlineID + and Flight.FlightDate = FlightDate + and Flight.ConnectionID = ConnectionID; }; entity BookingSupplement : managed { @@ -60,9 +60,9 @@ entity BookingSupplement : managed { BookingSupplementID : Integer @Core.Computed; Price : Decimal(16, 3); CurrencyCode : Currency; - to_Booking : Association to Booking; - to_Travel : Association to Travel; - to_Supplement : Association to Supplement; + Booking : Association to Booking; + Travel : Association to Travel; + Supplement : Association to Supplement; }; diff --git a/srv/analytics-service.cds b/srv/analytics-service.cds index 8e9fe59e..eec3b226 100644 --- a/srv/analytics-service.cds +++ b/srv/analytics-service.cds @@ -9,11 +9,11 @@ service AnalyticsService @(path:'/analytics') { entity Bookings as projection on my.Booking { @UI.Hidden: false BookingUUID as ID, - to_Travel.TravelID, + Travel.TravelID, BookingID, @title : 'Travel/Booking ID' - to_Travel.TravelID || '/' || BookingID as CombinedID : String, + Travel.TravelID || '/' || BookingID as CombinedID : String, ConnectionID, @@ -32,29 +32,29 @@ service AnalyticsService @(path:'/analytics') { BookingStatus.name as statusName, @Common.Text: airlineName - to_Carrier.AirlineID as airline, - to_Carrier.Name as airlineName, + Carrier.AirlineID as airline, + Carrier.Name as airlineName, BookingDate, - to_Travel, - to_Carrier, + Travel, + Carrier, // Java has a problem with this association - to_Flight, + Flight, // Workaround: - to_Flight.PlaneType, - to_Flight.to_Connection.Distance, - to_Flight.to_Connection.DistanceUnit, + Flight.PlaneType, + Flight.to_Connection.Distance, + Flight.to_Connection.DistanceUnit, @Common.Label: '{i18n>DepartureAirport}' @Common.Text: DepCity - to_Flight.to_Connection.DepartureAirport.AirportID as DepAirport, - to_Flight.to_Connection.DepartureAirport.City as DepCity, + Flight.to_Connection.DepartureAirport.AirportID as DepAirport, + Flight.to_Connection.DepartureAirport.City as DepCity, @Common.Label: '{i18n>ArrivalAirport}' @Common.Text: DestCity - to_Flight.to_Connection.DestinationAirport.AirportID as DestAirport, - to_Flight.to_Connection.DestinationAirport.City as DestCity, + Flight.to_Connection.DestinationAirport.AirportID as DestAirport, + Flight.to_Connection.DestinationAirport.City as DestCity, }; @@ -68,7 +68,7 @@ service AnalyticsService @(path:'/analytics') { entity Travels as projection on my.Travel { *, @Common.Label: '{i18n>CustomerName}' - to_Customer.FirstName || ' ' || to_Customer.LastName as CustomerName : String, + Customer.FirstName || ' ' || Customer.LastName as CustomerName : String, }; annotate Travels:TravelID with @Common.Text: null; diff --git a/srv/src/main/java/com/sap/cap/sflight/processor/CreationHandler.java b/srv/src/main/java/com/sap/cap/sflight/processor/CreationHandler.java index 0cd09862..13aa101e 100644 --- a/srv/src/main/java/com/sap/cap/sflight/processor/CreationHandler.java +++ b/srv/src/main/java/com/sap/cap/sflight/processor/CreationHandler.java @@ -52,8 +52,8 @@ public void setBookingDateIfNotProvided(final Travel travel) { travel.endDate(LocalDate.now().plusDays(1)); } - if (travel.toBooking() != null) { - for (Booking booking : travel.toBooking()) { + if (travel.bookings() != null) { + for (Booking booking : travel.bookings()) { if (booking.bookingDate() == null) { booking.bookingDate(LocalDate.now()); } @@ -109,7 +109,7 @@ public void calculateTravelIdBeforeCreation(final Travel travel) { @Before(event = { CqnService.EVENT_CREATE, CqnService.EVENT_UPDATE, }, entity = Travel_.CDS_NAME) public void fillBookingIdsBeforeCreationAndUpdate(final Travel travel) { - if (travel.toBooking() != null) { + if (travel.bookings() != null) { addBookingIds(travel); addBookingSupplementIds(travel); } @@ -117,10 +117,10 @@ public void fillBookingIdsBeforeCreationAndUpdate(final Travel travel) { private void addBookingSupplementIds(Travel travel) { - travel.toBooking().stream() - .filter(booking -> booking.toBookSupplement() != null && !booking.toBookSupplement().isEmpty()) + travel.bookings().stream() + .filter(booking -> booking.bookSupplements() != null && !booking.bookSupplements().isEmpty()) .forEach(booking -> { - List bookingSupplements = booking.toBookSupplement(); + List bookingSupplements = booking.bookSupplements(); List bookingSupplementsWithoutIds = bookingSupplements.stream() .filter(bookingSupplement -> bookingSupplement.bookingSupplementID() == null @@ -139,11 +139,11 @@ private void addBookingSupplementIds(Travel travel) { } private void addBookingIds(Travel travel) { - List bookingsWithoutId = travel.toBooking().stream() + List bookingsWithoutId = travel.bookings().stream() .filter(booking -> booking.bookingID() == null || booking.bookingID() == 0) .collect(Collectors.toList()); - Integer currentMaxBookingId = travel.toBooking().stream() + Integer currentMaxBookingId = travel.bookings().stream() .filter(booking -> Objects.nonNull(booking.bookingID())) .max(Comparator.comparing(Booking::bookingID)).map(Booking::bookingID).orElse(0); diff --git a/srv/src/main/java/com/sap/cap/sflight/processor/RecalculatePriceHandler.java b/srv/src/main/java/com/sap/cap/sflight/processor/RecalculatePriceHandler.java index 2ef98615..bd81afa8 100644 --- a/srv/src/main/java/com/sap/cap/sflight/processor/RecalculatePriceHandler.java +++ b/srv/src/main/java/com/sap/cap/sflight/processor/RecalculatePriceHandler.java @@ -73,7 +73,7 @@ private static BigDecimal calculateTotalPriceForTravel(CqnService db, String tra BigDecimal flightPriceSum = new BigDecimal(0); Optional flightPriceRow = db .run(Select.from(BOOKING).columns(b -> sum(b.FlightPrice()).as("FlightPriceSum")) - .where(b -> b.to_Travel_TravelUUID().eq(travelUUID).and(b.IsActiveEntity().eq(isActiveEntity)))) + .where(b -> b.Travel_TravelUUID().eq(travelUUID).and(b.IsActiveEntity().eq(isActiveEntity)))) .first(); if (flightPriceRow.isPresent()) { @@ -84,7 +84,7 @@ private static BigDecimal calculateTotalPriceForTravel(CqnService db, String tra BigDecimal supplementPriceSum = new BigDecimal(0); Optional supplementPriceSumRow = db .run(Select.from(BOOKING_SUPPLEMENT).columns(c -> sum(c.Price()).as("PriceSum")) - .where(b -> b.to_Travel_TravelUUID().eq(travelUUID).and(b.IsActiveEntity().eq(isActiveEntity)))) + .where(b -> b.Travel_TravelUUID().eq(travelUUID).and(b.IsActiveEntity().eq(isActiveEntity)))) .first(); if (supplementPriceSumRow.isPresent()) { supplementPriceSum = (BigDecimal) Objects.requireNonNullElse(flightPriceRow.get().get("PriceSum"), new BigDecimal(0)); @@ -128,7 +128,7 @@ public void recalculateTravelPriceIfTravelWasUpdated(final Travel travel) { @After(event = { DraftService.EVENT_DRAFT_PATCH, DraftService.EVENT_DRAFT_NEW }, entity = Booking_.CDS_NAME) public void recalculateTravelPriceIfFlightPriceWasUpdated(final Booking booking) { - draftService.run(Select.from(BOOKING).columns(bs -> bs.to_Travel().TravelUUID().as(Travel.TRAVEL_UUID)) + draftService.run(Select.from(BOOKING).columns(bs -> bs.Travel().TravelUUID().as(Travel.TRAVEL_UUID)) .where(bs -> bs.BookingUUID().eq(booking.bookingUUID()) .and(bs.IsActiveEntity().eq(FALSE)))) .first() @@ -139,7 +139,7 @@ public void recalculateTravelPriceIfFlightPriceWasUpdated(final Booking booking) DraftService.EVENT_DRAFT_SAVE }, entity = BookingSupplement_.CDS_NAME) public void recalculateTravelPriceIfPriceWasUpdated(final BookingSupplement bookingSupplement) { draftService.run(Select.from(BOOKING_SUPPLEMENT) - .columns(bs -> bs.to_Booking().to_Travel().TravelUUID().as(Travel.TRAVEL_UUID)) + .columns(bs -> bs.Booking().Travel().TravelUUID().as(Travel.TRAVEL_UUID)) .where(bs -> bs.BookSupplUUID().eq(bookingSupplement.bookSupplUUID()) .and(bs.IsActiveEntity().eq(FALSE)))) .first() diff --git a/srv/travel-service.js b/srv/travel-service.js index 182dd45b..ab39a49d 100644 --- a/srv/travel-service.js +++ b/srv/travel-service.js @@ -24,10 +24,10 @@ init() { * Fill in defaults for new Bookings when editing Travels. */ this.before ('NEW', 'Booking', async (req) => { - const { to_Travel_TravelUUID } = req.data - const { status } = await SELECT `TravelStatus_code as status` .from (Travel.drafts, to_Travel_TravelUUID) + const { Travel_TravelUUID } = req.data + const { status } = await SELECT `TravelStatus_code as status` .from (Travel.drafts, Travel_TravelUUID) if (status === 'X') throw req.reject (400, 'Cannot add new bookings to rejected travels.') - const { maxID } = await SELECT.one `max(BookingID) as maxID` .from (Booking.drafts) .where ({to_Travel_TravelUUID}) + const { maxID } = await SELECT.one `max(BookingID) as maxID` .from (Booking.drafts) .where ({Travel_TravelUUID}) req.data.BookingID = maxID + 1 req.data.BookingStatus_code = 'N' req.data.BookingDate = (new Date).toISOString().slice(0,10) // today @@ -38,8 +38,8 @@ init() { * Fill in defaults for new BookingSupplements when editing Travels. */ this.before ('NEW', 'BookingSupplement', async (req) => { - const { to_Booking_BookingUUID } = req.data - const { maxID } = await SELECT.one `max(BookingSupplementID) as maxID` .from (BookingSupplement.drafts) .where ({to_Booking_BookingUUID}) + const { Booking_BookingUUID } = req.data + const { maxID } = await SELECT.one `max(BookingSupplementID) as maxID` .from (BookingSupplement.drafts) .where ({Booking_BookingUUID}) req.data.BookingSupplementID = maxID + 1 }) @@ -66,7 +66,7 @@ init() { */ this.after ('PATCH', 'Booking', async (_,req) => { if ('FlightPrice' in req.data) { // We need to fetch the Travel's UUID for the given Booking target - const { travel } = await SELECT.one `to_Travel_TravelUUID as travel` .from (req.subject) + const { travel } = await SELECT.one `Travel_TravelUUID as travel` .from (req.subject) return this._update_totals4 (travel) }}) @@ -76,9 +76,9 @@ init() { */ this.after ('PATCH', 'BookingSupplement', async (_,req) => { if ('Price' in req.data) { // We need to fetch the Travel's UUID for the given Supplement target - const { travel } = await SELECT.one `to_Travel_TravelUUID as travel` .from (Booking.drafts) - .where `BookingUUID = ${ SELECT.one `to_Booking_BookingUUID` .from (BookingSupplement.drafts).where({BookSupplUUID:req.data.BookSupplUUID}) }` - // .where `BookingUUID = ${ SELECT.one `to_Booking_BookingUUID` .from (req.subject) }` + const { travel } = await SELECT.one `Travel_TravelUUID as travel` .from (Booking.drafts) + .where `BookingUUID = ${ SELECT.one `Booking_BookingUUID` .from (BookingSupplement.drafts).where({BookSupplUUID:req.data.BookSupplUUID}) }` + // .where `BookingUUID = ${ SELECT.one `Booking_BookingUUID` .from (req.subject) }` //> REVISIT: req.subject not supported for subselects -> see tests return this._update_totals4 (travel) }}) @@ -89,13 +89,13 @@ init() { this.on('CANCEL', BookingSupplement, async (req, next) => { // Find out which travel is affected before the delete const { BookSupplUUID } = req.data - const { to_Travel_TravelUUID } = await SELECT.one - .from(BookingSupplement.drafts, ['to_Travel_TravelUUID']) + const { Travel_TravelUUID } = await SELECT.one + .from(BookingSupplement.drafts, ['Travel_TravelUUID']) .where({ BookSupplUUID }) // Delete handled by generic handlers const res = await next() // After the delete, update the totals - await this._update_totals4(to_Travel_TravelUUID) + await this._update_totals4(Travel_TravelUUID) return res }) @@ -105,13 +105,13 @@ init() { this.on('CANCEL', Booking, async (req, next) => { // Find out which travel is affected before the delete const { BookingUUID } = req.data - const { to_Travel_TravelUUID } = await SELECT.one - .from(Booking.drafts, ['to_Travel_TravelUUID']) + const { Travel_TravelUUID } = await SELECT.one + .from(Booking.drafts, ['Travel_TravelUUID']) .where({ BookingUUID }) // Delete handled by generic handlers const res = await next() // After the delete, update the totals - await this._update_totals4(to_Travel_TravelUUID) + await this._update_totals4(Travel_TravelUUID) return res }) @@ -123,8 +123,8 @@ init() { // Using plain native SQL for such complex queries return cds.run(`UPDATE ${Travel.drafts} SET TotalPrice = coalesce(BookingFee,0) - + ( SELECT coalesce (sum(FlightPrice),0) from ${Booking.drafts} where to_Travel_TravelUUID = TravelUUID ) - + ( SELECT coalesce (sum(Price),0) from ${BookingSupplement.drafts} where to_Travel_TravelUUID = TravelUUID ) + + ( SELECT coalesce (sum(FlightPrice),0) from ${Booking.drafts} where Travel_TravelUUID = TravelUUID ) + + ( SELECT coalesce (sum(Price),0) from ${BookingSupplement.drafts} where Travel_TravelUUID = TravelUUID ) WHERE TravelUUID = ?`, [travel]) } @@ -133,29 +133,29 @@ init() { * Validate a Travel's edited data before save. */ this.before ('SAVE', 'Travel', req => { - const { BeginDate, EndDate, BookingFee, to_Agency_AgencyID, to_Customer_CustomerID, to_Booking, TravelStatus_code } = req.data, today = (new Date).toISOString().slice(0,10) + const { BeginDate, EndDate, BookingFee, Agency_AgencyID, Customer_CustomerID, Bookings, TravelStatus_code } = req.data, today = (new Date).toISOString().slice(0,10) // validate only not rejected travels if (TravelStatus_code !== 'X') { if (BookingFee == null) req.error(400, "Enter a booking fee", "in/BookingFee") // 0 is a valid BookingFee if (!BeginDate) req.error(400, "Enter a begin date", "in/BeginDate") if (!EndDate) req.error(400, "Enter an end date", "in/EndDate") - if (!to_Agency_AgencyID) req.error(400, "Enter a travel agency", "in/to_Agency_AgencyID") - if (!to_Customer_CustomerID) req.error(400, "Enter a customer", "in/to_Customer_CustomerID") - - for (const booking of to_Booking) { - const { BookingUUID, ConnectionID, FlightDate, FlightPrice, BookingStatus_code, to_Carrier_AirlineID, to_Customer_CustomerID } = booking - if (!ConnectionID) req.error(400, "Enter a flight", `in/to_Booking(BookingUUID='${BookingUUID}',IsActiveEntity=false)/ConnectionID`) - if (!FlightDate) req.error(400, "Enter a flight date", `in/to_Booking(BookingUUID='${BookingUUID}',IsActiveEntity=false)/FlightDate`) - if (!FlightPrice) req.error(400, "Enter a flight price", `in/to_Booking(BookingUUID='${BookingUUID}',IsActiveEntity=false)/FlightPrice`) - if (!BookingStatus_code) req.error(400, "Enter a booking status", `in/to_Booking(BookingUUID='${BookingUUID}',IsActiveEntity=false)/BookingStatus_code`) - if (!to_Carrier_AirlineID) req.error(400, "Enter an airline", `in/to_Booking(BookingUUID='${BookingUUID}',IsActiveEntity=false)/to_Carrier_AirlineID`) - if (!to_Customer_CustomerID) req.error(400, "Enter a customer", `in/to_Booking(BookingUUID='${BookingUUID}',IsActiveEntity=false)/to_Customer_CustomerID`) - - for (const suppl of booking.to_BookSupplement) { - const { BookSupplUUID, Price, to_Supplement_SupplementID } = suppl - if (!Price) req.error(400, "Enter a price", `in/to_Booking(BookingUUID='${BookingUUID}',IsActiveEntity=false)/to_BookSupplement(BookSupplUUID='${BookSupplUUID}',IsActiveEntity=false)/Price`) - if (!to_Supplement_SupplementID) req.error(400, "Enter a supplement", `in/to_Booking(BookingUUID='${BookingUUID}',IsActiveEntity=false)/to_BookSupplement(BookSupplUUID='${BookSupplUUID}',IsActiveEntity=false)/to_Supplement_SupplementID`) + if (!Agency_AgencyID) req.error(400, "Enter a travel agency", "in/Agency_AgencyID") + if (!Customer_CustomerID) req.error(400, "Enter a customer", "in/Customer_CustomerID") + + for (const booking of Bookings) { + const { BookingUUID, ConnectionID, FlightDate, FlightPrice, BookingStatus_code, Carrier_AirlineID, Customer_CustomerID } = booking + if (!ConnectionID) req.error(400, "Enter a flight", `in/Bookings(BookingUUID='${BookingUUID}',IsActiveEntity=false)/ConnectionID`) + if (!FlightDate) req.error(400, "Enter a flight date", `in/Bookings(BookingUUID='${BookingUUID}',IsActiveEntity=false)/FlightDate`) + if (!FlightPrice) req.error(400, "Enter a flight price", `in/Bookings(BookingUUID='${BookingUUID}',IsActiveEntity=false)/FlightPrice`) + if (!BookingStatus_code) req.error(400, "Enter a booking status", `in/Bookings(BookingUUID='${BookingUUID}',IsActiveEntity=false)/BookingStatus_code`) + if (!Carrier_AirlineID) req.error(400, "Enter an airline", `in/Bookings(BookingUUID='${BookingUUID}',IsActiveEntity=false)/Carrier_AirlineID`) + if (!Customer_CustomerID) req.error(400, "Enter a customer", `in/Bookings(BookingUUID='${BookingUUID}',IsActiveEntity=false)/Customer_CustomerID`) + + for (const suppl of booking.BookSupplements) { + const { BookSupplUUID, Price, Supplement_SupplementID } = suppl + if (!Price) req.error(400, "Enter a price", `in/Bookings(BookingUUID='${BookingUUID}',IsActiveEntity=false)/BookSupplements(BookSupplUUID='${BookSupplUUID}',IsActiveEntity=false)/Price`) + if (!Supplement_SupplementID) req.error(400, "Enter a supplement", `in/Bookings(BookingUUID='${BookingUUID}',IsActiveEntity=false)/BookSupplements(BookSupplUUID='${BookSupplUUID}',IsActiveEntity=false)/Supplement_SupplementID`) } } } diff --git a/test/odata.test.js b/test/odata.test.js index daf1ab56..4d50958a 100644 --- a/test/odata.test.js +++ b/test/odata.test.js @@ -30,7 +30,7 @@ describe ("Basic Querying", () => { where: [ {ref:['TravelUUID']},'=',{val:'7A757221A8E4645C17002DF03754AB66'} ] }]} const travel = await SELECT.one.from ('TravelService.Travel') .where ({ - TravelUUID: SELECT.one `to_Travel_TravelUUID` .from (BookingRef) + TravelUUID: SELECT.one `Travel_TravelUUID` .from (BookingRef) }) expect (travel) .to.exist expect (travel.TravelID) .to.eql (1) @@ -68,8 +68,8 @@ describe('Basic OData', () => { IsActiveEntity: true, LastChangedAt: expectedValue => /2022-07-21T03:18:18\.000(0000)?Z/.test(expectedValue), // timestamp precision increase with cds^7 LastChangedBy: 'Deichgraeber', - to_Agency_AgencyID: '070029', - to_Customer_CustomerID: '000318', + Agency_AgencyID: '070029', + Customer_CustomerID: '000318', TotalPrice: 23439, TravelID: 175, TravelStatus_code: 'A', @@ -90,16 +90,16 @@ describe('Basic OData', () => { const { data } = await GET(`/processor/Travel`, { params: { $select: `TravelID`, - $expand: `to_Agency($select=Name,City)` + $expand: `Agency($select=Name,City)` } }) expect(data.value).to.containSubset([ - { TravelID: 175, to_Agency: {Name: "Up 'n' Away", City:'Hannover'} }, + { TravelID: 175, Agency: {Name: "Up 'n' Away", City:'Hannover'} }, ]) }) it('supports $value requests', async () => { - const { data } = await GET `/processor/Travel(TravelUUID='52657221A8E4645C17002DF03754AB66',IsActiveEntity=true)/to_Customer/LastName/$value` + const { data } = await GET `/processor/Travel(TravelUUID='52657221A8E4645C17002DF03754AB66',IsActiveEntity=true)/Customer/LastName/$value` expect(data).to.equal('Prinz') }) @@ -127,8 +127,8 @@ describe('Basic OData', () => { BeginDate: '2028-04-01', EndDate: '2028-04-02', BookingFee: '11', - to_Customer_CustomerID: '000001', - to_Agency_AgencyID: '070001', + Customer_CustomerID: '000001', + Agency_AgencyID: '070001', CurrencyCode_code: 'USD' })