Commit 9c59f5ea authored by Spencer Chang's avatar Spencer Chang

[feat] 合同变更功能二開

parent 6a9c2afa
...@@ -18,4 +18,37 @@ VALUES ...@@ -18,4 +18,37 @@ VALUES
LAST_UPDATE_DATE, LAST_UPDATE_DATE,
LAST_UPDATED_BY) LAST_UPDATED_BY)
VALUES VALUES
('CON_ET002', '提前结清申请明细', 1, SYSDATE, -1, SYSDATE, -1); ('CON_ET002', '提前结清申请明细', 1, SYSDATE, -1, SYSDATE, -1);
\ No newline at end of file
INSERT INTO SYS_FUNCTION_DYNAMIC
(FUNCTION_CODE,
FUNCTION_NAME,
SEQUENCE,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY)
VALUES
('CON733CF', '合同租金计划变更申请明细', 1, SYSDATE, -1, SYSDATE, -1);
INSERT INTO SYS_FUNCTION_DYNAMIC
(FUNCTION_CODE,
FUNCTION_NAME,
SEQUENCE,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY)
VALUES
('CON733BPT', '合同承租人变更申请明细', 1, SYSDATE, -1, SYSDATE, -1);
INSERT INTO SYS_FUNCTION_DYNAMIC
(FUNCTION_CODE,
FUNCTION_NAME,
SEQUENCE,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATED_BY)
VALUES
('CON733BPB', '合同回款账户变更申请明细', 1, SYSDATE, -1, SYSDATE, -1);
\ No newline at end of file
create or replace package "FND_CODE_RULE_PKG" is
-- Author : Tengjianbo
-- Created : 2009-5-14 14:44:24
-- Purpose :
--Ver: 1.11
-- Mantis 0025577:编码规则取日期相关时,即使按期间重置,也不校验期间状态是否打开。
--Modify by bobo
--Ver: 1.12
--规则明细界面增加一列是否显示DISPLAY_FLAG
--Modify by bobo 2009.09.08
--Ver: 1.15
--WEB界面查询用函数:get_document_type_name 中的sql对company_id加上nvl
--否则系统级单据类型会取不到描述
--Modify by Razgriz.Tang @2010-04-26
--Ver: 1.16
--32996: 取期间时,排除调整期间
c_function_code constant varchar2(30) := 'FND1910';
--编码规则获取失败
c_error constant varchar2(30) := 'ERROR';
--编码长度超过30位 error_code :FND_CODING_RULE_MAX_LENGTH_ERROR
--c_max_length_error constant varchar2(30) := 'MAX_LENGTH_ERROR';
--编码规则对象定义
procedure insert_fnd_coding_rule_objects(p_document_category varchar2,
p_document_type varchar2,
p_company_id number,
p_operation_unit_id number,
p_enabled_flag varchar2,
p_coding_rule_id number,
p_priority number,
p_created_by number,
p_coding_rule_object_id out number);
procedure update_fnd_coding_rule_objects(p_coding_rule_object_id number,
p_coding_rule_id number,
p_enabled_flag varchar2,
p_priority number,
p_last_updated_by number);
/*--编码规则只能有一个启用
procedure coding_rules_check(p_coding_rule_object_id number,
p_created_by number);*/
function get_coding_rule_object_id(p_document_category varchar2,
p_document_type varchar2,
p_company_id number,
p_operation_unit_id number,
p_object_document_type out varchar2,
p_object_company_id out number,
p_object_operation_unit_id out number,
p_object_coding_rule_id out number,
p_reset_frequence out varchar2)
return number;
--编码规则
procedure insert_fnd_coding_rules(p_document_category varchar2,
p_coding_rule_code varchar2,
p_description varchar2,
p_note varchar2,
p_enabled_flag varchar2,
p_created_by number,
p_reset_frequence varchar2,
p_coding_rule_id out number);
procedure update_fnd_coding_rules(p_coding_rule_id number,
p_description varchar2,
p_note varchar2,
p_enabled_flag varchar2,
p_last_updated_by number,
p_reset_frequence varchar2);
procedure delete_fnd_coding_rules(p_coding_rule_id number,
p_last_updated_by number);
--规则明细
procedure insert_fnd_coding_rule_details(p_coding_rule_id number,
p_sequence number,
p_segment_type varchar2,
p_segment_value varchar2,
p_length number,
p_incremental number,
p_start_value number,
p_created_by number,
p_date_format varchar2,
p_display_flag varchar2);
procedure update_fnd_coding_rule_details(p_coding_rule_line_id number,
p_coding_rule_id number,
p_sequence number,
p_segment_type varchar2,
p_segment_value varchar2,
p_length number,
p_incremental number,
p_start_value number,
p_last_updated_by number,
p_date_format varchar2,
p_display_flag varchar2);
procedure delete_fnd_coding_rule_details(p_coding_rule_line_id number,
p_coding_rule_id number,
p_last_updated_by number);
function get_rule_next_auto_num(p_document_category varchar2,
p_document_type varchar2,
p_company_id number,
p_operation_unit_id number,
p_operation_date date,
p_division varchar2 default null,
p_bp_info varchar2 default null,
p_province_id number default null,
p_agent_code varchar2 default null,
p_price_ref_v05 varchar2 default null,
p_product_code varchar2 default null, -- 产品编号 add by liukang
p_created_by number) return varchar2;
end fnd_code_rule_pkg;
/
create or replace package body "FND_CODE_RULE_PKG" is
e_fnd_c_r_status_error exception;
e_fnd_c_r_max_length_error exception;
e_fnd_c_r_start_value_error exception;
e_fnd_c_r_incremental_error exception;
e_fnd_c_r_segment_error exception;
e_fnd_segment_type_06_err exception;
e_fnd_segment_type_02_err exception; --Data format error
e_binary_integer_error exception;
g_company_id number;
g_document_category varchar2(30);
g_document_type varchar2(30);
g_operation_unit_id number;
g_operation_date date;
procedure error_log(p_message varchar2, p_user_id number) is
pragma autonomous_transaction;
begin
insert into fnd_coding_rule_error_logs
(company_id,
document_category,
document_type,
operation_unit_id,
operation_date,
message,
created_by,
creation_date,
last_updated_by,
last_update_date)
values
(g_company_id,
g_document_category,
g_document_type,
g_operation_unit_id,
g_operation_date,
p_message,
p_user_id,
sysdate,
p_user_id,
sysdate);
commit;
end error_log;
--编码规则对象定义
procedure insert_fnd_coding_rule_objects(p_document_category varchar2,
p_document_type varchar2,
p_company_id number,
p_operation_unit_id number,
p_enabled_flag varchar2,
p_coding_rule_id number,
p_priority number,
p_created_by number,
p_coding_rule_object_id out number) is
v_count number;
v_coding_rule_object_id fnd_coding_rule_objects.coding_rule_object_id%type;
e_priority_duplicat exception;
begin
select fnd_coding_rule_objects_s.nextval
into v_coding_rule_object_id
from dual;
insert into fnd_coding_rule_objects
(coding_rule_object_id,
document_category,
coding_rule_id,
document_type,
company_id,
operation_unit_id,
priority,
enabled_flag,
created_by,
creation_date,
last_updated_by,
last_update_date)
values
(v_coding_rule_object_id,
p_document_category,
p_coding_rule_id,
p_document_type,
p_company_id,
p_operation_unit_id,
p_priority,
p_enabled_flag,
p_created_by,
sysdate,
p_created_by,
sysdate);
p_coding_rule_object_id := v_coding_rule_object_id;
exception
when dup_val_on_index then
--捕获 唯一索引错误
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_OBJECTS_DUPLICATE',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_objects');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when others then
sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' ||
sqlerrm,
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_objects');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end insert_fnd_coding_rule_objects;
procedure update_fnd_coding_rule_objects(p_coding_rule_object_id number,
p_coding_rule_id number,
p_enabled_flag varchar2,
p_priority number,
p_last_updated_by number) is
begin
update fnd_coding_rule_objects o
set o.last_updated_by = p_last_updated_by,
o.last_update_date = sysdate,
o.coding_rule_id = p_coding_rule_id,
o.priority = p_priority,
o.enabled_flag = p_enabled_flag
where o.coding_rule_object_id = p_coding_rule_object_id;
end update_fnd_coding_rule_objects;
--校验编码规则是否已被引用
function coding_rule_details_modify_chk(p_coding_rule_id number)
return varchar2 is
v_ret varchar2(1);
begin
select 'N'
into v_ret
from dual
where exists (select 1
from fnd_coding_rule_values v
where v.coding_rule_id = p_coding_rule_id);
return v_ret;
exception
when no_data_found then
return 'Y';
end coding_rule_details_modify_chk;
/*--编码规则只能有一个启用
procedure coding_rules_check(p_coding_rule_object_id number,
p_created_by number) is
v_count number;
e_fnd_c_r_enabled_error exception;
begin
select count(1)
into v_count
from fnd_coding_rules r
where r.coding_rule_object_id = p_coding_rule_object_id
and r.enabled_flag = 'Y';
if v_count > 1 then
raise e_fnd_c_r_enabled_error;
end if;
exception
when e_fnd_c_r_enabled_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_ENABLED_FLAG_DUPLICATE',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'coding_rules_check');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end coding_rules_check;*/
--编码规则
procedure insert_fnd_coding_rules(p_document_category varchar2,
p_coding_rule_code varchar2,
p_description varchar2,
p_note varchar2,
p_enabled_flag varchar2,
p_created_by number,
p_reset_frequence varchar2,
p_coding_rule_id out number) is
v_description_id fnd_coding_rules.description_id%type;
begin
v_description_id := fnd_description_pkg.get_fnd_description_id;
select fnd_coding_rules_s.nextval into p_coding_rule_id from dual;
insert into fnd_coding_rules
(document_category,
coding_rule_id,
coding_rule_code,
description_id,
note,
enabled_flag,
created_by,
creation_date,
last_updated_by,
last_update_date,
reset_frequence)
values
(p_document_category,
p_coding_rule_id,
upper(p_coding_rule_code),
v_description_id,
p_note,
p_enabled_flag,
p_created_by,
sysdate,
p_created_by,
sysdate,
p_reset_frequence);
fnd_description_pkg.reset_fnd_descriptions(p_description_id => v_description_id,
p_ref_table => 'FND_CODING_RULES',
p_ref_field => 'DESCRIPTION_ID',
p_description_text => p_description,
p_function_name => c_function_code,
p_created_by => p_created_by,
p_last_updated_by => p_created_by,
p_language_code => userenv('lang'));
exception
when dup_val_on_index then
--捕获 唯一索引错误
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_DUPLICATE',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rules');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when others then
sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' ||
sqlerrm,
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rules');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end insert_fnd_coding_rules;
procedure update_fnd_coding_rules(p_coding_rule_id number,
p_description varchar2,
p_note varchar2,
p_enabled_flag varchar2,
p_last_updated_by number,
p_reset_frequence varchar2) is
v_description_id fnd_coding_rules.description_id%type;
v_reset_frequence fnd_coding_rules.reset_frequence%type;
begin
select description_id, reset_frequence
into v_description_id, v_reset_frequence
from fnd_coding_rules
where coding_rule_id = p_coding_rule_id;
if p_reset_frequence <> v_reset_frequence and
coding_rule_details_modify_chk(p_coding_rule_id) = 'N' then
raise e_fnd_c_r_status_error;
end if;
update fnd_coding_rules r
set r.last_updated_by = p_last_updated_by,
r.reset_frequence = p_reset_frequence,
r.last_update_date = sysdate,
r.enabled_flag = p_enabled_flag,
r.note = p_note
where coding_rule_id = p_coding_rule_id;
fnd_description_pkg.reset_fnd_descriptions(p_description_id => v_description_id,
p_ref_table => 'FND_CODING_RULES',
p_ref_field => 'DESCRIPTION_ID',
p_description_text => p_description,
p_function_name => c_function_code,
p_created_by => p_last_updated_by,
p_last_updated_by => p_last_updated_by,
p_language_code => userenv('lang'));
exception
when e_fnd_c_r_status_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_STATUS_CHECK_ERROR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rules');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when others then
sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' ||
sqlerrm,
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rules');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end update_fnd_coding_rules;
procedure delete_fnd_coding_rules(p_coding_rule_id number,
p_last_updated_by number) is
begin
if coding_rule_details_modify_chk(p_coding_rule_id) = 'Y' then
delete from fnd_coding_rule_details d
where d.coding_rule_id = p_coding_rule_id;
delete from fnd_coding_rules d
where d.coding_rule_id = p_coding_rule_id;
else
raise e_fnd_c_r_status_error;
end if;
exception
when e_fnd_c_r_status_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_STATUS_CHECK_ERROR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'delete_fnd_coding_rules');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end delete_fnd_coding_rules;
procedure binary_integer_check(p_nubmber number) is
v_temp number;
begin
if p_nubmber <= 0 then
raise e_binary_integer_error;
end if;
select instr(p_nubmber, '.') into v_temp from dual;
if v_temp > 0 then
raise e_binary_integer_error;
end if;
end binary_integer_check;
--规则长度校验
procedure coding_detail_rules_check(p_coding_rule_id number,
p_segment_type varchar2,
p_length number,
p_incremental number,
p_start_value number) is
v_max_length number;
v_count number;
begin
--06 序列号校验
if p_segment_type = '06' and
(p_length is null or p_incremental is null or p_start_value is null) then
raise e_fnd_segment_type_06_err;
end if;
if p_segment_type = '06' then
if length(p_start_value) > p_length then
raise e_fnd_c_r_start_value_error;
end if;
if length(p_incremental) > p_length then
raise e_fnd_c_r_incremental_error;
end if;
end if;
--(日期格式 + 序列号位数 + 字符串 )总长度校验
select sum(sub_length) + (decode(p_segment_type, '06', p_length, 0))
into v_max_length
from (select nvl(length(d.segment_value), 0) +
nvl(length(d.date_format), 0) sub_length
from fnd_coding_rule_details d
where d.coding_rule_id = p_coding_rule_id);
if v_max_length > 30 then
raise e_fnd_c_r_max_length_error;
end if;
--序列号只能有一个
select count(1)
into v_count
from fnd_coding_rule_details d
where d.coding_rule_id = p_coding_rule_id
and d.segment_type = '06';
if v_count > 1 then
raise e_fnd_c_r_segment_error;
end if;
end coding_detail_rules_check;
--规则明细
procedure insert_fnd_coding_rule_details(p_coding_rule_id number,
p_sequence number,
p_segment_type varchar2,
p_segment_value varchar2,
p_length number,
p_incremental number,
p_start_value number,
p_created_by number,
p_date_format varchar2,
p_display_flag varchar2) is
begin
if coding_rule_details_modify_chk(p_coding_rule_id) = 'Y' then
if p_segment_type = '02' and p_date_format is null then
raise e_fnd_segment_type_02_err;
end if;
binary_integer_check(p_sequence);
binary_integer_check(p_length);
binary_integer_check(p_incremental);
binary_integer_check(p_start_value);
insert into fnd_coding_rule_details
(coding_rule_line_id,
coding_rule_id,
sequence,
segment_type,
segment_value,
length,
incremental,
start_value,
created_by,
creation_date,
last_updated_by,
last_update_date,
date_format,
display_flag)
values
(fnd_coding_rule_details_s.nextval,
p_coding_rule_id,
p_sequence,
p_segment_type,
p_segment_value,
p_length,
p_incremental,
p_start_value,
p_created_by,
sysdate,
p_created_by,
sysdate,
p_date_format,
p_display_flag);
coding_detail_rules_check(p_coding_rule_id => p_coding_rule_id,
p_segment_type => p_segment_type,
p_length => p_length,
p_incremental => p_incremental,
p_start_value => p_start_value);
else
raise e_fnd_c_r_status_error;
end if;
exception
when e_binary_integer_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_BINARY_INTEGER_ERR',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_segment_type_06_err then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_SEGMENT_TYPE_06_ERR',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_segment_type_02_err then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_SEGMENT_TYPE_02_ERR',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_status_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_STATUS_CHECK_ERROR',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_segment_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_DETAILS_SEGMENT_DUPLICATE',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_max_length_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_MAX_LENGTH_ERROR',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_start_value_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULES_TART_VALUE_ERROR',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_incremental_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_INCREMENTAL_ERROR',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when dup_val_on_index then
--捕获 唯一索引错误
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_DETAILS_SEQ_DUPLICATE',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when others then
sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' ||
sqlerrm,
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'insert_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end insert_fnd_coding_rule_details;
procedure update_fnd_coding_rule_details(p_coding_rule_line_id number,
p_coding_rule_id number,
p_sequence number,
p_segment_type varchar2,
p_segment_value varchar2,
p_length number,
p_incremental number,
p_start_value number,
p_last_updated_by number,
p_date_format varchar2,
p_display_flag varchar2) is
begin
if coding_rule_details_modify_chk(p_coding_rule_id) = 'Y' then
if p_segment_type = '02' and p_date_format is null then
raise e_fnd_segment_type_02_err;
end if;
binary_integer_check(p_sequence);
binary_integer_check(p_length);
binary_integer_check(p_incremental);
binary_integer_check(p_start_value);
update fnd_coding_rule_details d
set d.sequence = p_sequence,
d.segment_type = p_segment_type,
d.segment_value = p_segment_value,
d.length = p_length,
d.incremental = p_incremental,
d.start_value = p_start_value,
d.last_updated_by = p_last_updated_by,
d.last_update_date = sysdate,
d.date_format = p_date_format,
d.display_flag = p_display_flag
where d.coding_rule_line_id = p_coding_rule_line_id;
coding_detail_rules_check(p_coding_rule_id => p_coding_rule_id,
p_segment_type => p_segment_type,
p_length => p_length,
p_incremental => p_incremental,
p_start_value => p_start_value);
else
raise e_fnd_c_r_status_error;
end if;
exception
when e_binary_integer_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_BINARY_INTEGER_ERR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_segment_type_02_err then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_SEGMENT_TYPE_02_ERR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_segment_type_06_err then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_SEGMENT_TYPE_06_ERR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_segment_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_DETAILS_SEGMENT_DUPLICATE',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_max_length_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_MAX_LENGTH_ERROR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_start_value_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULES_TART_VALUE_ERROR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_incremental_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_INCREMENTAL_ERROR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when e_fnd_c_r_status_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_STATUS_CHECK_ERROR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when dup_val_on_index then
--捕获 唯一索引错误
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_DETAILS_SEQ_DUPLICATE',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when others then
sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' ||
sqlerrm,
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'update_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end update_fnd_coding_rule_details;
procedure delete_fnd_coding_rule_details(p_coding_rule_line_id number,
p_coding_rule_id number,
p_last_updated_by number) is
begin
if coding_rule_details_modify_chk(p_coding_rule_id) = 'Y' then
delete from fnd_coding_rule_details d
where d.coding_rule_line_id = p_coding_rule_line_id;
else
raise e_fnd_c_r_status_error;
end if;
exception
when e_fnd_c_r_status_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_STATUS_CHECK_ERROR',
p_created_by => p_last_updated_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'delete_fnd_coding_rule_details');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end delete_fnd_coding_rule_details;
--编码规则当前值
procedure insert_fnd_coding_rule_values(p_coding_rule_id number,
p_company_id number,
p_year number,
p_period_name varchar2,
p_current_value number,
p_created_by number,
p_document_category varchar2,
p_document_type varchar2,
p_operation_unit_id number,
p_bp_info varchar2,
p_province_id number,
p_days varchar2,
--p_product_code varchar2,
p_agent_value varchar2 default null) is
begin
insert into fnd_coding_rule_values
(coding_rule_id,
company_id,
year,
period_name,
current_value,
created_by,
creation_date,
last_updated_by,
last_update_date,
document_category,
document_type,
operation_unit_id,
agent_value,
bp_info,
province_id,
days)
values
(p_coding_rule_id,
'', --p_company_id,
p_year,
p_period_name,
p_current_value,
p_created_by,
sysdate,
p_created_by,
sysdate,
p_document_category,
null, --p_document_type,
null, --p_operation_unit_id
p_agent_value,
p_bp_info,
p_province_id,
p_days);
end insert_fnd_coding_rule_values;
function get_coding_rule_object_id(p_document_category varchar2,
p_document_type varchar2,
p_company_id number,
p_operation_unit_id number,
p_object_document_type out varchar2,
p_object_company_id out number,
p_object_operation_unit_id out number,
p_object_coding_rule_id out number,
p_reset_frequence out varchar2)
return number is
cursor cur_priority is
select o.coding_rule_object_id,
o.priority,
o.document_type,
o.company_id,
o.operation_unit_id,
o.coding_rule_id,
r.reset_frequence
from fnd_coding_rule_objects o, fnd_coding_rules r
where o.document_category = p_document_category
and o.enabled_flag = 'Y'
and o.coding_rule_id = r.coding_rule_id
and r.enabled_flag = 'Y'
order by o.priority;
v_coding_rule_object_id fnd_coding_rule_objects.coding_rule_object_id%type;
begin
v_coding_rule_object_id := null;
if p_document_type is null then
for c_priority in cur_priority loop
if nvl(c_priority.document_type, nvl(p_document_type, -1)) =
nvl(p_document_type, -1) and
nvl(c_priority.company_id, nvl(p_company_id, -1)) =
nvl(p_company_id, -1) and
nvl(c_priority.operation_unit_id, nvl(p_operation_unit_id, -1)) =
nvl(p_operation_unit_id, -1) then
v_coding_rule_object_id := c_priority.coding_rule_object_id;
p_object_document_type := c_priority.document_type;
p_object_company_id := c_priority.company_id;
p_object_operation_unit_id := c_priority.operation_unit_id;
p_object_coding_rule_id := c_priority.coding_rule_id;
p_reset_frequence := c_priority.reset_frequence;
exit;
end if;
end loop;
else
for c_coding_rules in (select o.coding_rule_object_id,
o.priority,
o.document_type,
o.company_id,
o.operation_unit_id,
o.coding_rule_id,
r.reset_frequence
from fnd_coding_rule_objects o,
fnd_coding_rules r
where o.document_category =
p_document_category
and o.document_type = p_document_type
and o.enabled_flag = 'Y'
and o.coding_rule_id = r.coding_rule_id
and r.enabled_flag = 'Y'
order by o.priority) loop
if nvl(c_coding_rules.company_id, nvl(p_company_id, -1)) =
nvl(p_company_id, -1) and
nvl(c_coding_rules.operation_unit_id,
nvl(p_operation_unit_id, -1)) = nvl(p_operation_unit_id, -1) then
v_coding_rule_object_id := c_coding_rules.coding_rule_object_id;
p_object_document_type := c_coding_rules.document_type;
p_object_company_id := c_coding_rules.company_id;
p_object_operation_unit_id := c_coding_rules.operation_unit_id;
p_object_coding_rule_id := c_coding_rules.coding_rule_id;
p_reset_frequence := c_coding_rules.reset_frequence;
exit;
end if;
end loop;
end if;
return v_coding_rule_object_id;
exception
when no_data_found then
return null;
end get_coding_rule_object_id;
/*function get_coding_rule_id(p_coding_rule_object_id number,
p_reset_frequence out varchar2)
return number is
v_coding_rule_id fnd_coding_rules.coding_rule_id%type;
begin
select coding_rule_id, reset_frequence
into v_coding_rule_id, p_reset_frequence
from fnd_coding_rules
where coding_rule_object_id = p_coding_rule_object_id
and enabled_flag = 'Y';
return v_coding_rule_id;
exception
when no_data_found then
return null;
end get_coding_rule_id;*/
function get_current_value(p_coding_rule_id number,
p_company_id number,
p_year number,
p_period_name varchar2,
p_document_category varchar2,
p_document_type varchar2,
p_operation_unit_id number,
p_bp_info varchar2 default null,
p_province_id number default null,
p_days varchar2,
-- p_product_code varchar2, -- add by liukang
p_agent_value varchar2 default null)
return number is
v_current_value fnd_coding_rule_values.current_value%type;
begin
select current_value
into v_current_value
from fnd_coding_rule_values v
where coding_rule_id = p_coding_rule_id
and v.document_category = p_document_category
and (bp_info = p_bp_info or (bp_info is null and p_bp_info is null))
and (province_id = p_province_id or
(province_id is null and p_province_id is null))
--AND (operation_unit_id = p_operation_unit_id OR
-- (operation_unit_id IS NULL AND p_operation_unit_id IS NULL))
and (v.year = p_year or (v.year is null and p_year is null))
and (period_name = p_period_name or
(period_name is null and p_period_name is null))
and (agent_value = p_agent_value or (p_agent_value is null))
and (v.days = p_days or (v.days is null and p_days is null));
--add by liukang
--and v.product_code = p_product_code;
return v_current_value;
exception
when no_data_found then
return null;
end get_current_value;
function get_gld_period_name(p_company_id number, p_operation_date date)
return varchar2 is
v_period_name gld_periods.period_name%type;
begin
select g.period_name
into v_period_name
from gld_periods g
--, gld_period_status p
where g.start_date <= trunc(p_operation_date)
and g.end_date >= trunc(p_operation_date)
--and g.period_set_code = p.period_set_code
--and p.company_id = p_company_id
--and p.internal_period_num = g.internal_period_num
--and p.period_status_code = 'O' --for mantis 0025577
and g.period_set_code =
(select b.period_set_code
from gld_set_of_books b
where b.set_of_books_id =
(select f.set_of_books_id
from fnd_companies f
where f.company_id = p_company_id))
and g.adjustment_flag = 'N';
return v_period_name;
exception
when no_data_found then
return null;
end get_gld_period_name;
function get_company_code(p_company_id number) return varchar2 is
v_company_code fnd_companies.company_code%type;
begin
select company_code
into v_company_code
from fnd_companies
where company_id = p_company_id;
return v_company_code;
exception
when no_data_found then
return null;
end get_company_code;
--获取经营单位代码
function get_operation_unit_code(p_operation_unit_id number)
return varchar2 is
v_operation_unit_code fnd_operation_units.operation_unit_code%type;
begin
select operation_unit_code
into v_operation_unit_code
from fnd_operation_units o
where o.operation_unit_id = p_operation_unit_id;
return v_operation_unit_code;
exception
when no_data_found then
return null;
end get_operation_unit_code;
function get_detail_segment_value(p_coding_rule_id number,
p_segment_type varchar2) return boolean is
v_exists number;
begin
select 1
into v_exists
from dual
where exists (select 1
from fnd_coding_rule_details d
where d.coding_rule_id = p_coding_rule_id
and d.segment_type = p_segment_type);
return true;
exception
when no_data_found then
return false;
end get_detail_segment_value;
--获取厂商代码 add by liukang 20160617
function get_product_code(p_product_plan_id number) return varchar2 is
v_product_code varchar2(2000);
begin
select hp.product_code
into v_product_code
from hls_product_plan_definition hp
where hp.product_plan_id = p_product_plan_id;
return v_product_code;
exception
when no_data_found then
return null;
end get_product_code;
function get_rule_next_auto_num(p_document_category varchar2,
p_document_type varchar2,
p_company_id number,
p_operation_unit_id number,
p_operation_date date,
p_division varchar2 default null,
p_bp_info varchar2 default null,
p_province_id number default null,
p_agent_code varchar2 default null,
p_price_ref_v05 varchar2 default null,
p_product_code varchar2 default null, -- 产品编号 add by liukang
p_created_by number) return varchar2 is
pragma autonomous_transaction;
cursor cur_details(p_coding_rule_id number) is
select d.segment_type,
d.segment_value,
d.date_format,
nvl(d.display_flag, 'N') display_flag
from fnd_coding_rule_details d
where d.coding_rule_id = p_coding_rule_id
order by d.sequence
for update;
v_details cur_details%rowtype;
v_coding_rule_object_id fnd_coding_rule_objects.coding_rule_object_id%type;
v_object_document_type fnd_coding_rule_objects.document_type%type;
v_object_company_id fnd_coding_rule_objects.company_id%type;
v_object_operation_unit_id fnd_coding_rule_objects.operation_unit_id%type;
v_reset_frequence fnd_coding_rules.reset_frequence%type;
v_coding_rule_id fnd_coding_rules.coding_rule_id%type;
v_length fnd_coding_rule_details.length%type;
v_incremental fnd_coding_rule_details.incremental%type;
v_start_value fnd_coding_rule_details.start_value%type;
v_current_value fnd_coding_rule_values.current_value%type;
v_year fnd_coding_rule_values.year%type;
v_period_name fnd_coding_rule_values.period_name%type;
--当前值
v_cur_document_type fnd_coding_rule_values.document_type%type;
v_cur_operation_unit_id fnd_coding_rule_values.operation_unit_id%type;
v_cur_company_id fnd_coding_rule_values.company_id%type;
--规则明细定义的段值
v_segment_document_type fnd_coding_rule_values.document_type%type;
v_segment_operation_unit_id fnd_coding_rule_values.operation_unit_id%type;
v_segment_company_id fnd_coding_rule_values.company_id%type;
v_operation_date date;
v_doc_number varchar2(500);
v_doc_number_tmp varchar2(30);
v_agent_value varchar2(30);
v_days varchar2(30);
e_null_error exception;
e_codeing_rule_null_error exception;
v_err_msg varchar2(2000);
--产品编号 add by liukang
--v_product_code varchar2(2000);
begin
--v_product_code := get_product_code(p_product_plan_id => p_product_plan_id);
-- 获取产品编号 add by liukang
g_company_id := p_company_id;
g_document_category := p_document_category;
g_document_type := p_document_type;
g_operation_unit_id := p_operation_unit_id;
g_operation_date := p_operation_date;
--获取编码规则对象
v_coding_rule_object_id := get_coding_rule_object_id(p_document_category => p_document_category,
p_document_type => p_document_type,
p_company_id => p_company_id,
p_operation_unit_id => p_operation_unit_id,
p_object_document_type => v_object_document_type,
p_object_company_id => v_object_company_id,
p_object_operation_unit_id => v_object_operation_unit_id,
p_object_coding_rule_id => v_coding_rule_id,
p_reset_frequence => v_reset_frequence);
if v_coding_rule_object_id is null then
error_log(p_message => sys_message_pkg.get_string('FND_CODING_RULE_OBJECT_NULL'),
p_user_id => p_created_by);
rollback;
-- raise e_codeing_rule_null_error;
return c_error;
end if;
if v_coding_rule_id is null then
error_log(p_message => sys_message_pkg.get_string('FND_CODING_RULE_NULL'),
p_user_id => p_created_by);
rollback;
-- raise e_codeing_rule_null_error;
return c_error;
end if;
--锁表
open cur_details(v_coding_rule_id);
--获取开始值、步长、位数
begin
select length, incremental, start_value
into v_length, v_incremental, v_start_value
from fnd_coding_rule_details d
where d.coding_rule_id = v_coding_rule_id
and d.segment_type = '06';
exception
when no_data_found then
error_log(p_message => sys_message_pkg.get_string('FND_CODING_RULE_SEQUENCE_NULL'),
p_user_id => p_created_by);
raise e_null_error;
end;
if p_operation_date is null then
select to_date(to_char(sysdate, 'YYYYMMDD'), 'YYYYMMDD')
into v_operation_date
from dual;
else
v_operation_date := p_operation_date;
end if;
if v_reset_frequence = 'NEVER' then
v_year := '';
v_period_name := '';
elsif v_reset_frequence = 'PERIOD' then
v_year := '';
v_period_name := get_gld_period_name(p_company_id => p_company_id,
p_operation_date => v_operation_date);
if v_period_name is null then
error_log(p_message => sys_message_pkg.get_string('FND_CODING_RULE_PERIOD_NAME_NULL'),
p_user_id => p_created_by);
raise e_null_error;
end if;
elsif v_reset_frequence = 'YEAR' then
v_period_name := '';
v_year := to_number(to_char(v_operation_date, 'YYYY'));
elsif v_reset_frequence = 'DAY' then
v_days := to_char(v_operation_date, 'YYYY-MM-DD');
end if;
--规则明细界面 段值
if get_detail_segment_value(v_coding_rule_id, '04') then
v_segment_company_id := p_company_id;
end if;
if get_detail_segment_value(v_coding_rule_id, '05') then
v_segment_operation_unit_id := p_operation_unit_id;
end if;
if get_detail_segment_value(v_coding_rule_id, '03') then
v_segment_document_type := p_document_type;
end if;
--取明细界面段值
v_cur_company_id := v_segment_company_id;
v_cur_document_type := v_segment_document_type;
v_cur_operation_unit_id := v_segment_operation_unit_id;
--取不到明细值,再取规则对象界面中的值
if v_cur_company_id is null then
v_cur_company_id := v_object_company_id;
end if;
if v_cur_document_type is null then
v_cur_document_type := v_object_document_type;
end if;
if v_cur_operation_unit_id is null then
v_cur_operation_unit_id := v_object_operation_unit_id;
end if;
--商业伙伴特俗编码规则
if p_bp_info is not null and p_province_id is not null then
if p_bp_info = 'GROUP_IN' then
v_agent_value := 'R';
elsif p_bp_info = 'GROUP_OUT' then
v_agent_value := 'S';
end if;
select v_agent_value || a.province_abbr
into v_agent_value
from fnd_province a
where a.province_id = p_province_id;
else
v_agent_value := null;
end if;
v_current_value := get_current_value(p_coding_rule_id => v_coding_rule_id,
p_company_id => v_cur_company_id,
p_year => v_year,
p_period_name => v_period_name,
p_document_category => p_document_category,
p_document_type => v_cur_document_type,
p_operation_unit_id => v_cur_operation_unit_id,
p_bp_info => p_bp_info,
p_province_id => p_province_id,
p_days => v_days,
--p_product_code => v_product_code, -- add by liukang
p_agent_value => v_agent_value);
if v_current_value is null then
v_current_value := v_start_value;
insert_fnd_coding_rule_values(p_coding_rule_id => v_coding_rule_id,
p_company_id => v_cur_company_id,
p_year => v_year,
p_period_name => v_period_name,
p_current_value => v_current_value,
p_created_by => p_created_by,
p_document_category => p_document_category,
p_document_type => v_cur_document_type,
p_operation_unit_id => v_cur_operation_unit_id,
p_bp_info => p_bp_info,
p_province_id => p_province_id,
p_days => v_days,
--p_product_code => v_product_code, -- add by liukang
p_agent_value => v_agent_value);
else
--当前值非空,判断是否达到最大位数
if length(v_current_value + v_incremental) > v_length then
--v_current_value := v_current_value;
error_log(p_message => sys_message_pkg.get_string('FND_CODING_RULE_SEQUENCE_MAX'),
p_user_id => p_created_by);
rollback;
return c_error;
else
v_current_value := v_current_value + v_incremental;
end if;
update fnd_coding_rule_values v
set v.current_value = v_current_value,
v.last_update_date = sysdate,
v.last_updated_by = p_created_by
where coding_rule_id = v_coding_rule_id
and v.document_category = p_document_category
and (bp_info = p_bp_info or
(bp_info is null and p_bp_info is null))
and (province_id = p_province_id or
(province_id is null and p_province_id is null))
/* AND (operation_unit_id = v_cur_operation_unit_id OR
(operation_unit_id IS NULL AND
v_cur_operation_unit_id IS NULL))*/
and (v.year = v_year or (v.year is null and v_year is null))
and (v.days = v_days or (v.days is null and v_days is null))
and (period_name = v_period_name or
(period_name is null and v_period_name is null));
-- add by liukang
--and v.product_code = v_product_code;
end if;
loop
fetch cur_details
into v_details;
exit when cur_details%notfound;
v_doc_number_tmp := '';
if v_details.segment_type = '03' then
--获取单据类型
if p_company_id is null or p_document_type is null then
close cur_details;
rollback;
error_log(p_message => sys_message_pkg.get_string('FND_CODING_RULE_SEGMENT_TYPE_06_ERROR'),
p_user_id => p_created_by);
return c_error;
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND_CODING_RULE_GET_DOC_TYPE_CODE_ERR',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'get_rule_next_auto_num',
p_token_1 => '#COMPANY_ID',
p_token_value_1 => p_company_id,
p_token_2 => '#DOCUMENT_TYPE',
p_token_value_2 => p_document_type);
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end if;
--HLS修改
--直接使用document_type作为单据类型
--不通过value进行关联
v_doc_number_tmp := p_document_type;
elsif v_details.segment_type = '04' then
if v_details.display_flag = 'Y' then
--获取公司编码
v_doc_number_tmp := get_company_code(p_company_id);
end if;
elsif v_details.segment_type = '06' then
--左面补零
select lpad(v_current_value, v_length, '0')
into v_doc_number_tmp
from dual;
elsif v_details.segment_type = '02' then
--日期格式
v_doc_number_tmp := to_char(v_operation_date, v_details.date_format);
elsif v_details.segment_type = '01' then
v_doc_number_tmp := v_details.segment_value;
elsif v_details.segment_type = '05' then
--获取经营单位代码
v_doc_number_tmp := get_operation_unit_code(p_operation_unit_id);
-- 内外部
elsif v_details.segment_type = '07' then
if p_bp_info = 'GROUP_IN' then
v_doc_number_tmp := 'R';
elsif p_bp_info = 'GROUP_OUT' then
v_doc_number_tmp := 'S';
end if;
elsif v_details.segment_type = '08' then
select a.province_abbr
into v_doc_number_tmp
from fnd_province a
where a.province_id = p_province_id;
elsif v_details.segment_type = '09' then
v_doc_number_tmp := p_agent_code;
elsif v_details.segment_type = '10' then
v_doc_number_tmp := p_price_ref_v05;
elsif v_details.segment_type = '11' then
v_doc_number_tmp := p_product_code;
end if;
if v_doc_number is null then
v_doc_number := v_doc_number_tmp;
else
v_doc_number := v_doc_number || v_doc_number_tmp;
end if;
end loop;
close cur_details;
if length(v_doc_number) > 30 then
rollback;
error_log(p_message => sys_message_pkg.get_string('FND_CODING_RULE_MAX_LENGTH'),
p_user_id => p_created_by);
--return c_max_length_error;
return c_error;
end if;
evt_event_core_pkg.fire_event(p_event_name => 'FND_CODE_RULE_NEXT',
p_event_param => null,
p_param1 => v_doc_number,
p_param2 => p_document_category,
p_created_by => p_created_by);
commit;
return v_doc_number;
exception
when e_codeing_rule_null_error then
if cur_details%isopen then
close cur_details;
end if;
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'FND1910_CODING_RULE_NULL',
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'get_rule_next_auto_num');
return c_error;
when e_null_error then
if cur_details%isopen then
close cur_details;
end if;
rollback;
return c_error;
when others then
if cur_details%isopen then
close cur_details;
end if;
v_err_msg := dbms_utility.format_error_backtrace || ' ' || sqlerrm;
sys_raise_app_error_pkg.raise_sys_others_error(p_message => v_err_msg,
p_created_by => p_created_by,
p_package_name => 'fnd_code_rule_pkg',
p_procedure_function_name => 'get_rule_next_auto_num');
rollback;
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
return c_error;
end get_rule_next_auto_num;
end fnd_code_rule_pkg;
/
create or replace package cus_con_change_req_pkg is
-- Author : Spencer 3893
-- Created : 9/23/2019 4:25:37 PM
-- Purpose : 合同變更申請
procedure create_change_req(p_contract_id number,
p_req_date date,
p_req_type varchar2,
p_description varchar2,
p_user_id number,
p_simulation_flag varchar2 default 'N',
p_ref_v01 number,
p_change_req_id out number);
--報價計算
procedure calc_change_req(p_change_req_id in number,
p_ccr_start_times in number,
p_ccr_outstanding_times in number,
p_calc_session_id in out number,
p_calc_successful out varchar2,
p_warning_message out varchar2,
p_user_id in number);
--承租人變更日計算應繳金額相關信息
procedure calc_tenant_change_req(p_change_req_id in number,
p_ccr_lease_date in date,
p_ccr_lease_rental out number, --应交租金
p_ccr_lease_principal out number, --应交本金
p_ccr_lease_interest out number, --应交利息
p_ccr_lease_penalty out number, --应交罚息
p_user_id in number);
end cus_con_change_req_pkg;
/
create or replace package body cus_con_change_req_pkg is
e_lock_table exception;
pragma exception_init(e_lock_table, -54);
function get_contract_rec(p_contract_id number, p_user_id number)
return con_contract%rowtype is
v_con_contract_rec con_contract%rowtype;
begin
select *
into v_con_contract_rec
from con_contract t
where t.contract_id = p_contract_id
for update nowait;
return v_con_contract_rec;
exception
when e_lock_table then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'CON_CONTRACT_PKG.CONTRACT_LOCK_ERROR',
p_created_by => p_user_id,
p_package_name => 'cus_con_change_req_pkg',
p_procedure_function_name => 'get_contract_rec');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end;
function get_con_change_req_rec(p_change_req_id con_contract_change_req.change_req_id%type,
p_user_id con_contract_change_req.created_by%type)
return con_contract_change_req%rowtype is
v_change_req_rec con_contract_change_req%rowtype;
begin
select *
into v_change_req_rec
from con_contract_change_req t
where t.change_req_id = p_change_req_id
for update nowait;
return v_change_req_rec;
exception
when e_lock_table then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'CON_CONTRACT_CHANGE_REQ_PKG.CON_CHANGE_REQ_LOCK',
p_created_by => p_user_id,
p_package_name => 'cus_con_change_req_pkg',
p_procedure_function_name => 'get_con_change_req_rec');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end;
procedure create_change_req(p_contract_id number,
p_req_date date,
p_req_type varchar2,
p_description varchar2,
p_user_id number,
p_simulation_flag varchar2 default 'N',
p_ref_v01 number,
p_change_req_id out number) is
v_change_req_id number;
v_contract_rec con_contract%rowtype;
begin
v_contract_rec := get_contract_rec(p_contract_id, p_user_id);
if v_contract_rec.contract_status <> 'INCEPT' and
p_req_type in ('CUT_CHAG', 'LEASE_CHAG', 'ACC_CHAG') then
sys_raise_app_error_pkg.raise_sys_others_error(p_message => '只有起租状态的合同才能进行合同变更申请!',
p_created_by => p_user_id,
p_package_name => 'cus_con_change_req_pkg',
p_procedure_function_name => 'create_change_req');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end if;
con_contract_history_pkg.create_change_req(p_contract_id => p_contract_id,
p_change_req_id => v_change_req_id,
p_req_date => p_req_date,
p_ref_v01 => p_ref_v01,
p_description => p_description,
p_change_quotation => null,
p_change_lease_item => null,
p_change_bp => null,
p_req_doc_type => p_req_type,
p_simulation_flag => p_simulation_flag,
p_cashflow_change_flag => 'Y',
p_user_id => p_user_id);
p_change_req_id := v_change_req_id;
end create_change_req;
--報價計算
procedure calc_change_req(p_change_req_id in number,
p_ccr_start_times in number,
p_ccr_outstanding_times in number,
p_calc_session_id in out number,
p_calc_successful out varchar2,
p_warning_message out varchar2,
p_user_id in number) is
r_change_req con_contract_change_req%rowtype;
r_contract_rec con_contract%rowtype;
v_ccr_outstanding_incld number;
v_exists number;
v_count number;
begin
r_change_req := get_con_change_req_rec(p_change_req_id, p_user_id);
r_contract_rec := get_contract_rec(p_change_req_id, p_user_id);
--根据开始期数计算未到期本金
select nvl(sum(nvl(ccc.principal, 0) - nvl(ccc.received_principal, 0)),
0) sum_ccr_outstanding_incld
into v_ccr_outstanding_incld
from con_contract_cashflow ccc
where ccc.contract_id = r_change_req.contract_id
and ccc.write_off_flag <> 'FULL'
and ccc.cf_item = 1
and ccc.cf_direction = 'INFLOW'
and ccc.cf_status = 'RELEASE'
and ccc.times >= p_ccr_start_times;
--核销的不能进行更改,要从没核销的期数开始修改
select count(1)
into v_count
from con_contract_cashflow ccc
where ccc.contract_id = r_change_req.contract_id
and ccc.times >= p_ccr_start_times
and ccc.cf_item <> 304
and ccc.cf_direction = 'INFLOW'
and ccc.cf_status = 'RELEASE'
and ccc.write_off_flag <> 'NOT';
if v_count > 0 then
sys_raise_app_error_pkg.raise_sys_others_error(p_message => '延期开始期数之后的期数存在核销,请选择正确的日期或者进行核销反冲!',
p_created_by => -1,
p_package_name => 'cus_con_change_req_pkg',
p_procedure_function_name => 'calc_change_req');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end if;
if r_change_req.ccr_start_times is not null then
begin
select 1
into v_exists
from dual
where exists (select 1
from con_contract_cashflow a
where contract_id = p_change_req_id
and cf_type = 1
and times >= r_change_req.ccr_start_times
and nvl(a.received_amount, 0) <> 0);
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'CON_CHANGE_REQ_CALC_ITFC_PKG.CCR_START_TIMES_ERROR',
p_created_by => p_user_id,
p_package_name => 'cus_con_change_req_pkg',
p_procedure_function_name => 'calc_change_req');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
exception
when no_data_found then
null;
end;
end if;
select hls_fin_calculator_hd_s.nextval
into r_contract_rec.calc_session_id
from dual;
hls_fin_calculator_ccr_pkg.create_calculate(p_change_req_id => p_change_req_id,
p_calc_session_id => r_contract_rec.calc_session_id,
p_recreate_h_formula => 'Y', --modify 2017年12月18日16:40:01
p_recreate_l_std => 'Y',
p_recreate_l_formula => 'Y',
p_calc_successful => p_calc_successful,
p_warning_message => p_warning_message,
p_user_id => p_user_id);
update con_contract_change_req
set calc_session_id = r_contract_rec.calc_session_id,
ccr_calc_session_id = r_contract_rec.calc_session_id,
is_calc_flag = 'Y'
where change_req_id = p_change_req_id;
update con_contract
set calc_session_id = r_contract_rec.calc_session_id
where contract_id = p_change_req_id;
p_calc_session_id := r_contract_rec.calc_session_id;
end calc_change_req;
--承租人變更日計算應繳金額相關信息
procedure calc_tenant_change_req(p_change_req_id in number,
p_ccr_lease_date in date,
p_ccr_lease_rental out number, --应交租金
p_ccr_lease_principal out number, --应交本金
p_ccr_lease_interest out number, --应交利息
p_ccr_lease_penalty out number, --应交罚息
p_user_id in number) is
v_ccr_lease_rental number; --应交租金
v_ccr_lease_principal number; --应交本金
v_ccr_lease_interest number; --应交利息
v_ccr_lease_penalty number; --应交罚息
begin
select nvl(sum(f.due_amount), 0),
nvl(sum(f.principal), 0),
nvl(sum(f.interest), 0)
into v_ccr_lease_rental, v_ccr_lease_principal, v_ccr_lease_interest
from con_contract_cashflow f
where f.due_date <= p_ccr_lease_date
and f.write_off_flag = 'NOT'
and f.cf_item = 1
and f.cf_type = 1
and f.cf_direction = 'INFLOW'
and f.contract_id = p_change_req_id;
select nvl(sum(f.due_amount), 0)
into v_ccr_lease_penalty
from con_contract_cashflow f
where f.due_date <= p_ccr_lease_date
and f.write_off_flag = 'NOT'
and f.cf_item = 9
and f.cf_type = 9
and f.cf_direction = 'INFLOW'
and f.contract_id = p_change_req_id;
p_ccr_lease_rental := v_ccr_lease_rental;
p_ccr_lease_principal := v_ccr_lease_principal;
p_ccr_lease_interest := v_ccr_lease_interest;
p_ccr_lease_penalty := v_ccr_lease_penalty;
exception
when others then
null;
end calc_tenant_change_req;
end cus_con_change_req_pkg;
/
create or replace package hls_fin_calculator_ccr_pkg is
-- Author : ZHANGLEI
-- Created : 2014/10/20 9:15:42
-- Purpose :
procedure create_calculate(p_change_req_id in number,
p_calc_session_id in number,
p_recreate_h_formula in varchar2 default 'N',
p_recreate_l_std in varchar2 default 'N',
p_recreate_l_formula in varchar2 default 'N',
p_calc_successful out varchar2,
p_warning_message out varchar2,
p_user_id in number);
end hls_fin_calculator_ccr_pkg;
/
create or replace package body hls_fin_calculator_ccr_pkg is
function replace_k(p_source varchar2, p_replace_j number) return varchar2 is
begin
return hls_fin_calculator_itfc_pkg.replace_k(p_source => p_source,
p_replace_j => p_replace_j);
end;
function replace_n(p_source varchar2, p_replace_j number) return varchar2 is
begin
return hls_fin_calculator_itfc_pkg.replace_n(p_source => p_source,
p_replace_j => p_replace_j);
end;
procedure create_h_data(p_calc_session_id number,
p_contract_id number,
p_change_req_id number,
p_price_list varchar2,
p_ccr_start_times number,
p_ccr_lease_times number,
p_user_id number) is
r_hls_fin_calculator_hd hls_fin_calculator_hd%rowtype;
begin
hls_document_transfer_pkg.doc_to_doc(p_from_doc_table => 'CON_CONTRACT',
p_from_doc_pk => p_change_req_id,
p_to_doc_table => 'HLS_FIN_CALCULATOR_HD',
p_to_doc_pk => p_calc_session_id,
p_to_doc_column_1 => 'source_doc_category',
p_to_doc_column_1_value => 'CHANGE_REQ',
p_to_doc_column_2 => 'source_doc_id',
p_to_doc_column_2_value => p_change_req_id,
p_to_doc_column_3 => 'price_list',
p_to_doc_column_3_value => p_price_list,
p_user_id => p_user_id);
-- replace hd.lease_times
update hls_fin_calculator_hd
set lease_times = p_ccr_start_times + p_ccr_lease_times - 1,
business_type =
(select BUSINESS_TYPE
from con_contract
where contract_id = p_contract_id)
where calc_session_id = p_calc_session_id;
hls_document_transfer_pkg.doc_to_doc(p_from_doc_table => 'HLS_FIN_CALCULATOR_HD',
p_from_doc_pk => p_calc_session_id,
p_to_doc_table => 'HLS_FIN_CALCULATOR_HD_FORMULA',
p_to_doc_pk => p_calc_session_id,
p_user_id => p_user_id);
hls_fin_calculator_itfc_pkg.calculator_h_formula(p_calc_session_id => p_calc_session_id,
p_user_id => p_user_id);
end;
procedure create_l_data(p_calc_session_id number,
p_contract_id number,
p_change_req_id number,
p_price_list varchar2,
p_ccr_start_times number,
p_ccr_lease_times number,
p_recreate_l_std varchar2,
p_recreate_l_formula varchar2,
p_user_id number) is
n number; --原合同总期数
k number; --变更后总期数
i number;
v_lease_times number;
t_column_cf_item hls_fin_calculator_itfc_pkg.column_cf_item_t;
r_calculator_ln hls_fin_calculator_ln%rowtype;
r_calculator_ln_formula hls_fin_calculator_ln_formula%rowtype;
ln_formula_record hls_fin_calculator_itfc_pkg.ln_formula_type;
v_cf_item varchar2(100);
v_calc_line_id number;
v_exists varchar2(1);
v_sql varchar2(32767);
v_matrix_j_initial number;
v_matrix_j_interval number;
v_formula varchar2(4000);
v_old_calc_session_id number;
e_lease_times_error exception;
e_times_formula_error exception;
function get_column_value(p_source in varchar2, p_j in number)
return number is
i number := 0;
v_instr number;
v_text varchar2(2000);
v_sql varchar2(32767);
v_value varchar2(1000);
v_parent_column varchar2(100);
e_ignore_flag exception;
begin
if substr(ltrim(p_source), 1, 1) <> '=' then
return p_source;
end if;
v_text := p_source;
--检索头数组 H
loop
i := i + 1;
v_instr := instr(upper(v_text),
hls_fin_calculator_core_pkg.c_h,
1,
i);
if v_instr = 0 or v_instr is null then
exit;
end if;
v_parent_column := null;
for i in 1 .. length(v_text) - v_instr loop
begin
if substr(v_text, v_instr + i, 1) not in
('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') then
if i = 1 then
raise e_ignore_flag; --H数组第一个字符必须是数组
end if;
v_parent_column := hls_fin_calculator_core_pkg.c_h ||
substr(v_text, v_instr + 1, i - 1);
begin
select b.column_name
into v_parent_column
from hls_fin_calc_config b
where b.layout_area_seq = 'H'
and b.price_list = p_price_list
and b.column_code = v_parent_column;
begin
v_sql := 'select ' || v_parent_column ||
' from hls_fin_calculator_hd where calc_session_id = ' ||
p_calc_session_id;
execute immediate v_sql
into v_value;
v_text := substr(v_text, 1, v_instr - 1) || v_value ||
substr(v_text, v_instr + i);
--v_text := replace(v_text,v_parent_column,v_value);
exception
when others then
raise e_ignore_flag;
end;
exception
when no_data_found then
raise e_ignore_flag;
end;
exit;
end if;
if i = (length(v_text) - v_instr) then
v_parent_column := hls_fin_calculator_core_pkg.c_h ||
substr(v_text, v_instr + 1);
begin
select b.column_name
into v_parent_column
from hls_fin_calc_config b
where b.layout_area_seq = 'H'
and b.price_list = p_price_list
and b.column_code = v_parent_column;
begin
v_sql := 'select ' || v_parent_column ||
' from hls_fin_calculator_hd where calc_session_id = ' ||
p_calc_session_id;
execute immediate v_sql
into v_value;
v_text := substr(v_text, 1, v_instr - 1) || v_value;
--v_text := replace(v_text,v_parent_column,v_value);
exception
when others then
raise e_ignore_flag;
end;
exception
when no_data_found then
raise e_ignore_flag;
end;
end if;
exception
when e_ignore_flag then
exit;
end;
end loop;
end loop;
v_value := hls_fin_calculator_itfc_pkg.execute_formula(v_text,
p_calc_session_id,
p_price_list);
return v_value;
exception
when others then
return null;
end;
begin
select lease_times
into v_lease_times
from hls_fin_calculator_hd
where calc_session_id = p_calc_session_id;
if p_ccr_lease_times is null or p_ccr_lease_times < 0 or
p_ccr_start_times is null or p_ccr_start_times < 0 then
raise e_lease_times_error;
end if;
if p_recreate_l_std = 'Y' then
delete from hls_fin_calculator_ln
where calc_session_id = p_calc_session_id
and to_number(times) < p_ccr_start_times;
delete from hls_fin_calculator_ln_formula
where calc_session_id = p_calc_session_id
and to_number(times) < p_ccr_start_times;
t_column_cf_item := hls_fin_calculator_itfc_pkg.get_column_cf_item(p_price_list => p_price_list);
--------------------------------------
--step 1 将调整之前的期数回写到计算器行表
--------------------------------------
i := t_column_cf_item.first;
while t_column_cf_item.exists(i) loop
v_cf_item := t_column_cf_item(i).cf_item;
for c_cf in (select a.cashflow_id, a.times
from con_contract_cashflow a
where a.contract_id = p_change_req_id
and a.cf_item = v_cf_item
and a.times < p_ccr_start_times) loop
if v_cf_item = 1 then
for c_column in (select c.DATA_TYPE,
c.COLUMN_NAME,
c.COLUMN_NAME as COLUMN_NAME_cf,
cc.column_id as matrix_i
from user_tab_columns c,
hls_fin_calc_column_code cc
where c.TABLE_NAME = 'CON_CONTRACT_CASHFLOW'
and cc.table_name = 'HLS_FIN_CALCULATOR_LN'
and c.COLUMN_NAME = cc.column_name
union
select c.data_type,
c.column_name,
'DUE_AMOUNT' as column_name_cf,
c.column_id as matrix_i
from hls_fin_calc_config c
where c.price_list = p_price_list
and c.column_name = 'RENTAL'
and c.layout_area_seq = 'L'
union
select c.data_type,
c.column_name,
'NET_DUE_AMOUNT' as column_name_cf,
c.column_id as matrix_i
from hls_fin_calc_config c
where c.price_list = p_price_list
and c.column_name = 'NET_RENTAL'
and c.layout_area_seq = 'L'
union
select c.data_type,
c.column_name,
'VAT_DUE_AMOUNT' as column_name_cf,
c.column_id as matrix_i
from hls_fin_calc_config c
where c.price_list = p_price_list
and c.column_name = 'VAT_RENTAL'
and c.layout_area_seq = 'L') loop
execute immediate 'select ' || c_column.column_name_cf ||
' from con_contract_cashflow where cashflow_id=' ||
c_cf.cashflow_id
into v_formula;
ln_formula_record(c_cf.times).n(c_column.matrix_i).column_name := c_column.column_name;
ln_formula_record(c_cf.times).n(c_column.matrix_i).data_type := c_column.data_type;
ln_formula_record(c_cf.times).n(c_column.matrix_i).formula := v_formula;
end loop;
elsif v_cf_item = 0 then
for c_column in (select c.DATA_TYPE,
c.COLUMN_NAME,
c.COLUMN_NAME as COLUMN_NAME_cf,
cc.column_id as matrix_i
from user_tab_columns c,
hls_fin_calc_column_code cc
where c.TABLE_NAME = 'CON_CONTRACT_CASHFLOW'
and cc.table_name = 'HLS_FIN_CALCULATOR_LN'
and c.column_name = cc.column_name
and c.column_name <> t_column_cf_item(i)
.column_name
union
select c.data_type,
c.column_name,
'DUE_AMOUNT' as column_name_cf,
c.column_id as matrix_i
from hls_fin_calc_config c
where c.price_list = p_price_list
and c.layout_area_seq = 'L'
and c.column_name = t_column_cf_item(i)
.column_name) loop
execute immediate 'select ' || c_column.column_name_cf ||
' from con_contract_cashflow where cashflow_id=' ||
c_cf.cashflow_id
into v_formula;
ln_formula_record(c_cf.times).n(c_column.matrix_i).column_name := c_column.column_name;
ln_formula_record(c_cf.times).n(c_column.matrix_i).data_type := c_column.data_type;
ln_formula_record(c_cf.times).n(c_column.matrix_i).formula := v_formula;
end loop;
else
for c_column in (select c.data_type,
c.column_name,
'DUE_AMOUNT' as column_name_cf,
c.column_id as matrix_i
from hls_fin_calc_config c
where c.price_list = p_price_list
and c.layout_area_seq = 'L'
and c.column_name = t_column_cf_item(i)
.column_name
union
select c.data_type,
c.column_name,
'NET_DUE_AMOUNT' as column_name_cf,
c.column_id as matrix_i
from hls_fin_calc_config c
where c.price_list = p_price_list
and c.layout_area_seq = 'L'
and c.column_name = t_column_cf_item(i)
.net_column_name
union
select c.data_type,
c.column_name,
'VAT_DUE_AMOUNT' as column_name_cf,
c.column_id as matrix_i
from hls_fin_calc_config c
where c.price_list = p_price_list
and c.layout_area_seq = 'L'
and c.column_name = t_column_cf_item(i)
.vat_column_name
) loop
execute immediate 'select ' || c_column.column_name_cf ||
' from con_contract_cashflow where cashflow_id=' ||
c_cf.cashflow_id
into v_formula;
ln_formula_record(c_cf.times).n(c_column.matrix_i).column_name := c_column.column_name;
ln_formula_record(c_cf.times).n(c_column.matrix_i).data_type := c_column.data_type;
ln_formula_record(c_cf.times).n(c_column.matrix_i).formula := v_formula;
end loop;
end if;
end loop;
i := t_column_cf_item.next(i);
end loop;
end if;
--------------------------------------
--step 2 按新公式填写剩余的计算器行表
--------------------------------------
if p_recreate_l_formula = 'Y' then
delete from hls_fin_calculator_ln
where calc_session_id = p_calc_session_id
and to_number(times) >= p_ccr_start_times;
delete from hls_fin_calculator_ln_formula
where calc_session_id = p_calc_session_id
and to_number(times) >= p_ccr_start_times;
for c_l_column in (select a.column_name, a.config_id, a.data_type
from hls_fin_calc_config a
where a.price_list = p_price_list
and a.layout_area_seq = 'L'
and a.enabled_flag = 'Y') loop
for c_l_formula in (select b.matrix_i,
b.matrix_j_type,
b.matrix_j_initial,
b.matrix_j_interval,
b.calc_formula,
b.loop_remain_times_only
from hls_fin_calc_config_formula b
where b.config_id = c_l_column.config_id
and b.enabled_flag = 'Y'
order by b.matrix_i asc,
b.calc_seq asc,
decode(b.matrix_j_type, 'CYCLE', 1, 2) asc
) loop
/* 起始值字段如果没有输入=,自动补等号 */
if substr(ltrim(c_l_formula.matrix_j_initial), 1, 1) <> '=' then
c_l_formula.matrix_j_initial := '=' ||
c_l_formula.matrix_j_initial;
end if;
/* 间隔 字段如果没有输入=,自动补等号 */
if substr(ltrim(c_l_formula.matrix_j_interval), 1, 1) <> '=' then
c_l_formula.matrix_j_interval := '=' ||
c_l_formula.matrix_j_interval;
end if;
if c_l_formula.matrix_j_type = 'CYCLE' then
v_matrix_j_initial := get_column_value(c_l_formula.matrix_j_initial,
null);
v_matrix_j_interval := get_column_value(c_l_formula.matrix_j_interval,
null);
if v_matrix_j_initial is null then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'HLS050_MATRIX_J_INITIAL_VALUE_ERROR',
p_token_1 => '',
p_token_value_1 => c_l_column.column_name,
p_token_2 => '',
p_token_value_2 => c_l_formula.matrix_j_initial,
p_created_by => -1,
p_package_name => 'con_change_req_calc_itfc_pkg',
p_procedure_function_name => 'create_l_data');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end if;
if v_matrix_j_interval is null then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'HLS050_MATRIX_J_INTERVAL_VALUE_ERROR',
p_token_1 => '',
p_token_value_1 => c_l_column.column_name,
p_token_2 => '',
p_token_value_2 => c_l_formula.matrix_j_interval,
p_created_by => -1,
p_package_name => 'con_change_req_calc_itfc_pkg',
p_procedure_function_name => 'create_l_data');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end if;
if v_matrix_j_interval > 0 then
--从小到大循环
if c_l_formula.loop_remain_times_only = 'Y' then
for j in v_matrix_j_initial .. p_ccr_lease_times loop
if v_matrix_j_initial is not null and
v_matrix_j_interval is not null then
--能计算循环周期
if j >= v_matrix_j_initial and
mod(j - v_matrix_j_initial, v_matrix_j_interval) = 0 then
k := p_ccr_start_times + j - 1;
v_formula := replace_k(c_l_formula.calc_formula, k);
ln_formula_record(k).n(c_l_formula.matrix_i).column_name := c_l_column.column_name;
ln_formula_record(k).n(c_l_formula.matrix_i).data_type := c_l_column.data_type;
if c_l_column.column_name = 'TIMES' then
v_formula := get_column_value(v_formula, k);
if v_formula is null then
raise e_times_formula_error;
end if;
end if;
ln_formula_record(k).n(c_l_formula.matrix_i).formula := v_formula;
end if;
end if;
end loop;
else
for j in v_matrix_j_initial .. v_lease_times loop
if v_matrix_j_initial is not null and
v_matrix_j_interval is not null then
--能计算循环周期
if j >= v_matrix_j_initial and
mod(j - v_matrix_j_initial, v_matrix_j_interval) = 0 then
n := j;
v_formula := replace_n(c_l_formula.calc_formula, n);
ln_formula_record(n).n(c_l_formula.matrix_i).column_name := c_l_column.column_name;
ln_formula_record(n).n(c_l_formula.matrix_i).data_type := c_l_column.data_type;
if c_l_column.column_name = 'TIMES' then
v_formula := get_column_value(v_formula, n);
if v_formula is null then
raise e_times_formula_error;
end if;
end if;
ln_formula_record(n).n(c_l_formula.matrix_i).formula := v_formula;
end if;
end if;
end loop;
end if;
elsif v_matrix_j_interval < 0 then
--从大到小循环
if c_l_formula.loop_remain_times_only = 'Y' then
for j in 0 .. v_matrix_j_initial loop
if v_matrix_j_initial is not null and
v_matrix_j_interval is not null then
--能计算循环周期
if j <= v_matrix_j_initial and
mod(v_matrix_j_initial - j, v_matrix_j_interval) = 0 then
k := p_ccr_start_times + j - 1;
v_formula := replace_k(c_l_formula.calc_formula, k);
ln_formula_record(k).n(c_l_formula.matrix_i).column_name := c_l_column.column_name;
ln_formula_record(k).n(c_l_formula.matrix_i).data_type := c_l_column.data_type;
if c_l_column.column_name = 'TIMES' then
v_formula := get_column_value(v_formula, k);
if v_formula is null then
raise e_times_formula_error;
end if;
end if;
ln_formula_record(k).n(c_l_formula.matrix_i).formula := v_formula;
end if;
end if;
end loop;
else
for j in 0 .. v_matrix_j_initial loop
if v_matrix_j_initial is not null and
v_matrix_j_interval is not null then
--能计算循环周期
if j <= v_matrix_j_initial and
mod(v_matrix_j_initial - j, v_matrix_j_interval) = 0 then
n := j;
v_formula := replace_n(c_l_formula.calc_formula, n);
ln_formula_record(n).n(c_l_formula.matrix_i).column_name := c_l_column.column_name;
ln_formula_record(n).n(c_l_formula.matrix_i).data_type := c_l_column.data_type;
if c_l_column.column_name = 'TIMES' then
v_formula := get_column_value(v_formula, n);
if v_formula is null then
raise e_times_formula_error;
end if;
end if;
ln_formula_record(n).n(c_l_formula.matrix_i).formula := v_formula;
end if;
end if;
end loop;
end if;
end if;
elsif c_l_formula.matrix_j_type = 'FIXED' then
v_matrix_j_initial := get_column_value(c_l_formula.matrix_j_initial,
null);
if v_matrix_j_initial is null then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'HLS050_MATRIX_J_INITIAL_VALUE_ERROR',
p_token_1 => '',
p_token_value_1 => c_l_column.column_name,
p_token_2 => '',
p_token_value_2 => c_l_formula.matrix_j_initial,
p_created_by => -1,
p_package_name => 'con_change_req_calc_itfc_pkg',
p_procedure_function_name => 'create_l_data');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end if;
if c_l_formula.loop_remain_times_only = 'Y' then
k := v_matrix_j_initial + p_ccr_start_times - 1;
if k is not null then
v_formula := replace_k(c_l_formula.calc_formula, k);
if c_l_column.column_name = 'TIMES' then
v_formula := get_column_value(v_formula, k);
if v_formula is null then
raise e_times_formula_error;
end if;
end if;
ln_formula_record(k).n(c_l_formula.matrix_i).data_type := c_l_column.data_type;
ln_formula_record(k).n(c_l_formula.matrix_i).column_name := c_l_column.column_name;
ln_formula_record(k).n(c_l_formula.matrix_i).formula := v_formula;
end if;
else
n := v_matrix_j_initial;
if n is not null then
v_formula := replace_n(c_l_formula.calc_formula, n);
if c_l_column.column_name = 'TIMES' then
v_formula := get_column_value(v_formula, n);
if v_formula is null then
raise e_times_formula_error;
end if;
end if;
ln_formula_record(n).n(c_l_formula.matrix_i).data_type := c_l_column.data_type;
ln_formula_record(n).n(c_l_formula.matrix_i).column_name := c_l_column.column_name;
ln_formula_record(n).n(c_l_formula.matrix_i).formula := v_formula;
end if;
end if;
end if;
end loop;
end loop;
end if;
hls_fin_calculator_itfc_pkg.save_l_formula(p_ln_formula_record => ln_formula_record,
p_user_id => p_user_id,
p_calc_session_id => p_calc_session_id);
--计算复制于源价目表字段
if p_recreate_l_std = 'Y' then
select calc_session_id
into v_old_calc_session_id
from con_contract a
where a.contract_id = p_contract_id;
for cur in (select a.column_name
from hls_fin_calc_config a
where a.layout_area_seq = 'L'
and a.price_list = p_price_list
and a.ref_v03 = 'Y') loop
v_sql := 'update hls_fin_calculator_ln_formula l set ' ||
cur.column_name || ' = (select ' || cur.column_name ||
' from hls_fin_calculator_ln ol where ol.calc_session_id = ' ||
v_old_calc_session_id || ' and ol.times = l.times)' ||
' where calc_session_id = ' || p_calc_session_id ||
' and to_number(times) <' || p_ccr_start_times;
execute immediate v_sql;
end loop;
end if;
end;
procedure create_calculate(p_change_req_id in number,
p_calc_session_id in number,
p_recreate_h_formula in varchar2 default 'N',
p_recreate_l_std in varchar2 default 'N',
p_recreate_l_formula in varchar2 default 'N',
p_calc_successful out varchar2,
p_warning_message out varchar2,
p_user_id in number) is
column_list_array hls_fin_calculator_core_pkg.column_list_type;
v_error_count number;
r_hls_fin_calc_hd_rec hls_fin_calculator_hd%rowtype;
r_contract con_contract%rowtype;
v_contract_id number;
e_ccr_start_times_error exception;
begin
if p_calc_session_id is null then
return;
else
execute immediate 'alter session set nls_date_format = ''yyyy-mm-dd''';
r_contract := con_contract_pkg.get_contract_rec(p_contract_id => p_change_req_id,
p_user_id => p_user_id);
if r_contract.ccr_start_times is null or
r_contract.ccr_outstanding_times is null then
raise e_ccr_start_times_error;
end if;
if r_contract.ccr_start_times < 1 then
raise e_ccr_start_times_error;
end if;
select contract_id
into v_contract_id
from con_contract_change_req
where change_req_id = p_change_req_id;
if p_recreate_h_formula = 'Y' then
delete from hls_fin_calculator_hd
where calc_session_id = p_calc_session_id;
delete from hls_fin_calculator_hd_formula
where calc_session_id = p_calc_session_id;
--create h
create_h_data(p_calc_session_id => p_calc_session_id,
p_contract_id => v_contract_id,
p_change_req_id => p_change_req_id,
p_price_list => r_contract.price_list,
p_ccr_start_times => r_contract.ccr_start_times,
p_ccr_lease_times => r_contract.ccr_outstanding_times,
p_user_id => p_user_id);
end if;
select *
into r_hls_fin_calc_hd_rec
from hls_fin_calculator_hd
where calc_session_id = p_calc_session_id;
if not (r_hls_fin_calc_hd_rec.source_doc_category = 'CHANGE_REQ' and
r_hls_fin_calc_hd_rec.source_doc_id is not null) then
return;
end if;
if p_recreate_l_formula = 'Y' then
update hls_fin_calculator_hd_formula
set lease_times = r_hls_fin_calc_hd_rec.ccr_start_times +
r_hls_fin_calc_hd_rec.ccr_outstanding_times - 1
where calc_session_id = p_calc_session_id;
update hls_fin_calculator_hd hd
set lease_times = r_hls_fin_calc_hd_rec.ccr_start_times +
r_hls_fin_calc_hd_rec.ccr_outstanding_times - 1
where calc_session_id = p_calc_session_id;
--create l
create_l_data(p_calc_session_id => p_calc_session_id,
p_contract_id => v_contract_id,
p_change_req_id => p_change_req_id,
p_price_list => r_hls_fin_calc_hd_rec.price_list,
p_ccr_start_times => r_hls_fin_calc_hd_rec.ccr_start_times,
p_ccr_lease_times => r_hls_fin_calc_hd_rec.ccr_outstanding_times,
p_recreate_l_std => p_recreate_l_std,
p_recreate_l_formula => p_recreate_l_formula,
p_user_id => p_user_id);
end if;
end if;
hls_fin_calculator_itfc_pkg.calculate_main(p_calc_session_id => p_calc_session_id,
p_calc_successful => p_calc_successful,
p_warning_message => p_warning_message,
p_user_id => p_user_id);
exception
when e_ccr_start_times_error then
sys_raise_app_error_pkg.raise_user_define_error(p_message_code => 'HLS_FIN_CALCULATOR_CCR_PKG.CCR_START_TIMES_ERROR',
p_created_by => p_user_id,
p_package_name => 'hls_fin_calculator_ccr_pkg',
p_procedure_function_name => 'create_calculate');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
when others then
sys_raise_app_error_pkg.raise_sys_others_error(p_message => dbms_utility.format_error_backtrace || ' ' ||
sqlerrm,
p_created_by => p_user_id,
p_package_name => 'hls_fin_calculator_ccr_pkg',
p_procedure_function_name => 'create_calculate');
raise_application_error(sys_raise_app_error_pkg.c_error_number,
sys_raise_app_error_pkg.g_err_line_id);
end;
end hls_fin_calculator_ccr_pkg;
/
WHENEVER SQLERROR EXIT FAILURE ROLLBACK;
WHENEVER OSERROR EXIT FAILURE ROLLBACK;
spool REGISTER_CON_ET001.log
set feedback off
set define off
begin
--分配bm
sys_function_assign_pkg.func_bm_load('CON733','cont.CON733.create_change_req');
sys_function_assign_pkg.func_bm_load('CON733','cont.CON733.calc_change_req');
sys_function_assign_pkg.func_bm_load('CON733','cont.CON733.calc_tenant_change_req');
end;
/
commit;
set feedback on
set define on
spool off
exit
CREATE OR REPLACE VIEW CON_CHANGE_CONTRACT_LV AS
SELECT t1.contract_id,
t1.calc_session_id,
(SELECT t.calc_successful FROM hls_fin_calculator_hd t WHERE t.calc_session_id = t1.calc_session_id)calc_successful,
t1.contract_number,
t1.contract_name,
t1.document_type,
(SELECT dt.description
FROM hls_document_type dt
WHERE dt.document_type = t1.document_type) AS document_type_n,
t1.document_category,
(SELECT dc.description
FROM hls_document_category dc
WHERE dc.document_category = t1.document_category) AS document_category_n,
t1.project_id,
(SELECT p.project_number
FROM prj_project p
WHERE t1.project_id = p.project_id) AS project_id_c,
(SELECT p.project_name
FROM prj_project p
WHERE t1.project_id = p.project_id) AS project_id_n,
t1.company_id,
(SELECT c.company_short_name
FROM fnd_companies_vl c
WHERE c.company_id = t1.company_id) AS company_id_n,
t1.division,
(SELECT d.description
FROM hls_division d
WHERE d.division = t1.division) AS division_n,
t1.bp_id_tenant,
(SELECT m.bp_name
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_tenant) AS bp_id_tenant_n,
(SELECT ma.bp_name
FROM hls_bp_master ma
WHERE ma.bp_id = t1.bp_id_tenant) bp_id_tenant_name,
t1.bp_id_agent_level1,
(SELECT m.bp_name
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level1) AS bp_id_agent_level1_n,
t1.bp_id_agent_level2,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level2) AS bp_id_agent_level2_n,
t1.bp_id_agent_level3,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level3) AS bp_id_agent_level3_n,
t1.owner_user_id,
(SELECT a.description
FROM sys_user a
WHERE a.user_id = t1.owner_user_id) owner_user_id_n,
t1.employee_id,
(SELECT e.name
FROM exp_employees e
WHERE e.employee_id = t1.employee_id) AS employee_id_n,
t1.unit_id,
(SELECT h.bp_name FROM hls_bp_master h WHERE h.bp_id = t1.unit_id) AS unit_id_n,
t1.employee_id_of_manager,
(SELECT e.name
FROM exp_employees e
WHERE e.employee_id = t1.employee_id_of_manager) AS employee_id_of_manager_n,
t1.description,
t1.price_list,
(SELECT l.description
FROM hls_price_list l
WHERE l.price_list = t1.price_list) AS price_list_n,
t1.calc_method,
t1.inception_of_lease,
t1.lease_start_date,
t1.first_pay_date,
t1.lease_end_date,
t1.lease_times,
t1.pay_times,
t1.int_rate_display,
t1.annual_pay_times,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_ANNUAL_PAY_TIMES'
AND v.code_value = t1.annual_pay_times) AS annual_pay_times_n,
t1.lease_term,
t1.pay_type,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_PAY_TYPE'
AND v.code_value = t1.pay_type) AS pay_type_n,
t1.currency,
(SELECT g.currency_name
FROM gld_currency_vl g
WHERE g.currency_code = t1.currency) AS currency_n,
t1.currency_precision,
t1.machinery_amount,
t1.parts_amount,
t1.lease_item_amount,
t1.lease_item_cost,
t1.down_payment,
t1.down_payment_ratio,
t1.finance_amount,
t1.net_finance_amount,
t1.total_interest,
t1.total_rental,
t1.total_fee,
t1.contract_amount,
t1.tax_type_id,
(SELECT t.description
FROM fnd_tax_type_codes t
WHERE t.tax_type_id = t1.tax_type_id) AS tax_type_id_n,
t1.vat_flag,
t1.vat_rate,
t1.vat_input,
t1.vat_total_interest,
t1.vat_finance_amount,
t1.vat_total_rental,
t1.vat_total_fee,
t1.net_total_interest,
t1.net_total_rental,
t1.net_total_fee,
t1.net_lease_item_amount,
nvl(t1.lease_charge, 0) lease_charge,
t1.lease_charge_ratio,
t1.lease_mgt_fee,
t1.lease_mgt_fee_ratio,
t1.lease_mgt_fee_rule,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_MGT_FEE_RULE'
AND v.code_value = t1.lease_mgt_fee_rule) AS lease_mgt_fee_rule_n,
t1.deposit,
t1.deposit_ratio,
nvl(t1.residual_value, 0) residual_value,
t1.other_fee,
t1.base_rate,
t1.int_rate,
t1.int_rate_implicit,
t1.int_rate_type,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON500_INT_RATE_TYPE'
AND v.code_value = t1.int_rate_type) AS int_rate_type_n,
t1.contract_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON500_CONTRACT_STATUS'
AND v.code_value = t1.contract_status) AS contract_status_n,
t1.created_by,
t1.creation_date,
t1.last_updated_by,
t1.last_update_date,
t1.data_class,
(SELECT sc.code_value_name
FROM sys_code_values_v sc
WHERE sc.code = 'HLS_DATA_CLASS'
AND sc.code_value = t1.data_class) data_class_n,
t1.ccr_penalty,
nvl(t1.ccr_fee,
decode((SELECT ccc1.document_type
FROM con_contract_change_req ccc1
WHERE ccc1.change_req_id = t1.contract_id),
'LEASSE_CHAG',
'1000',
'LEASEHOLD_CHAG',
'1000',
'CONEXTHAG',
'1000',
'DEBT_CHAG',
'2000',
'PART_CHAG',
'500',
'PAY_CHAG',
'0')) ccr_fee,
--modify by liyuan begin
(SELECT ccb.score_level
FROM con_contract_bp ccb
WHERE t1.contract_id = ccb.contract_id
AND ccb.bp_category = 'TENANT') score_level,
(SELECT ccc1.document_type
FROM con_contract_change_req ccc1
WHERE ccc1.change_req_id = t1.contract_id) ccr_document_type,
(SELECT ht.description
FROM hls_document_type ht
WHERE ht.document_type =
(SELECT ccc1.document_type
FROM con_contract_change_req ccc1
WHERE ccc1.change_req_id = t1.contract_id)) AS ccr_document_type_n, --变更类型
/*decode((SELECT ccc1.document_type
FROM con_contract_change_req ccc1
WHERE ccc1.change_req_id = t1.contract_id),
'LEASSE_CHAG',
'1',
'LEASEHOLD_CHAG',
'2',
'CONEXTHAG',
'3',
'DEBT_CHAG',
'4',
'PART_CHAG',
'5',
'PAY_CHAG',
'6') times,*/
(SELECT to_date(to_char(cccc.req_date,'yyyy-mm-dd'),'yyyy-mm-dd')
FROM con_contract_change_req cccc
WHERE cccc.change_req_id = t1.contract_id) req_date, --变更申请日期
(SELECT cccc.ref_v01
FROM con_contract_change_req cccc
WHERE cccc.change_req_id = t1.contract_id) ref_v01, --变更人
(SELECT cli.pattern
FROM con_contract_lease_item cli
WHERE cli.contract_id = t1.contract_id
AND cli.equipment_type = 'MAIN') lease_item_id_n, --机型
(SELECT cli.lease_item_id
FROM con_contract_lease_item cli
WHERE cli.contract_id = t1.contract_id
AND cli.equipment_type = 'MAIN') lease_item_id,
(SELECT cli.machine_number
FROM con_contract_lease_item cli
WHERE cli.contract_id = t1.contract_id
AND cli.equipment_type = 'MAIN') machine_number, --机号 --end
t1.ccr_leasse_rental,
t1.ccr_leasse_interest,
t1.ccr_leasse_principal,
t1.ccr_leasse_penalty,
t1.ccr_reason,
t1.ccr_opinion,
nvl(t1.hd_user_col_v04, 'DELAY') hd_user_col_v04, --冬雨季延期方式
t1.ccr_start_times,
t1.interim_times, --延期期数
t1.ccr_outstanding_prin_tax_incld, --剩余本金
t1.ccr_finance_amount,
t1.interim_rental,
t1.ccr_outstanding_times,
t1.ccr_dept,
t1.btb_payment_date, --变更基准日期
t1.btb_finance_amount,
t1.ccr_overdue_rental, --变更逾期租金
t1.HD_USER_COL_V06, --罚息是否参与债权再调整
(select v.code_value_name as value_name
from sys_code_values_v v
where v.code_enabled_flag = 'Y'
and v.code_value_enabled_flag = 'Y'
and v.code = 'YES_NO'
and v.code_value = t1.HD_USER_COL_V06) HD_USER_COL_V06_n,
t1.ccr_overdue_prin, --逾期本金
t1.CCR_OVERDUE_INTEREST, --变更逾期利息
t1.CCR_OUTSTANDING_PRIN_TI_TOTAL, --未到期本金
t1. CCR_DUE_AMOUNT, --变更罚息总金额
t1. CCR_DUE_RATIO, --变更收取比例
t1.CCR_DUE_CHARGE, --变更收取罚息金额
t1.BTB_INTEREST_MARGIN, --债权再调整变更不收本金期数
t1.bp_character, --承租人性格
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code_value = t1.bp_character
and v.code='BP_CHARACTER') bp_character_n,
t1.bp_engineer_source, --工程来源
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code_value = t1.bp_engineer_source
and v.code='BP_ENGINEER_SOURCE') bp_engineer_source_n,
t1.bp_credit_conscious, --信用意识
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code_value = t1.bp_credit_conscious
and v.code='BP_CREDIT_CONSCIOUS') bp_credit_conscious_n,
t1.bp_income_situation, --资产与收入情况
t1.bp_engineer_discrip, --工程情况描述
t1.bp_risk, --有何风险
t1.bp_evaluate, --整体风险
t1.fee_waiver, --是否手续费减免
t1.fee_waiver_reason,--手续费减免说明
--租金計劃變更 start
(SELECT c.lease_times FROM con_contract c,con_contract_change_req cr WHERE c.contract_id = cr.contract_id
AND cr.change_req_id = t1.contract_id)TIMES_S,
(SELECT c.irr FROM con_contract c ,con_contract_change_req cr WHERE c.contract_id = cr.contract_id
AND cr.change_req_id = t1.contract_id)IRR_S,
(SELECT c.int_rate_display FROM con_contract c,con_contract_change_req cr WHERE c.contract_id = cr.contract_id
AND cr.change_req_id = t1.contract_id)RATE_S,
t1.lease_times TIMES_C,
t1.irr IRR_C,
t1.int_rate_display RATE_C,
--租金計劃變更 end
--回款賬戶變更 start
(SELECT v.code_value_name FROM con_contract c,con_contract_change_req cr,sys_code_values_v v WHERE c.contract_id = cr.contract_id
AND v.code_value = c.pay_method
AND cr.change_req_id = t1.contract_id)PAYMENT_METHOD_ID_S, --原支付方式
(SELECT c.BANK_BRANCH_NAME FROM con_contract c,con_contract_change_req cr WHERE c.contract_id = cr.contract_id
AND cr.change_req_id = t1.contract_id)BANK_FULL_NAME_S, --原扣款银行
(SELECT c.BANK_ACCOUNT_NAME FROM con_contract c,con_contract_change_req cr WHERE c.contract_id = cr.contract_id
AND cr.change_req_id = t1.contract_id)BANK_ACCOUNT_NAME_S, --原扣款账户名
(SELECT c.BANK_BRANCH_NUM FROM con_contract c,con_contract_change_req cr WHERE c.contract_id = cr.contract_id
AND cr.change_req_id = t1.contract_id)BANK_ACCOUNT_NUM_S, --原扣款账号
t1.pay_method,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code_value = t1.pay_method
and v.code='PAY_METHODS') PAYMENT_METHOD_ID_C, --现支付方式
t1.BANK_BRANCH_NAME BANK_FULL_NAME_C, --现扣款银行
t1.BANK_ACCOUNT_NAME BANK_ACCOUNT_NAME_C, --现扣款账户名
t1.BANK_BRANCH_NUM BANK_ACCOUNT_NUM_C --现扣款账号
--回款賬戶變更 end
FROM con_contract t1
;
CREATE OR REPLACE VIEW CON_CONTRACT_CCR_LV AS
SELECT t1.contract_id,
t1.calc_session_id,
t1.contract_number,
t1.contract_name,
t1.business_type,
(SELECT bt.description
FROM hls_business_type bt
WHERE bt.business_type = t1.business_type) AS business_type_n,
t1.document_type,
(SELECT dt.description
FROM hls_document_type dt
WHERE dt.document_type = t1.document_type) AS document_type_n,
t1.document_category,
(SELECT dc.description
FROM hls_document_category dc
WHERE dc.document_category = t1.document_category) AS document_category_n,
t1.project_id,
(SELECT p.project_number
FROM prj_project p
WHERE t1.project_id = p.project_id) AS project_id_c,
(SELECT p.project_name
FROM prj_project p
WHERE t1.project_id = p.project_id) AS project_id_n,
t1.company_id,
(SELECT c.company_short_name
FROM fnd_companies_vl c
WHERE c.company_id = t1.company_id) AS company_id_n,
t1.spv_company_id,
(SELECT c.company_short_name
FROM fnd_companies_vl c
WHERE c.company_id = t1.spv_company_id) AS spv_company_id_n,
t1.lease_organization,
(SELECT o.description
FROM hls_lease_organization o
WHERE o.lease_organization = t1.lease_organization) AS lease_organization_n,
t1.lease_channel,
(SELECT ch.description
FROM hls_lease_channel ch
WHERE ch.lease_channel = t1.lease_channel) AS lease_channel_n,
t1.division,
(SELECT d.description
FROM hls_division d
WHERE d.division = t1.division) AS division_n,
t1.bp_id_tenant,
(SELECT m.bp_name
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_tenant) AS bp_id_tenant_n,
(SELECT ma.bp_name
FROM hls_bp_master ma
WHERE ma.bp_id = t1.bp_id_tenant) bp_id_tenant_name,
t1.bp_id_agent_level1,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level1) AS bp_id_agent_level1_n,
t1.bp_id_agent_level2,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level2) AS bp_id_agent_level2_n,
t1.bp_id_agent_level3,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level3) AS bp_id_agent_level3_n,
t1.owner_user_id,
t1.employee_id,
(SELECT e.name
FROM exp_employees e
WHERE e.employee_id = t1.employee_id) AS employee_id_n,
t1.unit_id,
(SELECT u.description
FROM exp_org_unit_vl u
WHERE u.unit_id = t1.unit_id) AS unit_id_n,
t1.employee_id_of_manager,
(SELECT e.name
FROM exp_employees e
WHERE e.employee_id = t1.employee_id_of_manager) AS employee_id_of_manager_n,
t1.factoring_type,
t1.description,
t1.price_list,
(SELECT l.description
FROM hls_price_list l
WHERE l.price_list = t1.price_list) AS price_list_n,
t1.calc_method,
t1.inception_of_lease,
t1.lease_start_date,
t1.first_pay_date,
t1.last_pay_date,
t1.lease_end_date,
t1.lease_times,
t1.pay_times,
t1.annual_pay_times,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_ANNUAL_PAY_TIMES'
AND v.code_value = t1.annual_pay_times) AS annual_pay_times_n,
t1.lease_term,
t1.pay_type,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_PAY_TYPE'
AND v.code_value = t1.pay_type) AS pay_type_n,
t1.currency,
(SELECT g.currency_name
FROM gld_currency_vl g
WHERE g.currency_code = t1.currency) AS currency_n,
t1.currency_precision,
t1.machinery_amount,
t1.parts_amount,
t1.lease_item_amount,
t1.lease_item_cost,
t1.down_payment,
t1.down_payment_ratio,
t1.finance_amount,
t1.net_finance_amount,
t1.total_interest,
t1.total_rental,
t1.total_fee,
t1.contract_amount,
t1.tax_type_id,
(SELECT t.description
FROM fnd_tax_type_codes t
WHERE t.tax_type_id = t1.tax_type_id) AS tax_type_id_n,
t1.vat_flag,
t1.vat_rate,
t1.vat_input,
t1.vat_total_interest,
t1.vat_finance_amount,
t1.vat_total_rental,
t1.vat_total_fee,
t1.net_total_interest,
t1.net_total_rental,
t1.net_total_fee,
t1.net_lease_item_amount,
t1.lease_charge,
t1.lease_charge_ratio,
t1.lease_mgt_fee,
t1.lease_mgt_fee_ratio,
t1.lease_mgt_fee_rule,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_MGT_FEE_RULE'
AND v.code_value = t1.lease_mgt_fee_rule) AS lease_mgt_fee_rule_n,
t1.deposit,
t1.deposit_ratio,
t1.deposit_deduction,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_DEPOSIT_DEDUCTION'
AND v.code_value = t1.deposit_deduction) AS deposit_deduction_n,
t1.residual_value,
t1.residual_ratio,
t1.balloon,
t1.balloon_ratio,
t1.interim_rent_period,
t1.interim_times,
t1.interim_rental,
t1.insurance_fee,
t1.insurance_rate,
t1.commission_payable,
t1.commission_receivable,
t1.third_party_deposit,
t1.promise_to_pay,
t1.other_fee,
t1.other_payment,
t1.rounding_object,
t1.rounding_method,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_CASHFLOW_ACCURATED'
AND v.code_value = t1.rounding_method) AS rounding_method_n,
t1.int_rate_fixing_way,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'TRE502_INT_RATE_FIXING_WAY'
AND v.code_value = t1.int_rate_fixing_way) AS int_rate_fixing_way_n,
t1.int_rate_fixing_range,
t1.int_rate_display,
t1.base_rate_type,
(SELECT rt.description
FROM fnd_base_rate_type rt
WHERE rt.base_rate_type = t1.base_rate_type) AS base_rate_type_n,
t1.base_rate,
t1.int_rate,
t1.int_rate_implicit,
t1.int_rate_type,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON500_INT_RATE_TYPE'
AND v.code_value = t1.int_rate_type) AS int_rate_type_n,
t1.flt_rate_profile,
(SELECT description
FROM con_flt_rate_profile p
WHERE p.flt_rate_profile = t1.flt_rate_profile) AS flt_rate_profile_n,
t1.flt_rate_adj_method,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_FLT_RATE_ADJ_METHOD'
AND v.code_value = t1.flt_rate_adj_method) AS flt_rate_adj_method_n,
t1.flt_simulate_step,
t1.flt_simulate_range,
t1.flt_unit_adj_amt,
t1.flt_execute_times_rule,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS_FLT_EXECUTE_TIMES_RULE'
AND v.code_value = t1.flt_execute_times_rule) AS flt_execute_times_rule_n,
t1.flt_int_rate_adj_date,
t1.flt_delay_execute_period,
t1.flt_annual_adj_times,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS_FLT_ANNUAL_ADJ_TIMES'
AND v.code_value = t1.flt_annual_adj_times) AS flt_annual_adj_times_n,
flt_next_adj_date,
t1.int_rate_precision,
t1.irr,
t1.irr_after_tax,
t1.int_rate_implicit_after_tax,
t1.irr_reserved1,
t1.irr_reserved2,
t1.irr_reserved3,
t1.pmt,
t1.pmt_first,
t1.npv_using_cof,
t1.annual_mean_rate,
t1.total_salestax,
t1.biz_day_convention,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS050_BIZ_DAY_CONVENTION'
AND v.code_value = t1.biz_day_convention) AS biz_day_convention_n,
t1.calc_with_residual_value,
t1.exchange_rate_type,
(SELECT v.rate_type_desc
FROM gld_exchange_rate_type_v v
WHERE v.rate_type_code = t1.exchange_rate_type) AS exchange_rate_type_n,
t1.exchange_rate_quotation,
t1.exchange_rate,
t1.penalty_profile,
t1.grace_period,
t1.penalty_rate,
t1.penalty_calc_base,
t1.penalty_total_base_ratio,
t1.credit_write_off_order, --?
t1.fin_income_recognize_method,
t1.early_termination_profile,
(SELECT p.description
FROM con_contract_et_profile p
WHERE p.et_profile = t1.early_termination_profile
AND rownum = 1) AS early_termination_profile_n,
t1.payment_method_id,
t1.telex_transfer_bank_id,
t1.tt_bank_branch_name,
t1.tt_bank_account_num,
t1.tt_bank_account_name,
t1.tt_remark,
t1.direct_debit_bank_id,
t1.dd_bank_branch_name,
t1.dd_bank_account_num,
t1.dd_bank_account_name,
t1.dd_agreement_no,
t1.dd_agreement_status,
t1.dd_remark,
t1.purchase_order_no,
t1.contract_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON500_CONTRACT_STATUS'
AND v.code_value = t1.contract_status) AS contract_status_n,
t1.user_status_1,
t1.user_status_2,
t1.user_status_3,
t1.print_status,
t1.print_times,
t1.first_print_date,
t1.first_print_by,
t1.delivery_status,
t1.delivery_date,
t1.billing_method,
(SELECT bm.description
FROM con_billing_method bm
WHERE bm.billing_method = t1.billing_method) AS billing_method_n,
t1.billing_status,
t1.signing_date,
t1.original_recall_date,
t1.lease_card_recall_date,
t1.early_termination_date,
t1.termination_date,
t1.assignment_agreement_no,
t1.assignment_date,
t1.btb_payment_date,
t1.btb_int_rate,
t1.btb_int_rate_implicit,
t1.btb_finance_amount,
t1.btb_net_finance_amount,
t1.btb_total_repayment,
t1.btb_total_interest,
t1.btb_total_fee_pv,
t1.btb_total_fee,
t1.btb_finance_ratio,
t1.btb_interest_margin,
t1.btb_vat_interest,
t1.btb_vat_fee,
t1.btb_interest_after_tax,
t1.btb_fee_after_tax,
t1.cdd_list_id,
t1.hd_user_col_d01,
t1.hd_user_col_d02,
t1.hd_user_col_d03,
t1.hd_user_col_d04,
t1.hd_user_col_d05,
t1.hd_user_col_v01,
t1.hd_user_col_v02,
t1.hd_user_col_v03,
t1.hd_user_col_v04,
t1.hd_user_col_v05,
t1.hd_user_col_v06,
t1.hd_user_col_v07,
t1.hd_user_col_v08,
t1.hd_user_col_v09,
t1.hd_user_col_v10,
t1.hd_user_col_n01,
t1.hd_user_col_n02,
t1.hd_user_col_n03,
t1.hd_user_col_n04,
t1.hd_user_col_n05,
t1.hd_user_col_n06,
t1.hd_user_col_n07,
t1.hd_user_col_n08,
t1.hd_user_col_n09,
t1.hd_user_col_n10,
t1.hd_user_col_n11,
t1.hd_user_col_n12,
t1.hd_user_col_n13,
t1.serial_number,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n13)) AS hd_user_col_n13_n,
t1.hd_user_col_n14,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n14)) AS hd_user_col_n14_n,
t1.hd_user_col_n15,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n15)) AS hd_user_col_n15_n,
overdue_status,
overdue_max_days,
five_class_code,
(SELECT r.description
FROM rsc_five_class_code r
WHERE t1.five_class_code = r.five_class_code) AS five_class_code_n,
main_business_income,
main_business_cost,
financing_cost,
calc_prompt,
calc_prompt_msg,
lease_item_price_agent,
legal_fee,
version,
version_date,
version_display,
version_external,
version_reason,
version_note,
t1.created_by,
(SELECT su.description
FROM sys_user su
WHERE su.user_id = cr.created_by) change_created_by_n,
t1.creation_date,
t1.last_updated_by,
t1.last_update_date,
t1.search_term_1,
t1.search_term_2,
'CHANGE_REQ' data_class,
t1.ccr_start_times,
t1.ccr_outstanding_times,
t1.ccr_outstanding_prin_tax_incld,
t1.ccr_overdue_rental,
t1.ccr_penalty,
t1.ccr_fee,
t1.ccr_finance_amount,
t1.ccr_pmt,
t1.ccr_outstanding_prin_ti_total,
t1.ccr_financing_overdue_rental,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.ccr_financing_overdue_rental)) AS ccr_financing_overdue_rental_n,
t1.ccr_period_int_rate_implicit,
t1.ccr_period_lease_start_date,
t1.ccr_added_principal,
t1.ccr_nominal_finance_amount,
t1.ccr_original_finance_amount,
cr.change_quotation,
cr.change_lease_item,
cr.change_bp,
cr.change_req_number,
cr.req_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON_CHANGE_REQ_STATUS'
AND v.code_value = cr.req_status) AS req_status_n,
cr.req_date,
cr.description AS ccr_description,
cr.document_type AS ccr_document_type,
(SELECT dt.description
FROM hls_document_type dt
WHERE dt.document_type = cr.document_type) AS ccr_document_type_n,
cr.document_category AS ccr_document_category,
(SELECT dc.description
FROM hls_document_category dc
WHERE dc.document_category = cr.document_category) AS ccr_document_category_n,
cr.business_type AS ccr_business_type,
(SELECT bt.description
FROM hls_business_type bt
WHERE bt.business_type = cr.business_type) AS ccr_business_type_n,
cr.change_req_id,
(SELECT su.description
FROM sys_user su
WHERE su.user_id = t1.owner_user_id) owner, -- 单据所有者
t1.depart_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'DEPART_STATUS'
AND v.code_value = t1.depart_status) depart_status_n, --发车状态
t1.history_contract_id,
(SELECT ccd.comments
FROM con_contract_case_record ccd
WHERE ccd.document_table = 'CON_CONTRACT_CHANGE_REQ'
AND ccd.document_id = cr.change_req_id
and ccd.status in ('APPROVING','APPROVED','REJECT')) comments, --返回意见
cr.approved_date,--审批通过时间
cr.creation_date create_date,--创建时间
cr.contract_id source_contract_id
FROM con_contract t1,
con_contract_change_req cr
WHERE t1.contract_id = cr.change_req_id
AND cr.document_type IN ('CUT_CHAG' ,'LEASE_CHAG','ACC_CHAG')
;
CREATE OR REPLACE VIEW CON_CONTRACT_CCR_LV AS
SELECT t1.contract_id,
t1.calc_session_id,
t1.contract_number,
t1.contract_name,
t1.business_type,
(SELECT bt.description
FROM hls_business_type bt
WHERE bt.business_type = t1.business_type) AS business_type_n,
t1.document_type,
(SELECT dt.description
FROM hls_document_type dt
WHERE dt.document_type = t1.document_type) AS document_type_n,
t1.document_category,
(SELECT dc.description
FROM hls_document_category dc
WHERE dc.document_category = t1.document_category) AS document_category_n,
t1.project_id,
(SELECT p.project_number
FROM prj_project p
WHERE t1.project_id = p.project_id) AS project_id_c,
(SELECT p.project_name
FROM prj_project p
WHERE t1.project_id = p.project_id) AS project_id_n,
t1.company_id,
(SELECT c.company_short_name
FROM fnd_companies_vl c
WHERE c.company_id = t1.company_id) AS company_id_n,
t1.spv_company_id,
(SELECT c.company_short_name
FROM fnd_companies_vl c
WHERE c.company_id = t1.spv_company_id) AS spv_company_id_n,
t1.lease_organization,
(SELECT o.description
FROM hls_lease_organization o
WHERE o.lease_organization = t1.lease_organization) AS lease_organization_n,
t1.lease_channel,
(SELECT ch.description
FROM hls_lease_channel ch
WHERE ch.lease_channel = t1.lease_channel) AS lease_channel_n,
t1.division,
(SELECT d.description
FROM hls_division d
WHERE d.division = t1.division) AS division_n,
t1.bp_id_tenant,
(SELECT m.bp_name
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_tenant) AS bp_id_tenant_n,
(SELECT ma.bp_name
FROM hls_bp_master ma
WHERE ma.bp_id = t1.bp_id_tenant) bp_id_tenant_name,
t1.bp_id_agent_level1,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level1) AS bp_id_agent_level1_n,
t1.bp_id_agent_level2,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level2) AS bp_id_agent_level2_n,
t1.bp_id_agent_level3,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level3) AS bp_id_agent_level3_n,
t1.owner_user_id,
t1.employee_id,
(SELECT e.name
FROM exp_employees e
WHERE e.employee_id = t1.employee_id) AS employee_id_n,
t1.unit_id,
(SELECT u.description
FROM exp_org_unit_vl u
WHERE u.unit_id = t1.unit_id) AS unit_id_n,
t1.employee_id_of_manager,
(SELECT e.name
FROM exp_employees e
WHERE e.employee_id = t1.employee_id_of_manager) AS employee_id_of_manager_n,
t1.factoring_type,
t1.description,
t1.price_list,
(SELECT l.description
FROM hls_price_list l
WHERE l.price_list = t1.price_list) AS price_list_n,
t1.calc_method,
t1.inception_of_lease,
t1.lease_start_date,
t1.first_pay_date,
t1.last_pay_date,
t1.lease_end_date,
t1.lease_times,
t1.pay_times,
t1.annual_pay_times,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_ANNUAL_PAY_TIMES'
AND v.code_value = t1.annual_pay_times) AS annual_pay_times_n,
t1.lease_term,
t1.pay_type,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_PAY_TYPE'
AND v.code_value = t1.pay_type) AS pay_type_n,
t1.currency,
(SELECT g.currency_name
FROM gld_currency_vl g
WHERE g.currency_code = t1.currency) AS currency_n,
t1.currency_precision,
t1.machinery_amount,
t1.parts_amount,
t1.lease_item_amount,
t1.lease_item_cost,
t1.down_payment,
t1.down_payment_ratio,
t1.finance_amount,
t1.net_finance_amount,
t1.total_interest,
t1.total_rental,
t1.total_fee,
t1.contract_amount,
t1.tax_type_id,
(SELECT t.description
FROM fnd_tax_type_codes t
WHERE t.tax_type_id = t1.tax_type_id) AS tax_type_id_n,
t1.vat_flag,
t1.vat_rate,
t1.vat_input,
t1.vat_total_interest,
t1.vat_finance_amount,
t1.vat_total_rental,
t1.vat_total_fee,
t1.net_total_interest,
t1.net_total_rental,
t1.net_total_fee,
t1.net_lease_item_amount,
t1.lease_charge,
t1.lease_charge_ratio,
t1.lease_mgt_fee,
t1.lease_mgt_fee_ratio,
t1.lease_mgt_fee_rule,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_MGT_FEE_RULE'
AND v.code_value = t1.lease_mgt_fee_rule) AS lease_mgt_fee_rule_n,
t1.deposit,
t1.deposit_ratio,
t1.deposit_deduction,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_DEPOSIT_DEDUCTION'
AND v.code_value = t1.deposit_deduction) AS deposit_deduction_n,
t1.residual_value,
t1.residual_ratio,
t1.balloon,
t1.balloon_ratio,
t1.interim_rent_period,
t1.interim_times,
t1.interim_rental,
t1.insurance_fee,
t1.insurance_rate,
t1.commission_payable,
t1.commission_receivable,
t1.third_party_deposit,
t1.promise_to_pay,
t1.other_fee,
t1.other_payment,
t1.rounding_object,
t1.rounding_method,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_CASHFLOW_ACCURATED'
AND v.code_value = t1.rounding_method) AS rounding_method_n,
t1.int_rate_fixing_way,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'TRE502_INT_RATE_FIXING_WAY'
AND v.code_value = t1.int_rate_fixing_way) AS int_rate_fixing_way_n,
t1.int_rate_fixing_range,
t1.int_rate_display,
t1.base_rate_type,
(SELECT rt.description
FROM fnd_base_rate_type rt
WHERE rt.base_rate_type = t1.base_rate_type) AS base_rate_type_n,
t1.base_rate,
t1.int_rate,
t1.int_rate_implicit,
t1.int_rate_type,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON500_INT_RATE_TYPE'
AND v.code_value = t1.int_rate_type) AS int_rate_type_n,
t1.flt_rate_profile,
(SELECT description
FROM con_flt_rate_profile p
WHERE p.flt_rate_profile = t1.flt_rate_profile) AS flt_rate_profile_n,
t1.flt_rate_adj_method,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_FLT_RATE_ADJ_METHOD'
AND v.code_value = t1.flt_rate_adj_method) AS flt_rate_adj_method_n,
t1.flt_simulate_step,
t1.flt_simulate_range,
t1.flt_unit_adj_amt,
t1.flt_execute_times_rule,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS_FLT_EXECUTE_TIMES_RULE'
AND v.code_value = t1.flt_execute_times_rule) AS flt_execute_times_rule_n,
t1.flt_int_rate_adj_date,
t1.flt_delay_execute_period,
t1.flt_annual_adj_times,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS_FLT_ANNUAL_ADJ_TIMES'
AND v.code_value = t1.flt_annual_adj_times) AS flt_annual_adj_times_n,
flt_next_adj_date,
t1.int_rate_precision,
t1.irr,
t1.irr_after_tax,
t1.int_rate_implicit_after_tax,
t1.irr_reserved1,
t1.irr_reserved2,
t1.irr_reserved3,
t1.pmt,
t1.pmt_first,
t1.npv_using_cof,
t1.annual_mean_rate,
t1.total_salestax,
t1.biz_day_convention,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS050_BIZ_DAY_CONVENTION'
AND v.code_value = t1.biz_day_convention) AS biz_day_convention_n,
t1.calc_with_residual_value,
t1.exchange_rate_type,
(SELECT v.rate_type_desc
FROM gld_exchange_rate_type_v v
WHERE v.rate_type_code = t1.exchange_rate_type) AS exchange_rate_type_n,
t1.exchange_rate_quotation,
t1.exchange_rate,
t1.penalty_profile,
t1.grace_period,
t1.penalty_rate,
t1.penalty_calc_base,
t1.penalty_total_base_ratio,
t1.credit_write_off_order, --?
t1.fin_income_recognize_method,
t1.early_termination_profile,
(SELECT p.description
FROM con_contract_et_profile p
WHERE p.et_profile = t1.early_termination_profile
AND rownum = 1) AS early_termination_profile_n,
t1.payment_method_id,
t1.telex_transfer_bank_id,
t1.tt_bank_branch_name,
t1.tt_bank_account_num,
t1.tt_bank_account_name,
t1.tt_remark,
t1.direct_debit_bank_id,
t1.dd_bank_branch_name,
t1.dd_bank_account_num,
t1.dd_bank_account_name,
t1.dd_agreement_no,
t1.dd_agreement_status,
t1.dd_remark,
t1.purchase_order_no,
t1.contract_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON500_CONTRACT_STATUS'
AND v.code_value = t1.contract_status) AS contract_status_n,
t1.user_status_1,
t1.user_status_2,
t1.user_status_3,
t1.print_status,
t1.print_times,
t1.first_print_date,
t1.first_print_by,
t1.delivery_status,
t1.delivery_date,
t1.billing_method,
(SELECT bm.description
FROM con_billing_method bm
WHERE bm.billing_method = t1.billing_method) AS billing_method_n,
t1.billing_status,
t1.signing_date,
t1.original_recall_date,
t1.lease_card_recall_date,
t1.early_termination_date,
t1.termination_date,
t1.assignment_agreement_no,
t1.assignment_date,
t1.btb_payment_date,
t1.btb_int_rate,
t1.btb_int_rate_implicit,
t1.btb_finance_amount,
t1.btb_net_finance_amount,
t1.btb_total_repayment,
t1.btb_total_interest,
t1.btb_total_fee_pv,
t1.btb_total_fee,
t1.btb_finance_ratio,
t1.btb_interest_margin,
t1.btb_vat_interest,
t1.btb_vat_fee,
t1.btb_interest_after_tax,
t1.btb_fee_after_tax,
t1.cdd_list_id,
t1.hd_user_col_d01,
t1.hd_user_col_d02,
t1.hd_user_col_d03,
t1.hd_user_col_d04,
t1.hd_user_col_d05,
t1.hd_user_col_v01,
t1.hd_user_col_v02,
t1.hd_user_col_v03,
t1.hd_user_col_v04,
t1.hd_user_col_v05,
t1.hd_user_col_v06,
t1.hd_user_col_v07,
t1.hd_user_col_v08,
t1.hd_user_col_v09,
t1.hd_user_col_v10,
t1.hd_user_col_n01,
t1.hd_user_col_n02,
t1.hd_user_col_n03,
t1.hd_user_col_n04,
t1.hd_user_col_n05,
t1.hd_user_col_n06,
t1.hd_user_col_n07,
t1.hd_user_col_n08,
t1.hd_user_col_n09,
t1.hd_user_col_n10,
t1.hd_user_col_n11,
t1.hd_user_col_n12,
t1.hd_user_col_n13,
t1.serial_number,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n13)) AS hd_user_col_n13_n,
t1.hd_user_col_n14,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n14)) AS hd_user_col_n14_n,
t1.hd_user_col_n15,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n15)) AS hd_user_col_n15_n,
overdue_status,
overdue_max_days,
five_class_code,
(SELECT r.description
FROM rsc_five_class_code r
WHERE t1.five_class_code = r.five_class_code) AS five_class_code_n,
main_business_income,
main_business_cost,
financing_cost,
calc_prompt,
calc_prompt_msg,
lease_item_price_agent,
legal_fee,
version,
version_date,
version_display,
version_external,
version_reason,
version_note,
t1.created_by,
(SELECT su.description
FROM sys_user su
WHERE su.user_id = cr.created_by) change_created_by_n,
t1.creation_date,
t1.last_updated_by,
t1.last_update_date,
t1.search_term_1,
t1.search_term_2,
t1.data_class,
t1.ccr_start_times,
t1.ccr_outstanding_times,
t1.ccr_outstanding_prin_tax_incld,
t1.ccr_overdue_rental,
t1.ccr_penalty,
t1.ccr_fee,
t1.ccr_finance_amount,
t1.ccr_pmt,
t1.ccr_outstanding_prin_ti_total,
t1.ccr_financing_overdue_rental,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.ccr_financing_overdue_rental)) AS ccr_financing_overdue_rental_n,
t1.ccr_period_int_rate_implicit,
t1.ccr_period_lease_start_date,
t1.ccr_added_principal,
t1.ccr_nominal_finance_amount,
t1.ccr_original_finance_amount,
cr.change_quotation,
cr.change_lease_item,
cr.change_bp,
cr.change_req_number,
cr.req_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON_CHANGE_REQ_STATUS'
AND v.code_value = cr.req_status) AS req_status_n,
cr.req_date,
cr.description AS ccr_description,
cr.document_type AS ccr_document_type,
(SELECT dt.description
FROM hls_document_type dt
WHERE dt.document_type = cr.document_type) AS ccr_document_type_n,
cr.document_category AS ccr_document_category,
(SELECT dc.description
FROM hls_document_category dc
WHERE dc.document_category = cr.document_category) AS ccr_document_category_n,
cr.business_type AS ccr_business_type,
(SELECT bt.description
FROM hls_business_type bt
WHERE bt.business_type = cr.business_type) AS ccr_business_type_n,
cr.change_req_id,
(SELECT su.description
FROM sys_user su
WHERE su.user_id = t1.owner_user_id) owner, -- 单据所有者
t1.depart_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'DEPART_STATUS'
AND v.code_value = t1.depart_status) depart_status_n, --发车状态
t1.history_contract_id,
(SELECT ccd.comments
FROM con_contract_case_record ccd
WHERE ccd.document_table = 'CON_CONTRACT_CHANGE_REQ'
AND ccd.document_id = cr.change_req_id
and ccd.status in ('APPROVING','APPROVED','REJECT')) comments, --doodream返回意见
cr.approved_date,--审批通过时间
cr.creation_date create_date--创建时间
FROM con_contract t1,
con_contract_change_req cr
WHERE t1.data_class = 'CHANGE_REQ'
AND t1.contract_id = cr.change_req_id
--增加migration数据
UNION ALL
SELECT t1.contract_id,
t1.calc_session_id,
t1.contract_number,
t1.contract_name,
t1.business_type,
(SELECT bt.description
FROM hls_business_type bt
WHERE bt.business_type = t1.business_type) AS business_type_n,
t1.document_type,
(SELECT dt.description
FROM hls_document_type dt
WHERE dt.document_type = t1.document_type) AS document_type_n,
t1.document_category,
(SELECT dc.description
FROM hls_document_category dc
WHERE dc.document_category = t1.document_category) AS document_category_n,
t1.project_id,
(SELECT p.project_number
FROM prj_project p
WHERE t1.project_id = p.project_id) AS project_id_c,
(SELECT p.project_name
FROM prj_project p
WHERE t1.project_id = p.project_id) AS project_id_n,
t1.company_id,
(SELECT c.company_short_name
FROM fnd_companies_vl c
WHERE c.company_id = t1.company_id) AS company_id_n,
t1.spv_company_id,
(SELECT c.company_short_name
FROM fnd_companies_vl c
WHERE c.company_id = t1.spv_company_id) AS spv_company_id_n,
t1.lease_organization,
(SELECT o.description
FROM hls_lease_organization o
WHERE o.lease_organization = t1.lease_organization) AS lease_organization_n,
t1.lease_channel,
(SELECT ch.description
FROM hls_lease_channel ch
WHERE ch.lease_channel = t1.lease_channel) AS lease_channel_n,
t1.division,
(SELECT d.description
FROM hls_division d
WHERE d.division = t1.division) AS division_n,
t1.bp_id_tenant,
(SELECT m.bp_name
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_tenant) AS bp_id_tenant_n,
(SELECT ma.bp_name
FROM hls_bp_master ma
WHERE ma.bp_id = t1.bp_id_tenant) bp_id_tenant_name,
t1.bp_id_agent_level1,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level1) AS bp_id_agent_level1_n,
t1.bp_id_agent_level2,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level2) AS bp_id_agent_level2_n,
t1.bp_id_agent_level3,
(SELECT m.bp_code
FROM hls_bp_master m
WHERE m.bp_id = t1.bp_id_agent_level3) AS bp_id_agent_level3_n,
t1.owner_user_id,
t1.employee_id,
(SELECT e.name
FROM exp_employees e
WHERE e.employee_id = t1.employee_id) AS employee_id_n,
t1.unit_id,
(SELECT u.description
FROM exp_org_unit_vl u
WHERE u.unit_id = t1.unit_id) AS unit_id_n,
t1.employee_id_of_manager,
(SELECT e.name
FROM exp_employees e
WHERE e.employee_id = t1.employee_id_of_manager) AS employee_id_of_manager_n,
t1.factoring_type,
t1.description,
t1.price_list,
(SELECT l.description
FROM hls_price_list l
WHERE l.price_list = t1.price_list) AS price_list_n,
t1.calc_method,
t1.inception_of_lease,
t1.lease_start_date,
t1.first_pay_date,
t1.last_pay_date,
t1.lease_end_date,
t1.lease_times,
t1.pay_times,
t1.annual_pay_times,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_ANNUAL_PAY_TIMES'
AND v.code_value = t1.annual_pay_times) AS annual_pay_times_n,
t1.lease_term,
t1.pay_type,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_PAY_TYPE'
AND v.code_value = t1.pay_type) AS pay_type_n,
t1.currency,
(SELECT g.currency_name
FROM gld_currency_vl g
WHERE g.currency_code = t1.currency) AS currency_n,
t1.currency_precision,
t1.machinery_amount,
t1.parts_amount,
t1.lease_item_amount,
t1.lease_item_cost,
t1.down_payment,
t1.down_payment_ratio,
t1.finance_amount,
t1.net_finance_amount,
t1.total_interest,
t1.total_rental,
t1.total_fee,
t1.contract_amount,
t1.tax_type_id,
(SELECT t.description
FROM fnd_tax_type_codes t
WHERE t.tax_type_id = t1.tax_type_id) AS tax_type_id_n,
t1.vat_flag,
t1.vat_rate,
t1.vat_input,
t1.vat_total_interest,
t1.vat_finance_amount,
t1.vat_total_rental,
t1.vat_total_fee,
t1.net_total_interest,
t1.net_total_rental,
t1.net_total_fee,
t1.net_lease_item_amount,
t1.lease_charge,
t1.lease_charge_ratio,
t1.lease_mgt_fee,
t1.lease_mgt_fee_ratio,
t1.lease_mgt_fee_rule,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_MGT_FEE_RULE'
AND v.code_value = t1.lease_mgt_fee_rule) AS lease_mgt_fee_rule_n,
t1.deposit,
t1.deposit_ratio,
t1.deposit_deduction,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_DEPOSIT_DEDUCTION'
AND v.code_value = t1.deposit_deduction) AS deposit_deduction_n,
t1.residual_value,
t1.residual_ratio,
t1.balloon,
t1.balloon_ratio,
t1.interim_rent_period,
t1.interim_times,
t1.interim_rental,
t1.insurance_fee,
t1.insurance_rate,
t1.commission_payable,
t1.commission_receivable,
t1.third_party_deposit,
t1.promise_to_pay,
t1.other_fee,
t1.other_payment,
t1.rounding_object,
t1.rounding_method,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_CASHFLOW_ACCURATED'
AND v.code_value = t1.rounding_method) AS rounding_method_n,
t1.int_rate_fixing_way,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'TRE502_INT_RATE_FIXING_WAY'
AND v.code_value = t1.int_rate_fixing_way) AS int_rate_fixing_way_n,
t1.int_rate_fixing_range,
t1.int_rate_display,
t1.base_rate_type,
(SELECT rt.description
FROM fnd_base_rate_type rt
WHERE rt.base_rate_type = t1.base_rate_type) AS base_rate_type_n,
t1.base_rate,
t1.int_rate,
t1.int_rate_implicit,
t1.int_rate_type,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON500_INT_RATE_TYPE'
AND v.code_value = t1.int_rate_type) AS int_rate_type_n,
t1.flt_rate_profile,
(SELECT description
FROM con_flt_rate_profile p
WHERE p.flt_rate_profile = t1.flt_rate_profile) AS flt_rate_profile_n,
t1.flt_rate_adj_method,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS500_FLT_RATE_ADJ_METHOD'
AND v.code_value = t1.flt_rate_adj_method) AS flt_rate_adj_method_n,
t1.flt_simulate_step,
t1.flt_simulate_range,
t1.flt_unit_adj_amt,
t1.flt_execute_times_rule,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS_FLT_EXECUTE_TIMES_RULE'
AND v.code_value = t1.flt_execute_times_rule) AS flt_execute_times_rule_n,
t1.flt_int_rate_adj_date,
t1.flt_delay_execute_period,
t1.flt_annual_adj_times,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS_FLT_ANNUAL_ADJ_TIMES'
AND v.code_value = t1.flt_annual_adj_times) AS flt_annual_adj_times_n,
flt_next_adj_date,
t1.int_rate_precision,
t1.irr,
t1.irr_after_tax,
t1.int_rate_implicit_after_tax,
t1.irr_reserved1,
t1.irr_reserved2,
t1.irr_reserved3,
t1.pmt,
t1.pmt_first,
t1.npv_using_cof,
t1.annual_mean_rate,
t1.total_salestax,
t1.biz_day_convention,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'HLS050_BIZ_DAY_CONVENTION'
AND v.code_value = t1.biz_day_convention) AS biz_day_convention_n,
t1.calc_with_residual_value,
t1.exchange_rate_type,
(SELECT v.rate_type_desc
FROM gld_exchange_rate_type_v v
WHERE v.rate_type_code = t1.exchange_rate_type) AS exchange_rate_type_n,
t1.exchange_rate_quotation,
t1.exchange_rate,
t1.penalty_profile,
t1.grace_period,
t1.penalty_rate,
t1.penalty_calc_base,
t1.penalty_total_base_ratio,
t1.credit_write_off_order, --?
t1.fin_income_recognize_method,
t1.early_termination_profile,
(SELECT p.description
FROM con_contract_et_profile p
WHERE p.et_profile = t1.early_termination_profile
AND rownum = 1) AS early_termination_profile_n,
t1.payment_method_id,
t1.telex_transfer_bank_id,
t1.tt_bank_branch_name,
t1.tt_bank_account_num,
t1.tt_bank_account_name,
t1.tt_remark,
t1.direct_debit_bank_id,
t1.dd_bank_branch_name,
t1.dd_bank_account_num,
t1.dd_bank_account_name,
t1.dd_agreement_no,
t1.dd_agreement_status,
t1.dd_remark,
t1.purchase_order_no,
t1.contract_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON500_CONTRACT_STATUS'
AND v.code_value = t1.contract_status) AS contract_status_n,
t1.user_status_1,
t1.user_status_2,
t1.user_status_3,
t1.print_status,
t1.print_times,
t1.first_print_date,
t1.first_print_by,
t1.delivery_status,
t1.delivery_date,
t1.billing_method,
(SELECT bm.description
FROM con_billing_method bm
WHERE bm.billing_method = t1.billing_method) AS billing_method_n,
t1.billing_status,
t1.signing_date,
t1.original_recall_date,
t1.lease_card_recall_date,
t1.early_termination_date,
t1.termination_date,
t1.assignment_agreement_no,
t1.assignment_date,
t1.btb_payment_date,
t1.btb_int_rate,
t1.btb_int_rate_implicit,
t1.btb_finance_amount,
t1.btb_net_finance_amount,
t1.btb_total_repayment,
t1.btb_total_interest,
t1.btb_total_fee_pv,
t1.btb_total_fee,
t1.btb_finance_ratio,
t1.btb_interest_margin,
t1.btb_vat_interest,
t1.btb_vat_fee,
t1.btb_interest_after_tax,
t1.btb_fee_after_tax,
t1.cdd_list_id,
t1.hd_user_col_d01,
t1.hd_user_col_d02,
t1.hd_user_col_d03,
t1.hd_user_col_d04,
t1.hd_user_col_d05,
t1.hd_user_col_v01,
t1.hd_user_col_v02,
t1.hd_user_col_v03,
t1.hd_user_col_v04,
t1.hd_user_col_v05,
t1.hd_user_col_v06,
t1.hd_user_col_v07,
t1.hd_user_col_v08,
t1.hd_user_col_v09,
t1.hd_user_col_v10,
t1.hd_user_col_n01,
t1.hd_user_col_n02,
t1.hd_user_col_n03,
t1.hd_user_col_n04,
t1.hd_user_col_n05,
t1.hd_user_col_n06,
t1.hd_user_col_n07,
t1.hd_user_col_n08,
t1.hd_user_col_n09,
t1.hd_user_col_n10,
t1.hd_user_col_n11,
t1.hd_user_col_n12,
t1.hd_user_col_n13,
t1.serial_number,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n13)) AS hd_user_col_n13_n,
t1.hd_user_col_n14,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n14)) AS hd_user_col_n14_n,
t1.hd_user_col_n15,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.hd_user_col_n15)) AS hd_user_col_n15_n,
overdue_status,
overdue_max_days,
five_class_code,
(SELECT r.description
FROM rsc_five_class_code r
WHERE t1.five_class_code = r.five_class_code) AS five_class_code_n,
main_business_income,
main_business_cost,
financing_cost,
calc_prompt,
calc_prompt_msg,
lease_item_price_agent,
legal_fee,
version,
version_date,
version_display,
version_external,
version_reason,
version_note,
t1.created_by,
(SELECT su.description
FROM sys_user su
WHERE su.user_id = cr.created_by) change_created_by_n,
t1.creation_date,
t1.last_updated_by,
t1.last_update_date,
t1.search_term_1,
t1.search_term_2,
'CHANGE_REQ' data_class,
t1.ccr_start_times,
t1.ccr_outstanding_times,
t1.ccr_outstanding_prin_tax_incld,
t1.ccr_overdue_rental,
t1.ccr_penalty,
t1.ccr_fee,
t1.ccr_finance_amount,
t1.ccr_pmt,
t1.ccr_outstanding_prin_ti_total,
t1.ccr_financing_overdue_rental,
(SELECT t.code_value_name
FROM sys_code_values_v t
WHERE t.code = 'HLS050_ZERO_OR_ONE'
AND t.code_value = to_char(t1.ccr_financing_overdue_rental)) AS ccr_financing_overdue_rental_n,
t1.ccr_period_int_rate_implicit,
t1.ccr_period_lease_start_date,
t1.ccr_added_principal,
t1.ccr_nominal_finance_amount,
t1.ccr_original_finance_amount,
cr.change_quotation,
cr.change_lease_item,
cr.change_bp,
cr.change_req_number,
cr.req_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'CON_CHANGE_REQ_STATUS'
AND v.code_value = cr.req_status) AS req_status_n,
cr.req_date,
cr.description AS ccr_description,
cr.document_type AS ccr_document_type,
(SELECT dt.description
FROM hls_document_type dt
WHERE dt.document_type = cr.document_type) AS ccr_document_type_n,
cr.document_category AS ccr_document_category,
(SELECT dc.description
FROM hls_document_category dc
WHERE dc.document_category = cr.document_category) AS ccr_document_category_n,
cr.business_type AS ccr_business_type,
(SELECT bt.description
FROM hls_business_type bt
WHERE bt.business_type = cr.business_type) AS ccr_business_type_n,
cr.change_req_id,
(SELECT su.description
FROM sys_user su
WHERE su.user_id = t1.owner_user_id) owner, -- 单据所有者
t1.depart_status,
(SELECT v.code_value_name
FROM sys_code_values_v v
WHERE v.code = 'DEPART_STATUS'
AND v.code_value = t1.depart_status) depart_status_n, --发车状态
t1.history_contract_id,
(SELECT ccd.comments
FROM con_contract_case_record ccd
WHERE ccd.document_table = 'CON_CONTRACT_CHANGE_REQ'
AND ccd.document_id = cr.change_req_id
and ccd.status in ('APPROVING','APPROVED','REJECT')) comments, --doodream返回意见
cr.approved_date,--审批通过时间
cr.creation_date create_date--创建时间
FROM con_contract t1,
con_contract_change_req cr
WHERE t1.contract_id = cr.change_req_id
AND (cr.cashflow_change_flag='Y' OR cr.extension_change_flag = 'Y' OR
cr.RESCHEDULE_FLAG='Y' OR cr.BANK_ACC_CHANGE_FLAG= 'Y')
;
CREATE OR REPLACE VIEW CON_CONTRACT_CHANGE_REQ_LV AS CREATE OR REPLACE VIEW CON_CONTRACT_CHANGE_REQ_LV AS
select t.change_req_id, select t.change_req_id,
t.batch_id, t.batch_id,
t.change_quotation, t.change_quotation,
...@@ -66,13 +66,13 @@ select t.change_req_id, ...@@ -66,13 +66,13 @@ select t.change_req_id,
nvl(t.et_fee,500) et_fee, nvl(t.et_fee,500) et_fee,
nvl(t.et_total_amount,0) et_total_amount, nvl(t.et_total_amount,0) et_total_amount,
nvl(t.et_interest,0) et_interest, nvl(t.et_interest,0) et_interest,
--提前结清 start --提前结清 start
nvl(t.FUND_POSSESSION_TIME,0)FUND_POSSESSION_TIME,--资金占用天数 nvl(t.FUND_POSSESSION_TIME,0)FUND_POSSESSION_TIME,--资金占用天数
NVL(t.FUND_POSSESSION_COST,0)FUND_POSSESSION_COST,--资金占用费 NVL(t.FUND_POSSESSION_COST,0)FUND_POSSESSION_COST,--资金占用费
NVL(t.FUND_POSSESSION_RATE,0)FUND_POSSESSION_RATE,--资金占用费利率 NVL(t.FUND_POSSESSION_RATE,0)FUND_POSSESSION_RATE,--资金占用费利率
NVL(t.ET_DUE_AMOUNT,0)ET_DUE_AMOUNT,--提前结清租金 NVL(t.ET_DUE_AMOUNT,0)ET_DUE_AMOUNT,--提前结清租金
NVL(t.SUM_UNRECEIVED_PRINCIPAL,0)SUM_UNRECEIVED_PRINCIPAL,--剩余本金 NVL(t.SUM_UNRECEIVED_PRINCIPAL,0)SUM_UNRECEIVED_PRINCIPAL,--剩余本金
NVL(t.ET_INTEREST_RATE,cc.int_rate_display)ET_INTEREST_RATE,--提前结清利率 NVL(t.ET_INTEREST_RATE,cc.int_rate_display)ET_INTEREST_RATE,--提前结清利率
cc.bp_id_agent_level1, cc.bp_id_agent_level1,
(SELECT m.bp_name (SELECT m.bp_name
FROM hls_bp_master m FROM hls_bp_master m
...@@ -80,8 +80,9 @@ select t.change_req_id, ...@@ -80,8 +80,9 @@ select t.change_req_id,
AS bp_id_agent_level1_n, AS bp_id_agent_level1_n,
nvl(t.residual_value,cc.residual_value)residual_value, nvl(t.residual_value,cc.residual_value)residual_value,
t.ccr_reason t.ccr_reason
--提前结清 end --提前结清 end
from con_contract_change_req t, from con_contract_change_req t,
con_contract cc con_contract cc
where t.contract_id = cc.contract_id where cc.contract_id = t.change_req_id
AND cc.data_class = 'CHANGE_REQ'
; ;
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="execute">
<bm:parameters>
<bm:parameter name="calc_session_id" dataType="java.lang.Long" input="false" output="true"/>
<bm:parameter name="calc_successful" dataType="java.lang.String" input="false" output="true"/>
<bm:parameter name="warning_message" dataType="java.lang.String" input="false" output="true"/>
</bm:parameters>
<bm:update-sql><![CDATA[
begin
cus_con_change_req_pkg.CALC_CHANGE_REQ
(
p_change_req_id=>${@change_req_id},
p_ccr_start_times =>${@ccr_start_times},
p_ccr_outstanding_times =>${@ccr_outstanding_times},
p_calc_session_id=>${@calc_session_id},
p_calc_successful=>${@calc_successful},
p_warning_message=>${@warning_message},
p_user_id=>${/session/@user_id}
);
end;]]></bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="execute">
<bm:parameters>
<bm:parameter name="ccr_lease_rental" dataType="java.lang.Double" input="false" output="true" outputPath="@ccr_lease_rental"/>
<bm:parameter name="ccr_lease_principal" dataType="java.lang.Double" input="false" output="true" outputPath="@ccr_lease_principal"/>
<bm:parameter name="ccr_lease_interest" dataType="java.lang.Double" input="false" output="true" outputPath="@ccr_lease_interest"/>
<bm:parameter name="ccr_lease_penalty" dataType="java.lang.Double" input="false" output="true" outputPath="@ccr_lease_penalty"/>
</bm:parameters>
<bm:update-sql><![CDATA[
begin
cus_con_change_req_pkg.calc_tenant_change_req(p_change_req_id =>${@change_req_id},
p_ccr_lease_date =>to_date(${@ccr_lease_date},'yyyy-mm-dd'),
p_ccr_lease_rental =>${@ccr_lease_rental},
p_ccr_lease_principal =>${@ccr_lease_principal},
p_ccr_lease_interest =>${@ccr_lease_interest},
p_ccr_lease_penalty =>${@ccr_lease_penalty},
p_user_id =>${/session/@user_id}
);
end;]]></bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="execute">
<bm:parameters>
<bm:parameter name="change_req_id" dataType="java.lang.Long" input="false" output="true"/>
</bm:parameters>
<bm:update-sql><![CDATA[
DECLARE
v_change_req_id NUMBER;
BEGIN
cus_con_change_req_pkg.create_change_req(p_contract_id=>${@contract_id},
p_req_date=>to_date(${@req_date},'YYYY-MM-DD'),
p_req_type=>${@req_type},
p_description=>${@description},
p_user_id=>${/session/@user_id},
p_simulation_flag=>${@simulation_flag},
p_ref_v01=>${@ref_v01},
p_change_req_id=>v_change_req_id );
${@change_req_id}:=v_change_req_id;
END;
]]>
</bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
...@@ -6,6 +6,9 @@ var override_queryfields = [ ...@@ -6,6 +6,9 @@ var override_queryfields = [
{ {
name : 'bp_name', name : 'bp_name',
queryexpression : "exists (select 1 from hls_bp_master hr where hr.bp_id=t1.bp_id_tenant and hr.bp_name like ${@bp_name})" queryexpression : "exists (select 1 from hls_bp_master hr where hr.bp_id=t1.bp_id_tenant and hr.bp_name like ${@bp_name})"
},{
name : 'bp_id_agent_level1_n',
queryexpression : "exists (select 1 from hls_bp_master hr where hr.bp_id=t1.bp_id_agent_level1 and hr.bp_name like ${@bp_id_agent_level1_n})"
}, },
{ {
name : 'lease_start_date_from', name : 'lease_start_date_from',
...@@ -14,6 +17,14 @@ var override_queryfields = [ ...@@ -14,6 +17,14 @@ var override_queryfields = [
{ {
name : 'lease_start_date_to', name : 'lease_start_date_to',
queryexpression : "t1.lease_start_date between nvl(to_date(${@lease_start_date_from},'yyyy-mm-dd'),t1.lease_start_date) and to_date(${@lease_start_date_to},'yyyy-mm-dd')" queryexpression : "t1.lease_start_date between nvl(to_date(${@lease_start_date_from},'yyyy-mm-dd'),t1.lease_start_date) and to_date(${@lease_start_date_to},'yyyy-mm-dd')"
},
{
name : 'inception_of_lease_from',
queryexpression : "t1.inception_of_lease between to_date(${@inception_of_lease_from},'yyyy-mm-dd') and nvl(to_date(${@inception_of_lease_to},'yyyy-mm-dd'),t1.inception_of_lease)"
},
{
name : 'inception_of_lease_to',
queryexpression : "t1.inception_of_lease between nvl(to_date(${@inception_of_lease_from},'yyyy-mm-dd'),t1.inception_of_lease) and to_date(${@inception_of_lease_to},'yyyy-mm-dd')"
}, { }, {
field : 'project_id', field : 'project_id',
queryoperator : "=" queryoperator : "="
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true"> <a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
<a:view> <a:view>
<a:link id="con731_calc_ccr_fee_link" model="cont.CON731.calc_ccr_fee" modelaction="execute"/> <!-- <a:link id="con731_calc_ccr_fee_link" model="cont.CON731.calc_ccr_fee" modelaction="execute"/>-->
<a:link id="calc_leasse_amount_link" model="cont.CON731.calc_leasse_date" modelaction="execute"/> <a:link id="calc_leasse_amount_link" model="cont.CON731.calc_leasse_date" modelaction="execute"/>
<a:link id="calc_pay_amount_link" model="cont.CON731.calc_leasse_pay" modelaction="execute"/> <a:link id="calc_pay_amount_link" model="cont.CON731.calc_leasse_pay" modelaction="execute"/>
<a:link id="con731_update_link" model="cont.CON731.update_change_req" modelaction="execute"/> <a:link id="calc_tenant_amount_link" model="cont.CON733.calc_tenant_change_req" modelaction="execute"/>
<a:link id="con731_quote_link" url="${/request/@context_path}/modules/hls/HLS500N/hls_fin_calculator_update_n.lview"/> <a:link id="con731_quote_link" url="${/request/@context_path}/modules/hls/HLS500N/hls_fin_calculator_update_n.lview"/>
<a:link id="con731_quote_calc_link" model="cont.CON731.calc_change_req" modelaction="execute"/> <a:link id="con733_quote_calc_change_req_link" model="cont.CON733.calc_change_req" modelaction="execute"/>
<a:link id="con731_submit_link" model="cont.CON731.submit_change_req" modelaction="execute"/> <a:link id="con731_submit_link" model="cont.CON731.submit_change_req" modelaction="execute"/>
<a:link id="con731_cancel_link" model="cont.CON731.cancel_change_req" modelaction="execute"/> <a:link id="con731_cancel_link" model="cont.CON731.cancel_change_req" modelaction="execute"/>
<a:link id="${/parameter/@layout_code}_prj500_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/> <a:link id="${/parameter/@layout_code}_prj500_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
...@@ -14,45 +14,54 @@ ...@@ -14,45 +14,54 @@
<script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/> <script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/>
<link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/> <link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/>
<a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_doc_quotation_link_id" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_doc_quotation.lsc"/> <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_doc_quotation_link_id" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_doc_quotation.lsc"/>
<a:link id="get_xml" model="cont.CON731.con_change_case_submit" modelaction="execute"/>
<script type="text/javascript"><![CDATA[ <script type="text/javascript"><![CDATA[
Ext.ux.Lightbox.register('a[ref=img]', true); Ext.ux.Lightbox.register('a[ref=img]', true);
Leaf.onReady(function() { Leaf.onReady(function() {
if ('${/parameter/@layout_code}' == 'CCR_UNIVERSAL_LEASSE' || '${/parameter/@layout_code}' == 'CCR_UNIVERSAL_LEASEHOLD') { var ds_con_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'],'F_QUOTATION_01', 'con_contract');
($('${/parameter/@layout_code}_quote'))?$('${/parameter/@layout_code}_quote').disable():null; if ($(ds_con_id)) {
($('${/parameter/@layout_code}_user_button2'))?$('${/parameter/@layout_code}_user_button2').hide():null;//隐藏生效按钮 $(ds_con_id).setQueryParameter('contract_id','${/parameter/@contract_id}');
} else if ('${/parameter/@layout_code}' == 'CCR_UNIVERSAL_PAYDATE') { $(ds_con_id).query();
($('${/parameter/@layout_code}_quote'))?$('${/parameter/@layout_code}_quote').disable():null; }
($('${/parameter/@layout_code}_user_button2'))?$('${/parameter/@layout_code}_user_button2').show():null; //显示生效按钮
} else {
($('${/parameter/@layout_code}_quote'))?$('${/parameter/@layout_code}_quote').enable():null;
($('${/parameter/@layout_code}_user_button2'))?$('${/parameter/@layout_code}_user_button2').hide():null; //隐藏生效按钮
}
}); });
function open_contract_win(ds_id, record_id) {
var record = $(ds_id).findById(record_id);
var param = record.data;
param['function_code'] = 'CON301';
param['function_usage'] = 'QUERY';
param['download'] = 'Y';
param['maintain_type'] = 'UPDATE';
param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link', ds_id);
}
window['${/parameter/@layout_code}_quote_layout_dynamic_click'] = function() { window['${/parameter/@layout_code}_quote_layout_dynamic_click'] = function() {
var req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract'); $('${/parameter/@layout_code}_quote').disable(); //按钮不可用
var req_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'],'F_QUOTATION_01', 'con_contract');
var req_record = $(req_ds_id).getAt(0); var req_record = $(req_ds_id).getAt(0);
var calc_session_id = req_record.get('calc_session_id'); var calc_session_id = req_record.get('calc_session_id');
var quo_win; var quo_win;
var calc_type = '${/parameter/@calc_type}'; var calc_type = '${/parameter/@calc_type}';
var document_category = req_record.get('document_category'); var document_category = req_record.get('document_category');
var btb_payment_date = req_record.get('btb_payment_date'); // 變更起始期數
var ccr_start_times = req_record.get('ccr_start_times');
//變更剩餘期數
var ccr_outstanding_times = req_record.get('ccr_outstanding_times');
var change_document_type = req_record.get('change_document_type'); var change_document_type = req_record.get('change_document_type');
if ($(req_ds_id).validate()) { if ($(req_ds_id).validate($('${/parameter/@layout_code}_quote').enable())) {
if (req_record.dirty) { if (req_record.dirty) {
Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}'); Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
return; return;
} }
// if (!calc_session_id) {
window['${/parameter/@layout_code}_lock_layout_dynamic_window'](); window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
Leaf.request({ Leaf.request({
url: $('con731_quote_calc_link').getUrl(), url: $('con733_quote_calc_change_req_link').getUrl(),
para: { para: {
change_req_id: ${/parameter/@change_req_id}, change_req_id: ${/parameter/@change_req_id},
btb_payment_date: btb_payment_date, ccr_start_times: ccr_start_times,
ccr_outstanding_times: ccr_outstanding_times,
calc_session_id: calc_session_id calc_session_id: calc_session_id
}, },
success: function(res) { success: function(res) {
$('${/parameter/@layout_code}_quote').enable();
req_record.set('calc_session_id', res.result.calc_session_id); req_record.set('calc_session_id', res.result.calc_session_id);
req_record.dirty = false; req_record.dirty = false;
quo_win = new Leaf.Window({ quo_win = new Leaf.Window({
...@@ -76,13 +85,18 @@ ...@@ -76,13 +85,18 @@
}); });
quo_win.addListener('close', function() { quo_win.addListener('close', function() {
$(req_ds_id).query(); $(req_ds_id).query();
var cf_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'],'G_QUOTATION_04', 'con_contract_cashflow');
$(cf_ds_id).setQueryParameter('contract_id','${/parameter/@contract_id}');
$(cf_ds_id).query();
}); });
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}, },
failure: function() { failure: function() {
$('${/parameter/@layout_code}_quote').enable();
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}, },
error: function() { error: function() {
$('${/parameter/@layout_code}_quote').enable();
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}, },
scope: this scope: this
...@@ -96,63 +110,37 @@ ...@@ -96,63 +110,37 @@
var lease_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_lease_item'); var lease_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_lease_item');
var con_contract_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract'); var con_contract_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var con_contract_change_req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_change_req'); var con_contract_change_req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_change_req');
if (ds.id == con_contract_ds_id) {
if (name == 'price_list') { if (ds.id == con_contract_change_req_ds_id) {
if (!(Ext.isEmpty(record.get('price_list')))) { // 承租人变更
if (record.get('price_list') == 'DS_PRICE_CHANGE_50') { if ('${/parameter/@layout_code}' == 'CON_TENANT_CHANGE_MODIFY') {
record.getField('btb_interest_margin').setRequired(true); // 承租人变更日計算應繳金額相關信息
record.getField('btb_interest_margin').setReadOnly(false); if(name == 'ccr_lease_date'){
record.set('btb_interest_margin', 0); Leaf.request({
} else { url: $('calc_tenant_amount_link').getUrl(),
record.getField('btb_interest_margin').setRequired(false); para: {
record.getField('btb_interest_margin').setReadOnly(true); change_req_id: ${/parameter/@change_req_id},
record.set('btb_interest_margin', 0); ccr_lease_date: record.get('ccr_lease_date')
} },
} success: function(res) {
} record.set('ccr_lease_rental', res.result.ccr_lease_rental);
// 承租人变更和債權債務时计算变更费用 record.set('ccr_lease_principal', res.result.ccr_lease_principal);
if (name == 'btb_payment_date') { record.set('ccr_lease_interest', res.result.ccr_lease_interest);
record.set('ccr_lease_penalty', res.result.ccr_lease_penalty);
if (!(Ext.isEmpty(record.get('btb_payment_date')))) { },
var today = new Date(); error: function() {
var btb_payment_date = record.get('btb_payment_date'); },
if (btb_payment_date.format('yyyy-mm-dd') < today.format('yyyy-mm-dd')) { failure: function() {
Leaf.showMessage('提示', '结算日期早于当前日期!'); },
} sync: true,
Leaf.request({ scope: this
url: $('calc_leasse_amount_link').getUrl(), });
para: { }
contract_id: record.get('contract_id'),
btb_payment_date: record.get('btb_payment_date')
},
success: function(res) {
if ('${/parameter/@layout_code}' == 'CCR_UNIVERSAL_LEASSE') {
record.set('ccr_leasse_rental', res.result.ccr_leasse_rental);
record.set('ccr_leasse_principal', res.result.ccr_leasse_principal);
record.set('ccr_leasse_interest', res.result.ccr_leasse_interest);
record.set('ccr_leasse_penalty', res.result.ccr_leasse_penalty);
} else if ('${/parameter/@layout_code}' == 'CCR_UNIVERSAL_DEPT') {
record.set('ccr_overdue_rental', res.result.ccr_leasse_rental);
record.set('ccr_overdue_prin', res.result.ccr_leasse_principal);
record.set('ccr_overdue_interest', res.result.ccr_leasse_interest);
record.set('ccr_due_amount', res.result.ccr_leasse_penalty);
record.set('ccr_outstanding_prin_ti_total', res.result.ccr_outstanding_prin_ti_total); //未到期本金
record.set('ccr_outstanding_prin_tax_incld', res.result.ccr_outstanding_prin_ti_total + res.result.ccr_leasse_principal); //剩余本金
}
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
error: function() {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
failure: function() {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
sync: true,
scope: this
});
} }
} }
// 还款日变更时计算变更期数 if (ds.id == con_contract_ds_id) {
//还款日变更时计算变更期数
if ('${/parameter/@layout_code}' == 'CCR_UNIVERSAL_PAYDATE') { if ('${/parameter/@layout_code}' == 'CCR_UNIVERSAL_PAYDATE') {
if (name == 'ccr_start_times' || name == 'btb_payment_date' || name == 'interim_rental') { if (name == 'ccr_start_times' || name == 'btb_payment_date' || name == 'interim_rental') {
if (!(Ext.isEmpty(record.get('ccr_start_times'))) && !(Ext.isEmpty(record.get('btb_payment_date'))) && !(Ext.isEmpty(record.get('interim_rental')))) { if (!(Ext.isEmpty(record.get('ccr_start_times'))) && !(Ext.isEmpty(record.get('btb_payment_date'))) && !(Ext.isEmpty(record.get('interim_rental')))) {
...@@ -181,138 +169,38 @@ ...@@ -181,138 +169,38 @@
} }
} }
} }
// 非月付变更时计算变更费用
if ('${/parameter/@layout_code}' == 'CCR_UNIVERSAL_PAY') {
if (name == 'ccr_start_times') {
if (!(Ext.isEmpty(record.get('ccr_start_times')))) {
Leaf.request({
url: $('calc_pay_amount_link').getUrl(),
para: {
contract_id: record.get('contract_id'),
layout_code: '${/parameter/@layout_code}',
ccr_start_times: record.get('ccr_start_times')
},
success: function(res) {
record.set('ccr_dept', res.result.ccr_dept);
record.set('ccr_outstanding_times', res.result.ccr_outstanding_times);
record.set('ccr_outstanding_prin_tax_incld', res.result.ccr_outstanding_prin_tax_incld);
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
error: function() {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
failure: function() {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
sync: true,
scope: this
});
}
}
}
if (name == 'ccr_due_ratio') {
if (!(Ext.isEmpty(record.get('ccr_due_ratio'))) && !(Ext.isEmpty(record.get('ccr_due_amount')))) {
record.set('ccr_penalty', record.get('ccr_due_amount') * record.get('ccr_due_ratio'));
}
}
} }
}; };
// //提交之前插入手续费
// window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
// var check_flag = true;
//
// return check_flag;
// };
//新增和加载时调用form //新增和加载时调用form
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function(ds, record, config_records, bp_seq) { window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function(ds, record, config_records, bp_seq) {
}; };
window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() { window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
$('${/parameter/@layout_code}_submit_approval').disable();
var req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract'); var req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var req_record = $(req_ds_id).getAt(0); var req_record = $(req_ds_id).getAt(0);
var case_type = ''; var case_type = '';
var document_type = '${/parameter/@document_type}'; var document_type = '${/parameter/@document_type}';
var calc_session_id = req_record.get('calc_session_id'); var calc_session_id = req_record.get('calc_session_id');
//冬雨季变更,债权待调整 走企案doodream //承租人 ,租赁物
if (document_type == 'CONEXTHAG' || document_type == 'DEBT_CHAG') { if (document_type == 'LEASSE_CHAG') {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
if (Leaf.isEmpty(calc_session_id)) { if ($(req_ds_id).validate($('${/parameter/@layout_code}_submit_approval').enable())) {
Leaf.showMessage('提示', '请先进行报价之后再提交审批!');
} else{
if ($(req_ds_id).validate()) {
if (req_record.dirty) {
Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
return;
}
// setTimeout(window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK'](con731_submit), 2000);
if (document_type == 'CONEXTHAG') {
//冬雨季延期工作申请禀议 CFL-34392ECC-275A-4118-A4FE-4269818973A8
case_type = 'CFL-34392ECC-275A-4118-A4FE-4269818973A8';
}
//债务再调整工作申请禀议 CFL-3332CCE6-8AB4-4FC0-B0F4-FB8EE9C7F9CE
else if (document_type == 'DEBT_CHAG') {
case_type = 'CFL-3332CCE6-8AB4-4FC0-B0F4-FB8EE9C7F9CE';
}
$('${/parameter/@layout_code}_save').disable();
$('${/parameter/@layout_code}_quote').disable();
$('${/parameter/@layout_code}_submit_approval').disable();
$('${/parameter/@layout_code}_user_button1').disable();
getXml(case_type);
} else {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}
}
}
//承租人 ,租赁物 走企案doodream
else if (document_type == 'LEASSE_CHAG') {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
if ($(req_ds_id).validate()) {
if (req_record.dirty) { if (req_record.dirty) {
Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}'); Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
return; return;
} }
// setTimeout(window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK'](con731_submit), 2000);
if (document_type == 'LEASSE_CHAG') {
//承租人变更工作申请禀议 CFL-315FB433-77A0-4548-BC03-46F6CE55B8AE
case_type = 'CFL-315FB433-77A0-4548-BC03-46F6CE55B8AE';
}
// else if (document_type == 'LEASEHOLD_CHAG') {
// case_type = '';
// }
$('${/parameter/@layout_code}_save').disable(); $('${/parameter/@layout_code}_save').disable();
$('${/parameter/@layout_code}_quote').disable(); $('${/parameter/@layout_code}_quote').disable();
$('${/parameter/@layout_code}_submit_approval').disable(); $('${/parameter/@layout_code}_submit_approval').disable();
$('${/parameter/@layout_code}_user_button1').disable(); $('${/parameter/@layout_code}_user_button1').disable();
getXml(case_type);
} else { } else {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
} }
} }else {
//非月付转月付
else if (document_type == 'PAY_CHAG') {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
if (Leaf.isEmpty(calc_session_id)) {
Leaf.showMessage('提示', '请先进行报价之后再提交审批!');
} else {
if ($(req_ds_id).validate()) {
if (req_record.dirty) {
Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
return;
}
setTimeout(window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK'](con731_submit), 2000);
} else {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}
}
} else {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
if ($(req_ds_id).validate()) { if ($(req_ds_id).validate()) {
if (req_record.dirty) { if (req_record.dirty) {
...@@ -354,99 +242,39 @@ ...@@ -354,99 +242,39 @@
}); });
} }
function getXml(case_type) {
var req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var req_record = $(req_ds_id).getAt(0);
var change_req_id = ${/parameter/@change_req_id};
if (req_record.dirty) {
Leaf.showMessage('${l:HLS.PROMPT}', '页面数据存在修改,请先保存再发起起案!');
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
return;
}
Leaf.request({
url: $('get_xml').getUrl(),
para: {
change_req_id: change_req_id,
interface_name: case_type
},
success: function(res) {
getUrl(res.result.xml)
//document.getElementById("doodream_iframe").contentWindow.ConnData(res.result.xml);
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
failure: function() {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
error: function() {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
scope: this
});
}
function getUrl(xml) {
Leaf.request({
url: '${/request/@context_path}/doodream/post/url',
para: {
xml: xml
},
success: function(res) {
window.open(res.message, "", "width=940, height=650, scrollbars=yes, toolbar=no, location=no, status=no, menubar=no");
Leaf.SideBar.show({
msg: '${l:HLS.SUBMIT_SUCCESS}',
duration: 2000
});
},
failure: function() {
Leaf.SideBar.show({
msg: 'failure',
duration: 2000
});
},
error: function() {
Leaf.SideBar.show({
msg: 'error',
duration: 2000
});
},
scope: this
});
}
//保存submitsuccess调用 //保存submitsuccess调用
window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function(ds, record, res, bp_seq) { window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function(ds, record, res, bp_seq) {
var ca_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_cashflow'); var ca_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_cashflow');
if (ca_ds_id) { if (ca_ds_id) {
$(ca_ds_id).query(); $(ca_ds_id).query();
} }
var con_contract_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract'); // var con_contract_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var record = $(con_contract_ds_id).getCurrentRecord(); // var record = $(con_contract_ds_id).getCurrentRecord();
Leaf.request({ // Leaf.request({
url: $('con731_calc_ccr_fee_link').getUrl(), // url: $('con731_calc_ccr_fee_link').getUrl(),
para: { // para: {
contract_id: ${/parameter/@change_req_id}, // contract_id: ${/parameter/@change_req_id},
bp_id: record.get('bp_id_tenant'), // bp_id: record.get('bp_id_tenant'),
lease_item_id: record.get('lease_item_id'), // lease_item_id: record.get('lease_item_id'),
pattern: record.get('lease_item_id_n'), // pattern: record.get('lease_item_id_n'),
machine_number: record.get('machine_number'), // machine_number: record.get('machine_number'),
interim_times: record.get('interim_times'), // interim_times: record.get('interim_times'),
ccr_start_times: record.get('ccr_start_times'), // ccr_start_times: record.get('ccr_start_times'),
ccr_document_type: record.get('ccr_document_type'), // ccr_document_type: record.get('ccr_document_type'),
hd_user_col_v04: record.get('hd_user_col_v04'), // hd_user_col_v04: record.get('hd_user_col_v04'),
btb_payment_date: record.get('btb_payment_date') // btb_payment_date: record.get('btb_payment_date')
}, // },
success: function(res) { // success: function(res) {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window'](); // window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}, // },
failure: function() { // failure: function() {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window'](); // window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}, // },
error: function() { // error: function() {
window['${/parameter/@layout_code}_unlock_layout_dynamic_window'](); // window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}, // },
scope: this // scope: this
}); // });
window['${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
...@@ -454,6 +282,7 @@ ...@@ -454,6 +282,7 @@
window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() { window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
$('${/parameter/@layout_code}_user_button1').disable();
Leaf.showConfirm('${l:HLS.PROMPT}', '是否确认取消变更?', function() { Leaf.showConfirm('${l:HLS.PROMPT}', '是否确认取消变更?', function() {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
Leaf.request({ Leaf.request({
...@@ -462,61 +291,29 @@ ...@@ -462,61 +291,29 @@
change_req_id: ${/parameter/@change_req_id} change_req_id: ${/parameter/@change_req_id}
}, },
success: function(res) { success: function(res) {
$('${/parameter/@layout_code}_user_button1').enable();
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
$('${/parameter/@winid}').close(); $('${/parameter/@winid}').close();
}, },
failure: function() { failure: function() {
$('${/parameter/@layout_code}_user_button1').enable();
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}, },
error: function() { error: function() {
$('${/parameter/@layout_code}_user_button1').enable();
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'](); window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}, },
scope: this scope: this
}); });
}); });
}; };
//还款日期变更更新现金流的日期生效按钮
window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() { window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
var req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract'); $('${/parameter/@layout_code}_user_button1').disable();
var req_record = $(req_ds_id).getAt(0);
if ($(req_ds_id).validate()) { $('${/parameter/@layout_code}_user_button1').enable();
if (req_record.dirty) {
Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
return;
}else{
Leaf.request({
url: $('con731_update_link').getUrl(),
para: {
contract_id: req_record.get('contract_id'),
ccr_start_times: req_record.get('ccr_start_times'),
btb_payment_date: req_record.get('btb_payment_date')
},
success: function(res) {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
var ca_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_cashflow');
if (ca_ds_id) {
$(ca_ds_id).query();
}
parent.Leaf.SideBar.show({
msg: '已生效',
duration: 2000
});
},
failure: function() {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
error: function() {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
scope: this
});
}
}else {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
}
};
};
//////附件上传 //////附件上传
window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record, bp_seq) { window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record, bp_seq) {
...@@ -525,7 +322,9 @@ ...@@ -525,7 +322,9 @@
if (name == 'leasse_attachment') { if (name == 'leasse_attachment') {
link_function = '${/parameter/@layout_code}_leasse_cdd_attachtment_upload'; link_function = '${/parameter/@layout_code}_leasse_cdd_attachtment_upload';
return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>'; return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
} else if (name == 'leasse_attach_file_name') { } else if (name == 'contract_number' && value) {
return '<a href="javascript:open_contract_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
}else if (name == 'leasse_attach_file_name') {
if (value != null) { if (value != null) {
var link = '${/request/@context_path}/atm_download.lsc?attachment_id='; var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
var str = value.split(';;'); var str = value.split(';;');
......
...@@ -85,36 +85,27 @@ ...@@ -85,36 +85,27 @@
var param = record.data; var param = record.data;
var req_status = record.get('req_status'); var req_status = record.get('req_status');
param['change_req_id'] = record.get('contract_id'); param['change_req_id'] = record.get('contract_id');
param['source_contract_id'] = record.get('source_contract_id');//變更前源合同id
param['contract_id'] = record.get('contract_id'); param['contract_id'] = record.get('contract_id');
param['function_code'] = 'CON732D';
param['function_usage'] = 'MODIFY';
param['req_status'] = req_status; param['req_status'] = req_status;
if (req_status == 'APPROVED' || req_status == 'APPROVING' || req_status == 'CANCEL') { if (req_status == 'APPROVED' || req_status == 'APPROVING' || req_status == 'CANCEL' || req_status == 'REJECT' ) {
param['maintain_type'] = 'READONLY'; param['maintain_type'] = 'READONLY';
param['function_usage'] = 'QUERY';
} else { } else {
param['maintain_type'] = 'UPDATE'; param['maintain_type'] = 'UPDATE';
param['function_usage'] = 'MODIFY';
} }
if (record.get('ccr_document_type') == 'CUT_CHAG') {
param['function_code'] = 'CON733CF';
if (record.get('ccr_document_type') == 'PAYCARD' && (req_status == 'REJECT' || req_status == 'CANCEL' || req_status == 'APPROVED' || req_status == 'APPROVING')) { param['url_title'] = '变更申请-合同回款账户变更';
param['function_code'] = 'CON732Q'; } else if (record.get('ccr_document_type') == 'LEASE_CHAG') {
param['function_usage'] = 'QUERY'; param['function_code'] = 'CON733BPT';
param['url_title'] = '变更申请-还款卡变更查询 '; param['url_title'] = '变更申请-合同回款账户变更';
} else if (record.get('ccr_document_type') == 'BASICHAG' && (req_status == 'REJECT' || req_status == 'CANCEL' || req_status == 'APPROVED' || req_status == 'APPROVING')) { } else if (record.get('ccr_document_type') == 'ACC_CHAG') {
param['function_code'] = 'CON702E'; param['function_code'] = 'CON733BPB';
param['function_usage'] = 'QUERY'; param['url_title'] = '变更申请-合同回款账户变更';
param['url_title'] = '变更申请-常规信息查询 ';
} else if (record.get('ccr_document_type') == 'CONEXTHAG' && (req_status == 'REJECT' || req_status == 'CANCEL' || req_status == 'APPROVED' || req_status == 'APPROVING')) {
param['function_code'] = 'CON732D';
param['function_usage'] = 'QUERY';
param['url_title'] = '变更申请-还款卡变更 ';
} else {
param['function_code'] = 'CON732D_BASIC';
param['url_title'] = '变更申请-常规信息调整 ';
} }
param['function_code'] = 'CON732D';
param['function_usage'] = 'MODIFY';
param['document_type'] = record.get('ccr_document_type'); param['document_type'] = record.get('ccr_document_type');
hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_change_link', ds_id); hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_change_link', ds_id);
}; };
......
...@@ -124,10 +124,19 @@ ...@@ -124,10 +124,19 @@
var param = record.data; var param = record.data;
var req_status = record.get('req_status'); var req_status = record.get('req_status');
param['change_req_id'] = record.get('contract_id'); param['change_req_id'] = record.get('contract_id');
param['source_contract_id'] = record.get('source_contract_id');//變更前源合同id
param['contract_id'] = record.get('contract_id'); param['contract_id'] = record.get('contract_id');
param['function_code'] = 'CON732E'; if (record.get('ccr_document_type') == 'CUT_CHAG') {
param['function_code'] = 'CON733CF';
param['url_title'] = '变更申请-合同回款账户变更查询';
} else if (record.get('ccr_document_type') == 'LEASE_CHAG') {
param['function_code'] = 'CON733BPT';
param['url_title'] = '变更申请-合同回款账户变更查询';
} else if (record.get('ccr_document_type') == 'ACC_CHAG') {
param['function_code'] = 'CON733BPB';
param['url_title'] = '变更申请-合同回款账户变更查询';
}
param['function_usage'] = 'QUERY'; param['function_usage'] = 'QUERY';
param['url_title'] = '变更申请查询';
param['req_status'] = req_status; param['req_status'] = req_status;
param['query_flag'] = 'Y'; param['query_flag'] = 'Y';
param['maintain_type'] = 'QUERY'; param['maintain_type'] = 'QUERY';
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
2017-1-10 Harry 9952 2017/1/10 合同变更-经销商 合同变更
租金計劃變更
承租人變更
回款賬戶變更
--> -->
<a:screen xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" <a:screen xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application"
customizationEnabled="true" dynamiccreateenabled="true" trace="true"> customizationEnabled="true" dynamiccreateenabled="true" trace="true">
...@@ -13,7 +15,7 @@ ...@@ -13,7 +15,7 @@
url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/> url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
<a:link id="con_contract_change_link" <a:link id="con_contract_change_link"
url="${/request/@context_path}/modules/cont/CON731/hls_con_contract_change_detail.lview"/> url="${/request/@context_path}/modules/cont/CON731/hls_con_contract_change_detail.lview"/>
<a:link id="con731_create_change_link" model="cont.CON731.create_change_req" modelaction="execute"/> <a:link id="con733_create_change_link" model="cont.CON733.create_change_req" modelaction="execute"/>
<a:link id="con_contract_change_req_link" <a:link id="con_contract_change_req_link"
url="${/request/@context_path}/modules/cont/CON701/con_contract_et_print.lsc"/> url="${/request/@context_path}/modules/cont/CON701/con_contract_et_print.lsc"/>
<script type="text/javascript"><![CDATA[ <script type="text/javascript"><![CDATA[
...@@ -34,6 +36,7 @@ ...@@ -34,6 +36,7 @@
return value; return value;
}; };
window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () { window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {
$('${/parameter/@layout_code}_user_button1').disable(); //按钮不可用
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract'); var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var prj_project_result_ds = $(ds_id); var prj_project_result_ds = $(ds_id);
var records = prj_project_result_ds.getSelected(); var records = prj_project_result_ds.getSelected();
...@@ -41,12 +44,12 @@ ...@@ -41,12 +44,12 @@
Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}'); Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
return; return;
} }
Leaf.showConfirm('特别注意', '<font color="">该操作将导致合同在变更期间无法进行后续操作,请谨慎操作!!!如果需要取消变更,请一定点击取消变更按钮!!!</font>', function () { Leaf.showConfirm('特别注意', '<span style="color: #ff0000; ">该操作将导致合同在变更期间无法进行后续操作,请谨慎操作!!!如果需要取消变更,请一定点击取消变更按钮!!!</span>', function () {
var record = records[0]; var record = records[0];
var head_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_change_req'); var head_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_change_req');
var head_record = $(head_ds_id).getAt(0); var head_record = $(head_ds_id).getAt(0);
if ($(head_ds_id).validate()) { if ($(head_ds_id).validate($('${/parameter/@layout_code}_user_button1').enable())) {
var contract = record.get('contract_id'); var contract = record.get('contract_id');
var ccr_document_type = head_record.get('ccr_document_type'); var ccr_document_type = head_record.get('ccr_document_type');
var req_date = head_record.get('req_date'); var req_date = head_record.get('req_date');
...@@ -54,7 +57,7 @@ ...@@ -54,7 +57,7 @@
var ref_v01 = head_record.get('ref_v01'); var ref_v01 = head_record.get('ref_v01');
Leaf.Masker.mask(Ext.getBody()); Leaf.Masker.mask(Ext.getBody());
Leaf.request({ Leaf.request({
url: $('con731_create_change_link').getUrl(), url: $('con733_create_change_link').getUrl(),
para: { para: {
simulation_flag: 'N', simulation_flag: 'N',
contract_id: record.get('contract_id'), contract_id: record.get('contract_id'),
...@@ -64,21 +67,35 @@ ...@@ -64,21 +67,35 @@
ref_v01: ref_v01 ref_v01: ref_v01
}, },
success: function (res) { success: function (res) {
$('${/parameter/@layout_code}_user_button1').enable(); //按钮启用
var param = record.data; var param = record.data;
param['change_req_id'] = res.result.change_req_id; param['change_req_id'] = res.result.change_req_id;
param['source_contract_id'] = record.get('contract_id');//變更前源合同id
param['contract_id'] = res.result.change_req_id; param['contract_id'] = res.result.change_req_id;
param['function_code'] = 'CON732D';
param['url_title'] = '变更申请-合同变更';
param['function_usage'] = 'MODIFY'; param['function_usage'] = 'MODIFY';
param['maintain_type'] = 'UPDATE'; param['maintain_type'] = 'UPDATE';
param['document_type'] = ccr_document_type; param['document_type'] = ccr_document_type;
if(ccr_document_type == 'CUT_CHAG'){//租金計劃變更
param['function_code'] = 'CON733CF';
param['url_title'] = '变更申请-合同租金计划变更';
param['winid'] = 'con733_cf_change_detail_winid';
}else if(ccr_document_type == 'LEASE_CHAG'){//承租人變更
param['function_code'] = 'CON733BPT';
param['url_title'] = '变更申请-合同承租人变更';
param['winid'] = 'con733_bpt_change_detail_winid';
}else if(ccr_document_type == 'ACC_CHAG'){//回款賬戶變更
param['function_code'] = 'CON733BPB';
param['url_title'] = '变更申请-合同回款账户变更';
param['winid'] = 'con733_bpb_change_detail_winid';
}
hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_change_link', ds_id); hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_change_link', ds_id);
}, },
failure: function () { failure: function () {
$('${/parameter/@layout_code}_user_button1').enable(); //按钮启用
Leaf.Masker.unmask(Ext.getBody()); Leaf.Masker.unmask(Ext.getBody());
}, },
error: function () { error: function () {
$('${/parameter/@layout_code}_user_button1').enable(); //按钮启用
Leaf.Masker.unmask(Ext.getBody()); Leaf.Masker.unmask(Ext.getBody());
}, },
scope: this scope: this
...@@ -86,23 +103,13 @@ ...@@ -86,23 +103,13 @@
} }
}, null, 300, 150); }, null, 300, 150);
}; };
//变更申请打印单
window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function () {
var xmlTemp = '';
var fileName = '';
xmlTemp = 'con_contract_change_req_apply.xml';
fileName = '变更申请单.pdf';
var url = $('con_contract_change_req_link').getUrl() + '?xmlTemp=' + xmlTemp + '&fileName=' + fileName;
window.open(url);
};
window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function (ds, qpara, bp_seq) { window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function (ds, qpara, bp_seq) {
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract'); var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
if (ds == $(ds_id)) { // if (ds == $(ds_id)) {
aut_authority_list_validate_query(ds, qpara); // aut_authority_list_validate_query(ds, qpara);
//
} // }
}; };
]]></script> ]]></script>
<a:screen-include <a:screen-include
......
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