<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
  <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.xml">
    <edmx:Include Alias="Core" Namespace="Org.OData.Core.V1"/>
  </edmx:Reference>
  <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Capabilities.V1.xml">
    <edmx:Include Alias="Capabilities" Namespace="Org.OData.Capabilities.V1"/>
  </edmx:Reference>
  <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Aggregation.V1.xml">
    <edmx:Include Alias="Aggregation" Namespace="Org.OData.Aggregation.V1"/>
  </edmx:Reference>
  <edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.xml">
    <edmx:Include Alias="Measures" Namespace="Org.OData.Measures.V1"/>
  </edmx:Reference>
  <edmx:Reference Uri="https://sap.github.io/odata-vocabularies/vocabularies/Common.xml">
    <edmx:Include Alias="Common" Namespace="com.sap.vocabularies.Common.v1"/>
  </edmx:Reference>
  <edmx:Reference Uri="https://sap.github.io/odata-vocabularies/vocabularies/Communication.xml">
    <edmx:Include Alias="Communication" Namespace="com.sap.vocabularies.Communication.v1"/>
  </edmx:Reference>
  <edmx:Reference Uri="https://sap.github.io/odata-vocabularies/vocabularies/UI.xml">
    <edmx:Include Alias="UI" Namespace="com.sap.vocabularies.UI.v1"/>
  </edmx:Reference>
  <edmx:DataServices>
    <Schema Namespace="Roastery" xmlns="http://docs.oasis-open.org/odata/ns/edm">

      <!-- ── Entity sets ─────────────────────────────────────────────────────────────────────── -->

      <EntityContainer Name="EntityContainer">
        <EntitySet Name="Coffees" EntityType="Roastery.Coffee">
          <Annotation Term="Core.OptimisticConcurrency">
            <Collection><PropertyPath>modifiedAt</PropertyPath></Collection>
          </Annotation>
          <Annotation Term="Capabilities.SearchRestrictions">
            <Record><PropertyValue Property="Searchable" Bool="true"/></Record>
          </Annotation>
          <Annotation Term="Capabilities.SortRestrictions">
            <Record>
              <PropertyValue Property="NonSortableProperties">
                <Collection><PropertyPath>notes</PropertyPath></Collection>
              </PropertyValue>
            </Record>
          </Annotation>
          <Annotation Term="Aggregation.ApplySupported">
            <Record>
              <PropertyValue Property="Transformations">
                <Collection><String>filter</String><String>groupby</String><String>aggregate</String></Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </EntitySet>

        <EntitySet Name="Cafes" EntityType="Roastery.Cafe">
          <Annotation Term="Core.OptimisticConcurrency">
            <Collection><PropertyPath>modifiedAt</PropertyPath></Collection>
          </Annotation>
          <Annotation Term="Capabilities.SearchRestrictions">
            <Record><PropertyValue Property="Searchable" Bool="true"/></Record>
          </Annotation>
        </EntitySet>

        <!-- Orders are cancelled, never deleted. -->
        <EntitySet Name="Orders" EntityType="Roastery.Order">
          <NavigationPropertyBinding Path="items" Target="OrderItems"/>
          <NavigationPropertyBinding Path="cafe" Target="Cafes"/>
          <Annotation Term="Core.OptimisticConcurrency">
            <Collection><PropertyPath>modifiedAt</PropertyPath></Collection>
          </Annotation>
          <Annotation Term="Capabilities.SearchRestrictions">
            <Record><PropertyValue Property="Searchable" Bool="true"/></Record>
          </Annotation>
          <Annotation Term="Capabilities.DeleteRestrictions">
            <Record><PropertyValue Property="Deletable" Bool="false"/></Record>
          </Annotation>
          <Annotation Term="Aggregation.ApplySupported">
            <Record>
              <PropertyValue Property="Transformations">
                <Collection><String>filter</String><String>groupby</String><String>aggregate</String></Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </EntitySet>

        <EntitySet Name="OrderItems" EntityType="Roastery.OrderItem">
          <NavigationPropertyBinding Path="order" Target="Orders"/>
          <NavigationPropertyBinding Path="coffee" Target="Coffees"/>
          <Annotation Term="Core.OptimisticConcurrency">
            <Collection><PropertyPath>modifiedAt</PropertyPath></Collection>
          </Annotation>
          <Annotation Term="Capabilities.SearchRestrictions">
            <Record><PropertyValue Property="Searchable" Bool="false"/></Record>
          </Annotation>
          <Annotation Term="Aggregation.ApplySupported">
            <Record>
              <PropertyValue Property="Transformations">
                <Collection><String>filter</String><String>groupby</String><String>aggregate</String></Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </EntitySet>

        <!-- Code lists: read-only. -->
        <EntitySet Name="Countries" EntityType="Roastery.Country">
          <Annotation Term="Capabilities.InsertRestrictions"><Record><PropertyValue Property="Insertable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.UpdateRestrictions"><Record><PropertyValue Property="Updatable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.DeleteRestrictions"><Record><PropertyValue Property="Deletable" Bool="false"/></Record></Annotation>
        </EntitySet>
        <EntitySet Name="Regions" EntityType="Roastery.Region">
          <Annotation Term="Capabilities.SearchRestrictions"><Record><PropertyValue Property="Searchable" Bool="true"/></Record></Annotation>
          <Annotation Term="Capabilities.InsertRestrictions"><Record><PropertyValue Property="Insertable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.UpdateRestrictions"><Record><PropertyValue Property="Updatable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.DeleteRestrictions"><Record><PropertyValue Property="Deletable" Bool="false"/></Record></Annotation>
        </EntitySet>
        <EntitySet Name="Processes" EntityType="Roastery.Process">
          <Annotation Term="Capabilities.InsertRestrictions"><Record><PropertyValue Property="Insertable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.UpdateRestrictions"><Record><PropertyValue Property="Updatable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.DeleteRestrictions"><Record><PropertyValue Property="Deletable" Bool="false"/></Record></Annotation>
        </EntitySet>
        <EntitySet Name="OrderStatuses" EntityType="Roastery.OrderStatus">
          <Annotation Term="Capabilities.InsertRestrictions"><Record><PropertyValue Property="Insertable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.UpdateRestrictions"><Record><PropertyValue Property="Updatable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.DeleteRestrictions"><Record><PropertyValue Property="Deletable" Bool="false"/></Record></Annotation>
        </EntitySet>
        <EntitySet Name="Currencies" EntityType="Roastery.Currency">
          <Annotation Term="Capabilities.InsertRestrictions"><Record><PropertyValue Property="Insertable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.UpdateRestrictions"><Record><PropertyValue Property="Updatable" Bool="false"/></Record></Annotation>
          <Annotation Term="Capabilities.DeleteRestrictions"><Record><PropertyValue Property="Deletable" Bool="false"/></Record></Annotation>
        </EntitySet>

        <ActionImport Name="receiveBeans" Action="Roastery.receiveBeans" EntitySet="Coffees"/>
        <FunctionImport Name="bestsellers" Function="Roastery.bestsellers" EntitySet="Coffees"/>
      </EntityContainer>

      <!-- ── Coffee ──────────────────────────────────────────────────────────────────────────── -->

      <EntityType Name="Coffee">
        <Annotation Term="Common.Label" String="Coffee"/>
        <Key><PropertyRef Name="ID"/></Key>
        <Property Name="ID" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Coffee"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="Common.Text" Path="name">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextFirst"/>
          </Annotation>
        </Property>
        <Property Name="name" Type="Edm.String" MaxLength="60" Nullable="false">
          <Annotation Term="Common.Label" String="Name"/>
        </Property>
        <!-- Producing countries only: a constant narrows the list. -->
        <Property Name="origin_code" Type="Edm.String" MaxLength="2" Nullable="false">
          <Annotation Term="Common.Label" String="Origin"/>
          <Annotation Term="Common.Text" Path="originName">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextLast"/>
          </Annotation>
          <Annotation Term="Common.ValueListWithFixedValues"/>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="Label" String="Origins"/>
              <PropertyValue Property="CollectionPath" String="Countries"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterConstant">
                    <PropertyValue Property="ValueListProperty" String="isOrigin"/>
                    <PropertyValue Property="Constant" String="true"/>
                  </Record>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="origin_code"/>
                    <PropertyValue Property="ValueListProperty" String="code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="originName"/>
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="originName" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="Origin name"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <!-- The regions of the coffee's origin only: an In parameter narrows the list. -->
        <Property Name="region_code" Type="Edm.String" MaxLength="10">
          <Annotation Term="Common.Label" String="Region"/>
          <Annotation Term="Common.Text" Path="regionName">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextOnly"/>
          </Annotation>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="Label" String="Regions"/>
              <PropertyValue Property="CollectionPath" String="Regions"/>
              <PropertyValue Property="SearchSupported" Bool="true"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterIn">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="origin_code"/>
                    <PropertyValue Property="ValueListProperty" String="country_code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="region_code"/>
                    <PropertyValue Property="ValueListProperty" String="code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="regionName"/>
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                  <Record Type="Common.ValueListParameterDisplayOnly">
                    <PropertyValue Property="ValueListProperty" String="altitude"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="regionName" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="Region name"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="process_code" Type="Edm.String" MaxLength="1" Nullable="false">
          <Annotation Term="Common.Label" String="Process"/>
          <Annotation Term="Common.Text" Path="processName">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextOnly"/>
          </Annotation>
          <Annotation Term="Common.ValueListWithFixedValues"/>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="Label" String="Processes"/>
              <PropertyValue Property="CollectionPath" String="Processes"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="process_code"/>
                    <PropertyValue Property="ValueListProperty" String="code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="processName"/>
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="processName" Type="Edm.String" MaxLength="20">
          <Annotation Term="Common.Label" String="Process name"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="roastLevel" Type="Edm.Int32">
          <Annotation Term="Common.Label" String="Roast"/>
        </Property>
        <Property Name="score" Type="Edm.Decimal" Precision="3" Scale="1">
          <Annotation Term="Common.Label" String="Cup score"/>
        </Property>
        <Property Name="notes" Type="Edm.String" MaxLength="120">
          <Annotation Term="Common.Label" String="Tasting notes"/>
          <Annotation Term="UI.MultiLineText"/>
        </Property>
        <Property Name="price" Type="Edm.Decimal" Precision="9" Scale="2" Nullable="false">
          <Annotation Term="Common.Label" String="Price per kg"/>
          <Annotation Term="Measures.ISOCurrency" Path="currency_code"/>
        </Property>
        <Property Name="costPrice" Type="Edm.Decimal" Precision="9" Scale="2" Nullable="false">
          <Annotation Term="Common.Label" String="Cost per kg"/>
          <Annotation Term="Measures.ISOCurrency" Path="currency_code"/>
        </Property>
        <!-- The roaster sells in EUR. -->
        <Property Name="currency_code" Type="Edm.String" MaxLength="3">
          <Annotation Term="Common.Label" String="Currency"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="Common.ValueListWithFixedValues"/>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="CollectionPath" String="Currencies"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="currency_code"/>
                    <PropertyValue Property="ValueListProperty" String="code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterDisplayOnly">
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="stockKg" Type="Edm.Int32">
          <Annotation Term="Common.Label" String="Stock (kg)"/>
        </Property>
        <Property Name="active" Type="Edm.Boolean">
          <Annotation Term="Common.Label" String="On sale"/>
        </Property>
        <Property Name="modifiedAt" Type="Edm.DateTimeOffset" Precision="3">
          <Annotation Term="Common.Label" String="Changed at"/>
          <Annotation Term="Core.Computed"/>
        </Property>
      </EntityType>

      <!-- ── Cafe ────────────────────────────────────────────────────────────────────────────── -->

      <EntityType Name="Cafe">
        <Annotation Term="Common.Label" String="Café"/>
        <Key><PropertyRef Name="ID"/></Key>
        <Property Name="ID" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Café"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="Common.Text" Path="name">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextFirst"/>
          </Annotation>
        </Property>
        <Property Name="name" Type="Edm.String" MaxLength="60" Nullable="false">
          <Annotation Term="Common.Label" String="Name"/>
        </Property>
        <!-- The countries the roaster ships to. -->
        <Property Name="country_code" Type="Edm.String" MaxLength="2" Nullable="false">
          <Annotation Term="Common.Label" String="Country"/>
          <Annotation Term="Common.Text" Path="countryName">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextLast"/>
          </Annotation>
          <Annotation Term="Common.ValueListWithFixedValues"/>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="Label" String="Countries"/>
              <PropertyValue Property="CollectionPath" String="Countries"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterConstant">
                    <PropertyValue Property="ValueListProperty" String="isMarket"/>
                    <PropertyValue Property="Constant" String="true"/>
                  </Record>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="country_code"/>
                    <PropertyValue Property="ValueListProperty" String="code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="countryName"/>
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="countryName" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="Country name"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="city" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="City"/>
        </Property>
        <Property Name="email" Type="Edm.String" MaxLength="80">
          <Annotation Term="Common.Label" String="E-mail"/>
          <Annotation Term="Communication.IsEmailAddress"/>
        </Property>
        <Property Name="modifiedAt" Type="Edm.DateTimeOffset" Precision="3">
          <Annotation Term="Common.Label" String="Changed at"/>
          <Annotation Term="Core.Computed"/>
        </Property>
      </EntityType>

      <!-- ── Order ───────────────────────────────────────────────────────────────────────────── -->

      <EntityType Name="Order">
        <Annotation Term="Common.Label" String="Order"/>
        <Key><PropertyRef Name="ID"/></Key>
        <Property Name="ID" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Order"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="country_code" Type="Edm.String" MaxLength="2" Nullable="false">
          <Annotation Term="Common.Label" String="Ship-to country"/>
          <Annotation Term="Common.Text" Path="countryName">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextLast"/>
          </Annotation>
          <Annotation Term="Common.ValueListWithFixedValues"/>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="Label" String="Countries"/>
              <PropertyValue Property="CollectionPath" String="Countries"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterConstant">
                    <PropertyValue Property="ValueListProperty" String="isMarket"/>
                    <PropertyValue Property="Constant" String="true"/>
                  </Record>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="country_code"/>
                    <PropertyValue Property="ValueListProperty" String="code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="countryName"/>
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="countryName" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="Country name"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <!-- The cafés of the ship-to country only; a pick fills the café's name and city. -->
        <Property Name="cafe_ID" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Café"/>
          <Annotation Term="Common.Text" Path="cafeName">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextFirst"/>
          </Annotation>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="Label" String="Cafés"/>
              <PropertyValue Property="CollectionPath" String="Cafes"/>
              <PropertyValue Property="SearchSupported" Bool="true"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterIn">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="country_code"/>
                    <PropertyValue Property="ValueListProperty" String="country_code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="cafe_ID"/>
                    <PropertyValue Property="ValueListProperty" String="ID"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="cafeName"/>
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="city"/>
                    <PropertyValue Property="ValueListProperty" String="city"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="cafeName" Type="Edm.String" MaxLength="60">
          <Annotation Term="Common.Label" String="Café name"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="city" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="Ship-to city"/>
        </Property>
        <Property Name="orderDate" Type="Edm.Date">
          <Annotation Term="Common.Label" String="Ordered on"/>
        </Property>
        <Property Name="deliveryDate" Type="Edm.Date">
          <Annotation Term="Common.Label" String="Deliver by"/>
        </Property>
        <Property Name="orderMonth" Type="Edm.String" MaxLength="7">
          <Annotation Term="Common.Label" String="Month"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="status_code" Type="Edm.String" MaxLength="1">
          <Annotation Term="Common.Label" String="Status"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="Common.Text" Path="statusName">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextOnly"/>
          </Annotation>
          <Annotation Term="Common.ValueListWithFixedValues"/>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="Label" String="Statuses"/>
              <PropertyValue Property="CollectionPath" String="OrderStatuses"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="status_code"/>
                    <PropertyValue Property="ValueListProperty" String="code"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="statusName"/>
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="statusName" Type="Edm.String" MaxLength="20">
          <Annotation Term="Common.Label" String="Status name"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="total" Type="Edm.Decimal" Precision="11" Scale="2">
          <Annotation Term="Common.Label" String="Total"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="Measures.ISOCurrency" Path="currency_code"/>
        </Property>
        <Property Name="currency_code" Type="Edm.String" MaxLength="3">
          <Annotation Term="Common.Label" String="Currency"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="note" Type="Edm.String" MaxLength="200">
          <Annotation Term="Common.Label" String="Note"/>
        </Property>
        <!-- What the order's actions are available on (Core.OperationAvailable). -->
        <Property Name="canConfirm" Type="Edm.Boolean">
          <Annotation Term="Common.Label" String="Can be confirmed"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="UI.Hidden"/>
        </Property>
        <Property Name="canShip" Type="Edm.Boolean">
          <Annotation Term="Common.Label" String="Can be shipped"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="UI.Hidden"/>
        </Property>
        <Property Name="canCancel" Type="Edm.Boolean">
          <Annotation Term="Common.Label" String="Can be cancelled"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="UI.Hidden"/>
        </Property>
        <Property Name="modifiedAt" Type="Edm.DateTimeOffset" Precision="3">
          <Annotation Term="Common.Label" String="Changed at"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <NavigationProperty Name="items" Type="Collection(Roastery.OrderItem)" Partner="order">
          <Annotation Term="Common.Label" String="Items"/>
        </NavigationProperty>
        <NavigationProperty Name="cafe" Type="Roastery.Cafe">
          <Annotation Term="Common.Label" String="Café"/>
          <ReferentialConstraint Property="cafe_ID" ReferencedProperty="ID"/>
        </NavigationProperty>
      </EntityType>

      <!-- ── OrderItem ───────────────────────────────────────────────────────────────────────── -->

      <EntityType Name="OrderItem">
        <Annotation Term="Common.Label" String="Order item"/>
        <Key><PropertyRef Name="ID"/></Key>
        <Property Name="ID" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Item"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="order_ID" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Order"/>
        </Property>
        <!-- Coffees on sale only; a pick fills the name and the price per kg. -->
        <Property Name="coffee_ID" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Coffee"/>
          <Annotation Term="Common.Text" Path="coffeeName">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextFirst"/>
          </Annotation>
          <Annotation Term="Common.ValueList">
            <Record>
              <PropertyValue Property="Label" String="Coffees on sale"/>
              <PropertyValue Property="CollectionPath" String="Coffees"/>
              <PropertyValue Property="SearchSupported" Bool="true"/>
              <PropertyValue Property="Parameters">
                <Collection>
                  <Record Type="Common.ValueListParameterConstant">
                    <PropertyValue Property="ValueListProperty" String="active"/>
                    <PropertyValue Property="Constant" String="true"/>
                  </Record>
                  <Record Type="Common.ValueListParameterInOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="coffee_ID"/>
                    <PropertyValue Property="ValueListProperty" String="ID"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="coffeeName"/>
                    <PropertyValue Property="ValueListProperty" String="name"/>
                  </Record>
                  <Record Type="Common.ValueListParameterOut">
                    <PropertyValue Property="LocalDataProperty" PropertyPath="unitPrice"/>
                    <PropertyValue Property="ValueListProperty" String="price"/>
                  </Record>
                  <Record Type="Common.ValueListParameterDisplayOnly">
                    <PropertyValue Property="ValueListProperty" String="originName"/>
                  </Record>
                  <Record Type="Common.ValueListParameterDisplayOnly">
                    <PropertyValue Property="ValueListProperty" String="stockKg"/>
                  </Record>
                </Collection>
              </PropertyValue>
            </Record>
          </Annotation>
        </Property>
        <Property Name="coffeeName" Type="Edm.String" MaxLength="60">
          <Annotation Term="Common.Label" String="Coffee name"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="quantityKg" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Quantity (kg)"/>
        </Property>
        <!-- The coffee's price when not sent. -->
        <Property Name="unitPrice" Type="Edm.Decimal" Precision="9" Scale="2">
          <Annotation Term="Common.Label" String="Price per kg"/>
          <Annotation Term="Measures.ISOCurrency" Path="currency_code"/>
        </Property>
        <Property Name="amount" Type="Edm.Decimal" Precision="11" Scale="2">
          <Annotation Term="Common.Label" String="Amount"/>
          <Annotation Term="Core.Computed"/>
          <Annotation Term="Measures.ISOCurrency" Path="currency_code"/>
        </Property>
        <Property Name="currency_code" Type="Edm.String" MaxLength="3">
          <Annotation Term="Common.Label" String="Currency"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <Property Name="modifiedAt" Type="Edm.DateTimeOffset" Precision="3">
          <Annotation Term="Common.Label" String="Changed at"/>
          <Annotation Term="Core.Computed"/>
        </Property>
        <NavigationProperty Name="order" Type="Roastery.Order" Partner="items">
          <Annotation Term="Common.Label" String="Order"/>
          <ReferentialConstraint Property="order_ID" ReferencedProperty="ID"/>
        </NavigationProperty>
        <NavigationProperty Name="coffee" Type="Roastery.Coffee">
          <Annotation Term="Common.Label" String="Coffee"/>
          <ReferentialConstraint Property="coffee_ID" ReferencedProperty="ID"/>
        </NavigationProperty>
      </EntityType>

      <!-- ── Code lists ──────────────────────────────────────────────────────────────────────── -->

      <EntityType Name="Country">
        <Annotation Term="Common.Label" String="Country"/>
        <Key><PropertyRef Name="code"/></Key>
        <Property Name="code" Type="Edm.String" MaxLength="2" Nullable="false">
          <Annotation Term="Common.Label" String="Country"/>
          <Annotation Term="Common.IsUpperCase"/>
          <Annotation Term="Common.Text" Path="name">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextLast"/>
          </Annotation>
        </Property>
        <Property Name="name" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="Country name"/>
        </Property>
        <Property Name="isOrigin" Type="Edm.Boolean">
          <Annotation Term="Common.Label" String="Grows coffee"/>
        </Property>
        <Property Name="isMarket" Type="Edm.Boolean">
          <Annotation Term="Common.Label" String="Ships here"/>
        </Property>
      </EntityType>

      <EntityType Name="Region">
        <Annotation Term="Common.Label" String="Region"/>
        <Key><PropertyRef Name="code"/></Key>
        <Property Name="code" Type="Edm.String" MaxLength="10" Nullable="false">
          <Annotation Term="Common.Label" String="Region"/>
          <Annotation Term="Common.Text" Path="name">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextOnly"/>
          </Annotation>
        </Property>
        <Property Name="name" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="Region name"/>
        </Property>
        <Property Name="country_code" Type="Edm.String" MaxLength="2">
          <Annotation Term="Common.Label" String="Country"/>
        </Property>
        <Property Name="altitude" Type="Edm.String" MaxLength="20">
          <Annotation Term="Common.Label" String="Altitude"/>
        </Property>
      </EntityType>

      <EntityType Name="Process">
        <Annotation Term="Common.Label" String="Process"/>
        <Key><PropertyRef Name="code"/></Key>
        <Property Name="code" Type="Edm.String" MaxLength="1" Nullable="false">
          <Annotation Term="Common.Label" String="Process"/>
          <Annotation Term="Common.Text" Path="name">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextOnly"/>
          </Annotation>
        </Property>
        <Property Name="name" Type="Edm.String" MaxLength="20">
          <Annotation Term="Common.Label" String="Process name"/>
        </Property>
      </EntityType>

      <EntityType Name="OrderStatus">
        <Annotation Term="Common.Label" String="Order status"/>
        <Key><PropertyRef Name="code"/></Key>
        <Property Name="code" Type="Edm.String" MaxLength="1" Nullable="false">
          <Annotation Term="Common.Label" String="Status"/>
          <Annotation Term="Common.Text" Path="name">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextOnly"/>
          </Annotation>
        </Property>
        <Property Name="name" Type="Edm.String" MaxLength="20">
          <Annotation Term="Common.Label" String="Status name"/>
        </Property>
      </EntityType>

      <EntityType Name="Currency">
        <Annotation Term="Common.Label" String="Currency"/>
        <Key><PropertyRef Name="code"/></Key>
        <Property Name="code" Type="Edm.String" MaxLength="3" Nullable="false">
          <Annotation Term="Common.Label" String="Currency"/>
          <Annotation Term="Common.Text" Path="name">
            <Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextLast"/>
          </Annotation>
        </Property>
        <Property Name="name" Type="Edm.String" MaxLength="40">
          <Annotation Term="Common.Label" String="Currency name"/>
        </Property>
      </EntityType>

      <!-- ── Operations ──────────────────────────────────────────────────────────────────────── -->

      <!-- Bound action: takes a coffee off sale. -->
      <Action Name="retire" IsBound="true" EntitySetPath="_it">
        <Parameter Name="_it" Type="Roastery.Coffee" Nullable="false"/>
        <Parameter Name="reason" Type="Edm.String" MaxLength="80">
          <Annotation Term="Common.Label" String="Reason"/>
        </Parameter>
        <ReturnType Type="Roastery.Coffee"/>
        <Annotation Term="Common.Label" String="Retire"/>
        <Annotation Term="Core.OperationAvailable" Path="_it/active"/>
      </Action>

      <!-- Bound function: what the coffee in stock cost. -->
      <Function Name="stockValue" IsBound="true" IsComposable="false">
        <Parameter Name="_it" Type="Roastery.Coffee" Nullable="false"/>
        <ReturnType Type="Edm.Decimal" Precision="11" Scale="2"/>
        <Annotation Term="Common.Label" String="Stock value"/>
      </Function>

      <!-- Collection-bound action: changes the price of every coffee on sale; returns how many. -->
      <Action Name="reprice" IsBound="true">
        <Parameter Name="_it" Type="Collection(Roastery.Coffee)" Nullable="false"/>
        <Parameter Name="percent" Type="Edm.Decimal" Precision="5" Scale="2" Nullable="false">
          <Annotation Term="Common.Label" String="Change (%)"/>
        </Parameter>
        <ReturnType Type="Edm.Int32"/>
        <Annotation Term="Common.Label" String="Reprice all"/>
      </Action>

      <!-- Bound actions of an order: New → Confirmed → Shipped; New or Confirmed → Cancelled. -->
      <Action Name="confirm" IsBound="true" EntitySetPath="_it">
        <Parameter Name="_it" Type="Roastery.Order" Nullable="false"/>
        <ReturnType Type="Roastery.Order"/>
        <Annotation Term="Common.Label" String="Confirm"/>
        <Annotation Term="Core.OperationAvailable" Path="_it/canConfirm"/>
      </Action>
      <Action Name="ship" IsBound="true" EntitySetPath="_it">
        <Parameter Name="_it" Type="Roastery.Order" Nullable="false"/>
        <ReturnType Type="Roastery.Order"/>
        <Annotation Term="Common.Label" String="Ship"/>
        <Annotation Term="Core.OperationAvailable" Path="_it/canShip"/>
      </Action>
      <Action Name="cancel" IsBound="true" EntitySetPath="_it">
        <Parameter Name="_it" Type="Roastery.Order" Nullable="false"/>
        <Parameter Name="reason" Type="Edm.String" MaxLength="80">
          <Annotation Term="Common.Label" String="Reason"/>
        </Parameter>
        <ReturnType Type="Roastery.Order"/>
        <Annotation Term="Common.Label" String="Cancel order"/>
        <Annotation Term="Core.OperationAvailable" Path="_it/canCancel"/>
      </Action>

      <!-- Unbound action (an action import): beans arrive at the warehouse. -->
      <Action Name="receiveBeans" IsBound="false">
        <Parameter Name="coffee" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Coffee"/>
        </Parameter>
        <Parameter Name="kg" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Kilograms"/>
        </Parameter>
        <ReturnType Type="Roastery.Coffee"/>
        <Annotation Term="Common.Label" String="Receive beans"/>
      </Action>

      <!-- Unbound function (a function import): the coffees ordered most, by kg. -->
      <Function Name="bestsellers" IsBound="false" IsComposable="false">
        <Parameter Name="weeks" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="Weeks"/>
        </Parameter>
        <Parameter Name="count" Type="Edm.Int32" Nullable="false">
          <Annotation Term="Common.Label" String="How many"/>
        </Parameter>
        <ReturnType Type="Collection(Roastery.Coffee)"/>
        <Annotation Term="Common.Label" String="Bestsellers"/>
      </Function>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>
