<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="STOR" 
Name="SHIPPING_CONTAINER" 
Description="Транспортная упаковка" 
PrimaryKey="ShippingContainerID" 
DNAttributes="{SSCC}" 
DisplayName="{0}">
  <Fields>
    <Attribute Name="ShippingContainerID" Type="guid" Description="Идентификатор" />
    <Attribute Name="SSCC" Type="string" Description="SSCC" CharacterMaximumLength="18" Required="1" />
    <Parent Name="SSCC_Parent" Type="STOR.SHIPPING_CONTAINER" Description="Родительский SSCC" />
    <Child Name="InvoiceItems" Type="STOR.INVOICE_ITEM" Description="Элемент медицинской накладной" ChildAttribute="SSCC" />
    <Child Name="ShippingContainers" Type="STOR.SHIPPING_CONTAINER" Description="Транспортная упаковка" ChildAttribute="SSCC_Parent" />
    <Parent Name="StorageInvoice" Type="STOR.STORAGE_INVOICE" Description="Медицинская накладная" Required="1" />
    <Parent Name="UnpackSSCCMarkMessage" Type="STOR.MARK_MESSAGE" Description="Сообщение в МДЛП(расформирование)" />
    <Parent Name="InfoSSCCMarkMessage" Type="STOR.MARK_MESSAGE" Description="Сообщение в МДЛП(структура SSCC)" />
    <Attribute Name="Price" Type="float" DefaultFormat="{0:F2}" Description="Цена" NumericPrecision="12" NumericScale="2" />
    <Attribute Name="Vat_Value" Type="float" DefaultFormat="{0:F2}" Description="Cумма НДС" NumericPrecision="12" NumericScale="2" />
    <Attribute Name="Serial" Type="string" Description="Серия" CharacterMaximumLength="20" />
    <Attribute Name="MarkCheck" Type="bool" Description="Проверен в маркировке" Required="1" />
    <Child Name="MarkMessages" Type="STOR.MARK_MESSAGE" Description="Сообщения в МДЛП" ChildAttribute="ShippingContainer" />
    <Parent Name="SupplierContract" Type="STOR.SUPPLIER_CONTRACT" Description="Договор от поставщика" />
    <Attribute Name="ExpirationDate" Type="date" Description="Срок годности" />
    <Attribute Name="LotNumber" Type="int" Description="Партия" />
    <Parent Name="BillOfGoods" Type="PHARM.BILL_OF_GOODS" Description="Номенклатура товаров" />
    <Parent Name="SupplierContractAbr" Type="STOR.SUPPLIER_CONTRACT_ABR" Description="Аббревиатура договора" CharacterMaximumLength="20" />
    <Attribute Name="Comment" Type="string" Description="Комментарий" />
    <Attribute Name="Error" Type="string" Description="Ошибка" />
    <Attribute Name="Recursive" Type="bool" Description="Рекурсивное расформирование" Required="1" />
    <Child Name="Remainss" Type="STOR.REMAINS" Description="Остатки на складе" ChildAttribute="ShippingContainer" />
    <Attribute Name="OrdinalNumber" Type="int" Description="Порядковый номер" Required="1" />
    <Attribute Name="Disbanded" Type="bool" Description="Расформирован" Required="1" />
  </Fields>
  <DbMapping>
    <Table name="T_SHIPPING_CONTAINER">
      <Map Name="ShippingContainerID" Column="ShippingContainerID" />
      <Map Name="SSCC" Column="SSCC" />
      <Map Name="SSCC_Parent" Column="SSCC_Parent" />
      <Map Name="StorageInvoice" Column="StorageInvoice" />
      <Map Name="UnpackSSCCMarkMessage" Function="stor.fn_GetUnpackMarkMessageForSSCC" IsStored="0" />
      <Map Name="Price" Column="Price" />
      <Map Name="Vat_Value" Column="Vat_Value" />
      <Map Name="Serial" Column="Serial" />
      <Map Name="MarkCheck" Column="MarkCheck" />
      <Map Name="SupplierContract" Column="SupplierContract" />
      <Map Name="ExpirationDate" Column="ExpirationDate" />
      <Map Name="LotNumber" Column="LotNumber" />
      <Map Name="BillOfGoods" Column="BillOfGoods" />
      <Map Name="SupplierContractAbr" Column="SupplierContractAbr" />
      <Map Name="Comment" Column="Comment" />
      <Map Name="Error" Column="Error" />
      <Map Name="Recursive" Column="Recursive" />
      <Map Name="OrdinalNumber" Column="OrdinalNumber" />
      <Map Name="Disbanded" Column="Disbanded" />
    </Table>
    <Lexem>
      <Map Name="InfoSSCCMarkMessage" PathAttributes="{MarkMessages}">
        <lx:ChildCount xmlns:lx="lexem">
          <condition>
            <lx:Criteria type="And">
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="MessageType" />
                </lx:Path>
                <lx:ChoiceOperand Entity="STOR.MARK_MESSAGE" AttributeName="MessageType" type="Int32" PrimaryKey="0" />
              </lx:Criterion>
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="Status" />
                </lx:Path>
                <lx:ChoiceOperand Entity="STOR.MARK_MESSAGE" AttributeName="Status" type="Int32" PrimaryKey="1" />
              </lx:Criterion>
              <lx:Criteria type="Or">
                <lx:Criterion type="=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="Schema" />
                    <lx:StepString name="Code" />
                  </lx:Path>
                  <lx:ConstOperand type="Int32">210</lx:ConstOperand>
                </lx:Criterion>
                <lx:Criterion type="=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="Schema" />
                    <lx:StepString name="Code" />
                  </lx:Path>
                  <lx:ConstOperand type="Int32">220</lx:ConstOperand>
                </lx:Criterion>
              </lx:Criteria>
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="ObjId" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepString name="ShippingContainerID" />
                </lx:Path>
              </lx:Criterion>
            </lx:Criteria>
          </condition>
          <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="MarkMessages" />
          </lx:Path>
          <lx:First>
            <lx:Path OwnerQueryLevel="0">
              <lx:StepCurrent />
            </lx:Path>
          </lx:First>
          <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="SendDateTime" />
          </lx:Path>
          <lx:ConstOperand type="String"><![CDATA[asc]]></lx:ConstOperand>
        </lx:ChildCount>
      </Map>
    </Lexem>
  </DbMapping>
  <CalculatingAttributes>
    <Choice Name="VAT" Description="НДС" RequiredAttributes="{Vat_Value};{Price}">
      <Item Name="Без НДС" Index="0" />
      <Item Name="10%" Index="1" />
      <Item Name="18%" Index="2" />
      <Item Name="20%" Index="3" />
    </Choice>
  </CalculatingAttributes>
</Entity>