<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lihh
    $Date: 2021-06-10 上午10:30:21
    $Revision: 1.0
    $Purpose: 逾期租金表（保证金后）获取数据
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                select
                rct.agent_extra_name agent_extra_name_af,
                rct.bp_tenant_name bp_tenant_name_af,
                rct.branch_code branch_code_af,
                rct.contract_id	contract_id_af,
                rct.contract_number	contract_number_af,
                rct.cshflow_id	cshflow_id_af,
                nvl(rct.deposit_amount,0) deposit_amount_af,
			   --modify by 18938 I-7310
			   (case
				 when rct.contract_number = 'SXJ21040016' and rct.times = '36' and
					  rct.cshflow_id = 259314 then
				  1170220.13
				 else				
				  rct.due_amount 
			   end) due_amount_af,
                to_char(rct.due_date,'yyyy-mm-dd') due_date_af,
                (NVL(rct.int_rate_display, 0) * 100 ||'%') int_rate_display_af,
                rct.is_buyout,
				(Select v1.code_value_name
                           From sys_code_values_v v1
                           Where v1.code = 'YES_OR_NO'
                                 And v1.code_enabled_flag = 'Y'
                                 And v1.code_value_enabled_flag = 'Y'
                                 and v1.CODE_VALUE = rct.is_buyout)  is_buyout_af,
                rct.large_balance	large_balance_af,
                rct.machine_number	machine_number_af,
                to_char(rct.lease_start_date,'yyyy-mm-dd') lease_start_date_af,
                rct.modelcd	modelcd_af,
			   --modify by 18938 I-7310
			   (case
				 when rct.contract_number = 'SXJ21040016' and rct.times = '36' and
					  rct.cshflow_id = 259314 then
				  0
				 else				
				   nvl(rct.overdue_days,0)
			   end)					overdue_days_af,
			   --modify by 18938 I-7310
			   (case
				 when rct.contract_number = 'SXJ21040016' and rct.times = '36' and
					  rct.cshflow_id = 259314 then
				  1170220.13
				 else			   
                  nvl(rct.received_amount,0) 
			   end) received_amount_af,
                rct.times	times_af,
			   --modify by 18938 I-7310
			   (case
				 when rct.contract_number = 'SXJ21040016' and rct.times = '36' and
					  rct.cshflow_id = 259314 then
				  0
				 else				
                  nvl(rct.unreceived_amount,0) 
			   end) unreceived_amount_af,
				rct.rent_type
                from
                rpt5012_csh_result_after_temp rct
								order by rct.contract_number,rct.times
                ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                begin
                csh_result_query_pkg.get_result_received_amount(
                p_month    =>${@month},
                p_cur_begin      =>${@cur_begin},
                p_cur_end      =>${@cur_end},
                p_before_begin      =>${@before_begin},
                p_before_end       =>${@before_end}
                );
                end;
                ]]></bm:update-sql>
				<bm:parameters>
                <bm:parameter name="cur_begin" dataType="date" input="true" output="true"
                              outputPath="/parameter/@cur_begin"/>
                <bm:parameter name="cur_end" dataType="date" input="true" output="true"
                              outputPath="/parameter/@cur_end"/>
                <bm:parameter name="before_begin" dataType="date" input="true" output="true"
                              outputPath="/parameter/@before_begin"/>
                <bm:parameter name="before_end" dataType="date" input="true" output="true"
                              outputPath="/parameter/@before_end"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="agent_extra_name_af"/>
        <bm:field name="bp_tenant_name_af"/>
        <bm:field name="contract_number_af"/>
        <bm:field name="lease_start_date_af"/>
        <bm:field name="modelcd_af"/>
        <bm:field name="machine_number_af"/>
        <bm:field name="int_rate_display_af"/>
        <bm:field name="times_af"/>
        <bm:field name="due_date_af"/>
        <bm:field name="due_amount_af" datatype="java.lang.Double"/>
        <bm:field name="received_amount_af" datatype="java.lang.Double"/>
        <bm:field name="unreceived_amount_af" datatype="java.lang.Double"/>
        <bm:field name="overdue_days_af" datatype="java.lang.Double"/>
        <bm:field name="deposit_amount_af" datatype="java.lang.Double"/>
        <bm:field name="is_buyout_af"/>
		<bm:field name="rent_type"/>
		<bm:field name="large_balance_af"/>
		<bm:field name="branch_code_af"/>
		
    </bm:fields>
</bm:model>
