Merge pull request #9 from SAP-samples/cleanup

removed total and netAmount
This commit is contained in:
Daniel
2019-11-22 17:13:03 +01:00
committed by GitHub
5 changed files with 12 additions and 51 deletions

View File

@@ -30,7 +30,6 @@ annotate AdminService.Orders with @(
SelectionFields: [ createdAt, createdBy ],
LineItem: [
{Value: createdBy, Label:'Customer'},
{Value: total, Label: 'Order Value' },
{Value: createdAt, Label:'Date'}
],
////////////////////////////////////////////////////////////////////////////
@@ -60,7 +59,6 @@ annotate AdminService.Orders with @(
],
FieldGroup#Details: {
Data: [
{Value: total, Label:'Total'},
{Value: currency_code, Label:'Currency'}
]
},
@@ -77,24 +75,9 @@ annotate AdminService.Orders with @(
]
},
},
Common: {
SideEffects#AmountChanges: {
SourceEntities: [
Items
],
TargetProperties: [
total
]
}
}
) {
createdAt @UI.HiddenFilter:false;
createdBy @UI.HiddenFilter:false;
total
@Common.FieldControl: #ReadOnly
@Measures.ISOCurrency:currency.code; //Bind the currency field to the amount field
//In all services we always find currency as the code and not as an object that contains a property code
//it seems to work but at least to me this is unconventional modeling.
};
@@ -121,39 +104,14 @@ annotate AdminService.OrderItems with @(
//The following entry is only used to have the assoication followed in the read event
{Value: book.price, Label:'Book Price'},
{Value: amount, Label:'Quantity'},
{Value: netAmount, Label: 'Net amount'}
],
Identification: [ //Is the main field group
//{Value: ID, Label:'ID'}, //A guid shouldn't be on the UI
{Value: book_ID, Label:'Book'},
{Value: amount, Label:'Amount'},
{Value: netAmount, Label: 'Net amount'}
],
Facets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: '@UI.Identification'},
],
},
Common: {
SideEffects#AmountChanges: {
SourceProperties: [
amount
],
TargetProperties: [
netAmount, parent.total
]
},
SideEffects#BookChanges: {
SourceProperties: [
book_ID
],
TargetProperties: [
netAmount, book.price, parent.total
]
}
}
) {
netAmount
@Common.FieldControl: #ReadOnly;
//ERROR ALERT: The following line refering to the parents currency code will lead to a server error
//@Measures.ISOCurrency:parent.currency.code; //Bind the currency field to the amount field of the parent
};
);

View File

@@ -1,6 +1,6 @@
using { sap.capire.bookshop as my } from '../db/schema';
service AdminService @(_requires:'admin') {
service AdminService @(_requires:'authenticated-user') {
entity Books as projection on my.Books;
entity Authors as projection on my.Authors;
entity Orders as select from my.Orders;
@@ -8,8 +8,9 @@ service AdminService @(_requires:'admin') {
// Enable Fiori Draft for Orders
annotate AdminService.Orders with @odata.draft.enabled;
// annotate AdminService.Books with @odata.draft.enabled;
// Temporary workaround for Fiori
// Temporary workaround -> https://github.wdf.sap.corp/cap/issues/issues/3121
extend service AdminService with {
entity OrderItems as select from my.OrderItems;
}

View File

@@ -2,6 +2,10 @@
### List Books with their current stocks
GET http://localhost:4004/admin/Books?$select=ID,stock
### List all Orders
GET http://localhost:4004/admin/Orders?
&$expand=Items
### Submit Orders
POST http://localhost:4004/browse/Orders
Content-Type: application/json

View File

@@ -1,4 +1,4 @@
ID;amount;parent_ID;article;netAmount
58040e66-1dcd-4ffb-ab10-fdce32028b79;1;7e2f2640-6866-4dcf-8f4d-3027aa831cad;201;11.11
64e718c9-ff99-47f1-8ca3-950c850777d4;1;7e2f2640-6866-4dcf-8f4d-3027aa831cad;271;15
e9641166-e050-4261-bfee-d1e797e6cb7f;2;64e718c9-ff99-47f1-8ca3-950c850777d4;252;28
ID;amount;parent_ID;article
58040e66-1dcd-4ffb-ab10-fdce32028b79;1;7e2f2640-6866-4dcf-8f4d-3027aa831cad;201
64e718c9-ff99-47f1-8ca3-950c850777d4;1;7e2f2640-6866-4dcf-8f4d-3027aa831cad;271
e9641166-e050-4261-bfee-d1e797e6cb7f;2;64e718c9-ff99-47f1-8ca3-950c850777d4;252
1 ID amount parent_ID article netAmount
2 58040e66-1dcd-4ffb-ab10-fdce32028b79 1 7e2f2640-6866-4dcf-8f4d-3027aa831cad 201 11.11
3 64e718c9-ff99-47f1-8ca3-950c850777d4 1 7e2f2640-6866-4dcf-8f4d-3027aa831cad 271 15
4 e9641166-e050-4261-bfee-d1e797e6cb7f 2 64e718c9-ff99-47f1-8ca3-950c850777d4 252 28

View File

@@ -5,7 +5,6 @@ using { Currency, cuid, managed } from '@sap/cds/common';
entity Orders : cuid, managed {
OrderNo : String @title:'Order Number'; //> readable key
Items : Composition of many OrderItems on Items.parent = $self;
total : Decimal(9,2) @readonly;
currency : Currency;
}
@@ -13,5 +12,4 @@ entity OrderItems : cuid {
parent : Association to Orders not null;
article : String;
amount : Integer;
netAmount : Decimal(9,2);
}