This commit is contained in:
Koch
2022-10-05 16:20:16 +02:00
parent 7af4e94b69
commit 76195703f4
7 changed files with 133 additions and 101 deletions

View File

@@ -1,24 +1,32 @@
using { Currency, User, managed, cuid } from '@sap/cds/common';
// using {Orders, OrderItems} from './schema';
namespace sap.capire.orders;
entity Orders : cuid, managed {
OrderNo : String @title:'Order Number'; //> readable key
Items : Composition of many {
entity Products {
key ID : String;
}
entity OrdersHeaders : managed {
key ID : UUID;
OrderNo : String @title:'Order Number'; //> readable key
buyer : User;
currency : Currency;
Items : Composition of many OrdersItems on Items.Header = $self;
}
entity OrdersItems {
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;
}
/** This is a stand-in for arbitrary ordered Products */
entity Products @(cds.persistence.skip:'always') {
key ID : String;
}
Header : Association to OrdersHeaders;
};
// this is to ensure we have filled-in currencies
using from '@capire/common';