<?xml version="1.0" encoding="utf-8"?>
<Entity 
Schema="STOR" 
Name="STORAGE_INVOICE" 
Description="Медицинская накладная" 
PrimaryKey="InvoiceID" 
DNAttributes="{Number};{Date}" 
DisplayName="Накладная №{0} от {1}">
  <Fields>
    <Attribute Name="InvoiceID" Index="19080001" Type="guid" Description="Идентификатор" />
    <Attribute Name="Number" Index="19080002" Type="string" Description="Номер" Required="1" />
    <Attribute Name="Date" Index="19080003" Type="date" Description="Дата" Required="1" />
    <Attribute Name="CreateDate" Index="19080011" Type="datetime" DefaultFormat="{0:dd.MM.yyyy HH:mm}" Description="Дата и время создания" />
    <Attribute Name="HoldingDate" Index="19080014" Type="datetime" DefaultFormat="{0:dd.MM.yyyy HH:mm}" Description="Дата проведения накладной" />
    <Attribute Name="TotalAmount" Index="19080021" Type="float" DefaultFormat="{0:F3}" Description="Итоговое количество" NumericPrecision="12" NumericScale="2" />
    <Attribute Name="TotalSum" Index="19080022" Type="float" DefaultFormat="{0:F2}" Description="Итоговая сумма" NumericPrecision="12" NumericScale="2" />
    <Attribute Name="Comment" Index="19080023" Type="string" Description="Комментарий" CharacterMaximumLength="8000" />
    <Attribute Name="Loaded" Index="19080024" Type="bool" Description="Загружена" Required="1" />
    <Parent Name="Storage" Index="19080009" Type="STOR.STORAGE" Description="Склад" Required="1" />
    <Parent Name="Creator" Index="19080010" Type="VCLib.BASE_USERS" Description="Создатель" />
    <Parent Name="HoldingUser" Index="19080012" Type="VCLib.BASE_USERS" Description="Пользователь сделавший проводку" />
    <Parent Name="ResponsiblePerson" Index="19080016" Type="STOR.POST" Description="Материально ответственное лицо" Required="1" />
    <Parent Name="PaymentType" Index="19080017" Type="STOR.PAYMENT_TYPE" Description="Источник финансирования" />
    <Parent Name="InventoryDocument" Index="19080019" Type="STOR.INVENTORY_DOCUMENT" Description="Документ инвентаризации" />
    <Child Name="InvoiceItems" Index="19080007" Type="STOR.INVOICE_ITEM" Description="Элемент накладной" ChildAttribute="StorageInvoice" Required="1" />
    <Child Name="DefectStorageInvoices" Index="19080018" Type="STOR.DEFECT_STORAGE_INVOICE" Description="Дефектные накладные" ChildAttribute="StorageInvoice" />
    <Choice Name="State" Index="19080008" Description="Состояние" Required="1">
      <Item Name="Не проведена" Index="0" />
      <Item Name="Проведена" Index="1" />
    </Choice>
    <Child Name="MarkMessages" Type="STOR.MARK_MESSAGE" Description="Отправка сообщений с систему Маркировка" ChildAttribute="StorageInvoice" />
    <Parent Name="SupplierContract" Type="STOR.SUPPLIER_CONTRACT" Description="Договор от поставщика" />
    <Parent Name="MarkSchemes" Type="STOR.MARK_SCHEMES" Description="Схемы работы с маркировкой" />
    <Parent Name="OutMarkMessage" Type="STOR.MARK_MESSAGE" Description="Исходящее сообщение в МДЛП" />
    <Parent Name="IncMarkMessage" Type="STOR.MARK_MESSAGE" Description="Входящее сообщение из МДЛП" />
    <Child Name="GroupedInvoiceItems" Type="STOR.GROUPED_INVOICE_ITEM" Description="Группированные элементы накладной" ChildAttribute="StorageInvoice" />
    <Attribute Name="ShipmentDate" Type="date" Description="Дата документа отгрузки" />
    <Attribute Name="ShipmentDocumentNumber" Type="string" Description="Номер документа отгрузки" CharacterMaximumLength="200" />
    <Parent Name="RegistratorMessage" Type="STOR.REGISTRATOR_MESSAGE" Description="Сообщения отправленые в регистратор выбытия" />
    <Parent Name="UnpackSSCCMarkMessage" Type="STOR.MARK_MESSAGE" Description="Сообщения в МДЛП(расформирование)" />
    <Child Name="ShippingContainers" Type="STOR.SHIPPING_CONTAINER" Description="Транспортная упаковка" ChildAttribute="StorageInvoice" />
    <Attribute Name="Mark" Type="bool" Description="Содержит маркированные элементы" />
    <Child Name="Sgtinss" Type="STOR.SGTINS" Description="Уникальная идентификационная кодовая информация вторичной потребительской упаковки" ChildAttribute="StorageInvoice" />
    <Parent Name="StorageApplication" Type="STOR.STORAGE_APPLICATION" Description="Заявка от склада" />
    <Choice Name="MdlpPaymentType" Description="Источник финансирования МДЛП">
      <Item Name="собственные средства" Index="1" />
      <Item Name="средства федерального бюджета" Index="2" />
      <Item Name="средства регионального бюджета" Index="3" />
      <Item Name="средства бюджетов внебюджетных фондов" Index="4" />
      <Item Name="смешенные средства бюджета" Index="5" />
    </Choice>
    <Child Name="RegistratorMessages" Type="STOR.REGISTRATOR_MESSAGE" Description="Сообщения отправленые в регистратор выбытия" ChildAttribute="Invoice" />
    <Link Name="Payment" Type="STOR.PAYMENT" Description="Квитанция оплаты" LinkAttribute="StorageInvoice" />
    <Attribute Name="TotalSellingSum" Type="float" Description="Итоговая сумма продажи" Required="1" />
  </Fields>
  <DbMapping>
    <Table name="T_STORAGE_INVOICE">
      <Map Name="InvoiceID" Column="InvoiceID" />
      <Map Name="Number" Column="Number" />
      <Map Name="Date" Column="Date" />
      <Map Name="CreateDate" Column="CreateDate" />
      <Map Name="HoldingDate" Column="HoldingDate" />
      <Map Name="Comment" Column="Comment" />
      <Map Name="Loaded" Column="Loaded" />
      <Map Name="Storage" Column="Storage" />
      <Map Name="Creator" Column="Creator" />
      <Map Name="HoldingUser" Column="HoldingUser" />
      <Map Name="ResponsiblePerson" Column="ResponsiblePerson" />
      <Map Name="PaymentType" Column="PaymentType" />
      <Map Name="InventoryDocument" Column="InventoryDocument" />
      <Map Name="State" Column="State" />
      <Map Name="SupplierContract" Column="SupplierContract" />
      <Map Name="MarkSchemes" Column="MarkSchemes" />
      <Map Name="ShipmentDate" Column="ShipmentDate" />
      <Map Name="ShipmentDocumentNumber" Column="ShipmentDocumentNumber" />
      <Map Name="StorageApplication" Column="StorageApplication" />
    </Table>
    <Lexem>
      <Map Name="TotalAmount">
        <lx:IsNull xmlns:lx="lexem">
          <lx:ChildCount>
            <condition />
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="InvoiceItems" />
            </lx:Path>
            <lx:Sum>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="QuantityInPackage" />
              </lx:Path>
            </lx:Sum>
          </lx:ChildCount>
          <lx:ConstOperand type="Int32">0</lx:ConstOperand>
        </lx:IsNull>
      </Map>
      <Map Name="TotalSum">
        <lx:IsNull xmlns:lx="lexem">
          <lx:ChildCount>
            <condition />
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="InvoiceItems" />
            </lx:Path>
            <lx:Sum>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="Sum" />
              </lx:Path>
            </lx:Sum>
          </lx:ChildCount>
          <lx:ConstOperand type="Decimal">0</lx:ConstOperand>
        </lx:IsNull>
      </Map>
      <Map Name="OutMarkMessage" 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:Criteria type="Or">
                <lx:Criterion not="1" type="=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="MarkMessage" />
                    <lx:StepString name="MessageType" />
                  </lx:Path>
                  <lx:ChoiceOperand Entity="STOR.MARK_MESSAGE" AttributeName="MessageType" type="Int32" PrimaryKey="2" />
                </lx:Criterion>
                <lx:Criterion type="=">
                  <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="MarkMessage" />
                  </lx:Path>
                  <lx:BaseObjectOperand Entity="STOR.MARK_MESSAGE" isNull="1" />
                </lx:Criterion>
              </lx:Criteria>
              <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:Criteria type="And">
                  <lx:Criterion type="=">
                    <lx:Path OwnerQueryLevel="1">
                      <lx:StepString name="MarkSchemes" />
                      <lx:StepString name="SchemaType" />
                    </lx:Path>
                    <lx:ChoiceOperand Entity="STOR.MARK_SCHEMES" AttributeName="SchemaType" type="Int32" PrimaryKey="1" />
                  </lx:Criterion>
                  <lx:Criterion type="=">
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepString name="Schema" />
                      <lx:StepString name="Code" />
                    </lx:Path>
                    <lx:Path OwnerQueryLevel="1">
                      <lx:StepString name="MarkSchemes" />
                      <lx:StepString name="Code" />
                    </lx:Path>
                  </lx:Criterion>
                </lx:Criteria>
                <lx:Criteria type="And">
                  <lx:Criterion type="=">
                    <lx:Path OwnerQueryLevel="1">
                      <lx:StepString name="MarkSchemes" />
                      <lx:StepString name="SchemaType" />
                    </lx:Path>
                    <lx:ChoiceOperand Entity="STOR.MARK_SCHEMES" AttributeName="SchemaType" type="Int32" PrimaryKey="0" />
                  </lx:Criterion>
                  <lx:Criteria type="Or">
                    <lx:Criteria type="And">
                      <lx:Criterion type="=">
                        <lx:Path OwnerQueryLevel="1">
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="SchemaType" />
                        </lx:Path>
                        <lx:ChoiceOperand Entity="STOR.MARK_SCHEMES" AttributeName="SchemaType" type="Int32" PrimaryKey="1" />
                      </lx:Criterion>
                      <lx:Criterion type="=">
                        <lx:Path OwnerQueryLevel="0">
                          <lx:StepString name="Schema" />
                          <lx:StepString name="Code" />
                        </lx:Path>
                        <lx:Path OwnerQueryLevel="1">
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="Code" />
                        </lx:Path>
                      </lx:Criterion>
                    </lx:Criteria>
                    <lx:Criteria type="And">
                      <lx:Criterion not="1" type="=">
                        <lx:Path OwnerQueryLevel="1">
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="SchemaType" />
                        </lx:Path>
                        <lx:ChoiceOperand Entity="STOR.MARK_SCHEMES" AttributeName="SchemaType" type="Int32" PrimaryKey="1" />
                      </lx:Criterion>
                      <lx:Criterion type="=">
                        <lx:Path OwnerQueryLevel="0">
                          <lx:StepString name="Schema" />
                          <lx:StepString name="Code" />
                        </lx:Path>
                        <lx:Path OwnerQueryLevel="1">
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="Code" />
                        </lx:Path>
                      </lx:Criterion>
                    </lx:Criteria>
                  </lx:Criteria>
                </lx:Criteria>
              </lx:Criteria>
            </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>
      <Map Name="IncMarkMessage" PathAttributes="{MarkMessages}">
        <lx:ChildCount xmlns:lx="lexem">
          <condition>
            <lx:Criteria type="And">
              <lx:Criteria type="Or">
                <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="1" />
                  </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="4" />
                  </lx:Criterion>
                  <lx:Criterion not="1" type="=">
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepString name="Schema" />
                      <lx:StepString name="Code" />
                    </lx:Path>
                    <lx:ConstOperand type="Int32">431</lx:ConstOperand>
                  </lx:Criterion>
                  <lx:Criteria type="Or">
                    <lx:Criteria type="And">
                      <lx:Criterion type="=">
                        <lx:Path OwnerQueryLevel="1">
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="SchemaType" />
                        </lx:Path>
                        <lx:ChoiceOperand Entity="STOR.MARK_SCHEMES" AttributeName="SchemaType" type="Int32" PrimaryKey="1" />
                      </lx:Criterion>
                      <lx:Criterion type="=">
                        <lx:Path OwnerQueryLevel="0">
                          <lx:StepString name="Schema" />
                          <lx:StepString name="Code" />
                        </lx:Path>
                        <lx:Path OwnerQueryLevel="1">
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="Code" />
                        </lx:Path>
                      </lx:Criterion>
                    </lx:Criteria>
                    <lx:Criteria type="And">
                      <lx:Criterion type="=">
                        <lx:Path OwnerQueryLevel="1">
                          <lx:StepString name="MarkSchemes" />
                          <lx:StepString name="SchemaType" />
                        </lx:Path>
                        <lx:ChoiceOperand Entity="STOR.MARK_SCHEMES" AttributeName="SchemaType" type="Int32" PrimaryKey="0" />
                      </lx:Criterion>
                      <lx:Criteria type="Or">
                        <lx:Criteria type="And">
                          <lx:Criterion not="1" type="=">
                            <lx:Path OwnerQueryLevel="1">
                              <lx:StepString name="MarkSchemes" />
                              <lx:StepString name="MarkSchemes" />
                              <lx:StepString name="SchemaType" />
                            </lx:Path>
                            <lx:ChoiceOperand Entity="STOR.MARK_SCHEMES" AttributeName="SchemaType" type="Int32" PrimaryKey="2" />
                          </lx:Criterion>
                          <lx:Criterion type="=">
                            <lx:Path OwnerQueryLevel="0">
                              <lx:StepString name="Schema" />
                              <lx:StepString name="Code" />
                            </lx:Path>
                            <lx:Path OwnerQueryLevel="1">
                              <lx:StepString name="MarkSchemes" />
                              <lx:StepString name="Code" />
                            </lx:Path>
                          </lx:Criterion>
                        </lx:Criteria>
                        <lx:Criteria type="And">
                          <lx:Criterion type="=">
                            <lx:Path OwnerQueryLevel="1">
                              <lx:StepString name="MarkSchemes" />
                              <lx:StepString name="MarkSchemes" />
                              <lx:StepString name="SchemaType" />
                            </lx:Path>
                            <lx:ChoiceOperand Entity="STOR.MARK_SCHEMES" AttributeName="SchemaType" type="Int32" PrimaryKey="2" />
                          </lx:Criterion>
                          <lx:Criterion type="=">
                            <lx:Path OwnerQueryLevel="0">
                              <lx:StepString name="Schema" />
                              <lx:StepString name="Code" />
                            </lx:Path>
                            <lx:Path OwnerQueryLevel="1">
                              <lx:StepString name="MarkSchemes" />
                              <lx:StepString name="MarkSchemes" />
                              <lx:StepString name="Code" />
                            </lx:Path>
                          </lx:Criterion>
                        </lx:Criteria>
                      </lx:Criteria>
                    </lx:Criteria>
                  </lx:Criteria>
                </lx:Criteria>
                <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="Schema" />
                      <lx:StepString name="Code" />
                    </lx:Path>
                    <lx:ConstOperand type="Int32">431</lx:ConstOperand>
                  </lx:Criterion>
                  <lx:Criterion type="=">
                    <lx:Path OwnerQueryLevel="0">
                      <lx:StepString name="Schema" />
                      <lx:StepString name="Code" />
                    </lx:Path>
                    <lx:Path OwnerQueryLevel="1">
                      <lx:StepString name="MarkSchemes" />
                      <lx:StepString name="Code" />
                    </lx:Path>
                  </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>
              </lx:Criteria>
            </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>
      <Map Name="RegistratorMessage">
        <lx:QueryValue entity="STOR.REGISTRATOR_MESSAGE" top="1" offset="0" hints="" xmlns:lx="lexem">
          <condition>
            <lx:Criterion type="=">
              <lx:Path OwnerQueryLevel="0">
                <lx:StepString name="ObjId" />
              </lx:Path>
              <lx:Path OwnerQueryLevel="1">
                <lx:StepString name="InvoiceID" />
              </lx:Path>
            </lx:Criterion>
          </condition>
          <value>
            <lx:LexemList>
              <lx:Path OwnerQueryLevel="0">
                <lx:StepCurrent />
              </lx:Path>
            </lx:LexemList>
          </value>
        </lx:QueryValue>
      </Map>
      <Map Name="UnpackSSCCMarkMessage" 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:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="Schema" />
                  <lx:StepString name="Code" />
                </lx:Path>
                <lx:ConstOperand type="Int32">912</lx:ConstOperand>
              </lx:Criterion>
              <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="ObjId" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="1">
                  <lx:StepString name="InvoiceID" />
                </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>
      <Map Name="Mark">
        <lx:Case xmlns:lx="lexem">
          <When>
            <lx:Criteria type="Or">
              <lx:CriterionExists entity="STOR.INVOICE_ITEM" top="-1" offset="0">
                <condition>
                  <lx:Criteria type="And">
                    <lx:Criterion not="1" type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepString name="GTINSerialNumber" />
                      </lx:Path>
                      <lx:ConstOperand isNull="1" />
                    </lx:Criterion>
                    <lx:Criterion not="1" type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepString name="GTINSerialNumber" />
                      </lx:Path>
                      <lx:ConstOperand type="String"><![CDATA[]]></lx:ConstOperand>
                    </lx:Criterion>
                    <lx:Criterion type="&gt;">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepString name="Amount" />
                      </lx:Path>
                      <lx:ConstOperand type="Decimal">0</lx:ConstOperand>
                    </lx:Criterion>
                    <lx:Criterion type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepString name="StorageInvoice" />
                        <lx:StepString name="InvoiceID" />
                      </lx:Path>
                      <lx:Path OwnerQueryLevel="1">
                        <lx:StepString name="InvoiceID" />
                      </lx:Path>
                    </lx:Criterion>
                  </lx:Criteria>
                </condition>
              </lx:CriterionExists>
              <lx:CriterionExists entity="STOR.SHIPPING_CONTAINER" top="-1" offset="0">
                <condition>
                  <lx:Criteria type="And">
                    <lx:Criterion type="=">
                      <lx:Path OwnerQueryLevel="0">
                        <lx:StepString name="StorageInvoice" />
                        <lx:StepString name="InvoiceID" />
                      </lx:Path>
                      <lx:Path OwnerQueryLevel="1">
                        <lx:StepString name="InvoiceID" />
                      </lx:Path>
                    </lx:Criterion>
                  </lx:Criteria>
                </condition>
              </lx:CriterionExists>
            </lx:Criteria>
          </When>
          <Then>
            <lx:ConstOperand type="Boolean">True</lx:ConstOperand>
          </Then>
          <Else>
            <lx:ConstOperand type="Boolean">False</lx:ConstOperand>
          </Else>
        </lx:Case>
      </Map>
      <Map Name="TotalSellingSum">
        <lx:IsNull xmlns:lx="lexem">
          <lx:ChildCount>
            <condition />
            <lx:Path OwnerQueryLevel="0">
              <lx:StepString name="InvoiceItems" />
            </lx:Path>
            <lx:Sum>
              <lx:MathOperator sign="*">
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="SellingPrice" />
                </lx:Path>
                <lx:Path OwnerQueryLevel="0">
                  <lx:StepString name="TotalAmount" />
                </lx:Path>
              </lx:MathOperator>
            </lx:Sum>
          </lx:ChildCount>
          <lx:ConstOperand type="Decimal">0</lx:ConstOperand>
        </lx:IsNull>
      </Map>
    </Lexem>
    <View name="V_SI_MDLP_PAYMENT_TYPE">
      <Map Name="MdlpPaymentType" Column="MdlpPaymentType" />
    </View>
  </DbMapping>
  <CalculatingAttributes>
    <Attribute Name="GetTemplateName" Index="19080025" Type="string" Description="Получить наименование шаблона" />
  </CalculatingAttributes>
</Entity>