Using managed compositions for Order.Items (#273)

* Using managed compositions for Order.Items
Co-authored-by: sjvans <30337871+sjvans@users.noreply.github.com>
This commit is contained in:
Daniel Hutzel
2021-11-08 17:41:33 +01:00
committed by GitHub
parent 482b71e60b
commit 8cc2db7118
7 changed files with 16 additions and 22 deletions

View File

@@ -3,27 +3,22 @@ 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 {
key ID : UUID;
product : Association to Products;
quantity : Integer;
title : String; //> intentionally replicated as snapshot from product.title
price : Double; //> materialized calculated field
};
buyer : User;
currency : Currency;
}
entity Orders_Items {
key ID : UUID;
up_ : Association to Orders;
product : Association to Products;
quantity : Integer;
title : String; //> intentionally replicated as snapshot from product.title
price : Double;
}
/** This is a stand-in for arbitrary ordered Products */
entity Products @(cds.persistence.skip:'always') {
key ID : String;
}
// this is to ensure we have filled-in currencies
using from '@capire/common';