<?xml version="1.0"?>

<report name="cash-report" pdf-renderer="Lagerbestand.xsl">
	<title>Lagerbestand</title>

<report-parameter name="TENANT" type="integer" hidden="true">
		<preset>@TENANT_NO</preset>
	</report-parameter>
	<report-parameter name="COMPANY" type="integer" hidden="true">
		<preset>@COMPANY_NO</preset>
	</report-parameter>
	<report-parameter name="DATE" type="date" label="Von Datum:">
		<preset>@TODAY</preset>
		<input type="datepicker" />
	</report-parameter>
	<report-parameter name="BUSINESSUNIT" type="integer">
		<label>Filiale:</label>
		<input type="selectlist">
			<source type="dataset" name="businessunits">
			</source>
		</input>
	</report-parameter>

	<report-result report-dataset="businessunits">
	</report-result>
	<report-result report-dataset="sales_pricelists">
	</report-result>
	<report-result report-dataset="item_groups">
	</report-result>
	<report-result report-dataset="sales_item_prices">
	</report-result>
	<report-result report-dataset="sales_pricelist_instance">
	</report-result>
<report-result report-dataset="departmentCurrency">
	</report-result>

    <report-dataset name="departmentCurrency">
		<sql>
			select * from currencies c join departments d on c.tenant_no = d.tenant_no AND c.currency_cd = d.currency_cd  where d.tenant_no=@TENANT_NO and d.company_no=@COMPANY_NO and d.department_no =@DEPARTMENT_NO 
		</sql>
	</report-dataset>

	<report-dataset name="businessunits">
		<sql>
			select * from businessunits where tenant_no=@TENANT_NO and company_no=@COMPANY_NO and department_no=@DEPARTMENT_NO and businessunit_no=@BUSINESSUNIT_NO
		</sql>
	</report-dataset>

	<report-dataset name="sales_pricelists">
		<sql>
			select * from sales_pricelists where tenant_no=@TENANT_NO and company_no=@COMPANY_NO and sales_pricelist_id=@SALES_PRICELIST_ID
		</sql>
	</report-dataset>
	
	<report-dataset name="sales_pricelist_instance">
		<sql>
			select * from sales_pricelist_instances where tenant_no=@TENANT_NO and company_no=@COMPANY_NO and sales_pricelist_id=@SALES_PRICELIST_ID and sales_pricelist_instance_id=@PRICELIST_INSTANCE_ID 
		</sql>
	</report-dataset>
	
	<report-dataset name="item_groups">
		<sql>
			select * from item_groups where tenant_no=@TENANT_NO and company_no=@COMPANY_NO and item_group_cd=@ITEM_GROUP_CD
		</sql>
	</report-dataset>
	
	<report-dataset name="sales_item_prices">
		<sql>
			select i.item_cd,
			sip.item_net_price,
			sip.item_gross_price,
			i.item_nm,
			t.tax_nm,
			prof.item_profession_nm
			from items i left join sales_item_prices sip on i.item_cd = sip.item_cd and sip.sales_pricelist_id=@SALES_PRICELIST_ID and sip.sales_pricelist_instance_id=@PRICELIST_INSTANCE_ID 
			inner join taxes t on i.tax_cd = t.tax_cd
			left join sales_item_professions prof on sip.item_profession_no = prof.item_profession_no
			where i.tenant_no=@TENANT_NO and i.company_no=@COMPANY_NO and i.item_group_cd=@ITEM_GROUP_CD
			order by i.item_cd, sip.item_profession_no
		</sql>
	</report-dataset>
	


</report>

