<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: WangYu  
    $Date: 2014-4-25 上午09: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 t.*,
				       m.bp_name  bp_id_agent_level1_n,
				       (select m.bp_code from hls_bp_master m where m.bp_id = t.bp_id) bp_code,
				       (select contract_number from con_contract where contract_id=t.contract_id) contract_number,
				       g.account_code account_id_n,
				       (select description_text from fnd_descriptions where description_id = g.description_id and language = 'ZHS' ) account_name
				from con_cashflow_monthly_temp t,hls_bp_master m,gld_accounts g
				where m.bp_id = t.agent_bp_id
				and g.account_id = t.account_id
				and t.session_id = ${/session/@session_id}
        		order by t.contract_id desc,g.account_code
                
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
		        begin
		           con_cashflow_monthly_pkg.insert_con_cash_temp(
		           p_session_id   =>${/session/@session_id},
                                 p_due_date     =>to_date(${@due_date},'yyyy-mm-dd'),
                                 p_user_id      =>${/session/@user_id},
                                 p_bp_id        =>${@bp_id},
                                 p_overday1     =>${@overday1},
                                 p_overday2     =>${@overday2},
                                 p_overday3     =>${@overday3},
                                 p_not_overday1 =>${@not_overday1},
                                 p_not_overday2 =>${@not_overday2},
                                 p_not_overday3 =>${@not_overday3},
                                 p_not_overday4 =>${@not_overday4},
                                 p_not_overday5 =>${@not_overday5},
                                 p_not_overday6 =>${@not_overday6});
		        end;
        ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_id"/>
        <bm:field name="bp_code"/>
        <bm:field name="contract_number"/>
        <bm:field name="bp_id_agent_level1_n"/>
        <bm:field name="account_id_n"/>
        <bm:field name="account_name"/>
        <bm:field name="unreceived_sum_amount"/>
        <bm:field name="overdue_amount_1"/>
        <bm:field name="overdue_amount_2"/>
        <bm:field name="overdue_amount_3"/>
        <bm:field name="overdue_amount_left"/>
        <bm:field name="overdue_sum_amount"/>
        <bm:field name="not_due_sum_amount"/>
        <bm:field name="not_due_amount_1"/>
        <bm:field name="not_due_amount_2"/>
        <bm:field name="not_due_amount_3"/>
        <bm:field name="not_due_amount_4"/>
        <bm:field name="not_due_amount_5"/>
        <bm:field name="not_due_amount_6"/>
        <bm:field name="not_due_amount_left"/>



    </bm:fields>
<!--    <bm:query-fields>-->
<!--        <bm:query-field field="bp_id_tenant_n" queryExpression="t1.bp_id_tenant_n = ${@bp_id_tenant_n}"/>-->
<!--        <bm:query-field field="account_name" queryExpression="t1.account_name = ${@account_name}"/>-->
<!--        <bm:query-field field="account_id_n" queryExpression="t1.account_id_n = ${@account_id_n}"/>-->
<!--    </bm:query-fields>-->
</bm:model>
