diff --git a/orders/.env b/orders/.env
index 616dd8d0..dee2b221 100644
--- a/orders/.env
+++ b/orders/.env
@@ -1,2 +1,3 @@
cds.requires.messaging.kind = file-based-messaging
-PORT = 4006
\ No newline at end of file
+PORT = 4006
+# cds.odata.flavor = x4
\ No newline at end of file
diff --git a/orders/app/orders/fiori-service.cds b/orders/app/orders/fiori-service.cds
index e58c8ccd..3a204ac8 100644
--- a/orders/app/orders/fiori-service.cds
+++ b/orders/app/orders/fiori-service.cds
@@ -68,7 +68,7 @@ annotate OrdersService.Orders with @(
-annotate OrdersService.Orders_Items with @(
+annotate OrdersService.Orders.Items with @(
UI: {
LineItem: [
{Value: product_ID, Label:'Product ID'},
diff --git a/orders/db/data/sap.capire.orders-Orders_Items.csv b/orders/db/data/sap.capire.orders-Orders.Items.csv
similarity index 100%
rename from orders/db/data/sap.capire.orders-Orders_Items.csv
rename to orders/db/data/sap.capire.orders-Orders.Items.csv
diff --git a/orders/db/schema.cds b/orders/db/schema.cds
index 0911a4c4..322aa103 100644
--- a/orders/db/schema.cds
+++ b/orders/db/schema.cds
@@ -3,17 +3,17 @@ namespace sap.capire.orders;
entity Orders : cuid, managed {
OrderNo : String @title:'Order Number'; //> readable key
- Items : Composition of many Orders_Items on Items.up_ = $self;
+ Items : Composition of many Orders.Items on Items.up_ = $self;
buyer : User;
currency : Currency;
}
-entity Orders_Items {
+entity Orders.Items {
key ID : UUID;
- up_ : Association to Orders;
+ /*key*/ up_ : Association to Orders; // REVISIT: 'key' doesn't work due to bug in runtime
product : Association to Products @assert.integrity:false; // REVISIT: this is a temporary workaround for a glitch in cds-runtime
amount : Integer;
- title : String; //> intentionally replicated as snapshot from product.title
+ title : String; //> intentionally replicated as snapshot from product.title or alike
price : Double;
}
@@ -21,3 +21,7 @@ entity Orders_Items {
entity Products @(cds.persistence.skip:'always') {
key ID : String;
}
+
+
+// REVISIT: below is a workaround for a GAP in Fiori elements, which crashes for proxies
+// annotate Products with @cds.autoexpose;
\ No newline at end of file
diff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4-with-product-entity.edmx b/orders/o-x4-with-product-entity.edmx
new file mode 100644
index 00000000..3872f55f
--- /dev/null
+++ b/orders/o-x4-with-product-entity.edmx
@@ -0,0 +1,414 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ createdAt
+ createdBy
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/orders/o-x4-with-product-proxy.edmx b/orders/o-x4-with-product-proxy.edmx
new file mode 100644
index 00000000..873aadb2
--- /dev/null
+++ b/orders/o-x4-with-product-proxy.edmx
@@ -0,0 +1,413 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ createdAt
+ createdBy
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/orders/package.json b/orders/package.json
index 7415f469..1b92b46b 100644
--- a/orders/package.json
+++ b/orders/package.json
@@ -2,6 +2,7 @@
"name": "@capire/orders",
"version": "1.0.0",
"dependencies": {
+ "@capire/common": "*",
"@sap/cds": "^5"
}
}
\ No newline at end of file
diff --git a/orders/requests.http b/orders/requests.http
new file mode 100644
index 00000000..eaf1a901
--- /dev/null
+++ b/orders/requests.http
@@ -0,0 +1,31 @@
+
+@Orders = http://localhost:4006/orders/Orders
+
+
+### Read Orders
+GET {{Orders}}?
+###
+GET {{Orders}}?$expand=Items
+###
+GET {{Orders}}(ID={{Order1}},IsActiveEntity=true)/Items
+
+
+
+@Order1 = 64e718c9-ff99-47f1-8ca3-950c850777d4
+@Order3 = e939604c-ab83-4d4f-bdb6-95fe30b3773e
+
+### Create order, still inactive
+POST {{Orders}}
+Content-Type: application/json
+
+{"ID": "{{Order3}}"}
+
+### Get inactive order. We have to specify `IsActiveEntity`.
+GET {{Orders}}(ID={{Order3}},IsActiveEntity=false)
+
+### Activate order using `.../.draftActivate`
+POST {{Orders}}(ID={{Order3}},IsActiveEntity=false)/OrdersService.draftActivate
+Content-Type: application/json
+
+### Get active order
+GET {{Orders}}(ID={{Order3}},IsActiveEntity=true)