<DODocTemplateConfigRoot><DODocTemplateList><DODocTemplate STATE="0"><DODocTemplate2DeviceList/><DODocTemplateParamList><DODocTemplateParam STATE="0"><DocTemplateParamId>94</DocTemplateParamId><DocTemplateId>49</DocTemplateId><ParamName NOTNULL="TRUE">TransactionId</ParamName><ParamType>3</ParamType><CntxPropertyType>142</CntxPropertyType><ParamValue NOTNULL="TRUE"></ParamValue><ParamCaption NOTNULL="TRUE">TransactionId</ParamCaption></DODocTemplateParam><DODocTemplateParam STATE="0"><DocTemplateParamId>95</DocTemplateParamId><DocTemplateId>49</DocTemplateId><ParamName NOTNULL="TRUE">TemplateId</ParamName><ParamType>3</ParamType><CntxPropertyType>141</CntxPropertyType><ParamValue NOTNULL="TRUE"></ParamValue><ParamCaption NOTNULL="TRUE">TemplateId</ParamCaption></DODocTemplateParam></DODocTemplateParamList><DODocRepositoryList/><DODocTemplateParamValueList><DODocTemplateParamValue STATE="0"><DocTemplateParamValueId>101</DocTemplateParamValueId><DocTemplateParamId>94</DocTemplateParamId><DocTemplateId>49</DocTemplateId><CntxPropertyType>0</CntxPropertyType><ParamValue NOTNULL="TRUE"></ParamValue><ParamCaption NOTNULL="TRUE">TransactionId</ParamCaption><ReadOnly>1</ReadOnly><NotNull>0</NotNull></DODocTemplateParamValue><DODocTemplateParamValue STATE="0"><DocTemplateParamValueId>102</DocTemplateParamValueId><DocTemplateParamId>95</DocTemplateParamId><DocTemplateId>49</DocTemplateId><CntxPropertyType>0</CntxPropertyType><ParamValue NOTNULL="TRUE"></ParamValue><ParamCaption NOTNULL="TRUE">TemplateId</ParamCaption><ReadOnly>1</ReadOnly><NotNull>0</NotNull></DODocTemplateParamValue></DODocTemplateParamValueList><DocTemplateId>29</DocTemplateId><SystemId>0</SystemId><DocTemplateAk NOTNULL="TRUE">11A07FDCC5FA466295197BC978BBF802</DocTemplateAk><DocCntxType>14</DocCntxType><DocTemplateType>1</DocTemplateType><DirectPrint>0</DirectPrint><DocTemplateName NOTNULL="TRUE">Restaurant1</DocTemplateName><Enabled>1</Enabled><DocDatasourceId>0</DocDatasourceId><PriorityOrder>0</PriorityOrder><DmgCategoryId>0</DmgCategoryId><SystemTemplate>1</SystemTemplate><DeleteFromConfig></DeleteFromConfig><DocTemplateGroup></DocTemplateGroup></DODocTemplate></DODocTemplateList><DODocTemplateDataList><DocTemplateData STATE="0"><DocTemplateAk>11A07FDCC5FA466295197BC978BBF802</DocTemplateAk><DocTemplateContent>&lt;root namespaceuri="otn.overview7.xmldata"&gt;&lt;queries&gt;&lt;query name="reportxmldata" context="14"&gt;&lt;params&gt;&lt;param name="TransactionId" datatype="3" contextproperty="142"/&gt;&lt;param name="TemplateId" datatype="3" contextproperty="141"/&gt;&lt;/params&gt;&lt;/query&gt;&lt;/queries&gt;&lt;datasets&gt;&lt;dataset name="Header" donotgeneratelist="N"&gt;&lt;select&gt;&lt;db query="reportxmldata" type="*" commadtype="query"&gt;SELECT
    DATA_Transaction.TransactionDate,
    DATA_Transaction.Serial AS TransactionNumber,
    DATA_Transaction.BoxId AS BoxNumber,
    CNF_Site.SiteCode,
    CNF_OperatingArea.AreaCode,
    CNF_Workstation.WorkstationAK AS Station,
    CNF_LookUp.Description AS TransactionType,
    CNF_Currency.Symbol AS Currency,    
    CNF_Currency.ISOCode,
    CNF_Site.SiteName,
    DATA_Transaction.TransactionAK,
    CNF_User.UserName,
    CNF_User.UserCode,   
    DATA_Transaction.Rounding
    
    FROM DATA_Transaction
    LEFT OUTER JOIN CNF_Site
      ON CNF_Site.SiteId = DATA_Transaction.SiteId
    LEFT OUTER JOIN CNF_Workstation
      ON CNF_Workstation.WorkStationId = DATA_Transaction.WorkStationId
    LEFT OUTER JOIN CNF_OperatingArea
      ON CNF_OperatingArea.OperatingAreaId = CNF_Workstation.OperatingAreaId
    LEFT OUTER JOIN CNF_LookUp
      ON CNF_LookUp.LookUpTableId = 3 -- Lookup_TransactionType
     AND CNF_LookUp.ItemId = DATA_Transaction.TransactionType
    LEFT OUTER JOIN CNF_User
      ON CNF_User.UserId = DATA_Transaction.UserId
    LEFT OUTER JOIN DATA_Sale
      ON DATA_Sale.SaleId = DATA_Transaction.SaleId
    LEFT OUTER JOIN CNF_Currency
      ON CNF_Currency.CurrencyId = DATA_Sale.CurrencyId
    
    WHERE DATA_Transaction.TransactionId = :TransactionId
    ORDER BY DATA_Transaction.TransactionId&lt;/db&gt;&lt;/select&gt;&lt;datasets/&gt;&lt;/dataset&gt;&lt;dataset name="Items" donotgeneratelist="N"&gt;&lt;select&gt;&lt;db query="reportxmldata" type="*" commadtype="query"&gt;select 
    case when mcoCode.OptionValue is null then ASet.AttributeCodes else mcoCode.OptionValue end as ProductCode, 
  case when mcoName.OptionValue is null then ASet.AttributeNames else mcoName.OptionValue end as ProductName, 
  SUM(SI.Quantity) as Qty

from 
DATA_Transaction as TR 
  inner join DATA_Transactionitem as TI on (Ti.Transactionid= TR.TransactionId)
  inner join DATA_SaleItem as Si on (Si.SaleItemId =TI.SaleItemId)
  inner join CNF_MatrixCell as MC on (MC.MatrixCellId=Si.MatrixCellId)
  left outer join CNF_AttributeSet ASet on ASet.AttributeSetId = MC.AttributeSetId
  left outer join CNF_MatrixCellOption mcoCode on mcoCode.MatrixCellId = MC.MatrixCellId 
              and mcoCode.OptionType = 5 /* Lk_MatrixCellOptionType_Code */
  left outer join CNF_MatrixCellOption mcoName on mcoName.MatrixCellId = MC.MatrixCellId 
              and mcoName.OptionType = 6 /* Lk_MatrixCellOptionType_Name */
where
 TR.TransactionId = :TransactionId 
 and MC.ReceiptTemplateId = :TemplateId

group by
  mcoName.OptionValue,
  ASet.AttributeNames, 
  ASet.AttributeCodes,
  mcoCode.OptionValue&lt;/db&gt;&lt;/select&gt;&lt;datasets/&gt;&lt;/dataset&gt;&lt;/datasets&gt;&lt;/root&gt;

</DocTemplateContent><ArchiveFileName>11A07FDCC5FA466295197BC978BBF802</ArchiveFileName></DocTemplateData></DODocTemplateDataList></DODocTemplateConfigRoot>