diff --git a/common/currencies.cds b/common/currencies.cds new file mode 100644 index 00000000..2b85915b --- /dev/null +++ b/common/currencies.cds @@ -0,0 +1,13 @@ +using { sap } from '@sap/cds/common'; + +extend sap.common.Currencies with { + // Currencies.code = ISO 4217 alphabetic three-letter code + // with the first two letters being equal to ISO 3166 alphabetic country codes + // See also: + // [1] https://www.iso.org/iso-4217-currency-codes.html + // [2] https://www.currency-iso.org/en/home/tables/table-a1.html + // [3] https://www.ibm.com/support/knowledgecenter/en/SSZLC2_7.0.0/com.ibm.commerce.payments.developer.doc/refs/rpylerl2mst97.htm + numcode : Integer; + exponent : Integer; //> e.g. 2 --> 1 Dollar = 10^2 Cent + minor : String; //> e.g. 'Cent' +} diff --git a/common/index.cds b/common/index.cds index cb89e28d..74f9033c 100644 --- a/common/index.cds +++ b/common/index.cds @@ -1,45 +1,2 @@ -using { sap } from '@sap/cds/common'; - -extend sap.common.Currencies with { - // Currencies.code = ISO 4217 alphabetic three-letter code - // with the first two letters being equal to ISO 3166 alphabetic country codes - // See also: - // [1] https://www.iso.org/iso-4217-currency-codes.html - // [2] https://www.currency-iso.org/en/home/tables/table-a1.html - // [3] https://www.ibm.com/support/knowledgecenter/en/SSZLC2_7.0.0/com.ibm.commerce.payments.developer.doc/refs/rpylerl2mst97.htm - numcode : Integer; - exponent : Integer; //> e.g. 2 --> 1 Dollar = 10^2 Cent - minor : String; //> e.g. 'Cent' -} - - -/** - * The Code Lists below are designed as optional extensions to - * the base schema. Switch them on by adding an Association to - * one of the code list entities in your models or by: - * annotate sap.common.Countries with @cds.persistence.skip:false; - */ - -context sap.common.countries { - - extend sap.common.Countries { - regions : Composition of many Regions on regions._parent = $self.code; - } - - entity Regions : sap.common.CodeList { - key code : String(5); // ISO 3166-2 alpha5 codes, e.g. DE-BW - children : Composition of many Regions on children._parent = $self.code; - cities : Composition of many Cities on cities.region = $self; - _parent : String(11); - } - entity Cities : sap.common.CodeList { - key code : String(11); - region : Association to Regions; - districts : Composition of many Districts on districts.city = $self; - } - entity Districts : sap.common.CodeList { - key code : String(11); - city : Association to Cities; - } - -} +using from './currencies'; +using from './regions'; diff --git a/common/regions.cds b/common/regions.cds new file mode 100644 index 00000000..73e93755 --- /dev/null +++ b/common/regions.cds @@ -0,0 +1,22 @@ +using { sap.common } from '@sap/cds/common'; +namespace sap.common.countries; + +extend common.Countries { + regions : Composition of many Regions on regions._parent = $self.code; +} + +entity Regions : common.CodeList { + key code : String(5); // ISO 3166-2 alpha5 codes, e.g. DE-BW + children : Composition of many Regions on children._parent = $self.code; + cities : Composition of many Cities on cities.region = $self; + _parent : String(11); +} +entity Cities : common.CodeList { + key code : String(11); + region : Association to Regions; + districts : Composition of many Districts on districts.city = $self; +} +entity Districts : common.CodeList { + key code : String(11); + city : Association to Cities; +}