Commit 96a0101c authored by stone's avatar stone

【fix】回收逾期报表以及付款申请的修改

parent 0352d31f
...@@ -27,21 +27,10 @@ SELECT h.extra_nam, ...@@ -27,21 +27,10 @@ SELECT h.extra_nam,
0 0
END) unpayment_amount, END) unpayment_amount,
--应付未付首付款总额 --首付款关联不到就取核销日期而不是收款日期 --应付未付首付款总额 --首付款关联不到就取核销日期而不是收款日期
(CASE contract_item_query_pkg.calc_down_payment_balance ( p_contract_id=>t.contract_id,
WHEN to_char(t.lease_start_date, 'yyyy-mm') <> ${@period_name} THEN p_calc_date =>to_date(${@last_month_date}, 'yyyy-mm-dd'),
(SELECT SUM(nvl(ccc.due_amount, 0)) p_calc_flag =>'START',
FROM con_contract_cashflow ccc p_user_id =>-1) undown_payment,
WHERE ccc.contract_id = t.contract_id
AND ccc.cf_item = 2
AND ccc.cf_status = 'RELEASE') -
contract_item_query_pkg.calc_down_payment_write(p_contract_id => t.contract_id,
p_calc_date => to_date(${@last_month_date},
'yyyy-mm-dd'),
p_user_id => -1)
ELSE
0
END) undown_payment,
--应付未付留购金总额 --应付未付留购金总额
(CASE (CASE
WHEN to_char(t.lease_start_date, 'yyyy-mm') <> ${@period_name} THEN WHEN to_char(t.lease_start_date, 'yyyy-mm') <> ${@period_name} THEN
...@@ -172,11 +161,12 @@ SELECT h.extra_nam, ...@@ -172,11 +161,12 @@ SELECT h.extra_nam,
TRUNC(to_date(${@start_calc_date}, 'yyyy-mm-dd'))), TRUNC(to_date(${@start_calc_date}, 'yyyy-mm-dd'))),
0) write_off_amount, 0) write_off_amount,
--当月回收首付款 --当月回收首付款
contract_item_query_pkg.calc_down_payment_write(p_contract_id => t.contract_id,
p_calc_date => to_date(${@start_calc_date}, contract_item_query_pkg.calc_down_payment_write(p_contract_id=> t.contract_id,
p_calc_date => to_date(${@start_calc_date},
'yyyy-mm-dd'), 'yyyy-mm-dd'),
p_calc_date_2 => last_day(to_date(${@start_calc_date},'yyyy-mm-dd')), p_user_id => -1) write_off_downpayment,
p_user_id => -1) write_off_downpayment,
--回收留购金 --回收留购金
nvl((SELECT SUM(cwo.write_off_due_amount) nvl((SELECT SUM(cwo.write_off_due_amount)
FROM csh_write_off cwo, csh_transaction ct FROM csh_write_off cwo, csh_transaction ct
...@@ -220,15 +210,11 @@ SELECT h.extra_nam, ...@@ -220,15 +210,11 @@ SELECT h.extra_nam,
contract_item_query_pkg.calc_rest_rent_by_dudt(p_contract_id => t.contract_id, contract_item_query_pkg.calc_rest_rent_by_dudt(p_contract_id => t.contract_id,
p_calc_date => last_day(to_date(${@start_calc_date},'yyyy-mm-dd')), p_calc_date => last_day(to_date(${@start_calc_date},'yyyy-mm-dd')),
p_user_id => -1) rest_unpayment_amount_af, p_user_id => -1) rest_unpayment_amount_af,
--应付未付首付款总额
(SELECT SUM(nvl(ccc.due_amount, 0)) contract_item_query_pkg.calc_down_payment_balance ( p_contract_id=>t.contract_id,
FROM con_contract_cashflow ccc p_calc_date =>last_day(to_date(${@start_calc_date},'yyyy-mm-dd')),
WHERE ccc.contract_id = t.contract_id p_calc_flag =>'END',
AND ccc.cf_item = 2 p_user_id =>-1) rest_undown_payment,
AND ccc.cf_status = 'RELEASE') -
contract_item_query_pkg.calc_down_payment_write(p_contract_id => t.contract_id,
p_calc_date => last_day(to_date(${@start_calc_date},'yyyy-mm-dd')),
p_user_id => -1) rest_undown_payment,
--应付未付留购金总额 --应付未付留购金总额
(SELECT SUM(nvl(ccc.due_amount, 0)) (SELECT SUM(nvl(ccc.due_amount, 0))
FROM con_contract_cashflow ccc FROM con_contract_cashflow ccc
...@@ -366,6 +352,7 @@ SELECT h.extra_nam, ...@@ -366,6 +352,7 @@ SELECT h.extra_nam,
'TERMINATING', 'TERMINATING',
'ETING', 'ETING',
'REPURING')or (to_char(t.et_date,'yyyy-mm')>=${@period_name} and t.contract_status='TERMINATE' )) 'REPURING')or (to_char(t.et_date,'yyyy-mm')>=${@period_name} and t.contract_status='TERMINATE' ))
and trunc(t.lease_start_date) <= trunc(last_day(to_date(${@start_calc_date},'yyyy-mm-dd')))
......
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT t.contract_id,
t.contract_number,
(SELECT h.extra_nam
FROM hls_bp_master h
WHERE h.bp_id=t.bp_id_agent_level1) extra_nam,
(SELECT h.bp_name
FROM hls_bp_master h
WHERE h.bp_id=t.bp_id_tenant) tenant_name,
--租赁开始日
t.lease_start_date,
--机型
ccli.modelcd,
--机号
ccli.machine_number,
--回数
decode(ccc.cf_item,8,'留购价格',ccc.times) times,
--支付预定日
ccc.due_date,
--应收款金额
(ccc.due_amount -
nvl((SELECT SUM(cwo.write_off_due_amount)
FROM csh_transaction t, csh_write_off cwo
WHERE cwo.cashflow_id = ccc.cashflow_id
AND t.transaction_id = cwo.csh_transaction_id
AND nvl(cwo.reversed_flag, 'N') = 'N'
AND trunc(t.transaction_date) <
trunc(to_date(${@start_calc_date}, 'yyyy-mm-dd'))),
0)) net_amount,
--当月已收款金额
nvl((SELECT SUM(cwo.write_off_due_amount)
FROM csh_transaction t, csh_write_off cwo
WHERE cwo.cashflow_id = ccc.cashflow_id
AND t.transaction_id = cwo.csh_transaction_id
AND nvl(cwo.reversed_flag, 'N') = 'N'
AND to_char(t.transaction_date, 'yyyy-mm') = ${@period_name}),
0) write_off_amount,
--剩余金额
(ccc.due_amount -
nvl((SELECT SUM(cwo.write_off_due_amount)
FROM csh_transaction t, csh_write_off cwo
WHERE cwo.cashflow_id = ccc.cashflow_id
AND t.transaction_id = cwo.csh_transaction_id
AND nvl(cwo.reversed_flag, 'N') = 'N'
AND trunc(t.transaction_date) <=
trunc(to_date(${@last_month_date}, 'yyyy-mm-dd'))),
0)) unrecived_amount,
--逾期天数
(CASE
WHEN (ccc.due_amount -
nvl((SELECT SUM(cwo.write_off_due_amount)
FROM csh_transaction t, csh_write_off cwo
WHERE cwo.cashflow_id = ccc.cashflow_id
AND t.transaction_id = cwo.csh_transaction_id
AND nvl(cwo.reversed_flag, 'N') = 'N'
AND trunc(t.transaction_date) <=
trunc(to_date(${@last_month_date}, 'yyyy-mm-dd'))),
0)) > 0 THEN
floor(to_date(${@last_month_date}, 'yyyy-mm-dd') - ccc.due_date)
ELSE
0
END) overdue_days
FROM con_contract_cashflow ccc,
con_contract t,
con_contract_lease_item ccli
WHERE ccc.contract_id = t.contract_id
AND t.contract_id = ccli.contract_id
AND ccc.cf_item IN (1, 8, 200, 250)
AND ccc.cf_status = 'RELEASE'
AND t.data_class = 'NORMAL'
AND trunc(ccc.due_date) <=
trunc(to_date(${@last_month_date}, 'yyyy-mm-dd'))
AND ((trunc(t.lease_start_date) <=
trunc(to_date(${@last_month_date}, 'yyyy-mm-dd')) AND
t.contract_status = 'INCEPT') OR
(to_char(t.et_date, 'yyyy-mm') = ${@period_name} AND
t.contract_status = 'TERMINATE'))
AND ccc.due_amount >
nvl((SELECT SUM(cwo.write_off_due_amount)
FROM csh_transaction t, csh_write_off cwo
WHERE cwo.cashflow_id = ccc.cashflow_id
AND t.transaction_id = cwo.csh_transaction_id
AND nvl(cwo.reversed_flag, 'N') = 'N'
AND trunc(t.transaction_date) <
trunc(to_date(${@start_calc_date}, 'yyyy-mm-dd'))),
0)
]]>
</bm:query-sql>
</bm:operation>
</bm:operations>
<bm:query-fields>
<!-- <bm:query-field name="period_name" queryExpression="t1.period_day=${@period_name}"/>-->
<!-- <bm:query-field name="journal_date_to" queryExpression="to_char(t.journal_date,&apos;yyyy-mm-dd&apos;) &lt;= ${@journal_date_to}"/>-->
<!-- <bm:query-field name="bp_id_agent_level1" queryExpression="t.bp_id_agent_level1=${@bp_id_agent_level1}"/>-->
</bm:query-fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
$Author: qwm $Author: qwm
$Date: 2013-5-24 下午03:50:31 $Date: 2013-5-24 下午03:50:31
$Revision: 1.0 $Revision: 1.0
$Purpose: $Purpose:
--> -->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" <bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1"
baseTable="CSH_PAYMENT_REQ_LN" needAccessControl="false"> baseTable="CSH_PAYMENT_REQ_LN" needAccessControl="false">
<bm:operations> <bm:operations>
<bm:operation name="query"> <bm:operation name="query">
<bm:query-sql><![CDATA[ <bm:query-sql><![CDATA[
SELECT v.contract_id, SELECT v.contract_id,
v.vender_id, v.vender_id,
v.other_payment2, v.other_payment2,
'NEW' approval_status, 'NEW' approval_status,
...@@ -53,18 +53,21 @@ ...@@ -53,18 +53,21 @@
--代理店账户 --代理店账户
(SELECT hbbc.bank_account_name (SELECT hbbc.bank_account_name
FROM hls_bp_master_bank_account hbbc FROM hls_bp_master_bank_account hbbc
WHERE hbbc.bp_id=v.bp_id_agent_level1) bp_bank_account_name, WHERE hbbc.bank_account_id=v.bp_bank_account_id ) bp_bank_account_name,
--代理店账户 --代理店账户
v.bp_bank_account_id, v.bp_bank_account_id,
--代理店账号 --代理店账号
(SELECT hbbc.bank_account_num (SELECT hbbc.bank_account_num
FROM hls_bp_master_bank_account hbbc FROM hls_bp_master_bank_account hbbc
WHERE hbbc.bp_id=v.bp_id_agent_level1) bp_bank_account_num, WHERE hbbc.bank_account_id=v.bp_bank_account_id ) bp_bank_account_num,
--代理店账号 --代理店账号
(SELECT hbbc.bank_account_num (SELECT hbbc.bank_account_num
FROM hls_bp_master_bank_account hbbc FROM hls_bp_master_bank_account hbbc
WHERE hbbc.bp_id=v.bp_id_agent_level1) bp_bank_account_num_n, WHERE hbbc.bank_account_id=v.bp_bank_account_id ) bp_bank_account_num_n,
--代理店开户行
(SELECT hbbc.bank_full_name
FROM hls_bp_master_bank_account hbbc
WHERE hbbc.bank_account_id=v.bp_bank_account_id ) bp_bank_full_name,
(SELECT hb.sap_bvtyp (SELECT hb.sap_bvtyp
FROM hls_bp_master_bank_account hb FROM hls_bp_master_bank_account hb
WHERE hb.bank_account_id = v.bp_bank_account_id) sap_bvtyp, WHERE hb.bank_account_id = v.bp_bank_account_id) sap_bvtyp,
...@@ -82,7 +85,7 @@ ...@@ -82,7 +85,7 @@
FROM (SELECT t.contract_id, FROM (SELECT t.contract_id,
(SELECT hbbc.bank_account_id (SELECT hbbc.bank_account_id
FROM hls_bp_master_bank_account hbbc FROM hls_bp_master_bank_account hbbc
WHERE hbbc.bp_id=t.bp_id_agent_level1)bp_bank_account_id, WHERE hbbc.bp_id=t.bp_id_agent_level1 AND ROWNUM=1)bp_bank_account_id,
(SELECT DECODE(COUNT(1), 0, 'N', 'Y') (SELECT DECODE(COUNT(1), 0, 'N', 'Y')
FROM acp_invoice_ln ai FROM acp_invoice_ln ai
WHERE ai.contract_id = t.contract_id) invoice_uploaded_flag, WHERE ai.contract_id = t.contract_id) invoice_uploaded_flag,
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<bm:operations> <bm:operations>
<bm:operation name="query"> <bm:operation name="query">
<bm:query-sql><![CDATA[ <bm:query-sql><![CDATA[
SELECT t1.*, SELECT t1.*,
(select v.code_value_name (select v.code_value_name
from sys_code_values_v v from sys_code_values_v v
where v.code = 'CON_WRITE_OFF_FLAG' where v.code = 'CON_WRITE_OFF_FLAG'
...@@ -178,35 +178,12 @@ ...@@ -178,35 +178,12 @@
AND f.write_off_flag <> 'FULL' AND f.write_off_flag <> 'FULL'
AND f.cf_status IN ('RELEASE', 'BLOCK') AND f.cf_status IN ('RELEASE', 'BLOCK')
AND f.cf_direction = 'OUTFLOW' AND f.cf_direction = 'OUTFLOW'
AND (nvl(f.due_amount, 0) - AND NOT EXISTS (
nvl((SELECT SUM(l.amount_paid) SELECT 1
FROM csh_payment_req_ln l, csh_payment_req_hd h FROM csh_payment_req_ln l
WHERE l.ref_doc_line_id = f.cashflow_id WHERE l.ref_doc_line_id=f.cashflow_id
AND l.payment_req_id = h.payment_req_id AND l.ref_doc_category='CONTRACT'
-- AND )
--h.submitted_flag = 'Y' AND
-- h.approval_status = 'APPROVED'
AND nvl(h.closed_flag, 'N') = 'Y'),
0) -
nvl((SELECT SUM(l.amount)
FROM csh_payment_req_ln l, csh_payment_req_hd h
WHERE l.ref_doc_line_id = f.cashflow_id
AND l.payment_req_id = h.payment_req_id
--AND
-- h.submitted_flag = 'Y' AND
--h.approval_status = 'APPROVED'
AND nvl(h.closed_flag, 'N') <> 'Y'),
0) -
nvl((SELECT SUM(l.amount)
FROM csh_payment_req_ln l, csh_payment_req_hd h
WHERE l.ref_doc_line_id = f.cashflow_id
AND l.payment_req_id = h.payment_req_id
AND h.approval_status = 'APPROVING'
--AND
--h.submitted_flag = 'Y' AND
--h.approval_status = 'APPROVING'
),
0)) > 0
AND t.data_class = 'NORMAL' AND t.data_class = 'NORMAL'
AND ('Y' = 'Y' AND EXISTS AND ('Y' = 'Y' AND EXISTS
(SELECT 1 (SELECT 1
...@@ -226,6 +203,7 @@ ...@@ -226,6 +203,7 @@
--测试用,cf_itme应当为0 --测试用,cf_itme应当为0
AND f.cf_item in (0)) t1 AND f.cf_item in (0)) t1
#WHERE_CLAUSE# #WHERE_CLAUSE#
#ORDER_BY_CLAUSE# #ORDER_BY_CLAUSE#
......
<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true"
trace="true">
<a:init-procedure/>
<a:view>
<a:link id="contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
<script type="text/javascript"><![CDATA[
function getNextDate(date,day) {
var dd = new Date(date);
dd.setDate(dd.getDate() + day);
var y = dd.getFullYear();
var m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;
var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();
return y + "-" + m + "-" + d;
};
window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
var query_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var grid_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_lease_item');
var period_name=$(query_ds_id).getAt(0).get('period_name');
if(!period_name){
$L.showInfoMessage("提示",'请选择期间进行查询!');
return;
}
//拆分成三个
//月初
var start_calc_date=period_name+'-01';
var temp_date = new Date(start_calc_date.replace(/-/g, '/')); // "2010/08/01";
temp_date.setMonth(temp_date.getMonth() + 1);//再设置成下个月
var last_month_date=getNextDate(temp_date,-1);
//查询数据
$(grid_ds_id).setQueryUrl("${/request/@context_path}/autocrud/cont.CON3700.contract_overdue_report/query");
$(grid_ds_id).setQueryParameter('period_name',period_name);
$(grid_ds_id).setQueryParameter('start_calc_date',start_calc_date);
$(grid_ds_id).setQueryParameter('last_month_date',last_month_date);
$(grid_ds_id).query();
}
]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
</a:view>
</a:screen>
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
if (!records.length) { if (!records.length) {
Leaf.showMessage('提示', '请至少选择一条数据!'); Leaf.showMessage('提示', '请至少选择一条数据!');
} else { } else {
for (var i = 0;i < records.length;i++) { for (var i = 0;i < records.length;i++) {
if (records[i].get('payment_req_id')) { if (records[i].get('payment_req_id')) {
if (records[i].get('approval_status') == 'APPROVING' || records[i].get('approval_status') == 'APPROVED') { if (records[i].get('approval_status') == 'APPROVING' || records[i].get('approval_status') == 'APPROVED') {
...@@ -49,11 +50,14 @@ ...@@ -49,11 +50,14 @@
} }
} }
param['details'] = datas; param['details'] = datas;
console.log(datas);
debugger
var url_l = $('delete_payment_req_link_id').getUrl(); var url_l = $('delete_payment_req_link_id').getUrl();
Leaf.request({ Leaf.request({
url: url_l, url: url_l,
para: datas, para: datas,
success: function() { success: function() {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
$(ds_id).query(); $(ds_id).query();
}, },
......
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