Commit 96a0101c authored by stone's avatar stone

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

parent 0352d31f
......@@ -27,21 +27,10 @@ SELECT h.extra_nam,
0
END) unpayment_amount,
--应付未付首付款总额 --首付款关联不到就取核销日期而不是收款日期
(CASE
WHEN to_char(t.lease_start_date, 'yyyy-mm') <> ${@period_name} THEN
(SELECT SUM(nvl(ccc.due_amount, 0))
FROM con_contract_cashflow ccc
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,
contract_item_query_pkg.calc_down_payment_balance ( p_contract_id=>t.contract_id,
p_calc_date =>to_date(${@last_month_date}, 'yyyy-mm-dd'),
p_calc_flag =>'START',
p_user_id =>-1) undown_payment,
--应付未付留购金总额
(CASE
WHEN to_char(t.lease_start_date, 'yyyy-mm') <> ${@period_name} THEN
......@@ -172,11 +161,12 @@ SELECT h.extra_nam,
TRUNC(to_date(${@start_calc_date}, 'yyyy-mm-dd'))),
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'),
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)
FROM csh_write_off cwo, csh_transaction ct
......@@ -220,15 +210,11 @@ SELECT h.extra_nam,
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_user_id => -1) rest_unpayment_amount_af,
--应付未付首付款总额
(SELECT SUM(nvl(ccc.due_amount, 0))
FROM con_contract_cashflow ccc
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 => last_day(to_date(${@start_calc_date},'yyyy-mm-dd')),
p_user_id => -1) rest_undown_payment,
contract_item_query_pkg.calc_down_payment_balance ( p_contract_id=>t.contract_id,
p_calc_date =>last_day(to_date(${@start_calc_date},'yyyy-mm-dd')),
p_calc_flag =>'END',
p_user_id =>-1) rest_undown_payment,
--应付未付留购金总额
(SELECT SUM(nvl(ccc.due_amount, 0))
FROM con_contract_cashflow ccc
......@@ -366,6 +352,7 @@ SELECT h.extra_nam,
'TERMINATING',
'ETING',
'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"?>
<!--
$Author: qwm
$Date: 2013-5-24 下午03:50:31
$Revision: 1.0
$Purpose:
$Author: qwm
$Date: 2013-5-24 下午03:50:31
$Revision: 1.0
$Purpose:
-->
<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">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT v.contract_id,
SELECT v.contract_id,
v.vender_id,
v.other_payment2,
'NEW' approval_status,
......@@ -53,18 +53,21 @@
--代理店账户
(SELECT hbbc.bank_account_name
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,
--代理店账号
(SELECT hbbc.bank_account_num
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
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
FROM hls_bp_master_bank_account hb
WHERE hb.bank_account_id = v.bp_bank_account_id) sap_bvtyp,
......@@ -82,7 +85,7 @@
FROM (SELECT t.contract_id,
(SELECT hbbc.bank_account_id
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')
FROM acp_invoice_ln ai
WHERE ai.contract_id = t.contract_id) invoice_uploaded_flag,
......
......@@ -10,7 +10,7 @@
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT t1.*,
SELECT t1.*,
(select v.code_value_name
from sys_code_values_v v
where v.code = 'CON_WRITE_OFF_FLAG'
......@@ -178,35 +178,12 @@
AND f.write_off_flag <> 'FULL'
AND f.cf_status IN ('RELEASE', 'BLOCK')
AND f.cf_direction = 'OUTFLOW'
AND (nvl(f.due_amount, 0) -
nvl((SELECT SUM(l.amount_paid)
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.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 NOT EXISTS (
SELECT 1
FROM csh_payment_req_ln l
WHERE l.ref_doc_line_id=f.cashflow_id
AND l.ref_doc_category='CONTRACT'
)
AND t.data_class = 'NORMAL'
AND ('Y' = 'Y' AND EXISTS
(SELECT 1
......@@ -226,6 +203,7 @@
--测试用,cf_itme应当为0
AND f.cf_item in (0)) t1
#WHERE_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 @@
if (!records.length) {
Leaf.showMessage('提示', '请至少选择一条数据!');
} else {
for (var i = 0;i < records.length;i++) {
if (records[i].get('payment_req_id')) {
if (records[i].get('approval_status') == 'APPROVING' || records[i].get('approval_status') == 'APPROVED') {
......@@ -49,11 +50,14 @@
}
}
param['details'] = datas;
console.log(datas);
debugger
var url_l = $('delete_payment_req_link_id').getUrl();
Leaf.request({
url: url_l,
para: datas,
success: function() {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
$(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