<?xml version="1.0"?>
|
<!DOCTYPE hibernate-mapping PUBLIC
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
|
<hibernate-mapping>
|
<sql-query name="IncomeStatementReportQuery">
|
<![CDATA[
|
|
select a1.fisu_sn, a2.year_lei_ji,a3.month_lei_ji from
|
fi_subject a1 left join
|
(
|
SELECT
|
fisu_id,
|
case when fisu_direction='借' then sum(fivd_debtor_money)
|
when fisu_direction='借' then sum(fivd_creditor_money)
|
else 0.0
|
end as year_lei_ji, 0 as month_lei_ji
|
FROM
|
fi_voucher v
|
LEFT JOIN fi_voucher_detail ON fivo_id = fivd_fivo_id
|
left join fi_subject on fivd_subject_id=fisu_id
|
where 1=1
|
and fivo_is_cancle<>'Y'
|
and fivo_type<>'初始化'
|
and fisu_type='损益类'
|
<<and fivo_date<=:endDate>>
|
<<and fivo_fiac_id=:fiboId>>
|
<<and v.factory_id=:factoryId>>
|
group by fisu_id
|
) a2 on a1.fisu_id=a2.fisu_id
|
left join
|
(
|
SELECT
|
fisu_id, 0 as year_lei_ji,
|
case when fisu_direction='借' then sum(fivd_debtor_money)
|
when fisu_direction='借' then sum(fivd_creditor_money)
|
else 0.0
|
end as month_lei_ji
|
FROM
|
fi_voucher v
|
LEFT JOIN fi_voucher_detail ON fivo_id = fivd_fivo_id
|
left join fi_subject on fivd_subject_id=fisu_id
|
where 1=1
|
and fivo_is_cancle<>'Y'
|
and fivo_type<>'初始化'
|
and fisu_type='损益类'
|
<<and fivo_date<=:endDate>>
|
<<and fivo_date>=:beginDate>>
|
<<and fivo_fiac_id=:fiboId>>
|
<<and v.factory_id=:factoryId>>
|
group by fisu_id
|
) a3 on a1.fisu_id=a3.fisu_id
|
where 1=1
|
and (a2.year_lei_ji is not null or a3.month_lei_ji is not null)
|
|
]]>
|
</sql-query>
|
</hibernate-mapping>
|