<?xml version="1.0"?>

<report name="cash-report" pdf-renderer="StockNoteDetail.xsl">
	<title>PurchaseNoteList</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-transaction report-nm="stock_note_detail" report-transaction="net.spa.pos.transactions.LoadJSStockNote">
	</report-transaction>
	<report-result report-dataset="businessunits">
	</report-result>

<report-result report-dataset="suppliers">
	</report-result>
	
	<report-result report-dataset="itemSuppliers">
	</report-result>

	<report-result report-dataset="stockRevisionTypes">
	</report-result>


	<report-dataset name="suppliers">
		<sql>
			SELECT c.contact_no, 
			       c.contact_nm
              FROM contacts c 
              join supplier_roles sr 
                on c.tenant_no = sr.tenant_no AND c.contact_no = sr.contact_no
             WHERE sr.company_no = @COMPANY_NO
		</sql>
	</report-dataset>
	


	<report-dataset name="itemSuppliers">
		<sql>
			select 
			       * 
			  from item_suppliers
			 where tenant_no=@TENANT_NO 
			   and company_no=@COMPANY_NO 
			   and department_no=@DEPARTMENT_NO 
			   and stock_no=(
			   				  SELECT 
			   				         stock_no 
			   				    FROM sales_dlns 
			   				   WHERE tenant_no = @TENANT_NO 
			   				     AND pos_cd =@POS_CD  
			   				     AND sales_dln_id = @NOTE_ID
			   				) 
		</sql>
	</report-dataset>


	<report-dataset name="dItemSuppliers">
		<sql>
			select 
			       * 
			  from item_suppliers
			 where tenant_no=@TENANT_NO 
			   and company_no=@COMPANY_NO 
			   and businessunit_no=@DEPARTMENT_NO 
			   and stock_no=(
			   				  SELECT 
			   				         stock_no 
			   				    FROM d_sales_dlns 
			   				   WHERE tenant_no = @TENANT_NO 
			   				     AND pos_cd =@POS_CD  
			   				     AND sales_dln_id = @NOTE_ID
			   				) 
		</sql>
	</report-dataset>

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

	<report-dataset name="stockRevisionTypes">
		<sql>
			select stock_revision_type_no ID, stock_revision_type_nm from stock_revision_type where tenant_no=@TENANT_NO 
		</sql>
	</report-dataset>


</report>

