<?xml version="1.0"?>

<report name="cash-report" pdf-renderer="AusgegebeneGutscheine.xsl">
	<title>AusgegebeneGutscheine</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="POSSESSIONID" type="integer"
		hidden="true">
		<preset>@POS_SESSION_ID</preset>
	</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="drawers">
	</report-result>

	<report-result report-dataset="cash_start">
	</report-result>
	<report-result report-dataset="cash_end">
	</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="drawers">
		<sql>
			select * from pos_drawers where tenant_no=@TENANT_NO and pos_cd=@POS_CD and drawer_no = @DRAWER_NO 
		</sql>
	</report-dataset>
	
	<report-dataset name="cash_start">
		<sql>
			SELECT ss.session_start_ts, ss.cash_start, ss.pos_session_cd from pos_sessions ss where tenant_no=@TENANT_NO and pos_cd=@POS_CD and ss.pos_session_id=@POS_SESSION_ID and ss.drawer_no = @DRAWER_NO
		</sql>
	</report-dataset>
	<report-dataset name="cash_end">
		<sql>
			SELECT ss.pos_session_id, case when ss.session_end_ts is null then 'Vorläufiger ' else '' end r_draft, ss.session_end_ts, ss.cash_end from pos_sessions ss where ss.tenant_no=@TENANT_NO and ss.pos_cd=@POS_CD and ss.pos_session_id= @POS_SESSION_ID and ss.drawer_no = @DRAWER_NO
		</sql>
	</report-dataset>


</report>
