From 03584a53966e6be18e28c710cceb63451535dc0e Mon Sep 17 00:00:00 2001 From: Daniel Hutzel Date: Fri, 19 Jan 2024 15:40:36 +0100 Subject: [PATCH] Improved UX --- app/travel_processor/layouts.cds | 4 +--- srv/travel-service.js | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/travel_processor/layouts.cds b/app/travel_processor/layouts.cds index 60eb37db..e02c8836 100644 --- a/app/travel_processor/layouts.cds +++ b/app/travel_processor/layouts.cds @@ -97,9 +97,8 @@ annotate TravelService.Travel with @UI : { Label : '{i18n>Bookings}' }], FieldGroup#TravelData : { Data : [ - { Value : TravelID }, - { Value : to_Agency_AgencyID }, { Value : to_Customer_CustomerID }, + { Value : to_Agency_AgencyID }, { Value : Description }, { $Type : 'UI.DataField', @@ -116,7 +115,6 @@ annotate TravelService.Travel with @UI : { FieldGroup #PriceData : {Data : [ { $Type : 'UI.DataField', Value : BookingFee }, { $Type : 'UI.DataField', Value : TotalPrice }, - { $Type : 'UI.DataField', Value : CurrencyCode_code } ]} }; diff --git a/srv/travel-service.js b/srv/travel-service.js index 4741b672..9646dc0f 100644 --- a/srv/travel-service.js +++ b/srv/travel-service.js @@ -14,6 +14,14 @@ init() { * Note: In contrast to Bookings and BookingSupplements that has to happen * upon SAVE, as multiple users could create new Travels concurrently. */ + this.before ('NEW', 'Travel.drafts', async req => { + let begin = new Date; begin.setDate (begin.getDate() + 1) + let end = new Date; end.setDate (begin.getDate() + 2) + req.data.BeginDate = begin.toISOString().slice(0,10) // today + req.data.EndDate = end.toISOString().slice(0,10) // today + req.data.BookingFee = 0 + }) + this.before ('CREATE', 'Travel', async req => { const { maxID } = await SELECT.one `max(TravelID) as maxID` .from (Travel) req.data.TravelID = maxID + 1