Commit c3f8c8f2 authored by TIANZHI.HU's avatar TIANZHI.HU

对账单打印报表逻辑问题的上线 add by 39135 HuTianzhi

parent 5f6bec40
......@@ -13,7 +13,7 @@
<select id="selectCashflowList" parameterType="integer" resultType="java.util.LinkedHashMap">
Select
Select
contract_id,
cashflow_id,
write_off_id,
......@@ -24,14 +24,41 @@
to_char(due_amount, 'fm999,999,999,990.00') due_amount,
transaction_date,
write_off_date,
to_char(received_amount, 'fm999,999,999,990.00') received_amount,
--to_char(received_amount, 'fm999,999,999,990.00') received_amount,
--modify by 18938 I-7256
to_char((case
when received_amount > 0 then
hlcm_query_entrance_pkg.get_due_amout(p_transaction_date => transaction_date,
p_times => times,
p_contract_id => contract_id,
p_received_amount_9 => received_amount_9,
p_due_amount => received_amount,
p_write_off_id => write_off_id,
p_field => 'received_amount')
else
received_amount
end), 'fm999,999,999,990.00') As received_amount,
to_char(unreceived_amount, 'fm999,999,999,990.00') unreceived_amount,
times_9,
to_char(due_amount_9, 'fm999,999,999,990.00') due_amount_9,
to_char(nvl(received_amount_9, 0), 'fm999,999,999,990.00') received_amount_9,
--to_char(nvl(received_amount_9, 0), 'fm999,999,999,990.00') received_amount_9,
--modify by 18938 I-7256
to_char((case
when received_amount_9 > 0 then
hlcm_query_entrance_pkg.get_due_amout_new(p_transaction_date => transaction_date,
p_times => times,
p_contract_id => contract_id,
p_due_amount => received_amount_9,
p_write_off_id => write_off_id,
p_field => 'received_amount_9',
p_write_off_id_9 =>write_off_id_9)
else
received_amount_9
end), 'fm999,999,999,990.00') As received_amount_9,
to_char(unreceived_amount_9, 'fm999,999,999,990.00') unreceived_amount_9
From (Select *
From (Select
From (select a.* from (Select
t2.write_off_id write_off_id_9,
t1.contract_id,
t1.cashflow_id,
t1.write_off_id,
......@@ -58,13 +85,15 @@
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, 'yyyy-mm-dd') due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--修改点1
ccc.due_amount due_amount,
--(ccc.due_amount -
--nvl((Select Sum(tn.write_off_due_amount)
--From csh_write_off tn
-- Where tn.cashflow_id = cwo.cashflow_id
-- And tn.creation_date &lt;=
--cwo.creation_date),
--0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, 'yyyy-mm-dd') transaction_date,
to_char(cwo.write_off_date, 'yyyy-mm-dd') write_off_date,
......@@ -72,10 +101,14 @@
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
From csh_write_off tn,csh_transaction ct
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
and tn.csh_transaction_id=ct.transaction_id
and (ct.transaction_date &lt; t.transaction_date or
(ct.transaction_date = t.transaction_date and
(tn.write_off_date &lt; cwo.write_off_date or
(tn.write_off_date = cwo.write_off_date and
tn.write_off_id &lt;= cwo.write_off_id))))),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
......@@ -172,9 +205,17 @@
cwo.write_off_id) t2
Where t1.transaction_date = t2.transaction_date (+)
And t1.times = t2.times (+)
And t1.cf_item = t2.cf_item (+)
And t1.cf_item = t2.cf_item (+)) a
where hlcm_query_entrance_pkg.get_due_amout(p_transaction_date => a.transaction_date,
p_times => a.times,
p_contract_id => a.contract_id,
p_received_amount_9 => a.received_amount_9,
p_due_amount => a.received_amount,
p_write_off_id => a.write_off_id,
p_field => 'received_amount')>0
Union
Select
select a.* from(Select
t2.write_off_id write_off_id_9,
nvl(t1.contract_id, t2.contract_id) contract_id,
nvl(t1.cashflow_id, t2.cashflow_id) cashflow_id,
nvl(t1.write_off_id, t2.write_off_id) write_off_id,
......@@ -297,13 +338,15 @@
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, 'yyyy-mm-dd') due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--修改点2
ccc.due_amount due_amount,
--(ccc.due_amount -
--nvl((Select Sum(tn.write_off_due_amount)
--From csh_write_off tn
--Where tn.cashflow_id = cwo.cashflow_id
-- And tn.creation_date &lt;=
--cwo.creation_date),
--0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, 'yyyy-mm-dd') transaction_date,
to_char(cwo.write_off_date, 'yyyy-mm-dd') write_off_date,
......@@ -311,10 +354,14 @@
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
From csh_write_off tn,csh_transaction ct
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
and tn.csh_transaction_id=ct.transaction_id
and (ct.transaction_date &lt; t.transaction_date or
(ct.transaction_date = t.transaction_date and
(tn.write_off_date &lt; cwo.write_off_date or
(tn.write_off_date = cwo.write_off_date and
tn.write_off_id &lt;= cwo.write_off_id))))),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
......@@ -414,9 +461,17 @@
cwo.write_off_id) t2
Where t1.transaction_date (+) = t2.transaction_date
And t1.times (+) = t2.times
And t1.cf_item (+) = t2.cf_item
And t1.cf_item (+) = t2.cf_item) a where
hlcm_query_entrance_pkg.get_due_amout(p_transaction_date => a.transaction_date,
p_times => a.times,
p_contract_id => a.contract_id,
p_received_amount_9 => a.received_amount_9,
p_due_amount => a.received_amount,
p_write_off_id => a.write_off_id,
p_field => 'received_amount')>0
Union
Select
null write_off_id_9,
ccc.contract_id,
ccc.cashflow_id,
Null write_off_id,
......@@ -494,6 +549,7 @@
-1)
Union
Select
null write_off_id_9,
Null contract_id,
Null cashflow_id,
Null write_off_id,
......@@ -510,7 +566,48 @@
Sum(due_amount_9) due_amount_9,
Sum(received_amount_9) received_amount_9,
Sum(unreceived_amount_9) unreceived_amount_9
From (Select
From(Select
contract_id,
cashflow_id,
write_off_id,
cf_item,
cf_item_n,
times,
due_date,
due_amount,
transaction_date,
write_off_date,
--to_char(received_amount, 'fm999,999,999,990.00') received_amount,
--modify by 18938 I-7256
(case
when received_amount > 0 then
hlcm_query_entrance_pkg.get_due_amout(p_transaction_date => transaction_date,
p_times => times,
p_contract_id => contract_id,
p_received_amount_9 => received_amount_9,
p_due_amount => received_amount,
p_write_off_id => write_off_id,
p_field => 'received_amount')
else
received_amount
end) As received_amount,
unreceived_amount,
times_9,
due_amount_9,
--to_char(nvl(received_amount_9, 0), 'fm999,999,999,990.00') received_amount_9,
--modify by 18938 I-7256
(case
when received_amount_9 > 0 then
hlcm_query_entrance_pkg.get_due_amout(p_transaction_date => transaction_date,
p_times => times,
p_contract_id => contract_id,
p_due_amount => received_amount_9,
p_write_off_id => write_off_id,
p_field => 'received_amount_9')
else
received_amount_9
end) As received_amount_9,
unreceived_amount_9 From (Select
t1.*,
nvl(t2.times, t1.times) As times_9,
nvl(t2.due_amount, 0) As due_amount_9,
......@@ -526,14 +623,16 @@
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, 'yyyy-mm-dd') due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id =
cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--修改点3
ccc.due_amount due_amount,
--(ccc.due_amount -
--nvl((Select Sum(tn.write_off_due_amount)
--From csh_write_off tn
--Where tn.cashflow_id =
--cwo.cashflow_id
--And tn.creation_date &lt;=
--cwo.creation_date),
--0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, 'yyyy-mm-dd') transaction_date,
to_char(cwo.write_off_date, 'yyyy-mm-dd') write_off_date,
......@@ -541,11 +640,14 @@
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id =
cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
From csh_write_off tn,csh_transaction ct
Where tn.cashflow_id = cwo.cashflow_id
and tn.csh_transaction_id=ct.transaction_id
and (ct.transaction_date &lt; t.transaction_date or
(ct.transaction_date = t.transaction_date and
(tn.write_off_date &lt; cwo.write_off_date or
(tn.write_off_date = cwo.write_off_date and
tn.write_off_id &lt;= cwo.write_off_id))))),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
......@@ -780,14 +882,16 @@
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, 'yyyy-mm-dd') due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id =
cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--修改点4
ccc.due_amount due_amount,
--(ccc.due_amount -
--nvl((Select Sum(tn.write_off_due_amount)
--From csh_write_off tn
--Where tn.cashflow_id =
--cwo.cashflow_id
--And tn.creation_date &lt;=
--cwo.creation_date),
--0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, 'yyyy-mm-dd') transaction_date,
to_char(cwo.write_off_date, 'yyyy-mm-dd') write_off_date,
......@@ -795,11 +899,14 @@
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id =
cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
From csh_write_off tn,csh_transaction ct
Where tn.cashflow_id = cwo.cashflow_id
and tn.csh_transaction_id=ct.transaction_id
and (ct.transaction_date &lt; t.transaction_date or
(ct.transaction_date = t.transaction_date and
(tn.write_off_date &lt; cwo.write_off_date or
(tn.write_off_date = cwo.write_off_date and
tn.write_off_id &lt;= cwo.write_off_id))))),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
......@@ -993,13 +1100,13 @@
Where cc2.contract_id = ccc.contract_id
And cc2.cf_item != 0
And nvl(cc2.received_amount, 0) != 0),
-1)))
-1))))
Order By times,
cf_item,
due_amount Desc,
--cf_item,
--due_amount Desc,
transaction_date,
write_off_date)
write_off_date,
write_off_id)
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment